SLC: add marker interface for collection inheritor
This commit is contained in:
committed by
Ilya Kirillov
parent
e15d8fc56f
commit
8d8d0d9922
@@ -43,6 +43,7 @@ import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
|
||||
import org.jetbrains.kotlin.resolve.annotations.JVM_STATIC_ANNOTATION_FQ_NAME
|
||||
import org.jetbrains.kotlin.resolve.annotations.argumentValue
|
||||
import org.jetbrains.kotlin.resolve.constants.EnumValue
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.classId
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOriginKind
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.typeUtil.isAnyOrNullableAny
|
||||
@@ -143,8 +144,8 @@ open class KtUltraLightClass(classOrObject: KtClassOrObject, internal val suppor
|
||||
//Add java supertype
|
||||
listBuilder.addReference(mappedToNoCollectionAsIs)
|
||||
//Add marker interface
|
||||
superType.tryResolveMarkerInterfaceFQName()?.let { marker ->
|
||||
listBuilder.addReference(marker)
|
||||
superType.constructor.declarationDescriptor.classId?.let { classId ->
|
||||
listBuilder.addMarkerInterfaceIfNeeded(classId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ import org.jetbrains.kotlin.asJava.builder.LightMemberOriginForDeclaration
|
||||
import org.jetbrains.kotlin.asJava.elements.*
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.StandardNames
|
||||
import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMap
|
||||
import org.jetbrains.kotlin.codegen.DescriptorAsmUtil
|
||||
import org.jetbrains.kotlin.codegen.JvmCodegenUtil
|
||||
import org.jetbrains.kotlin.codegen.OwnerKind
|
||||
@@ -48,7 +47,6 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.annotations.JVM_STATIC_ANNOTATION_FQ_NAME
|
||||
import org.jetbrains.kotlin.resolve.annotations.argumentValue
|
||||
import org.jetbrains.kotlin.resolve.constants.*
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.classId
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.module
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOriginKind
|
||||
import org.jetbrains.kotlin.resolve.source.KotlinSourceElement
|
||||
@@ -516,27 +514,6 @@ private fun ConstantValue<*>.asStringForPsiLiteral(parent: PsiElement): String =
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* @see org.jetbrains.kotlin.codegen.ImplementationBodyCodegen
|
||||
*/
|
||||
fun KotlinType.tryResolveMarkerInterfaceFQName(): String? {
|
||||
|
||||
val classId = constructor.declarationDescriptor.classId
|
||||
|
||||
for (mapping in JavaToKotlinClassMap.mutabilityMappings) {
|
||||
if (mapping.kotlinReadOnly == classId) {
|
||||
return "kotlin.jvm.internal.markers.KMappedMarker"
|
||||
} else if (mapping.kotlinMutable == classId) {
|
||||
return "kotlin.jvm.internal.markers.K" + classId.relativeClassName.asString()
|
||||
.replace("MutableEntry", "Entry") // kotlin.jvm.internal.markers.KMutableMap.Entry for some reason
|
||||
.replace(".", "$")
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
internal inline fun Project.applyCompilerPlugins(body: (UltraLightClassModifierExtension) -> Unit) {
|
||||
UltraLightClassModifierExtension.getInstances(this).forEach { body(it) }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user