[FIR] Java super-type arguments are now handled as flexible

This commit is contained in:
Mikhail Glukhikh
2020-01-31 12:57:29 +03:00
parent aeb6f35571
commit 91b432b4a1
32 changed files with 122 additions and 93 deletions
@@ -27,6 +27,7 @@ import org.jetbrains.kotlin.fir.scopes.FirScope
import org.jetbrains.kotlin.fir.scopes.impl.* import org.jetbrains.kotlin.fir.scopes.impl.*
import org.jetbrains.kotlin.fir.symbols.CallableId import org.jetbrains.kotlin.fir.symbols.CallableId
import org.jetbrains.kotlin.fir.symbols.impl.* import org.jetbrains.kotlin.fir.symbols.impl.*
import org.jetbrains.kotlin.fir.types.ConeNullability
import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl
import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl import org.jetbrains.kotlin.fir.types.impl.FirResolvedTypeRefImpl
import org.jetbrains.kotlin.load.java.JavaClassFinder import org.jetbrains.kotlin.load.java.JavaClassFinder
@@ -95,7 +96,7 @@ class JavaSymbolProvider(
) { ) {
require(this is FirTypeParameterImpl) require(this is FirTypeParameterImpl)
for (upperBound in javaTypeParameter.upperBounds) { for (upperBound in javaTypeParameter.upperBounds) {
bounds += upperBound.toFirResolvedTypeRef(this@JavaSymbolProvider.session, stack, isNullable = true) bounds += upperBound.toFirResolvedTypeRef(this@JavaSymbolProvider.session, stack, nullability = ConeNullability.NULLABLE)
} }
addDefaultBoundIfNecessary() addDefaultBoundIfNecessary()
} }
@@ -155,7 +156,9 @@ class JavaSymbolProvider(
this.typeParameters += foundClass.typeParameters.convertTypeParameters(javaTypeParameterStack) this.typeParameters += foundClass.typeParameters.convertTypeParameters(javaTypeParameterStack)
addAnnotationsFrom(this@JavaSymbolProvider.session, javaClass, javaTypeParameterStack) addAnnotationsFrom(this@JavaSymbolProvider.session, javaClass, javaTypeParameterStack)
for (supertype in javaClass.supertypes) { for (supertype in javaClass.supertypes) {
superTypeRefs += supertype.toFirResolvedTypeRef(this@JavaSymbolProvider.session, javaTypeParameterStack) superTypeRefs += supertype.toFirResolvedTypeRef(
this@JavaSymbolProvider.session, javaTypeParameterStack, typeParametersNullability = ConeNullability.UNKNOWN
)
} }
// TODO: may be we can process fields & methods later. // TODO: may be we can process fields & methods later.
// However, they should be built up to override resolve stage // However, they should be built up to override resolve stage
@@ -78,8 +78,8 @@ internal fun FirTypeRef.toNotNullConeKotlinType(
internal fun JavaType?.toNotNullConeKotlinType( internal fun JavaType?.toNotNullConeKotlinType(
session: FirSession, javaTypeParameterStack: JavaTypeParameterStack session: FirSession, javaTypeParameterStack: JavaTypeParameterStack
): ConeLookupTagBasedType { ): ConeKotlinType {
return toConeKotlinTypeWithNullability(session, javaTypeParameterStack, isNullable = false) return toConeKotlinTypeWithNullability(session, javaTypeParameterStack, ConeNullability.NOT_NULL)
} }
internal fun JavaType.toFirJavaTypeRef(session: FirSession, javaTypeParameterStack: JavaTypeParameterStack): FirJavaTypeRef { internal fun JavaType.toFirJavaTypeRef(session: FirSession, javaTypeParameterStack: JavaTypeParameterStack): FirJavaTypeRef {
@@ -91,9 +91,12 @@ internal fun JavaType.toFirJavaTypeRef(session: FirSession, javaTypeParameterSta
} }
internal fun JavaClassifierType.toFirResolvedTypeRef( internal fun JavaClassifierType.toFirResolvedTypeRef(
session: FirSession, javaTypeParameterStack: JavaTypeParameterStack, isNullable: Boolean = false session: FirSession,
javaTypeParameterStack: JavaTypeParameterStack,
nullability: ConeNullability = ConeNullability.NOT_NULL,
typeParametersNullability: ConeNullability = ConeNullability.NOT_NULL
): FirResolvedTypeRef { ): FirResolvedTypeRef {
val coneType = this.toConeKotlinTypeWithNullability(session, javaTypeParameterStack, isNullable) val coneType = this.toConeKotlinTypeWithNullability(session, javaTypeParameterStack, nullability, typeParametersNullability)
return FirResolvedTypeRefImpl( return FirResolvedTypeRefImpl(
source = null, type = coneType source = null, type = coneType
).apply { ).apply {
@@ -102,11 +105,14 @@ internal fun JavaClassifierType.toFirResolvedTypeRef(
} }
internal fun JavaType?.toConeKotlinTypeWithNullability( internal fun JavaType?.toConeKotlinTypeWithNullability(
session: FirSession, javaTypeParameterStack: JavaTypeParameterStack, isNullable: Boolean session: FirSession,
): ConeLookupTagBasedType { javaTypeParameterStack: JavaTypeParameterStack,
nullability: ConeNullability,
typeParametersNullability: ConeNullability = ConeNullability.NOT_NULL
): ConeKotlinType {
return when (this) { return when (this) {
is JavaClassifierType -> { is JavaClassifierType -> {
toConeKotlinTypeWithNullability(session, isNullable, javaTypeParameterStack) toConeKotlinTypeWithNullability(session, nullability, typeParametersNullability, javaTypeParameterStack)
} }
is JavaPrimitiveType -> { is JavaPrimitiveType -> {
val primitiveType = type val primitiveType = type
@@ -115,38 +121,47 @@ internal fun JavaType?.toConeKotlinTypeWithNullability(
else -> javaName.capitalize() else -> javaName.capitalize()
} }
val classId = StandardClassIds.byName(kotlinPrimitiveName) val classId = StandardClassIds.byName(kotlinPrimitiveName)
classId.toConeKotlinType(emptyArray(), isNullable) classId.toConeKotlinType(emptyArray(), nullability.isNullable)
} }
is JavaArrayType -> { is JavaArrayType -> {
val componentType = componentType val componentType = componentType
if (componentType !is JavaPrimitiveType) { if (componentType !is JavaPrimitiveType) {
val classId = StandardClassIds.Array val classId = StandardClassIds.Array
val argumentType = ConeFlexibleType( val argumentType = ConeFlexibleType(
componentType.toConeKotlinTypeWithNullability(session, javaTypeParameterStack, isNullable = false), componentType.toConeKotlinTypeWithNullability(session, javaTypeParameterStack, ConeNullability.NOT_NULL),
componentType.toConeKotlinTypeWithNullability(session, javaTypeParameterStack, isNullable = true) componentType.toConeKotlinTypeWithNullability(session, javaTypeParameterStack, ConeNullability.NULLABLE)
) )
classId.toConeKotlinType(arrayOf(argumentType), isNullable) classId.toConeKotlinType(arrayOf(argumentType), nullability.isNullable)
} else { } else {
val javaComponentName = componentType.type?.typeName?.asString()?.capitalize() ?: error("Array of voids") val javaComponentName = componentType.type?.typeName?.asString()?.capitalize() ?: error("Array of voids")
val classId = StandardClassIds.byName(javaComponentName + "Array") val classId = StandardClassIds.byName(javaComponentName + "Array")
classId.toConeKotlinType(emptyArray(), isNullable) classId.toConeKotlinType(emptyArray(), nullability.isNullable)
} }
} }
is JavaWildcardType -> bound?.toNotNullConeKotlinType(session, javaTypeParameterStack) ?: run { is JavaWildcardType -> bound?.toNotNullConeKotlinType(session, javaTypeParameterStack) ?: run {
val classId = StandardClassIds.Any val classId = StandardClassIds.Any
classId.toConeKotlinType(emptyArray(), isNullable) classId.toConeKotlinType(emptyArray(), nullability.isNullable)
} }
null -> { null -> {
val classId = StandardClassIds.Any val classId = StandardClassIds.Any
classId.toConeKotlinType(emptyArray(), isNullable) classId.toConeKotlinType(emptyArray(), nullability.isNullable)
} }
else -> error("Strange JavaType: ${this::class.java}") else -> error("Strange JavaType: ${this::class.java}")
} }
} }
internal fun JavaClassifierType.toConeKotlinTypeWithNullability( internal fun JavaClassifierType.toConeKotlinTypeWithNullability(
session: FirSession, isNullable: Boolean, javaTypeParameterStack: JavaTypeParameterStack session: FirSession,
): ConeLookupTagBasedType { nullability: ConeNullability,
typeParametersNullability: ConeNullability,
javaTypeParameterStack: JavaTypeParameterStack
): ConeKotlinType {
if (nullability == ConeNullability.UNKNOWN) {
return ConeFlexibleType(
toConeKotlinTypeWithNullability(session, ConeNullability.NOT_NULL, typeParametersNullability, javaTypeParameterStack),
toConeKotlinTypeWithNullability(session, ConeNullability.NULLABLE, typeParametersNullability, javaTypeParameterStack)
)
}
return when (val classifier = classifier) { return when (val classifier = classifier) {
is JavaClass -> { is JavaClass -> {
//val classId = classifier.classId!! //val classId = classifier.classId!!
@@ -155,17 +170,16 @@ internal fun JavaClassifierType.toConeKotlinTypeWithNullability(
val lookupTag = ConeClassLikeLookupTagImpl(classId) val lookupTag = ConeClassLikeLookupTagImpl(classId)
lookupTag.constructClassType( lookupTag.constructClassType(
typeArguments.mapIndexed { index, argument -> typeArguments.map { argument ->
argument.toConeProjection( argument.toConeProjection(
session, javaTypeParameterStack, null session, javaTypeParameterStack, boundTypeParameter = null, nullability = typeParametersNullability
//symbol.fir.typeParameters.getOrNull(index)
) )
}.toTypedArray(), isNullable }.toTypedArray(), nullability.isNullable
) )
} }
is JavaTypeParameter -> { is JavaTypeParameter -> {
val symbol = javaTypeParameterStack[classifier] val symbol = javaTypeParameterStack[classifier]
ConeTypeParameterTypeImpl(symbol.toLookupTag(), isNullable) ConeTypeParameterTypeImpl(symbol.toLookupTag(), nullability.isNullable)
} }
else -> ConeClassErrorType(reason = "Unexpected classifier: $classifier") else -> ConeClassErrorType(reason = "Unexpected classifier: $classifier")
} }
@@ -208,7 +222,10 @@ internal fun JavaValueParameter.toFirValueParameter(
} }
internal fun JavaType?.toConeProjection( internal fun JavaType?.toConeProjection(
session: FirSession, javaTypeParameterStack: JavaTypeParameterStack, boundTypeParameter: FirTypeParameter? session: FirSession,
javaTypeParameterStack: JavaTypeParameterStack,
boundTypeParameter: FirTypeParameter?,
nullability: ConeNullability = ConeNullability.NOT_NULL
): ConeKotlinTypeProjection { ): ConeKotlinTypeProjection {
return when (this) { return when (this) {
null -> ConeStarProjection null -> ConeStarProjection
@@ -219,7 +236,7 @@ internal fun JavaType?.toConeProjection(
if (bound == null || parameterVariance != INVARIANT && parameterVariance != argumentVariance) { if (bound == null || parameterVariance != INVARIANT && parameterVariance != argumentVariance) {
ConeStarProjection ConeStarProjection
} else { } else {
val boundType = bound.toConeKotlinTypeWithNullability(session, javaTypeParameterStack, isNullable = false) val boundType = bound.toConeKotlinTypeWithNullability(session, javaTypeParameterStack, nullability)
if (argumentVariance == OUT_VARIANCE) { if (argumentVariance == OUT_VARIANCE) {
ConeKotlinTypeProjectionOut(boundType) ConeKotlinTypeProjectionOut(boundType)
} else { } else {
@@ -227,7 +244,7 @@ internal fun JavaType?.toConeProjection(
} }
} }
} }
is JavaClassifierType -> toConeKotlinTypeWithNullability(session, javaTypeParameterStack, isNullable = false) is JavaClassifierType -> toConeKotlinTypeWithNullability(session, javaTypeParameterStack, nullability)
else -> ConeClassErrorType("Unexpected type argument: $this") else -> ConeClassErrorType("Unexpected type argument: $this")
} }
} }
@@ -260,7 +277,9 @@ private fun JavaAnnotationArgument.toFirExpression(
null null
} }
this.calleeReference = calleeReference this.calleeReference = calleeReference
?: FirErrorNamedReferenceImpl(null, FirSimpleDiagnostic("Strange Java enum value: $classId.$entryName", DiagnosticKind.Java)) ?: FirErrorNamedReferenceImpl(
null, FirSimpleDiagnostic("Strange Java enum value: $classId.$entryName", DiagnosticKind.Java)
)
} }
} }
is JavaClassObjectAnnotationArgument -> FirGetClassCallImpl(null).apply { is JavaClassObjectAnnotationArgument -> FirGetClassCallImpl(null).apply {
@@ -270,7 +289,9 @@ private fun JavaAnnotationArgument.toFirExpression(
) )
} }
is JavaAnnotationAsAnnotationArgument -> getAnnotation().toFirAnnotationCall(session, javaTypeParameterStack) is JavaAnnotationAsAnnotationArgument -> getAnnotation().toFirAnnotationCall(session, javaTypeParameterStack)
else -> FirErrorExpressionImpl(null, FirSimpleDiagnostic("Unknown JavaAnnotationArgument: ${this::class.java}", DiagnosticKind.Java)) else -> FirErrorExpressionImpl(
null, FirSimpleDiagnostic("Unknown JavaAnnotationArgument: ${this::class.java}", DiagnosticKind.Java)
)
} }
} }
@@ -304,7 +325,9 @@ internal fun Any?.createConstant(session: FirSession): FirExpression {
is BooleanArray -> toList().createArrayOfCall(session, FirConstKind.Boolean) is BooleanArray -> toList().createArrayOfCall(session, FirConstKind.Boolean)
null -> FirConstExpressionImpl(null, FirConstKind.Null, null) null -> FirConstExpressionImpl(null, FirConstKind.Null, null)
else -> FirErrorExpressionImpl(null, FirSimpleDiagnostic("Unknown value in JavaLiteralAnnotationArgument: $this", DiagnosticKind.Java)) else -> FirErrorExpressionImpl(
null, FirSimpleDiagnostic("Unknown value in JavaLiteralAnnotationArgument: $this", DiagnosticKind.Java)
)
} }
} }
@@ -152,8 +152,8 @@ internal class EnhancementSignatureParts(
is FirJavaTypeRef -> { is FirJavaTypeRef -> {
Pair( Pair(
// TODO: optimize // TODO: optimize
type.toConeKotlinTypeWithNullability(session, javaTypeParameterStack, isNullable = false), type.toConeKotlinTypeWithNullability(session, javaTypeParameterStack, nullability = ConeNullability.NOT_NULL),
type.toConeKotlinTypeWithNullability(session, javaTypeParameterStack, isNullable = true) type.toConeKotlinTypeWithNullability(session, javaTypeParameterStack, nullability = ConeNullability.NULLABLE)
) )
} }
else -> return JavaTypeQualifiers.NONE else -> return JavaTypeQualifiers.NONE
@@ -19,7 +19,6 @@ import org.jetbrains.kotlin.fir.java.declarations.FirJavaField
import org.jetbrains.kotlin.fir.java.toConeProjection import org.jetbrains.kotlin.fir.java.toConeProjection
import org.jetbrains.kotlin.fir.java.toNotNullConeKotlinType import org.jetbrains.kotlin.fir.java.toNotNullConeKotlinType
import org.jetbrains.kotlin.fir.references.impl.FirResolvedNamedReferenceImpl import org.jetbrains.kotlin.fir.references.impl.FirResolvedNamedReferenceImpl
import org.jetbrains.kotlin.fir.references.impl.FirSimpleNamedReference
import org.jetbrains.kotlin.fir.resolve.* import org.jetbrains.kotlin.fir.resolve.*
import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.firUnsafe import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.firUnsafe
import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag
@@ -124,12 +123,12 @@ private fun JavaType?.subtreeSize(): Int {
private fun coneFlexibleOrSimpleType( private fun coneFlexibleOrSimpleType(
session: FirSession, session: FirSession,
lowerBound: ConeLookupTagBasedType, lowerBound: ConeKotlinType,
upperBound: ConeLookupTagBasedType, upperBound: ConeKotlinType,
isNotNullTypeParameter: Boolean isNotNullTypeParameter: Boolean
): ConeKotlinType { ): ConeKotlinType {
if (AbstractStrictEqualityTypeChecker.strictEqualTypes(session.typeContext, lowerBound, upperBound)) { if (AbstractStrictEqualityTypeChecker.strictEqualTypes(session.typeContext, lowerBound, upperBound)) {
val lookupTag = lowerBound.lookupTag val lookupTag = (lowerBound as? ConeLookupTagBasedType)?.lookupTag
if (isNotNullTypeParameter && lookupTag is ConeTypeParameterLookupTag && !lowerBound.isMarkedNullable) { if (isNotNullTypeParameter && lookupTag is ConeTypeParameterLookupTag && !lowerBound.isMarkedNullable) {
// TODO: we need enhancement for type parameter bounds for this code to work properly // TODO: we need enhancement for type parameter bounds for this code to work properly
// At this moment, this condition is always true // At this moment, this condition is always true
@@ -164,8 +163,6 @@ private fun ClassId.mutableToReadOnly(): ClassId? {
} }
} }
// Definition: // Definition:
// ErasedUpperBound(T : G<t>) = G<*> // UpperBound(T) is a type G<t> with arguments // ErasedUpperBound(T : G<t>) = G<*> // UpperBound(T) is a type G<t> with arguments
// ErasedUpperBound(T : A) = A // UpperBound(T) is a type A without arguments // ErasedUpperBound(T : A) = A // UpperBound(T) is a type A without arguments
@@ -181,8 +178,7 @@ private fun FirTypeParameter.getErasedUpperBound(
val firstUpperBound = this.bounds.first().coneTypeUnsafe<ConeKotlinType>() val firstUpperBound = this.bounds.first().coneTypeUnsafe<ConeKotlinType>()
val firstUpperBoundClassifier = firstUpperBound if (firstUpperBound is ConeClassLikeType) {
if (firstUpperBoundClassifier is ConeClassLikeType) {
return firstUpperBound.withArguments(firstUpperBound.typeArguments.map { ConeStarProjection }.toTypedArray()) return firstUpperBound.withArguments(firstUpperBound.typeArguments.map { ConeStarProjection }.toTypedArray())
} }
@@ -225,7 +221,8 @@ fun computeProjection(
// in T -> Comparable<Nothing> // in T -> Comparable<Nothing>
session.builtinTypes.nothingType.type session.builtinTypes.nothingType.type
else if (erasedUpperBound is ConeClassLikeType && else if (erasedUpperBound is ConeClassLikeType &&
erasedUpperBound.lookupTag.toSymbol(session)!!.firUnsafe<FirRegularClass>().typeParameters.isNotEmpty()) erasedUpperBound.lookupTag.toSymbol(session)!!.firUnsafe<FirRegularClass>().typeParameters.isNotEmpty()
)
// T : Enum<E> -> out Enum<*> // T : Enum<E> -> out Enum<*>
ConeKotlinTypeProjectionOut(erasedUpperBound) ConeKotlinTypeProjectionOut(erasedUpperBound)
else else
@@ -234,8 +231,6 @@ fun computeProjection(
} }
} }
private fun JavaClassifierType.enhanceInflexibleType( private fun JavaClassifierType.enhanceInflexibleType(
session: FirSession, session: FirSession,
javaTypeParameterStack: JavaTypeParameterStack, javaTypeParameterStack: JavaTypeParameterStack,
@@ -244,9 +239,8 @@ private fun JavaClassifierType.enhanceInflexibleType(
position: TypeComponentPosition, position: TypeComponentPosition,
qualifiers: IndexedJavaTypeQualifiers, qualifiers: IndexedJavaTypeQualifiers,
index: Int index: Int
): ConeLookupTagBasedType { ): ConeKotlinType {
val classifier = classifier val originalTag = when (val classifier = classifier) {
val originalTag = when (classifier) {
is JavaClass -> { is JavaClass -> {
val classId = classifier.classId!! val classId = classifier.classId!!
var mappedId = JavaToKotlinClassMap.mapJavaToKotlin(classId.asSingleFqName()) var mappedId = JavaToKotlinClassMap.mapJavaToKotlin(classId.asSingleFqName())
@@ -217,10 +217,17 @@ fun coneFlexibleOrSimpleType(
if (upperBound is ConeFlexibleType) { if (upperBound is ConeFlexibleType) {
return coneFlexibleOrSimpleType(typeContext, lowerBound, upperBound.upperBound) return coneFlexibleOrSimpleType(typeContext, lowerBound, upperBound.upperBound)
} }
if (typeContext != null && AbstractStrictEqualityTypeChecker.strictEqualTypes(typeContext, lowerBound, upperBound)) { return when {
return lowerBound typeContext != null && AbstractStrictEqualityTypeChecker.strictEqualTypes(typeContext, lowerBound, upperBound) -> {
lowerBound
}
typeContext == null && lowerBound == upperBound -> {
lowerBound
}
else -> {
ConeFlexibleType(lowerBound, upperBound)
}
} }
return ConeFlexibleType(lowerBound, upperBound)
} }
fun <T : ConeKotlinType> T.withNullability(nullability: ConeNullability, typeContext: ConeInferenceContext? = null): T { fun <T : ConeKotlinType> T.withNullability(nullability: ConeNullability, typeContext: ConeInferenceContext? = null): T {
@@ -1,4 +1,4 @@
public abstract class AbstractMap : R|kotlin/Any|, R|kotlin/collections/MutableMap<kotlin/String, kotlin/String>| { public abstract class AbstractMap : R|kotlin/Any|, R|kotlin/collections/MutableMap<ft<kotlin/String, kotlin/String?>!, ft<kotlin/String, kotlin/String?>!>| {
public constructor(): R|AbstractMap| public constructor(): R|AbstractMap|
} }
@@ -10,7 +10,7 @@ public/*package*/ open class A : R|kotlin/Any| {
public/*package*/ constructor(): R|A| public/*package*/ constructor(): R|A|
} }
public final enum class Mixed : R|kotlin/Enum<Mixed>| { public final enum class Mixed : R|kotlin/Enum<ft<Mixed, Mixed?>!>| {
public final static field NOT_ENTRY_EITHER: R|ft<Mixed, Mixed?>!| public final static field NOT_ENTRY_EITHER: R|ft<Mixed, Mixed?>!|
public final static fun values(): R|kotlin/Array<Mixed>| { public final static fun values(): R|kotlin/Array<Mixed>| {
@@ -20,7 +20,7 @@ public final enum class Mixed : R|kotlin/Enum<Mixed>| {
} }
} }
public final enum class Signs : R|kotlin/Enum<Signs>| { public final enum class Signs : R|kotlin/Enum<ft<Signs, Signs?>!>| {
public final static field HELLO: R|ft<Signs, Signs?>!| public final static field HELLO: R|ft<Signs, Signs?>!|
public final static field WORLD: R|ft<Signs, Signs?>!| public final static field WORLD: R|ft<Signs, Signs?>!|
+3 -3
View File
@@ -1,10 +1,10 @@
FILE: hashSet.kt FILE: hashSet.kt
public final val a: R|kotlin/collections/MutableSet<kotlin/String>?| = R|java/util/HashSet.HashSet|<R|kotlin/String|>() public final val a: R|kotlin/collections/MutableSet<kotlin/String>?| = R|java/util/HashSet.HashSet|<R|ft<kotlin/String, kotlin/String?>!|>()
public get(): R|kotlin/collections/MutableSet<kotlin/String>?| public get(): R|kotlin/collections/MutableSet<kotlin/String>?|
public final var b: R|kotlin/collections/MutableSet<kotlin/String>?| = Null(null) public final var b: R|kotlin/collections/MutableSet<kotlin/String>?| = Null(null)
public get(): R|kotlin/collections/MutableSet<kotlin/String>?| public get(): R|kotlin/collections/MutableSet<kotlin/String>?|
public set(_: R|kotlin/collections/MutableSet<kotlin/String>?|): R|kotlin/Unit| { public set(_: R|kotlin/collections/MutableSet<kotlin/String>?|): R|kotlin/Unit| {
F|/b| = R|java/util/HashSet.HashSet|<R|kotlin/String|>() F|/b| = R|java/util/HashSet.HashSet|<R|ft<kotlin/String, kotlin/String?>!|>()
} }
public final var <T> R|kotlin/collections/MutableSet<T>|.d: R|T?| public final var <T> R|kotlin/collections/MutableSet<T>|.d: R|T?|
public get(): R|T?| { public get(): R|T?| {
@@ -17,6 +17,6 @@ FILE: hashSet.kt
} }
public final fun foo(): R|kotlin/Unit| { public final fun foo(): R|kotlin/Unit| {
lvar c: R|kotlin/collections/MutableSet<kotlin/String>?| = Null(null) lvar c: R|kotlin/collections/MutableSet<kotlin/String>?| = Null(null)
R|<local>/c| = R|java/util/HashSet.HashSet|<R|kotlin/String|>() R|<local>/c| = R|java/util/HashSet.HashSet|<R|ft<kotlin/String, kotlin/String?>!|>()
R|<local>/c|!!.R|/d| = R|/produce|<R|T?|>() R|<local>/c|!!.R|/d| = R|/produce|<R|T?|>()
} }
@@ -16,7 +16,7 @@ FILE: K2.kt
} }
public final fun bar(): R|kotlin/Unit| { public final fun bar(): R|kotlin/Unit| {
this@R|/K2|.R|FakeOverride</KFirst.foo: R|kotlin/Int|>|(Int(1)) this@R|/K2|.R|FakeOverride</KFirst.foo: R|ft<kotlin/Int, kotlin/Int?>!|>|(Int(1))
this@R|/K2|.R|/J1.baz|() this@R|/K2|.R|/J1.baz|()
} }
@@ -17,7 +17,7 @@ class MyMapEntry : Test.MapEntryImpl()
fun test() { fun test() {
val b = MyMapEntry() val b = MyMapEntry()
b.key val key = b.key
b.value val value = b.value
b.setValue(null) b.setValue(null)
} }
@@ -7,7 +7,7 @@ FILE: main.kt
} }
public final fun test(): R|kotlin/Unit| { public final fun test(): R|kotlin/Unit| {
lval b: R|MyMapEntry| = R|/MyMapEntry.MyMapEntry|() lval b: R|MyMapEntry| = R|/MyMapEntry.MyMapEntry|()
R|<local>/b|.R|/Test.MapEntryImpl.key| lval key: R|ft<kotlin/String, kotlin/String?>!| = R|<local>/b|.R|/Test.MapEntryImpl.key|
R|<local>/b|.R|/Test.MapEntryImpl.value| lval value: R|ft<kotlin/String, kotlin/String?>!| = R|<local>/b|.R|/Test.MapEntryImpl.value|
R|<local>/b|.R|/Test.MapEntryImpl.setValue|(Null(null)) R|<local>/b|.R|/Test.MapEntryImpl.setValue|(Null(null))
} }
@@ -1,8 +1,8 @@
FILE: test.kt FILE: test.kt
public abstract interface UseIterable : R|MyIterable<kotlin/String>| { public abstract interface UseIterable : R|MyIterable<kotlin/String>| {
public open fun test(): R|kotlin/Unit| { public open fun test(): R|kotlin/Unit| {
lval it: R|kotlin/collections/MutableIterator<kotlin/String>| = this@R|/UseIterable|.R|FakeOverride<kotlin/collections/MutableIterable.iterator: R|kotlin/collections/MutableIterator<kotlin/String>|>|() lval it: R|kotlin/collections/MutableIterator<ft<kotlin/String, kotlin/String?>!>| = this@R|/UseIterable|.R|FakeOverride<kotlin/collections/MutableIterable.iterator: R|kotlin/collections/MutableIterator<ft<kotlin/String, kotlin/String?>!>|>|()
lval split: R|java/util/Spliterator<kotlin/String>| = this@R|/UseIterable|.R|FakeOverride<java/lang/Iterable.spliterator: R|java/util/Spliterator<kotlin/String>|>|() lval split: R|java/util/Spliterator<ft<kotlin/String, kotlin/String?>!>| = this@R|/UseIterable|.R|FakeOverride<java/lang/Iterable.spliterator: R|java/util/Spliterator<ft<kotlin/String, kotlin/String?>!>|>|()
} }
} }
+6 -6
View File
@@ -1,20 +1,20 @@
FILE: test.kt FILE: test.kt
public final fun test(map: R|MyMap|): R|kotlin/Unit| { public final fun test(map: R|MyMap|): R|kotlin/Unit| {
lval result: R|kotlin/String| = R|<local>/map|.R|kotlin/collections/getOrPut|<R|kotlin/String|, R|kotlin/String|>(String(key), <L> = getOrPut@fun <anonymous>(): R|kotlin/String| <kind=UNKNOWN> { lval result: R|ft<kotlin/String, kotlin/String?>!| = R|<local>/map|.R|kotlin/collections/getOrPut|<R|ft<kotlin/String, kotlin/String?>!|, R|ft<kotlin/String, kotlin/String?>!|>(String(key), <L> = getOrPut@fun <anonymous>(): R|kotlin/String| <kind=UNKNOWN> {
String(value) String(value)
} }
) )
lval otherResult: R|kotlin/String| = R|<local>/map|.R|FakeOverride<kotlin/collections/Map.getOrDefault: R|kotlin/String|>|(String(key), String(value)) lval otherResult: R|ft<kotlin/String, kotlin/String?>!| = R|<local>/map|.R|FakeOverride<kotlin/collections/Map.getOrDefault: R|ft<kotlin/String, kotlin/String?>!|>|(String(key), String(value))
lval anotherResult: <ERROR TYPE REF: Unresolved name: replace> = R|<local>/map|.<Unresolved name: replace>#(String(key), String(value)) lval anotherResult: <ERROR TYPE REF: Unresolved name: replace> = R|<local>/map|.<Unresolved name: replace>#(String(key), String(value))
R|<local>/map|.R|FakeOverride<java/util/Map.forEach: R|kotlin/Unit|>|(<L> = forEach@fun <anonymous>(key: R|kotlin/String|, value: R|kotlin/String|): R|kotlin/Unit| { R|<local>/map|.R|FakeOverride<java/util/Map.forEach: R|kotlin/Unit|>|(<L> = forEach@fun <anonymous>(key: R|ft<kotlin/String, kotlin/String?>!|, value: R|ft<kotlin/String, kotlin/String?>!|): R|kotlin/Unit| {
R|kotlin/io/println|(<strcat>(R|<local>/key|.R|kotlin/Any.toString|(), String(: ), R|<local>/value|.R|kotlin/Any.toString|())) R|kotlin/io/println|(<strcat>(R|<local>/key|.R|kotlin/Any.toString|(), String(: ), R|<local>/value|.R|kotlin/Any.toString|()))
R|<local>/key|.R|kotlin/String.length| R|<local>/key|.R|kotlin/String.length|
R|<local>/value|.R|kotlin/String.length| R|<local>/value|.R|kotlin/String.length|
} }
) )
R|<local>/map|.R|kotlin/collections/forEach|<R|kotlin/String|, R|kotlin/String|>(<L> = forEach@fun <anonymous>(<destruct>: R|kotlin/collections/Map.Entry<kotlin/String, kotlin/String>|): R|kotlin/Unit| <kind=UNKNOWN> { R|<local>/map|.R|kotlin/collections/forEach|<R|ft<kotlin/String, kotlin/String?>!|, R|ft<kotlin/String, kotlin/String?>!|>(<L> = forEach@fun <anonymous>(<destruct>: R|kotlin/collections/Map.Entry<ft<kotlin/String, kotlin/String?>!, ft<kotlin/String, kotlin/String?>!>|): R|kotlin/Unit| <kind=UNKNOWN> {
lval key: R|kotlin/String| = R|<local>/<destruct>|.R|kotlin/collections/component1|<R|kotlin/String|, R|kotlin/String|>() lval key: R|ft<kotlin/String, kotlin/String?>!| = R|<local>/<destruct>|.R|kotlin/collections/component1|<R|ft<kotlin/String, kotlin/String?>!|, R|ft<kotlin/String, kotlin/String?>!|>()
lval value: R|kotlin/String| = R|<local>/<destruct>|.R|kotlin/collections/component2|<R|kotlin/String|, R|kotlin/String|>() lval value: R|ft<kotlin/String, kotlin/String?>!| = R|<local>/<destruct>|.R|kotlin/collections/component2|<R|ft<kotlin/String, kotlin/String?>!|, R|ft<kotlin/String, kotlin/String?>!|>()
R|kotlin/io/println|(<strcat>(R|<local>/key|.R|kotlin/Any.toString|(), String(: ), R|<local>/value|.R|kotlin/Any.toString|())) R|kotlin/io/println|(<strcat>(R|<local>/key|.R|kotlin/Any.toString|(), String(: ), R|<local>/value|.R|kotlin/Any.toString|()))
R|<local>/key|.R|kotlin/String.length| R|<local>/key|.R|kotlin/String.length|
R|<local>/value|.R|kotlin/String.length| R|<local>/value|.R|kotlin/String.length|
@@ -1,3 +1,4 @@
fun test(map: java.util.AbstractMap<String, Int>) { fun test(map: java.util.AbstractMap<String, Int>) {
map.<!INAPPLICABLE_CANDIDATE!>remove<!>("", null) map.remove("", null)
map.remove(null)
} }
@@ -1,4 +1,5 @@
FILE: removeOnAbstractMap.kt FILE: removeOnAbstractMap.kt
public final fun test(map: R|java/util/AbstractMap<kotlin/String, kotlin/Int>|): R|kotlin/Unit| { public final fun test(map: R|java/util/AbstractMap<kotlin/String, kotlin/Int>|): R|kotlin/Unit| {
R|<local>/map|.<Inapplicable(INAPPLICABLE): [kotlin/collections/MutableMap.remove]>#(String(), Null(null)) R|<local>/map|.R|FakeOverride<kotlin/collections/MutableMap.remove: R|kotlin/Boolean|>|(String(), Null(null))
R|<local>/map|.R|FakeOverride<kotlin/collections/MutableMap.remove: R|kotlin/Int?|>|(Null(null))
} }
@@ -11,7 +11,7 @@ FILE: typeAliasWithForEach.kt
public final fun R|Arguments|.deepCopy(): R|Arguments| { public final fun R|Arguments|.deepCopy(): R|Arguments| {
lval result: R|java/util/HashMap<kotlin/String, ArgsInfo>| = R|java/util/HashMap.HashMap|<R|kotlin/String|, R|ArgsInfo|>() lval result: R|java/util/HashMap<kotlin/String, ArgsInfo>| = R|java/util/HashMap.HashMap|<R|kotlin/String|, R|ArgsInfo|>()
this@R|/deepCopy|.R|FakeOverride<java/util/Map.forEach: R|kotlin/Unit|>|(<L> = forEach@fun <anonymous>(key: R|kotlin/String|, value: R|ArgsInfo|): R|kotlin/Unit| { this@R|/deepCopy|.R|FakeOverride<java/util/Map.forEach: R|kotlin/Unit|>|(<L> = forEach@fun <anonymous>(key: R|kotlin/String|, value: R|ArgsInfo|): R|kotlin/Unit| {
R|<local>/result|.R|kotlin/collections/set|<R|kotlin/String|, R|ArgsInfo|>(R|<local>/key|, R|/ArgsInfoImpl.ArgsInfoImpl|(R|<local>/value|)) R|<local>/result|.R|kotlin/collections/set|<R|ft<kotlin/String, kotlin/String?>!|, R|ft<ArgsInfo, ArgsInfo?>!|>(R|<local>/key|, R|/ArgsInfoImpl.ArgsInfoImpl|(R|<local>/value|))
} }
) )
^deepCopy R|<local>/result| ^deepCopy R|<local>/result|
@@ -28,11 +28,11 @@ interface WithFoo {
fun <M2: WithFoo> foo(delegateResolver: ResolverForProject<M2?>): ResolverForProject<M2?> { fun <M2: WithFoo> foo(delegateResolver: ResolverForProject<M2?>): ResolverForProject<M2?> {
val descriptorByModule = MyMap<M2, String>() val descriptorByModule = MyMap<M2, String>()
val result = <!INAPPLICABLE_CANDIDATE!>ResolverForProjectImpl<!>(descriptorByModule, delegateResolver) val result = ResolverForProjectImpl(descriptorByModule, delegateResolver)
result.<!UNRESOLVED_REFERENCE!>exposeM<!>.<!UNRESOLVED_REFERENCE!>foo<!>() // M is not M2? result.exposeM.foo() // M is not M2?
result.<!UNRESOLVED_REFERENCE!>exposeM<!>?.<!UNRESOLVED_REFERENCE!>foo<!>() // no warning, M is not M2, hense M is M2! result.exposeM?.foo() // no warning, M is not M2, hense M is M2!
return <!INAPPLICABLE_CANDIDATE!>ResolverForProjectImpl<!>(descriptorByModule, delegateResolver) // another bound check return ResolverForProjectImpl(descriptorByModule, delegateResolver) // another bound check
} }
// MyMap<M2, String> :< Map<M, String> => M = M2! // MyMap<M2, String> :< Map<M, String> => M = M2!
@@ -22,10 +22,10 @@ fun test(b: B, c: C, d: D, e: E) {
eatAString(d) eatAString(d)
eatAString(e) eatAString(e)
<!INAPPLICABLE_CANDIDATE!>eatAStringN<!>(b) eatAStringN(b)
<!INAPPLICABLE_CANDIDATE!>eatAStringN<!>(c) eatAStringN(c)
<!INAPPLICABLE_CANDIDATE!>eatAStringN<!>(d) eatAStringN(d)
<!INAPPLICABLE_CANDIDATE!>eatAStringN<!>(e) eatAStringN(e)
} }
// FILE: 3.kt // FILE: 3.kt
+1 -1
View File
@@ -26,7 +26,7 @@ FILE fqName:<root> fileName:/builtinMap.kt
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:java.util.LinkedHashMap<K1 of <root>.plus, V1 of <root>.plus>) returnType:kotlin.Unit FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:java.util.LinkedHashMap<K1 of <root>.plus, V1 of <root>.plus>) returnType:kotlin.Unit
$receiver: VALUE_PARAMETER name:<this> type:java.util.LinkedHashMap<K1 of <root>.plus, V1 of <root>.plus> $receiver: VALUE_PARAMETER name:<this> type:java.util.LinkedHashMap<K1 of <root>.plus, V1 of <root>.plus>
BLOCK_BODY BLOCK_BODY
CALL 'public open fun put (p0: K1 of <root>.plus, p1: V1 of <root>.plus): V1 of <root>.plus? [operator] declared in java.util.HashMap' type=V1 of <root>.plus? origin=null CALL 'public open fun put (p0: K1 of <root>.plus?, p1: V1 of <root>.plus?): V1 of <root>.plus? [operator] declared in java.util.HashMap' type=V1 of <root>.plus? origin=null
$this: GET_VAR '<this>: java.util.LinkedHashMap<K1 of <root>.plus, V1 of <root>.plus> declared in special.<anonymous>' type=java.util.LinkedHashMap<K1 of <root>.plus, V1 of <root>.plus> origin=null $this: GET_VAR '<this>: java.util.LinkedHashMap<K1 of <root>.plus, V1 of <root>.plus> declared in special.<anonymous>' type=java.util.LinkedHashMap<K1 of <root>.plus, V1 of <root>.plus> origin=null
p0: CALL 'public final fun <get-first> (): K1 of <root>.plus declared in kotlin.Pair' type=K1 of <root>.plus origin=null p0: CALL 'public final fun <get-first> (): K1 of <root>.plus declared in kotlin.Pair' type=K1 of <root>.plus origin=null
$this: GET_VAR 'pair: kotlin.Pair<K1 of <root>.plus, V1 of <root>.plus> declared in <root>.plus' type=kotlin.Pair<K1 of <root>.plus, V1 of <root>.plus> origin=null $this: GET_VAR 'pair: kotlin.Pair<K1 of <root>.plus, V1 of <root>.plus> declared in <root>.plus' type=kotlin.Pair<K1 of <root>.plus, V1 of <root>.plus> origin=null
@@ -1,4 +1,4 @@
public abstract class ClassWithTypePExtendsIterableP<P> : R|kotlin/Any|, R|kotlin/collections/MutableIterable<P>| { public abstract class ClassWithTypePExtendsIterableP<P> : R|kotlin/Any|, R|kotlin/collections/MutableIterable<ft<P, P?>!>| {
public constructor<P>(): R|test/ClassWithTypePExtendsIterableP<P>| public constructor<P>(): R|test/ClassWithTypePExtendsIterableP<P>|
} }
@@ -1,4 +1,4 @@
public final enum class AnnotatedEnumEntry : R|kotlin/Enum<test/AnnotatedEnumEntry>| { public final enum class AnnotatedEnumEntry : R|kotlin/Enum<ft<test/AnnotatedEnumEntry, test/AnnotatedEnumEntry?>!>| {
@R|test/AnnotatedEnumEntry.Anno|(String(a)) public final static field E1: R|ft<test/AnnotatedEnumEntry, test/AnnotatedEnumEntry?>!| @R|test/AnnotatedEnumEntry.Anno|(String(a)) public final static field E1: R|ft<test/AnnotatedEnumEntry, test/AnnotatedEnumEntry?>!|
@R|test/AnnotatedEnumEntry.Anno|(String(b)) @R|test/AnnotatedEnumEntry.Anno2|() public final static field E2: R|ft<test/AnnotatedEnumEntry, test/AnnotatedEnumEntry?>!| @R|test/AnnotatedEnumEntry.Anno|(String(b)) @R|test/AnnotatedEnumEntry.Anno2|() public final static field E2: R|ft<test/AnnotatedEnumEntry, test/AnnotatedEnumEntry?>!|
@@ -1,4 +1,4 @@
public final enum class EnumConstructorParameter : R|kotlin/Enum<test/EnumConstructorParameter>| { public final enum class EnumConstructorParameter : R|kotlin/Enum<ft<test/EnumConstructorParameter, test/EnumConstructorParameter?>!>| {
public final static field INSTANCE: R|ft<test/EnumConstructorParameter, test/EnumConstructorParameter?>!| public final static field INSTANCE: R|ft<test/EnumConstructorParameter, test/EnumConstructorParameter?>!|
private constructor(@R|test/EnumConstructorParameter.Anno|(String(string)) s: R|ft<kotlin/String, kotlin/String?>!|): R|test/EnumConstructorParameter| private constructor(@R|test/EnumConstructorParameter.Anno|(String(string)) s: R|ft<kotlin/String, kotlin/String?>!|): R|test/EnumConstructorParameter|
@@ -1,4 +1,4 @@
public final enum class EnumMembers : R|kotlin/Enum<test/EnumMembers>| { public final enum class EnumMembers : R|kotlin/Enum<ft<test/EnumMembers, test/EnumMembers?>!>| {
public final static field FIRST: R|ft<test/EnumMembers, test/EnumMembers?>!| public final static field FIRST: R|ft<test/EnumMembers, test/EnumMembers?>!|
public final static field SECOND: R|ft<test/EnumMembers, test/EnumMembers?>!| public final static field SECOND: R|ft<test/EnumMembers, test/EnumMembers?>!|
@@ -1,4 +1,4 @@
public open enum class EnumWithSpecializedEntry : R|kotlin/Enum<test/EnumWithSpecializedEntry>| { public open enum class EnumWithSpecializedEntry : R|kotlin/Enum<ft<test/EnumWithSpecializedEntry, test/EnumWithSpecializedEntry?>!>| {
public final static field E1: R|ft<test/EnumWithSpecializedEntry, test/EnumWithSpecializedEntry?>!| public final static field E1: R|ft<test/EnumWithSpecializedEntry, test/EnumWithSpecializedEntry?>!|
public final static field E2: R|ft<test/EnumWithSpecializedEntry, test/EnumWithSpecializedEntry?>!| public final static field E2: R|ft<test/EnumWithSpecializedEntry, test/EnumWithSpecializedEntry?>!|
@@ -1,4 +1,4 @@
public final enum class JavaEnum : R|kotlin/Enum<test/JavaEnum>| { public final enum class JavaEnum : R|kotlin/Enum<ft<test/JavaEnum, test/JavaEnum?>!>| {
public final static field ENTRY: R|ft<test/JavaEnum, test/JavaEnum?>!| public final static field ENTRY: R|ft<test/JavaEnum, test/JavaEnum?>!|
public final static field ANOTHER: R|ft<test/JavaEnum, test/JavaEnum?>!| public final static field ANOTHER: R|ft<test/JavaEnum, test/JavaEnum?>!|
@@ -1,4 +1,4 @@
public abstract interface SubclassOfCollection<E> : R|kotlin/collections/MutableCollection<E>| { public abstract interface SubclassOfCollection<E> : R|kotlin/collections/MutableCollection<ft<E, E?>!>| {
public abstract operator fun iterator(): R|kotlin/collections/MutableIterator<ft<E, E?>!>| public abstract operator fun iterator(): R|kotlin/collections/MutableIterator<ft<E, E?>!>|
} }
@@ -1,4 +1,4 @@
public abstract interface SubclassOfMapEntry<K, V> : R|kotlin/collections/MutableMap.MutableEntry<K, V>| { public abstract interface SubclassOfMapEntry<K, V> : R|kotlin/collections/MutableMap.MutableEntry<ft<K, K?>!, ft<V, V?>!>| {
public abstract operator fun setValue(value: R|V|): R|V| public abstract operator fun setValue(value: R|ft<V, V?>!|): R|ft<V, V?>!|
} }
@@ -1,4 +1,4 @@
public open class ModalityOfFakeOverrides : R|java/util/AbstractList<kotlin/String>| { public open class ModalityOfFakeOverrides : R|java/util/AbstractList<ft<kotlin/String, kotlin/String?>!>| {
@R|java/lang/Override|() @R|org/jetbrains/annotations/NotNull|() public open operator fun get(index: R|kotlin/Int|): R|kotlin/String| @R|java/lang/Override|() @R|org/jetbrains/annotations/NotNull|() public open operator fun get(index: R|kotlin/Int|): R|kotlin/String|
@R|java/lang/Override|() public open operator fun size(): R|kotlin/Int| @R|java/lang/Override|() public open operator fun size(): R|kotlin/Int|
@@ -1,2 +1,2 @@
public abstract interface SubstitutedSamInterface : R|java/util/Comparator<kotlin/String>| { public abstract interface SubstitutedSamInterface : R|java/util/Comparator<ft<kotlin/String, kotlin/String?>!>| {
} }
@@ -1,2 +1,2 @@
public abstract interface SubstitutedSamInterfaceSubclassOfBuiltin : R|kotlin/Comparable<test/SubstitutedSamInterfaceSubclassOfBuiltin>| { public abstract interface SubstitutedSamInterfaceSubclassOfBuiltin : R|kotlin/Comparable<ft<test/SubstitutedSamInterfaceSubclassOfBuiltin, test/SubstitutedSamInterfaceSubclassOfBuiltin?>!>| {
} }
@@ -1,4 +1,4 @@
public final enum class Enum : R|kotlin/Enum<test/Enum>| { public final enum class Enum : R|kotlin/Enum<ft<test/Enum, test/Enum?>!>| {
public final static field A: R|ft<test/Enum, test/Enum?>!| public final static field A: R|ft<test/Enum, test/Enum?>!|
public final static field B: R|ft<test/Enum, test/Enum?>!| public final static field B: R|ft<test/Enum, test/Enum?>!|
@@ -1,4 +1,4 @@
public final enum class StaticMembersInEnum : R|kotlin/Enum<test/StaticMembersInEnum>| { public final enum class StaticMembersInEnum : R|kotlin/Enum<ft<test/StaticMembersInEnum, test/StaticMembersInEnum?>!>| {
public final static field ENTRY: R|ft<test/StaticMembersInEnum, test/StaticMembersInEnum?>!| public final static field ENTRY: R|ft<test/StaticMembersInEnum, test/StaticMembersInEnum?>!|
public open static field STATIC_FIELD: R|kotlin/Int| public open static field STATIC_FIELD: R|kotlin/Int|