diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaSymbolProvider.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaSymbolProvider.kt index e5c8b8fa188..d89404e5036 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaSymbolProvider.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaSymbolProvider.kt @@ -27,6 +27,7 @@ import org.jetbrains.kotlin.fir.scopes.FirScope import org.jetbrains.kotlin.fir.scopes.impl.* import org.jetbrains.kotlin.fir.symbols.CallableId 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.FirResolvedTypeRefImpl import org.jetbrains.kotlin.load.java.JavaClassFinder @@ -95,7 +96,7 @@ class JavaSymbolProvider( ) { require(this is FirTypeParameterImpl) 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() } @@ -155,7 +156,9 @@ class JavaSymbolProvider( this.typeParameters += foundClass.typeParameters.convertTypeParameters(javaTypeParameterStack) addAnnotationsFrom(this@JavaSymbolProvider.session, javaClass, javaTypeParameterStack) 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. // However, they should be built up to override resolve stage diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaUtils.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaUtils.kt index 56ab61fb3ae..d09d9f32ebd 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaUtils.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/JavaUtils.kt @@ -78,8 +78,8 @@ internal fun FirTypeRef.toNotNullConeKotlinType( internal fun JavaType?.toNotNullConeKotlinType( session: FirSession, javaTypeParameterStack: JavaTypeParameterStack -): ConeLookupTagBasedType { - return toConeKotlinTypeWithNullability(session, javaTypeParameterStack, isNullable = false) +): ConeKotlinType { + return toConeKotlinTypeWithNullability(session, javaTypeParameterStack, ConeNullability.NOT_NULL) } internal fun JavaType.toFirJavaTypeRef(session: FirSession, javaTypeParameterStack: JavaTypeParameterStack): FirJavaTypeRef { @@ -91,9 +91,12 @@ internal fun JavaType.toFirJavaTypeRef(session: FirSession, javaTypeParameterSta } 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 { - val coneType = this.toConeKotlinTypeWithNullability(session, javaTypeParameterStack, isNullable) + val coneType = this.toConeKotlinTypeWithNullability(session, javaTypeParameterStack, nullability, typeParametersNullability) return FirResolvedTypeRefImpl( source = null, type = coneType ).apply { @@ -102,11 +105,14 @@ internal fun JavaClassifierType.toFirResolvedTypeRef( } internal fun JavaType?.toConeKotlinTypeWithNullability( - session: FirSession, javaTypeParameterStack: JavaTypeParameterStack, isNullable: Boolean -): ConeLookupTagBasedType { + session: FirSession, + javaTypeParameterStack: JavaTypeParameterStack, + nullability: ConeNullability, + typeParametersNullability: ConeNullability = ConeNullability.NOT_NULL +): ConeKotlinType { return when (this) { is JavaClassifierType -> { - toConeKotlinTypeWithNullability(session, isNullable, javaTypeParameterStack) + toConeKotlinTypeWithNullability(session, nullability, typeParametersNullability, javaTypeParameterStack) } is JavaPrimitiveType -> { val primitiveType = type @@ -115,38 +121,47 @@ internal fun JavaType?.toConeKotlinTypeWithNullability( else -> javaName.capitalize() } val classId = StandardClassIds.byName(kotlinPrimitiveName) - classId.toConeKotlinType(emptyArray(), isNullable) + classId.toConeKotlinType(emptyArray(), nullability.isNullable) } is JavaArrayType -> { val componentType = componentType if (componentType !is JavaPrimitiveType) { val classId = StandardClassIds.Array val argumentType = ConeFlexibleType( - componentType.toConeKotlinTypeWithNullability(session, javaTypeParameterStack, isNullable = false), - componentType.toConeKotlinTypeWithNullability(session, javaTypeParameterStack, isNullable = true) + componentType.toConeKotlinTypeWithNullability(session, javaTypeParameterStack, ConeNullability.NOT_NULL), + componentType.toConeKotlinTypeWithNullability(session, javaTypeParameterStack, ConeNullability.NULLABLE) ) - classId.toConeKotlinType(arrayOf(argumentType), isNullable) + classId.toConeKotlinType(arrayOf(argumentType), nullability.isNullable) } else { val javaComponentName = componentType.type?.typeName?.asString()?.capitalize() ?: error("Array of voids") val classId = StandardClassIds.byName(javaComponentName + "Array") - classId.toConeKotlinType(emptyArray(), isNullable) + classId.toConeKotlinType(emptyArray(), nullability.isNullable) } } is JavaWildcardType -> bound?.toNotNullConeKotlinType(session, javaTypeParameterStack) ?: run { val classId = StandardClassIds.Any - classId.toConeKotlinType(emptyArray(), isNullable) + classId.toConeKotlinType(emptyArray(), nullability.isNullable) } null -> { val classId = StandardClassIds.Any - classId.toConeKotlinType(emptyArray(), isNullable) + classId.toConeKotlinType(emptyArray(), nullability.isNullable) } else -> error("Strange JavaType: ${this::class.java}") } } internal fun JavaClassifierType.toConeKotlinTypeWithNullability( - session: FirSession, isNullable: Boolean, javaTypeParameterStack: JavaTypeParameterStack -): ConeLookupTagBasedType { + session: FirSession, + 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) { is JavaClass -> { //val classId = classifier.classId!! @@ -155,17 +170,16 @@ internal fun JavaClassifierType.toConeKotlinTypeWithNullability( val lookupTag = ConeClassLikeLookupTagImpl(classId) lookupTag.constructClassType( - typeArguments.mapIndexed { index, argument -> + typeArguments.map { argument -> argument.toConeProjection( - session, javaTypeParameterStack, null - //symbol.fir.typeParameters.getOrNull(index) + session, javaTypeParameterStack, boundTypeParameter = null, nullability = typeParametersNullability ) - }.toTypedArray(), isNullable + }.toTypedArray(), nullability.isNullable ) } is JavaTypeParameter -> { val symbol = javaTypeParameterStack[classifier] - ConeTypeParameterTypeImpl(symbol.toLookupTag(), isNullable) + ConeTypeParameterTypeImpl(symbol.toLookupTag(), nullability.isNullable) } else -> ConeClassErrorType(reason = "Unexpected classifier: $classifier") } @@ -208,7 +222,10 @@ internal fun JavaValueParameter.toFirValueParameter( } internal fun JavaType?.toConeProjection( - session: FirSession, javaTypeParameterStack: JavaTypeParameterStack, boundTypeParameter: FirTypeParameter? + session: FirSession, + javaTypeParameterStack: JavaTypeParameterStack, + boundTypeParameter: FirTypeParameter?, + nullability: ConeNullability = ConeNullability.NOT_NULL ): ConeKotlinTypeProjection { return when (this) { null -> ConeStarProjection @@ -219,7 +236,7 @@ internal fun JavaType?.toConeProjection( if (bound == null || parameterVariance != INVARIANT && parameterVariance != argumentVariance) { ConeStarProjection } else { - val boundType = bound.toConeKotlinTypeWithNullability(session, javaTypeParameterStack, isNullable = false) + val boundType = bound.toConeKotlinTypeWithNullability(session, javaTypeParameterStack, nullability) if (argumentVariance == OUT_VARIANCE) { ConeKotlinTypeProjectionOut(boundType) } 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") } } @@ -260,7 +277,9 @@ private fun JavaAnnotationArgument.toFirExpression( null } 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 { @@ -270,7 +289,9 @@ private fun JavaAnnotationArgument.toFirExpression( ) } 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) 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) + ) } } diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/EnhancementSignatureParts.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/EnhancementSignatureParts.kt index d4700040f68..0b78e903ebb 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/EnhancementSignatureParts.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/EnhancementSignatureParts.kt @@ -152,8 +152,8 @@ internal class EnhancementSignatureParts( is FirJavaTypeRef -> { Pair( // TODO: optimize - type.toConeKotlinTypeWithNullability(session, javaTypeParameterStack, isNullable = false), - type.toConeKotlinTypeWithNullability(session, javaTypeParameterStack, isNullable = true) + type.toConeKotlinTypeWithNullability(session, javaTypeParameterStack, nullability = ConeNullability.NOT_NULL), + type.toConeKotlinTypeWithNullability(session, javaTypeParameterStack, nullability = ConeNullability.NULLABLE) ) } else -> return JavaTypeQualifiers.NONE diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/javaTypeUtils.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/javaTypeUtils.kt index 77204bcbd3b..5347c308b4d 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/javaTypeUtils.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/enhancement/javaTypeUtils.kt @@ -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.toNotNullConeKotlinType 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.transformers.body.resolve.firUnsafe import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag @@ -124,12 +123,12 @@ private fun JavaType?.subtreeSize(): Int { private fun coneFlexibleOrSimpleType( session: FirSession, - lowerBound: ConeLookupTagBasedType, - upperBound: ConeLookupTagBasedType, + lowerBound: ConeKotlinType, + upperBound: ConeKotlinType, isNotNullTypeParameter: Boolean ): ConeKotlinType { if (AbstractStrictEqualityTypeChecker.strictEqualTypes(session.typeContext, lowerBound, upperBound)) { - val lookupTag = lowerBound.lookupTag + val lookupTag = (lowerBound as? ConeLookupTagBasedType)?.lookupTag if (isNotNullTypeParameter && lookupTag is ConeTypeParameterLookupTag && !lowerBound.isMarkedNullable) { // TODO: we need enhancement for type parameter bounds for this code to work properly // At this moment, this condition is always true @@ -164,8 +163,6 @@ private fun ClassId.mutableToReadOnly(): ClassId? { } } - - // Definition: // ErasedUpperBound(T : G) = G<*> // UpperBound(T) is a type G with 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() - val firstUpperBoundClassifier = firstUpperBound - if (firstUpperBoundClassifier is ConeClassLikeType) { + if (firstUpperBound is ConeClassLikeType) { return firstUpperBound.withArguments(firstUpperBound.typeArguments.map { ConeStarProjection }.toTypedArray()) } @@ -225,7 +221,8 @@ fun computeProjection( // in T -> Comparable session.builtinTypes.nothingType.type else if (erasedUpperBound is ConeClassLikeType && - erasedUpperBound.lookupTag.toSymbol(session)!!.firUnsafe().typeParameters.isNotEmpty()) + erasedUpperBound.lookupTag.toSymbol(session)!!.firUnsafe().typeParameters.isNotEmpty() + ) // T : Enum -> out Enum<*> ConeKotlinTypeProjectionOut(erasedUpperBound) else @@ -234,8 +231,6 @@ fun computeProjection( } } - - private fun JavaClassifierType.enhanceInflexibleType( session: FirSession, javaTypeParameterStack: JavaTypeParameterStack, @@ -244,9 +239,8 @@ private fun JavaClassifierType.enhanceInflexibleType( position: TypeComponentPosition, qualifiers: IndexedJavaTypeQualifiers, index: Int -): ConeLookupTagBasedType { - val classifier = classifier - val originalTag = when (classifier) { +): ConeKotlinType { + val originalTag = when (val classifier = classifier) { is JavaClass -> { val classId = classifier.classId!! var mappedId = JavaToKotlinClassMap.mapJavaToKotlin(classId.asSingleFqName()) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt index 63e361303e9..0d169c5f8b0 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/ResolveUtils.kt @@ -217,10 +217,17 @@ fun coneFlexibleOrSimpleType( if (upperBound is ConeFlexibleType) { return coneFlexibleOrSimpleType(typeContext, lowerBound, upperBound.upperBound) } - if (typeContext != null && AbstractStrictEqualityTypeChecker.strictEqualTypes(typeContext, lowerBound, upperBound)) { - return lowerBound + return when { + typeContext != null && AbstractStrictEqualityTypeChecker.strictEqualTypes(typeContext, lowerBound, upperBound) -> { + lowerBound + } + typeContext == null && lowerBound == upperBound -> { + lowerBound + } + else -> { + ConeFlexibleType(lowerBound, upperBound) + } } - return ConeFlexibleType(lowerBound, upperBound) } fun T.withNullability(nullability: ConeNullability, typeContext: ConeInferenceContext? = null): T { diff --git a/compiler/fir/resolve/testData/enhancement/mapping/AbstractMap.fir.txt b/compiler/fir/resolve/testData/enhancement/mapping/AbstractMap.fir.txt index 603e50dac32..be553283c51 100644 --- a/compiler/fir/resolve/testData/enhancement/mapping/AbstractMap.fir.txt +++ b/compiler/fir/resolve/testData/enhancement/mapping/AbstractMap.fir.txt @@ -1,4 +1,4 @@ -public abstract class AbstractMap : R|kotlin/Any|, R|kotlin/collections/MutableMap| { +public abstract class AbstractMap : R|kotlin/Any|, R|kotlin/collections/MutableMap!, ft!>| { public constructor(): R|AbstractMap| } diff --git a/compiler/fir/resolve/testData/enhancement/signatureAnnotations/DefaultEnum.fir.txt b/compiler/fir/resolve/testData/enhancement/signatureAnnotations/DefaultEnum.fir.txt index e33ca9da8b0..623bb613cc5 100644 --- a/compiler/fir/resolve/testData/enhancement/signatureAnnotations/DefaultEnum.fir.txt +++ b/compiler/fir/resolve/testData/enhancement/signatureAnnotations/DefaultEnum.fir.txt @@ -10,7 +10,7 @@ public/*package*/ open class A : R|kotlin/Any| { public/*package*/ constructor(): R|A| } -public final enum class Mixed : R|kotlin/Enum| { +public final enum class Mixed : R|kotlin/Enum!>| { public final static field NOT_ENTRY_EITHER: R|ft!| public final static fun values(): R|kotlin/Array| { @@ -20,7 +20,7 @@ public final enum class Mixed : R|kotlin/Enum| { } } -public final enum class Signs : R|kotlin/Enum| { +public final enum class Signs : R|kotlin/Enum!>| { public final static field HELLO: R|ft!| public final static field WORLD: R|ft!| diff --git a/compiler/fir/resolve/testData/resolve/stdlib/hashSet.txt b/compiler/fir/resolve/testData/resolve/stdlib/hashSet.txt index 33457b9721d..bd2a9176eb3 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/hashSet.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/hashSet.txt @@ -1,10 +1,10 @@ FILE: hashSet.kt - public final val a: R|kotlin/collections/MutableSet?| = R|java/util/HashSet.HashSet|() + public final val a: R|kotlin/collections/MutableSet?| = R|java/util/HashSet.HashSet|!|>() public get(): R|kotlin/collections/MutableSet?| public final var b: R|kotlin/collections/MutableSet?| = Null(null) public get(): R|kotlin/collections/MutableSet?| public set(_: R|kotlin/collections/MutableSet?|): R|kotlin/Unit| { - F|/b| = R|java/util/HashSet.HashSet|() + F|/b| = R|java/util/HashSet.HashSet|!|>() } public final var R|kotlin/collections/MutableSet|.d: R|T?| public get(): R|T?| { @@ -17,6 +17,6 @@ FILE: hashSet.kt } public final fun foo(): R|kotlin/Unit| { lvar c: R|kotlin/collections/MutableSet?| = Null(null) - R|/c| = R|java/util/HashSet.HashSet|() + R|/c| = R|java/util/HashSet.HashSet|!|>() R|/c|!!.R|/d| = R|/produce|() } diff --git a/compiler/fir/resolve/testData/resolve/stdlib/j+k/KJKInheritanceGeneric.txt b/compiler/fir/resolve/testData/resolve/stdlib/j+k/KJKInheritanceGeneric.txt index 83ad5f0436f..3a228e140b8 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/j+k/KJKInheritanceGeneric.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/j+k/KJKInheritanceGeneric.txt @@ -16,7 +16,7 @@ FILE: K2.kt } public final fun bar(): R|kotlin/Unit| { - this@R|/K2|.R|FakeOverride|(Int(1)) + this@R|/K2|.R|FakeOverride!|>|(Int(1)) this@R|/K2|.R|/J1.baz|() } diff --git a/compiler/fir/resolve/testData/resolve/stdlib/j+k/MapEntry.kt b/compiler/fir/resolve/testData/resolve/stdlib/j+k/MapEntry.kt index e96cc1d89d0..236ad672622 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/j+k/MapEntry.kt +++ b/compiler/fir/resolve/testData/resolve/stdlib/j+k/MapEntry.kt @@ -17,7 +17,7 @@ class MyMapEntry : Test.MapEntryImpl() fun test() { val b = MyMapEntry() - b.key - b.value + val key = b.key + val value = b.value b.setValue(null) } diff --git a/compiler/fir/resolve/testData/resolve/stdlib/j+k/MapEntry.txt b/compiler/fir/resolve/testData/resolve/stdlib/j+k/MapEntry.txt index 61f54feae89..51d578095bb 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/j+k/MapEntry.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/j+k/MapEntry.txt @@ -7,7 +7,7 @@ FILE: main.kt } public final fun test(): R|kotlin/Unit| { lval b: R|MyMapEntry| = R|/MyMapEntry.MyMapEntry|() - R|/b|.R|/Test.MapEntryImpl.key| - R|/b|.R|/Test.MapEntryImpl.value| + lval key: R|ft!| = R|/b|.R|/Test.MapEntryImpl.key| + lval value: R|ft!| = R|/b|.R|/Test.MapEntryImpl.value| R|/b|.R|/Test.MapEntryImpl.setValue|(Null(null)) } diff --git a/compiler/fir/resolve/testData/resolve/stdlib/j+k/MyIterable.txt b/compiler/fir/resolve/testData/resolve/stdlib/j+k/MyIterable.txt index 84c0407f2fe..5809c1b1e1c 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/j+k/MyIterable.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/j+k/MyIterable.txt @@ -1,8 +1,8 @@ FILE: test.kt public abstract interface UseIterable : R|MyIterable| { public open fun test(): R|kotlin/Unit| { - lval it: R|kotlin/collections/MutableIterator| = this@R|/UseIterable|.R|FakeOverride|>|() - lval split: R|java/util/Spliterator| = this@R|/UseIterable|.R|FakeOverride|>|() + lval it: R|kotlin/collections/MutableIterator!>| = this@R|/UseIterable|.R|FakeOverride!>|>|() + lval split: R|java/util/Spliterator!>| = this@R|/UseIterable|.R|FakeOverride!>|>|() } } diff --git a/compiler/fir/resolve/testData/resolve/stdlib/j+k/MyMap.txt b/compiler/fir/resolve/testData/resolve/stdlib/j+k/MyMap.txt index 5874a26facb..b60ab49c4b5 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/j+k/MyMap.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/j+k/MyMap.txt @@ -1,20 +1,20 @@ FILE: test.kt public final fun test(map: R|MyMap|): R|kotlin/Unit| { - lval result: R|kotlin/String| = R|/map|.R|kotlin/collections/getOrPut|(String(key), = getOrPut@fun (): R|kotlin/String| { + lval result: R|ft!| = R|/map|.R|kotlin/collections/getOrPut|!|, R|ft!|>(String(key), = getOrPut@fun (): R|kotlin/String| { String(value) } ) - lval otherResult: R|kotlin/String| = R|/map|.R|FakeOverride|(String(key), String(value)) + lval otherResult: R|ft!| = R|/map|.R|FakeOverride!|>|(String(key), String(value)) lval anotherResult: = R|/map|.#(String(key), String(value)) - R|/map|.R|FakeOverride|( = forEach@fun (key: R|kotlin/String|, value: R|kotlin/String|): R|kotlin/Unit| { + R|/map|.R|FakeOverride|( = forEach@fun (key: R|ft!|, value: R|ft!|): R|kotlin/Unit| { R|kotlin/io/println|((R|/key|.R|kotlin/Any.toString|(), String(: ), R|/value|.R|kotlin/Any.toString|())) R|/key|.R|kotlin/String.length| R|/value|.R|kotlin/String.length| } ) - R|/map|.R|kotlin/collections/forEach|( = forEach@fun (: R|kotlin/collections/Map.Entry|): R|kotlin/Unit| { - lval key: R|kotlin/String| = R|/|.R|kotlin/collections/component1|() - lval value: R|kotlin/String| = R|/|.R|kotlin/collections/component2|() + R|/map|.R|kotlin/collections/forEach|!|, R|ft!|>( = forEach@fun (: R|kotlin/collections/Map.Entry!, ft!>|): R|kotlin/Unit| { + lval key: R|ft!| = R|/|.R|kotlin/collections/component1|!|, R|ft!|>() + lval value: R|ft!| = R|/|.R|kotlin/collections/component2|!|, R|ft!|>() R|kotlin/io/println|((R|/key|.R|kotlin/Any.toString|(), String(: ), R|/value|.R|kotlin/Any.toString|())) R|/key|.R|kotlin/String.length| R|/value|.R|kotlin/String.length| diff --git a/compiler/fir/resolve/testData/resolve/stdlib/removeOnAbstractMap.kt b/compiler/fir/resolve/testData/resolve/stdlib/removeOnAbstractMap.kt index 09b29f723a7..1a52e06de36 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/removeOnAbstractMap.kt +++ b/compiler/fir/resolve/testData/resolve/stdlib/removeOnAbstractMap.kt @@ -1,3 +1,4 @@ fun test(map: java.util.AbstractMap) { - map.remove("", null) + map.remove("", null) + map.remove(null) } \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolve/stdlib/removeOnAbstractMap.txt b/compiler/fir/resolve/testData/resolve/stdlib/removeOnAbstractMap.txt index 2066a337a23..943b6c1626e 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/removeOnAbstractMap.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/removeOnAbstractMap.txt @@ -1,4 +1,5 @@ FILE: removeOnAbstractMap.kt public final fun test(map: R|java/util/AbstractMap|): R|kotlin/Unit| { - R|/map|.#(String(), Null(null)) + R|/map|.R|FakeOverride|(String(), Null(null)) + R|/map|.R|FakeOverride|(Null(null)) } diff --git a/compiler/fir/resolve/testData/resolve/stdlib/typeAliasWithForEach.txt b/compiler/fir/resolve/testData/resolve/stdlib/typeAliasWithForEach.txt index 4ca2ee9fc78..57372045c04 100644 --- a/compiler/fir/resolve/testData/resolve/stdlib/typeAliasWithForEach.txt +++ b/compiler/fir/resolve/testData/resolve/stdlib/typeAliasWithForEach.txt @@ -11,7 +11,7 @@ FILE: typeAliasWithForEach.kt public final fun R|Arguments|.deepCopy(): R|Arguments| { lval result: R|java/util/HashMap| = R|java/util/HashMap.HashMap|() this@R|/deepCopy|.R|FakeOverride|( = forEach@fun (key: R|kotlin/String|, value: R|ArgsInfo|): R|kotlin/Unit| { - R|/result|.R|kotlin/collections/set|(R|/key|, R|/ArgsInfoImpl.ArgsInfoImpl|(R|/value|)) + R|/result|.R|kotlin/collections/set|!|, R|ft!|>(R|/key|, R|/ArgsInfoImpl.ArgsInfoImpl|(R|/value|)) } ) ^deepCopy R|/result| diff --git a/compiler/testData/diagnostics/tests/platformTypes/methodCall/multipleExactBoundsNullable.fir.kt b/compiler/testData/diagnostics/tests/platformTypes/methodCall/multipleExactBoundsNullable.fir.kt index 73eb3d69552..9fe15a7742e 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/methodCall/multipleExactBoundsNullable.fir.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/methodCall/multipleExactBoundsNullable.fir.kt @@ -28,11 +28,11 @@ interface WithFoo { fun foo(delegateResolver: ResolverForProject): ResolverForProject { val descriptorByModule = MyMap() - val result = ResolverForProjectImpl(descriptorByModule, delegateResolver) - result.exposeM.foo() // M is not M2? - result.exposeM?.foo() // no warning, M is not M2, hense M is M2! + val result = ResolverForProjectImpl(descriptorByModule, delegateResolver) + result.exposeM.foo() // M is not M2? + result.exposeM?.foo() // no warning, M is not M2, hense M is M2! - return ResolverForProjectImpl(descriptorByModule, delegateResolver) // another bound check + return ResolverForProjectImpl(descriptorByModule, delegateResolver) // another bound check } // MyMap :< Map => M = M2! diff --git a/compiler/testData/diagnostics/tests/subtyping/javaAndKotlinSuperType.fir.kt b/compiler/testData/diagnostics/tests/subtyping/javaAndKotlinSuperType.fir.kt index 8f0cd59d18a..3b949012032 100644 --- a/compiler/testData/diagnostics/tests/subtyping/javaAndKotlinSuperType.fir.kt +++ b/compiler/testData/diagnostics/tests/subtyping/javaAndKotlinSuperType.fir.kt @@ -22,10 +22,10 @@ fun test(b: B, c: C, d: D, e: E) { eatAString(d) eatAString(e) - eatAStringN(b) - eatAStringN(c) - eatAStringN(d) - eatAStringN(e) + eatAStringN(b) + eatAStringN(c) + eatAStringN(d) + eatAStringN(e) } // FILE: 3.kt diff --git a/compiler/testData/ir/irText/stubs/builtinMap.fir.txt b/compiler/testData/ir/irText/stubs/builtinMap.fir.txt index c67b9a74516..3318d76d593 100644 --- a/compiler/testData/ir/irText/stubs/builtinMap.fir.txt +++ b/compiler/testData/ir/irText/stubs/builtinMap.fir.txt @@ -26,7 +26,7 @@ FILE fqName: fileName:/builtinMap.kt FUN LOCAL_FUNCTION_FOR_LAMBDA name: visibility:local modality:FINAL <> ($receiver:java.util.LinkedHashMap.plus, V1 of .plus>) returnType:kotlin.Unit $receiver: VALUE_PARAMETER name: type:java.util.LinkedHashMap.plus, V1 of .plus> BLOCK_BODY - CALL 'public open fun put (p0: K1 of .plus, p1: V1 of .plus): V1 of .plus? [operator] declared in java.util.HashMap' type=V1 of .plus? origin=null + CALL 'public open fun put (p0: K1 of .plus?, p1: V1 of .plus?): V1 of .plus? [operator] declared in java.util.HashMap' type=V1 of .plus? origin=null $this: GET_VAR ': java.util.LinkedHashMap.plus, V1 of .plus> declared in special.' type=java.util.LinkedHashMap.plus, V1 of .plus> origin=null p0: CALL 'public final fun (): K1 of .plus declared in kotlin.Pair' type=K1 of .plus origin=null $this: GET_VAR 'pair: kotlin.Pair.plus, V1 of .plus> declared in .plus' type=kotlin.Pair.plus, V1 of .plus> origin=null diff --git a/compiler/testData/loadJava/compiledJava/ClassWithTypePExtendsIterableP.fir.txt b/compiler/testData/loadJava/compiledJava/ClassWithTypePExtendsIterableP.fir.txt index c4810b10629..e505143535b 100644 --- a/compiler/testData/loadJava/compiledJava/ClassWithTypePExtendsIterableP.fir.txt +++ b/compiler/testData/loadJava/compiledJava/ClassWithTypePExtendsIterableP.fir.txt @@ -1,4 +1,4 @@ -public abstract class ClassWithTypePExtendsIterableP

: R|kotlin/Any|, R|kotlin/collections/MutableIterable

| { +public abstract class ClassWithTypePExtendsIterableP

: R|kotlin/Any|, R|kotlin/collections/MutableIterable!>| { public constructor

(): R|test/ClassWithTypePExtendsIterableP

| } diff --git a/compiler/testData/loadJava/compiledJava/annotations/AnnotatedEnumEntry.fir.txt b/compiler/testData/loadJava/compiledJava/annotations/AnnotatedEnumEntry.fir.txt index eae7a65bb70..1f862839fc3 100644 --- a/compiler/testData/loadJava/compiledJava/annotations/AnnotatedEnumEntry.fir.txt +++ b/compiler/testData/loadJava/compiledJava/annotations/AnnotatedEnumEntry.fir.txt @@ -1,4 +1,4 @@ -public final enum class AnnotatedEnumEntry : R|kotlin/Enum| { +public final enum class AnnotatedEnumEntry : R|kotlin/Enum!>| { @R|test/AnnotatedEnumEntry.Anno|(String(a)) public final static field E1: R|ft!| @R|test/AnnotatedEnumEntry.Anno|(String(b)) @R|test/AnnotatedEnumEntry.Anno2|() public final static field E2: R|ft!| diff --git a/compiler/testData/loadJava/compiledJava/annotations/EnumConstructorParameter.fir.txt b/compiler/testData/loadJava/compiledJava/annotations/EnumConstructorParameter.fir.txt index 80948008925..cef9b39dfb9 100644 --- a/compiler/testData/loadJava/compiledJava/annotations/EnumConstructorParameter.fir.txt +++ b/compiler/testData/loadJava/compiledJava/annotations/EnumConstructorParameter.fir.txt @@ -1,4 +1,4 @@ -public final enum class EnumConstructorParameter : R|kotlin/Enum| { +public final enum class EnumConstructorParameter : R|kotlin/Enum!>| { public final static field INSTANCE: R|ft!| private constructor(@R|test/EnumConstructorParameter.Anno|(String(string)) s: R|ft!|): R|test/EnumConstructorParameter| diff --git a/compiler/testData/loadJava/compiledJava/enum/EnumMembers.fir.txt b/compiler/testData/loadJava/compiledJava/enum/EnumMembers.fir.txt index 296adcc0a6d..8b8f5dbde8c 100644 --- a/compiler/testData/loadJava/compiledJava/enum/EnumMembers.fir.txt +++ b/compiler/testData/loadJava/compiledJava/enum/EnumMembers.fir.txt @@ -1,4 +1,4 @@ -public final enum class EnumMembers : R|kotlin/Enum| { +public final enum class EnumMembers : R|kotlin/Enum!>| { public final static field FIRST: R|ft!| public final static field SECOND: R|ft!| diff --git a/compiler/testData/loadJava/compiledJava/enum/EnumWithSpecializedEntry.fir.txt b/compiler/testData/loadJava/compiledJava/enum/EnumWithSpecializedEntry.fir.txt index 88b041979ad..5b0fc8a8638 100644 --- a/compiler/testData/loadJava/compiledJava/enum/EnumWithSpecializedEntry.fir.txt +++ b/compiler/testData/loadJava/compiledJava/enum/EnumWithSpecializedEntry.fir.txt @@ -1,4 +1,4 @@ -public open enum class EnumWithSpecializedEntry : R|kotlin/Enum| { +public open enum class EnumWithSpecializedEntry : R|kotlin/Enum!>| { public final static field E1: R|ft!| public final static field E2: R|ft!| diff --git a/compiler/testData/loadJava/compiledJava/enum/JavaEnum.fir.txt b/compiler/testData/loadJava/compiledJava/enum/JavaEnum.fir.txt index f3d233d9b69..633ef06a2e2 100644 --- a/compiler/testData/loadJava/compiledJava/enum/JavaEnum.fir.txt +++ b/compiler/testData/loadJava/compiledJava/enum/JavaEnum.fir.txt @@ -1,4 +1,4 @@ -public final enum class JavaEnum : R|kotlin/Enum| { +public final enum class JavaEnum : R|kotlin/Enum!>| { public final static field ENTRY: R|ft!| public final static field ANOTHER: R|ft!| diff --git a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/SubclassOfCollection.fir.txt b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/SubclassOfCollection.fir.txt index 4610cbb8125..601eaa20f8b 100644 --- a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/SubclassOfCollection.fir.txt +++ b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/SubclassOfCollection.fir.txt @@ -1,4 +1,4 @@ -public abstract interface SubclassOfCollection : R|kotlin/collections/MutableCollection| { +public abstract interface SubclassOfCollection : R|kotlin/collections/MutableCollection!>| { public abstract operator fun iterator(): R|kotlin/collections/MutableIterator!>| } diff --git a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/SubclassOfMapEntry.fir.txt b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/SubclassOfMapEntry.fir.txt index 99af87fa9e7..35cbf8d6d8c 100644 --- a/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/SubclassOfMapEntry.fir.txt +++ b/compiler/testData/loadJava/compiledJava/kotlinSignature/propagation/return/SubclassOfMapEntry.fir.txt @@ -1,4 +1,4 @@ -public abstract interface SubclassOfMapEntry : R|kotlin/collections/MutableMap.MutableEntry| { - public abstract operator fun setValue(value: R|V|): R|V| +public abstract interface SubclassOfMapEntry : R|kotlin/collections/MutableMap.MutableEntry!, ft!>| { + public abstract operator fun setValue(value: R|ft!|): R|ft!| } diff --git a/compiler/testData/loadJava/compiledJava/modality/ModalityOfFakeOverrides.fir.txt b/compiler/testData/loadJava/compiledJava/modality/ModalityOfFakeOverrides.fir.txt index 06e617e2e24..39a0fd869ca 100644 --- a/compiler/testData/loadJava/compiledJava/modality/ModalityOfFakeOverrides.fir.txt +++ b/compiler/testData/loadJava/compiledJava/modality/ModalityOfFakeOverrides.fir.txt @@ -1,4 +1,4 @@ -public open class ModalityOfFakeOverrides : R|java/util/AbstractList| { +public open class ModalityOfFakeOverrides : R|java/util/AbstractList!>| { @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| diff --git a/compiler/testData/loadJava/compiledJava/sam/SubstitutedSamInterface.fir.txt b/compiler/testData/loadJava/compiledJava/sam/SubstitutedSamInterface.fir.txt index 9b820565bdd..9ad3856f86f 100644 --- a/compiler/testData/loadJava/compiledJava/sam/SubstitutedSamInterface.fir.txt +++ b/compiler/testData/loadJava/compiledJava/sam/SubstitutedSamInterface.fir.txt @@ -1,2 +1,2 @@ -public abstract interface SubstitutedSamInterface : R|java/util/Comparator| { +public abstract interface SubstitutedSamInterface : R|java/util/Comparator!>| { } diff --git a/compiler/testData/loadJava/compiledJava/sam/SubstitutedSamInterfaceSubclassOfBuiltin.fir.txt b/compiler/testData/loadJava/compiledJava/sam/SubstitutedSamInterfaceSubclassOfBuiltin.fir.txt index 11c6dfe6587..8d760bb4261 100644 --- a/compiler/testData/loadJava/compiledJava/sam/SubstitutedSamInterfaceSubclassOfBuiltin.fir.txt +++ b/compiler/testData/loadJava/compiledJava/sam/SubstitutedSamInterfaceSubclassOfBuiltin.fir.txt @@ -1,2 +1,2 @@ -public abstract interface SubstitutedSamInterfaceSubclassOfBuiltin : R|kotlin/Comparable| { +public abstract interface SubstitutedSamInterfaceSubclassOfBuiltin : R|kotlin/Comparable!>| { } diff --git a/compiler/testData/loadJava/compiledJava/static/Enum.fir.txt b/compiler/testData/loadJava/compiledJava/static/Enum.fir.txt index bc4399f8fa4..0cd00dc98fc 100644 --- a/compiler/testData/loadJava/compiledJava/static/Enum.fir.txt +++ b/compiler/testData/loadJava/compiledJava/static/Enum.fir.txt @@ -1,4 +1,4 @@ -public final enum class Enum : R|kotlin/Enum| { +public final enum class Enum : R|kotlin/Enum!>| { public final static field A: R|ft!| public final static field B: R|ft!| diff --git a/compiler/testData/loadJava/compiledJava/static/StaticMembersInEnum.fir.txt b/compiler/testData/loadJava/compiledJava/static/StaticMembersInEnum.fir.txt index 7faa68bf2ea..b29e5dacd99 100644 --- a/compiler/testData/loadJava/compiledJava/static/StaticMembersInEnum.fir.txt +++ b/compiler/testData/loadJava/compiledJava/static/StaticMembersInEnum.fir.txt @@ -1,4 +1,4 @@ -public final enum class StaticMembersInEnum : R|kotlin/Enum| { +public final enum class StaticMembersInEnum : R|kotlin/Enum!>| { public final static field ENTRY: R|ft!| public open static field STATIC_FIELD: R|kotlin/Int|