From 11b223daa2c54d2b86efb5e6054fd7205ed0b37a Mon Sep 17 00:00:00 2001 From: Paweł Marks Date: Wed, 11 Mar 2020 11:51:57 +0100 Subject: Properly merge AdditionalModifiers from different platforms --- .../src/main/kotlin/converters/KotlinToJavaConverter.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'plugins/kotlin-as-java/src') diff --git a/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt b/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt index 2d73786b..3b0f69f6 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt @@ -78,7 +78,7 @@ internal fun Property.asJava(isTopLevel: Boolean = false, relocateToClass: Strin type = type.asJava(isTopLevel), // TODO: check setter = null, getter = null, // Removing getters and setters as they will be available as functions - extra = if (isTopLevel) extra.plus(extra.mergeAdditionalModifiers(listOf(ExtraModifiers.STATIC))) else extra + extra = if (isTopLevel) extra.plus(extra.mergeAdditionalModifiers(setOf(ExtraModifiers.STATIC))) else extra ) internal fun Property.javaAccessors(isTopLevel: Boolean = false, relocateToClass: String? = null): List = @@ -99,7 +99,7 @@ internal fun Property.javaAccessors(isTopLevel: Boolean = false, relocateToClass map = visibility.mapValues { JavaVisibility.Public } ), type = type.asJava(isTopLevel), // TODO: check - extra = if (isTopLevel) getter!!.extra.plus(getter!!.extra.mergeAdditionalModifiers(listOf(ExtraModifiers.STATIC))) else getter!!.extra + extra = if (isTopLevel) getter!!.extra.plus(getter!!.extra.mergeAdditionalModifiers(setOf(ExtraModifiers.STATIC))) else getter!!.extra ), setter?.copy( dri = if (relocateToClass.isNullOrBlank()) { @@ -117,7 +117,7 @@ internal fun Property.javaAccessors(isTopLevel: Boolean = false, relocateToClass map = visibility.mapValues { JavaVisibility.Public } ), type = type.asJava(isTopLevel), // TODO: check - extra = if (isTopLevel) setter!!.extra.plus(setter!!.extra.mergeAdditionalModifiers(listOf(ExtraModifiers.STATIC))) else setter!!.extra + extra = if (isTopLevel) setter!!.extra.plus(setter!!.extra.mergeAdditionalModifiers(setOf(ExtraModifiers.STATIC))) else setter!!.extra ) ) @@ -215,7 +215,7 @@ internal fun Object.asJava(): Object = copy( getter = null, platformData = platformData, receiver = null, - extra = PropertyContainer.empty() + AdditionalModifiers(listOf(ExtraModifiers.STATIC)) + extra = PropertyContainer.empty() + AdditionalModifiers(setOf(ExtraModifiers.STATIC)) ), classlikes = classlikes.map { it.asJava() }, supertypes = supertypes.copy( @@ -291,11 +291,11 @@ internal fun ClassId.toDRI(dri: DRI?): DRI = DRI( target = null ) -private fun PropertyContainer.mergeAdditionalModifiers(second: List) = +private fun PropertyContainer.mergeAdditionalModifiers(second: Set) = this[AdditionalModifiers.AdditionalKey]?.squash(AdditionalModifiers(second)) ?: AdditionalModifiers(second) private fun AdditionalModifiers.squash(second: AdditionalModifiers) = - AdditionalModifiers((content + second.content).distinct()) + AdditionalModifiers(content + second.content) internal fun ClassId.classNames(): String = shortClassName.identifier + (outerClassId?.classNames()?.let { ".$it" } ?: "") \ No newline at end of file -- cgit