Extract FE 1.0 dependent part from JavaToKotlinClassMap
Also move JavaToKotlinClassMap to :core:compiler.common.jvm
This commit is contained in:
+11
-74
@@ -1,42 +1,34 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.builtins.jvm
|
||||
|
||||
import org.jetbrains.kotlin.builtins.CompanionObjectMapping
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.StandardNames
|
||||
import org.jetbrains.kotlin.builtins.StandardNames.FqNames
|
||||
import org.jetbrains.kotlin.builtins.PlatformToKotlinClassMap
|
||||
import org.jetbrains.kotlin.builtins.functions.BuiltInFunctionArity
|
||||
import org.jetbrains.kotlin.builtins.functions.FunctionClassKind
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.name.*
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
|
||||
import org.jetbrains.kotlin.resolve.jvm.JvmPrimitiveType
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import java.util.*
|
||||
|
||||
object JavaToKotlinClassMap : PlatformToKotlinClassMap {
|
||||
private val NUMBERED_FUNCTION_PREFIX =
|
||||
object JavaToKotlinClassMap {
|
||||
private val NUMBERED_FUNCTION_PREFIX: String =
|
||||
FunctionClassKind.Function.packageFqName.toString() + "." + FunctionClassKind.Function.classNamePrefix
|
||||
private val NUMBERED_K_FUNCTION_PREFIX =
|
||||
private val NUMBERED_K_FUNCTION_PREFIX: String =
|
||||
FunctionClassKind.KFunction.packageFqName.toString() + "." + FunctionClassKind.KFunction.classNamePrefix
|
||||
private val NUMBERED_SUSPEND_FUNCTION_PREFIX =
|
||||
private val NUMBERED_SUSPEND_FUNCTION_PREFIX: String =
|
||||
FunctionClassKind.SuspendFunction.packageFqName.toString() + "." + FunctionClassKind.SuspendFunction.classNamePrefix
|
||||
private val NUMBERED_K_SUSPEND_FUNCTION_PREFIX =
|
||||
private val NUMBERED_K_SUSPEND_FUNCTION_PREFIX: String =
|
||||
FunctionClassKind.KSuspendFunction.packageFqName.toString() + "." + FunctionClassKind.KSuspendFunction.classNamePrefix
|
||||
|
||||
private val FUNCTION_N_CLASS_ID = ClassId.topLevel(FqName("kotlin.jvm.functions.FunctionN"))
|
||||
val FUNCTION_N_FQ_NAME = FUNCTION_N_CLASS_ID.asSingleFqName()
|
||||
private val K_FUNCTION_CLASS_ID = ClassId.topLevel(FqName("kotlin.reflect.KFunction"))
|
||||
private val K_CLASS_CLASS_ID = ClassId.topLevel(FqName("kotlin.reflect.KClass"))
|
||||
private val CLASS_CLASS_ID = classId(java.lang.Class::class.java)
|
||||
private val FUNCTION_N_CLASS_ID: ClassId = ClassId.topLevel(FqName("kotlin.jvm.functions.FunctionN"))
|
||||
val FUNCTION_N_FQ_NAME: FqName = FUNCTION_N_CLASS_ID.asSingleFqName()
|
||||
private val K_FUNCTION_CLASS_ID: ClassId = ClassId.topLevel(FqName("kotlin.reflect.KFunction"))
|
||||
private val K_CLASS_CLASS_ID: ClassId = ClassId.topLevel(FqName("kotlin.reflect.KClass"))
|
||||
private val CLASS_CLASS_ID: ClassId = classId(Class::class.java)
|
||||
|
||||
private val javaToKotlin = HashMap<FqNameUnsafe, ClassId>()
|
||||
private val kotlinToJava = HashMap<FqNameUnsafe, ClassId>()
|
||||
@@ -131,13 +123,6 @@ object JavaToKotlinClassMap : PlatformToKotlinClassMap {
|
||||
return mapJavaToKotlin(fqName)
|
||||
}
|
||||
|
||||
fun mapJavaToKotlin(fqName: FqName, builtIns: KotlinBuiltIns, functionTypeArity: Int? = null): ClassDescriptor? {
|
||||
val kotlinClassId =
|
||||
if (functionTypeArity != null && fqName == FUNCTION_N_FQ_NAME) StandardNames.getFunctionClassId(functionTypeArity)
|
||||
else mapJavaToKotlin(fqName)
|
||||
return if (kotlinClassId != null) builtIns.getBuiltInClassByFqName(kotlinClassId.asSingleFqName()) else null
|
||||
}
|
||||
|
||||
/**
|
||||
* E.g.
|
||||
* kotlin.Throwable -> java.lang.Throwable
|
||||
@@ -205,52 +190,14 @@ object JavaToKotlinClassMap : PlatformToKotlinClassMap {
|
||||
|
||||
fun isJavaPlatformClass(fqName: FqName): Boolean = mapJavaToKotlin(fqName) != null
|
||||
|
||||
fun mapPlatformClass(fqName: FqName, builtIns: KotlinBuiltIns): Collection<ClassDescriptor> {
|
||||
val kotlinAnalog = mapJavaToKotlin(fqName, builtIns) ?: return emptySet()
|
||||
|
||||
val kotlinMutableAnalogFqName = readOnlyToMutable[kotlinAnalog.fqNameUnsafe] ?: return setOf(kotlinAnalog)
|
||||
|
||||
return listOf(kotlinAnalog, builtIns.getBuiltInClassByFqName(kotlinMutableAnalogFqName))
|
||||
}
|
||||
|
||||
override fun mapPlatformClass(classDescriptor: ClassDescriptor): Collection<ClassDescriptor> {
|
||||
val className = DescriptorUtils.getFqName(classDescriptor)
|
||||
return if (className.isSafe)
|
||||
mapPlatformClass(className.toSafe(), classDescriptor.builtIns)
|
||||
else
|
||||
emptySet()
|
||||
}
|
||||
|
||||
fun mutableToReadOnly(fqNameUnsafe: FqNameUnsafe?): FqName? = mutableToReadOnly[fqNameUnsafe]
|
||||
|
||||
fun readOnlyToMutable(fqNameUnsafe: FqNameUnsafe?): FqName? = readOnlyToMutable[fqNameUnsafe]
|
||||
|
||||
fun isMutable(fqNameUnsafe: FqNameUnsafe?): Boolean = mutableToReadOnly.containsKey(fqNameUnsafe)
|
||||
|
||||
fun isMutable(mutable: ClassDescriptor): Boolean = isMutable(DescriptorUtils.getFqName(mutable))
|
||||
|
||||
fun isMutable(type: KotlinType): Boolean {
|
||||
val classDescriptor = TypeUtils.getClassDescriptor(type)
|
||||
return classDescriptor != null && isMutable(classDescriptor)
|
||||
}
|
||||
|
||||
fun isReadOnly(fqNameUnsafe: FqNameUnsafe?): Boolean = readOnlyToMutable.containsKey(fqNameUnsafe)
|
||||
|
||||
fun isReadOnly(readOnly: ClassDescriptor): Boolean = isReadOnly(DescriptorUtils.getFqName(readOnly))
|
||||
|
||||
fun isReadOnly(type: KotlinType): Boolean {
|
||||
val classDescriptor = TypeUtils.getClassDescriptor(type)
|
||||
return classDescriptor != null && isReadOnly(classDescriptor)
|
||||
}
|
||||
|
||||
fun convertMutableToReadOnly(mutable: ClassDescriptor): ClassDescriptor {
|
||||
return convertToOppositeMutability(mutable, mutableToReadOnly, "mutable")
|
||||
}
|
||||
|
||||
fun convertReadOnlyToMutable(readOnly: ClassDescriptor): ClassDescriptor {
|
||||
return convertToOppositeMutability(readOnly, readOnlyToMutable, "read-only")
|
||||
}
|
||||
|
||||
private fun classId(clazz: Class<*>): ClassId {
|
||||
assert(!clazz.isPrimitive && !clazz.isArray) { "Invalid class: $clazz" }
|
||||
val outer = clazz.declaringClass
|
||||
@@ -259,14 +206,4 @@ object JavaToKotlinClassMap : PlatformToKotlinClassMap {
|
||||
else
|
||||
classId(outer).createNestedClassId(Name.identifier(clazz.simpleName))
|
||||
}
|
||||
|
||||
private fun convertToOppositeMutability(
|
||||
descriptor: ClassDescriptor,
|
||||
map: Map<FqNameUnsafe, FqName>,
|
||||
mutabilityKindName: String
|
||||
): ClassDescriptor {
|
||||
val oppositeClassFqName = map[DescriptorUtils.getFqName(descriptor)]
|
||||
?: throw IllegalArgumentException("Given class $descriptor is not a $mutabilityKindName collection")
|
||||
return descriptor.builtIns.getBuiltInClassByFqName(oppositeClassFqName)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.builtins.jvm
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.PlatformToKotlinClassMapper
|
||||
import org.jetbrains.kotlin.builtins.StandardNames
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.FqNameUnsafe
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
|
||||
object JavaToKotlinClassMapper : PlatformToKotlinClassMapper {
|
||||
override fun mapPlatformClass(classDescriptor: ClassDescriptor): Collection<ClassDescriptor> {
|
||||
val className = DescriptorUtils.getFqName(classDescriptor)
|
||||
return if (className.isSafe)
|
||||
mapPlatformClass(className.toSafe(), classDescriptor.builtIns)
|
||||
else
|
||||
emptySet()
|
||||
}
|
||||
|
||||
fun mapPlatformClass(fqName: FqName, builtIns: KotlinBuiltIns): Collection<ClassDescriptor> {
|
||||
val kotlinAnalog = mapJavaToKotlin(fqName, builtIns) ?: return emptySet()
|
||||
|
||||
val kotlinMutableAnalogFqName = JavaToKotlinClassMap.readOnlyToMutable(kotlinAnalog.fqNameUnsafe) ?: return setOf(kotlinAnalog)
|
||||
|
||||
return listOf(kotlinAnalog, builtIns.getBuiltInClassByFqName(kotlinMutableAnalogFqName))
|
||||
}
|
||||
|
||||
fun mapJavaToKotlin(fqName: FqName, builtIns: KotlinBuiltIns, functionTypeArity: Int? = null): ClassDescriptor? {
|
||||
val kotlinClassId =
|
||||
if (functionTypeArity != null && fqName == JavaToKotlinClassMap.FUNCTION_N_FQ_NAME) StandardNames.getFunctionClassId(functionTypeArity)
|
||||
else JavaToKotlinClassMap.mapJavaToKotlin(fqName)
|
||||
return if (kotlinClassId != null) builtIns.getBuiltInClassByFqName(kotlinClassId.asSingleFqName()) else null
|
||||
}
|
||||
|
||||
fun isMutable(mutable: ClassDescriptor): Boolean = JavaToKotlinClassMap.isMutable(DescriptorUtils.getFqName(mutable))
|
||||
|
||||
fun isMutable(type: KotlinType): Boolean {
|
||||
val classDescriptor = TypeUtils.getClassDescriptor(type)
|
||||
return classDescriptor != null && isMutable(classDescriptor)
|
||||
}
|
||||
|
||||
fun isReadOnly(readOnly: ClassDescriptor): Boolean = JavaToKotlinClassMap.isReadOnly(DescriptorUtils.getFqName(readOnly))
|
||||
|
||||
fun isReadOnly(type: KotlinType): Boolean {
|
||||
val classDescriptor = TypeUtils.getClassDescriptor(type)
|
||||
return classDescriptor != null && isReadOnly(classDescriptor)
|
||||
}
|
||||
|
||||
fun convertMutableToReadOnly(mutable: ClassDescriptor): ClassDescriptor {
|
||||
return convertToOppositeMutability(mutable,"mutable") {
|
||||
JavaToKotlinClassMap.mutableToReadOnly(it)
|
||||
}
|
||||
}
|
||||
|
||||
fun convertReadOnlyToMutable(readOnly: ClassDescriptor): ClassDescriptor {
|
||||
return convertToOppositeMutability(readOnly, "read-only") {
|
||||
JavaToKotlinClassMap.readOnlyToMutable(it)
|
||||
}
|
||||
}
|
||||
|
||||
private inline fun convertToOppositeMutability(
|
||||
descriptor: ClassDescriptor,
|
||||
mutabilityKindName: String,
|
||||
oppositeNameExtractor: (FqNameUnsafe?) -> FqName?
|
||||
): ClassDescriptor {
|
||||
val oppositeClassFqName = oppositeNameExtractor(DescriptorUtils.getFqName(descriptor))
|
||||
?: throw IllegalArgumentException("Given class $descriptor is not a $mutabilityKindName collection")
|
||||
return descriptor.builtIns.getBuiltInClassByFqName(oppositeClassFqName)
|
||||
}
|
||||
}
|
||||
@@ -47,7 +47,7 @@ open class JvmBuiltInsSettings(
|
||||
deferredOwnerModuleDescriptor: () -> ModuleDescriptor,
|
||||
isAdditionalBuiltInsFeatureSupported: () -> Boolean
|
||||
) : AdditionalClassPartsProvider, PlatformDependentDeclarationFilter {
|
||||
private val j2kClassMap = JavaToKotlinClassMap
|
||||
private val j2kClassMapper = JavaToKotlinClassMapper
|
||||
|
||||
private val ownerModuleDescriptor: ModuleDescriptor by lazy(deferredOwnerModuleDescriptor)
|
||||
private val isAdditionalBuiltInsFeatureSupported: Boolean by lazy(isAdditionalBuiltInsFeatureSupported)
|
||||
@@ -164,11 +164,11 @@ open class JvmBuiltInsSettings(
|
||||
): Collection<SimpleFunctionDescriptor> {
|
||||
val javaAnalogueDescriptor = classDescriptor.getJavaAnalogue() ?: return emptyList()
|
||||
|
||||
val kotlinClassDescriptors = j2kClassMap.mapPlatformClass(javaAnalogueDescriptor.fqNameSafe, FallbackBuiltIns.Instance)
|
||||
val kotlinClassDescriptors = j2kClassMapper.mapPlatformClass(javaAnalogueDescriptor.fqNameSafe, FallbackBuiltIns.Instance)
|
||||
val kotlinMutableClassIfContainer = kotlinClassDescriptors.lastOrNull() ?: return emptyList()
|
||||
val kotlinVersions = SmartSet.create(kotlinClassDescriptors.map { it.fqNameSafe })
|
||||
|
||||
val isMutable = j2kClassMap.isMutable(classDescriptor)
|
||||
val isMutable = j2kClassMapper.isMutable(classDescriptor)
|
||||
|
||||
val fakeJavaClassDescriptor = javaAnalogueClassesWithCustomSupertypeCache.computeIfAbsent(javaAnalogueDescriptor.fqNameSafe) {
|
||||
javaAnalogueDescriptor.copy(
|
||||
@@ -214,7 +214,7 @@ open class JvmBuiltInsSettings(
|
||||
{ it.original.overriddenDescriptors }
|
||||
) { overridden ->
|
||||
overridden.kind == CallableMemberDescriptor.Kind.DECLARATION &&
|
||||
j2kClassMap.isMutable(overridden.containingDeclaration as ClassDescriptor)
|
||||
j2kClassMapper.isMutable(overridden.containingDeclaration as ClassDescriptor)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -262,7 +262,7 @@ open class JvmBuiltInsSettings(
|
||||
|
||||
val fqName = fqNameUnsafe
|
||||
if (!fqName.isSafe) return null
|
||||
val javaAnalogueFqName = j2kClassMap.mapKotlinToJava(fqName)?.asSingleFqName() ?: return null
|
||||
val javaAnalogueFqName = JavaToKotlinClassMap.mapKotlinToJava(fqName)?.asSingleFqName() ?: return null
|
||||
|
||||
return ownerModuleDescriptor.resolveClassByFqName(javaAnalogueFqName, NoLookupLocation.FROM_BUILTINS) as? LazyJavaClassDescriptor
|
||||
}
|
||||
@@ -273,7 +273,7 @@ open class JvmBuiltInsSettings(
|
||||
val javaAnalogueDescriptor = classDescriptor.getJavaAnalogue() ?: return emptyList()
|
||||
|
||||
val defaultKotlinVersion =
|
||||
j2kClassMap.mapJavaToKotlin(javaAnalogueDescriptor.fqNameSafe, FallbackBuiltIns.Instance) ?: return emptyList()
|
||||
j2kClassMapper.mapJavaToKotlin(javaAnalogueDescriptor.fqNameSafe, FallbackBuiltIns.Instance) ?: return emptyList()
|
||||
|
||||
val substitutor = createMappedTypeParametersSubstitution(defaultKotlinVersion, javaAnalogueDescriptor).buildSubstitutor()
|
||||
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.load.java.lazy.descriptors
|
||||
|
||||
import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMap
|
||||
import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMapper
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.findNonGenericClassAcrossDependencies
|
||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames.DEFAULT_ANNOTATION_MEMBER_NAME
|
||||
@@ -47,7 +47,7 @@ class LazyJavaAnnotationDescriptor(
|
||||
|
||||
override val type by c.storageManager.createLazyValue {
|
||||
val fqName = fqName ?: return@createLazyValue ErrorUtils.createErrorType("No fqName: $javaAnnotation")
|
||||
val annotationClass = JavaToKotlinClassMap.mapJavaToKotlin(fqName, c.module.builtIns)
|
||||
val annotationClass = JavaToKotlinClassMapper.mapJavaToKotlin(fqName, c.module.builtIns)
|
||||
?: javaAnnotation.resolve()?.let { javaClass -> c.components.moduleClassResolver.resolveClass(javaClass) }
|
||||
?: createTypeForMissingDependencies(fqName)
|
||||
annotationClass.defaultType
|
||||
|
||||
+3
-3
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.load.java.lazy.types
|
||||
|
||||
import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMap
|
||||
import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMapper
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.load.java.components.TypeUsage
|
||||
@@ -156,7 +156,7 @@ class JavaTypeResolver(
|
||||
return c.components.reflectionTypes.kClass
|
||||
}
|
||||
|
||||
val javaToKotlin = JavaToKotlinClassMap
|
||||
val javaToKotlin = JavaToKotlinClassMapper
|
||||
|
||||
val kotlinDescriptor = javaToKotlin.mapJavaToKotlin(fqName, c.module.builtIns) ?: return null
|
||||
|
||||
@@ -182,7 +182,7 @@ class JavaTypeResolver(
|
||||
fun JavaType?.isSuperWildcard(): Boolean = (this as? JavaWildcardType)?.let { it.bound != null && !it.isExtends } ?: false
|
||||
|
||||
if (!typeArguments.lastOrNull().isSuperWildcard()) return false
|
||||
val mutableLastParameterVariance = JavaToKotlinClassMap.convertReadOnlyToMutable(readOnlyContainer)
|
||||
val mutableLastParameterVariance = JavaToKotlinClassMapper.convertReadOnlyToMutable(readOnlyContainer)
|
||||
.typeConstructor.parameters.lastOrNull()?.variance ?: return false
|
||||
|
||||
return mutableLastParameterVariance != OUT_VARIANCE
|
||||
|
||||
+4
-3
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.kotlin.load.java.typeEnhancement
|
||||
|
||||
import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMap
|
||||
import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMapper
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotated
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
||||
@@ -257,7 +258,7 @@ class SignatureEnhancement(
|
||||
asFlexibleType().let { Pair(it.lowerBound, it.upperBound) }
|
||||
else Pair(this, this)
|
||||
|
||||
val mapping = JavaToKotlinClassMap
|
||||
val mapper = JavaToKotlinClassMapper
|
||||
return JavaTypeQualifiers(
|
||||
when {
|
||||
lower.isMarkedNullable -> NullabilityQualifier.NULLABLE
|
||||
@@ -265,8 +266,8 @@ class SignatureEnhancement(
|
||||
else -> null
|
||||
},
|
||||
when {
|
||||
mapping.isReadOnly(lower) -> MutabilityQualifier.READ_ONLY
|
||||
mapping.isMutable(upper) -> MutabilityQualifier.MUTABLE
|
||||
mapper.isReadOnly(lower) -> MutabilityQualifier.READ_ONLY
|
||||
mapper.isMutable(upper) -> MutabilityQualifier.MUTABLE
|
||||
else -> null
|
||||
},
|
||||
isNotNullTypeParameter = unwrap() is NotNullTypeParameter
|
||||
|
||||
+6
-6
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.load.java.typeEnhancement
|
||||
|
||||
import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMap
|
||||
import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMapper
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.SourceElement
|
||||
@@ -180,17 +180,17 @@ private fun ClassifierDescriptor.enhanceMutability(
|
||||
if (!position.shouldEnhance()) return this.noChange()
|
||||
if (this !is ClassDescriptor) return this.noChange() // mutability is not applicable for type parameters
|
||||
|
||||
val mapping = JavaToKotlinClassMap
|
||||
val mapper = JavaToKotlinClassMapper
|
||||
|
||||
when (qualifiers.mutability) {
|
||||
READ_ONLY -> {
|
||||
if (position == TypeComponentPosition.FLEXIBLE_LOWER && mapping.isMutable(this)) {
|
||||
return mapping.convertMutableToReadOnly(this).enhancedMutability()
|
||||
if (position == TypeComponentPosition.FLEXIBLE_LOWER && mapper.isMutable(this)) {
|
||||
return mapper.convertMutableToReadOnly(this).enhancedMutability()
|
||||
}
|
||||
}
|
||||
MUTABLE -> {
|
||||
if (position == TypeComponentPosition.FLEXIBLE_UPPER && mapping.isReadOnly(this)) {
|
||||
return mapping.convertReadOnlyToMutable(this).enhancedMutability()
|
||||
if (position == TypeComponentPosition.FLEXIBLE_UPPER && mapper.isReadOnly(this)) {
|
||||
return mapper.convertReadOnlyToMutable(this).enhancedMutability()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -12,12 +12,12 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
@DefaultImplementation(impl = PlatformToKotlinClassMap.Default.class)
|
||||
public interface PlatformToKotlinClassMap {
|
||||
@DefaultImplementation(impl = PlatformToKotlinClassMapper.Default.class)
|
||||
public interface PlatformToKotlinClassMapper {
|
||||
@NotNull
|
||||
Collection<ClassDescriptor> mapPlatformClass(@NotNull ClassDescriptor classDescriptor);
|
||||
|
||||
class Default implements PlatformToKotlinClassMap {
|
||||
class Default implements PlatformToKotlinClassMapper {
|
||||
@NotNull
|
||||
@Override
|
||||
public Collection<ClassDescriptor> mapPlatformClass(@NotNull ClassDescriptor classDescriptor) {
|
||||
Reference in New Issue
Block a user