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 3382290b384..c4fcd68e393 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 @@ -92,7 +92,12 @@ class JavaSymbolProvider( stack: JavaTypeParameterStack, ) { for (upperBound in javaTypeParameter.upperBounds) { - bounds += upperBound.toFirResolvedTypeRef(this@JavaSymbolProvider.session, stack, nullability = ConeNullability.UNKNOWN) + bounds += upperBound.toFirResolvedTypeRef( + this@JavaSymbolProvider.session, + stack, + isForSupertypes = false, + forTypeParameterBounds = true + ) } addDefaultBoundIfNecessary() } @@ -260,7 +265,7 @@ class JavaSymbolProvider( firJavaClass.replaceSuperTypeRefs( javaClass.supertypes.map { supertype -> supertype.toFirResolvedTypeRef( - this@JavaSymbolProvider.session, javaTypeParameterStack, typeParametersNullability = ConeNullability.UNKNOWN + this@JavaSymbolProvider.session, javaTypeParameterStack, isForSupertypes = true, forTypeParameterBounds = false ) } ) 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 f67b956a700..275367b3e12 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 @@ -11,6 +11,7 @@ import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder import org.jetbrains.kotlin.fir.builder.FirBuilderDsl +import org.jetbrains.kotlin.fir.declarations.FirRegularClass import org.jetbrains.kotlin.fir.declarations.FirTypeParameter import org.jetbrains.kotlin.fir.declarations.FirValueParameter import org.jetbrains.kotlin.fir.diagnostics.DiagnosticKind @@ -24,8 +25,11 @@ import org.jetbrains.kotlin.fir.java.declarations.buildJavaValueParameter import org.jetbrains.kotlin.fir.java.enhancement.readOnlyToMutable import org.jetbrains.kotlin.fir.references.builder.buildErrorNamedReference import org.jetbrains.kotlin.fir.references.builder.buildResolvedNamedReference +import org.jetbrains.kotlin.fir.resolve.defaultType import org.jetbrains.kotlin.fir.resolve.firSymbolProvider import org.jetbrains.kotlin.fir.resolve.getClassDeclaredCallableSymbols +import org.jetbrains.kotlin.fir.resolve.toSymbol +import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.firUnsafe import org.jetbrains.kotlin.fir.symbols.StandardClassIds import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagImpl import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol @@ -38,6 +42,7 @@ import org.jetbrains.kotlin.fir.types.jvm.FirJavaTypeRef import org.jetbrains.kotlin.fir.types.jvm.buildJavaTypeRef import org.jetbrains.kotlin.load.java.structure.* import org.jetbrains.kotlin.load.java.structure.impl.JavaElementImpl +import org.jetbrains.kotlin.load.java.typeEnhancement.TypeComponentPosition import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.types.Variance.* @@ -65,24 +70,17 @@ internal fun ClassId.toConeKotlinType( return ConeClassLikeTypeImpl(lookupTag, typeArguments, isNullable) } -internal fun FirTypeRef.toNotNullConeKotlinType( +internal fun FirTypeRef.toConeKotlinTypeProbablyFlexible( session: FirSession, javaTypeParameterStack: JavaTypeParameterStack ): ConeKotlinType = when (this) { is FirResolvedTypeRef -> type is FirJavaTypeRef -> { - val javaType = type - javaType.toNotNullConeKotlinType(session, javaTypeParameterStack) + type.toConeKotlinTypeWithoutEnhancement(session, javaTypeParameterStack) } else -> ConeKotlinErrorType("Unexpected type reference in JavaClassUseSiteMemberScope: ${this::class.java}") } -internal fun JavaType?.toNotNullConeKotlinType( - session: FirSession, javaTypeParameterStack: JavaTypeParameterStack -): ConeKotlinType { - return toConeKotlinTypeWithNullability(session, javaTypeParameterStack, ConeNullability.NOT_NULL) -} - internal fun JavaType.toFirJavaTypeRef(session: FirSession, javaTypeParameterStack: JavaTypeParameterStack): FirJavaTypeRef { val annotations = (this as? JavaClassifierType)?.annotations.orEmpty() return buildJavaTypeRef { @@ -94,25 +92,29 @@ internal fun JavaType.toFirJavaTypeRef(session: FirSession, javaTypeParameterSta internal fun JavaClassifierType.toFirResolvedTypeRef( session: FirSession, javaTypeParameterStack: JavaTypeParameterStack, - nullability: ConeNullability = ConeNullability.NOT_NULL, - typeParametersNullability: ConeNullability = ConeNullability.NOT_NULL + isForSupertypes: Boolean, + forTypeParameterBounds: Boolean ): FirResolvedTypeRef { - val coneType = this.toConeKotlinTypeWithNullability(session, javaTypeParameterStack, nullability, typeParametersNullability) + val coneType = + this.toConeKotlinTypeWithoutEnhancement(session, javaTypeParameterStack, forTypeParameterBounds).run { + if (isForSupertypes) + this.lowerBoundIfFlexible() + else + this + } return buildResolvedTypeRef { type = coneType this@toFirResolvedTypeRef.annotations.mapTo(annotations) { it.toFirAnnotationCall(session, javaTypeParameterStack) } } } -internal fun JavaType?.toConeKotlinTypeWithNullability( +internal fun JavaType?.toConeKotlinTypeWithoutEnhancement( session: FirSession, - javaTypeParameterStack: JavaTypeParameterStack, - nullability: ConeNullability, - typeParametersNullability: ConeNullability = ConeNullability.NOT_NULL + javaTypeParameterStack: JavaTypeParameterStack ): ConeKotlinType { return when (this) { is JavaClassifierType -> { - toConeKotlinTypeWithNullability(session, nullability, typeParametersNullability, javaTypeParameterStack) + toConeKotlinTypeWithoutEnhancement(session, javaTypeParameterStack) } is JavaPrimitiveType -> { val primitiveType = type @@ -120,77 +122,204 @@ internal fun JavaType?.toConeKotlinTypeWithNullability( null -> "Unit" else -> javaName.capitalize() } + val classId = StandardClassIds.byName(kotlinPrimitiveName) - classId.toConeKotlinType(emptyArray(), nullability.isNullable) + classId.toConeKotlinType(emptyArray(), isNullable = false) } is JavaArrayType -> { val componentType = componentType if (componentType !is JavaPrimitiveType) { val classId = StandardClassIds.Array - val argumentType = ConeFlexibleType( - componentType.toConeKotlinTypeWithNullability(session, javaTypeParameterStack, ConeNullability.NOT_NULL), - componentType.toConeKotlinTypeWithNullability(session, javaTypeParameterStack, ConeNullability.NULLABLE) + val argumentType = componentType.toConeKotlinTypeWithoutEnhancement(session, javaTypeParameterStack) + classId.toConeFlexibleType( + arrayOf(argumentType), + typeArgumentsForUpper = arrayOf(ConeKotlinTypeProjectionOut(argumentType)) ) - 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(), nullability.isNullable) + + classId.toConeFlexibleType(emptyArray()) } } - is JavaWildcardType -> bound?.toNotNullConeKotlinType(session, javaTypeParameterStack) ?: run { - val classId = StandardClassIds.Any - classId.toConeKotlinType(emptyArray(), nullability.isNullable) + is JavaWildcardType -> bound?.toConeKotlinTypeWithoutEnhancement(session, javaTypeParameterStack) ?: run { + StandardClassIds.Any.toConeFlexibleType(emptyArray()) } null -> { - val classId = StandardClassIds.Any - classId.toConeKotlinType(emptyArray(), nullability.isNullable) + StandardClassIds.Any.toConeFlexibleType(emptyArray()) } else -> error("Strange JavaType: ${this::class.java}") } } -internal fun JavaClassifierType.toConeKotlinTypeWithNullability( +private fun ClassId.toConeFlexibleType( + typeArguments: Array, + typeArgumentsForUpper: Array = typeArguments +) = ConeFlexibleType( + toConeKotlinType(typeArguments, isNullable = false), + toConeKotlinType(typeArgumentsForUpper, isNullable = true) +) + +private fun JavaClassifierType.toConeKotlinTypeWithoutEnhancement( session: FirSession, - nullability: ConeNullability, - typeParametersNullability: ConeNullability, - javaTypeParameterStack: JavaTypeParameterStack + javaTypeParameterStack: JavaTypeParameterStack, + forTypeParameterBounds: Boolean = false ): ConeKotlinType { - if (nullability == ConeNullability.UNKNOWN) { - return ConeFlexibleType( - toConeKotlinTypeWithNullability(session, ConeNullability.NOT_NULL, typeParametersNullability, javaTypeParameterStack), - toConeKotlinTypeWithNullability(session, ConeNullability.NULLABLE, typeParametersNullability, javaTypeParameterStack) - ) + val lowerBound = toConeKotlinTypeForFlexibleBound(session, javaTypeParameterStack, isLowerBound = true, forTypeParameterBounds) + val upperBound = toConeKotlinTypeForFlexibleBound(session, javaTypeParameterStack, isLowerBound = false, forTypeParameterBounds) + + return if (isRaw) ConeRawType(lowerBound, upperBound) else ConeFlexibleType(lowerBound, upperBound) +} + +private fun computeRawProjection( + session: FirSession, + parameter: FirTypeParameter, + attr: TypeComponentPosition, + erasedUpperBound: ConeKotlinType = parameter.getErasedUpperBound() +) = when (attr) { + // Raw(List) => (List..List<*>) + // Raw(Enum) => (Enum>..Enum>) + // In the last case upper bound is equal to star projection `Enum<*>`, + // but we want to keep matching tree structure of flexible bounds (at least they should have the same size) + TypeComponentPosition.FLEXIBLE_LOWER -> { + // T : String -> String + // in T : String -> String + // T : Enum -> Enum<*> + erasedUpperBound } + TypeComponentPosition.FLEXIBLE_UPPER, TypeComponentPosition.INFLEXIBLE -> { + if (!parameter.variance.allowsOutPosition) + // in T -> Comparable + session.builtinTypes.nothingType.type + else if (erasedUpperBound is ConeClassLikeType && + erasedUpperBound.lookupTag.toSymbol(session)!!.firUnsafe().typeParameters.isNotEmpty() + ) + // T : Enum -> out Enum<*> + ConeKotlinTypeProjectionOut(erasedUpperBound) + else + // T : String -> * + ConeStarProjection + } +} + +// 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 +// ErasedUpperBound(T : F) = UpperBound(F) // UB(T) is another type parameter F +private fun FirTypeParameter.getErasedUpperBound( + // Calculation of `potentiallyRecursiveTypeParameter.upperBounds` may recursively depend on `this.getErasedUpperBound` + // E.g. `class A` + // To prevent recursive calls return defaultValue() instead + potentiallyRecursiveTypeParameter: FirTypeParameter? = null, + defaultValue: (() -> ConeKotlinType) = { ConeKotlinErrorType("Can't compute erased upper bound of type parameter `$this`") } +): ConeKotlinType { + if (this === potentiallyRecursiveTypeParameter) return defaultValue() + + val firstUpperBound = this.bounds.first().coneTypeUnsafe() + + return getErasedVersionOfFirstUpperBound(firstUpperBound, mutableSetOf(this, potentiallyRecursiveTypeParameter), defaultValue) +} + +private fun getErasedVersionOfFirstUpperBound( + firstUpperBound: ConeKotlinType, + alreadyVisitedParameters: MutableSet, + defaultValue: () -> ConeKotlinType +): ConeKotlinType = + when (firstUpperBound) { + is ConeClassLikeType -> + firstUpperBound.withArguments(firstUpperBound.typeArguments.map { ConeStarProjection }.toTypedArray()) + + is ConeFlexibleType -> { + val lowerBound = + getErasedVersionOfFirstUpperBound(firstUpperBound.lowerBound, alreadyVisitedParameters, defaultValue) + .lowerBoundIfFlexible() + if (firstUpperBound.upperBound is ConeTypeParameterType) { + // Avoid exponential complexity + ConeFlexibleType( + lowerBound, + lowerBound.withNullability(ConeNullability.NULLABLE) + ) + } else { + ConeFlexibleType( + lowerBound, + getErasedVersionOfFirstUpperBound(firstUpperBound.upperBound, alreadyVisitedParameters, defaultValue) + ) + } + } + is ConeTypeParameterType -> { + val current = firstUpperBound.lookupTag.typeParameterSymbol.fir + + if (alreadyVisitedParameters.add(current)) { + val nextUpperBound = current.bounds.first().coneTypeUnsafe() + getErasedVersionOfFirstUpperBound(nextUpperBound, alreadyVisitedParameters, defaultValue) + } else { + defaultValue() + } + } + else -> error("Unexpected kind of firstUpperBound: $firstUpperBound [${firstUpperBound::class}]") + } + +private fun JavaClassifierType.toConeKotlinTypeForFlexibleBound( + session: FirSession, + javaTypeParameterStack: JavaTypeParameterStack, + isLowerBound: Boolean, + forTypeParameterBounds: Boolean +): ConeKotlinType { return when (val classifier = classifier) { is JavaClass -> { //val classId = classifier.classId!! var classId = JavaToKotlinClassMap.mapJavaToKotlin(classifier.fqName!!) ?: classifier.classId!! - classId = classId.readOnlyToMutable() ?: classId + + if (isLowerBound) { + classId = classId.readOnlyToMutable() ?: classId + } val lookupTag = ConeClassLikeLookupTagImpl(classId) - val mappedTypeArguments = when (isRaw) { - true -> classifier.typeParameters.map { ConeStarProjection } - false -> typeArguments.map { argument -> - argument.toConeProjection( - session, javaTypeParameterStack, boundTypeParameter = null, nullability = typeParametersNullability + val mappedTypeArguments = if (isRaw) { + + val defaultArgs = (1..classifier.typeParameters.size).map { ConeStarProjection } + + if (forTypeParameterBounds) { + // This is not fully correct, but it's a simple fix for some time to avoid recursive definition: + // to create a proper raw type arguments, we should take class parameters some time + defaultArgs + } else { + val classSymbol = session.firSymbolProvider.getClassLikeSymbolByFqName(classId) as? FirRegularClassSymbol + val position = if (isLowerBound) TypeComponentPosition.FLEXIBLE_LOWER else TypeComponentPosition.FLEXIBLE_UPPER + + classSymbol?.fir?.createRawArguments(defaultArgs, position) ?: defaultArgs + } + } else { + typeArguments.map { argument -> + argument.toConeProjectionWithoutEnhancement( + session, javaTypeParameterStack, boundTypeParameter = null ) } } lookupTag.constructClassType( - mappedTypeArguments.toTypedArray(), nullability.isNullable + mappedTypeArguments.toTypedArray(), isNullable = !isLowerBound ) } is JavaTypeParameter -> { val symbol = javaTypeParameterStack[classifier] - ConeTypeParameterTypeImpl(symbol.toLookupTag(), nullability.isNullable) + ConeTypeParameterTypeImpl(symbol.toLookupTag(), isNullable = !isLowerBound) } else -> ConeClassErrorType(reason = "Unexpected classifier: $classifier") } } +private fun FirRegularClass.createRawArguments( + defaultArgs: List, + position: TypeComponentPosition +) = typeParameters.map { typeParameter -> + val erasedUpperBound = typeParameter.getErasedUpperBound { + defaultType().withArguments(defaultArgs.toTypedArray()) + } + computeRawProjection(session, typeParameter, position, erasedUpperBound) +} + internal fun JavaAnnotation.toFirAnnotationCall( session: FirSession, javaTypeParameterStack: JavaTypeParameterStack ): FirAnnotationCall { @@ -226,11 +355,10 @@ internal fun JavaValueParameter.toFirValueParameter( } } -internal fun JavaType?.toConeProjection( +private fun JavaType?.toConeProjectionWithoutEnhancement( session: FirSession, javaTypeParameterStack: JavaTypeParameterStack, - boundTypeParameter: FirTypeParameter?, - nullability: ConeNullability = ConeNullability.NOT_NULL + boundTypeParameter: FirTypeParameter? ): ConeKotlinTypeProjection { return when (this) { null -> ConeStarProjection @@ -241,7 +369,7 @@ internal fun JavaType?.toConeProjection( if (bound == null || parameterVariance != INVARIANT && parameterVariance != argumentVariance) { ConeStarProjection } else { - val boundType = bound.toConeKotlinTypeWithNullability(session, javaTypeParameterStack, nullability) + val boundType = bound.toConeKotlinTypeWithoutEnhancement(session, javaTypeParameterStack) if (argumentVariance == OUT_VARIANCE) { ConeKotlinTypeProjectionOut(boundType) } else { @@ -249,7 +377,7 @@ internal fun JavaType?.toConeProjection( } } } - is JavaClassifierType -> toConeKotlinTypeWithNullability(session, javaTypeParameterStack, nullability) + is JavaClassifierType -> toConeKotlinTypeWithoutEnhancement(session, javaTypeParameterStack) else -> ConeClassErrorType("Unexpected type argument: $this") } } @@ -342,7 +470,12 @@ internal fun Any?.createConstant(session: FirSession): FirExpression { private fun JavaType.toFirResolvedTypeRef( session: FirSession, javaTypeParameterStack: JavaTypeParameterStack ): FirResolvedTypeRef { - if (this is JavaClassifierType) return toFirResolvedTypeRef(session, javaTypeParameterStack) + if (this is JavaClassifierType) return toFirResolvedTypeRef( + session, + javaTypeParameterStack, + isForSupertypes = false, + forTypeParameterBounds = false + ) return buildResolvedTypeRef { type = ConeClassErrorType("Unexpected JavaType: $this") } 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 0b78e903ebb..951aefe930e 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 @@ -12,9 +12,8 @@ import org.jetbrains.kotlin.fir.declarations.FirValueParameter import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.classId import org.jetbrains.kotlin.fir.java.JavaTypeParameterStack -import org.jetbrains.kotlin.fir.java.toConeKotlinTypeWithNullability +import org.jetbrains.kotlin.fir.java.toConeKotlinTypeWithoutEnhancement import org.jetbrains.kotlin.fir.java.toFirJavaTypeRef -import org.jetbrains.kotlin.fir.java.toNotNullConeKotlinType import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.types.jvm.FirJavaTypeRef @@ -58,7 +57,8 @@ internal class EnhancementSignatureParts( } } - val containsFunctionN = current.toNotNullConeKotlinType(session, javaTypeParameterStack).contains { + val typeWithoutEnhancement = current.type.toConeKotlinTypeWithoutEnhancement(session, javaTypeParameterStack) + val containsFunctionN = typeWithoutEnhancement.contains { if (it is ConeClassErrorType) false else { val classId = it.lookupTag.classId @@ -67,7 +67,10 @@ internal class EnhancementSignatureParts( } } - val enhancedCurrent = current.enhance(session, javaTypeParameterStack, qualifiersWithPredefined ?: qualifiers) + val enhancedCurrent = current.enhance( + session, qualifiersWithPredefined ?: qualifiers, + typeWithoutEnhancement + ) return PartEnhancementResult( enhancedCurrent, wereChanges = true, containsFunctionN = containsFunctionN ) @@ -150,10 +153,10 @@ internal class EnhancementSignatureParts( } } is FirJavaTypeRef -> { + val convertedType = type.toConeKotlinTypeWithoutEnhancement(session, javaTypeParameterStack) Pair( - // TODO: optimize - type.toConeKotlinTypeWithNullability(session, javaTypeParameterStack, nullability = ConeNullability.NOT_NULL), - type.toConeKotlinTypeWithNullability(session, javaTypeParameterStack, nullability = ConeNullability.NULLABLE) + convertedType.lowerBoundIfFlexible(), + convertedType.upperBoundIfFlexible() ) } 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 0fba96fe3e6..44772fed3fd 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 @@ -16,15 +16,11 @@ import org.jetbrains.kotlin.fir.expressions.builder.buildQualifiedAccessExpressi import org.jetbrains.kotlin.fir.java.JavaTypeParameterStack import org.jetbrains.kotlin.fir.java.declarations.FirJavaClass 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.builder.buildResolvedNamedReference -import org.jetbrains.kotlin.fir.resolve.* -import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.firUnsafe +import org.jetbrains.kotlin.fir.resolve.toSymbol import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag import org.jetbrains.kotlin.fir.symbols.ConeClassifierLookupTag import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterLookupTag -import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagImpl import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol import org.jetbrains.kotlin.fir.typeContext @@ -36,13 +32,14 @@ import org.jetbrains.kotlin.load.java.JvmAnnotationNames.DEFAULT_VALUE_FQ_NAME import org.jetbrains.kotlin.load.java.descriptors.AnnotationDefaultValue import org.jetbrains.kotlin.load.java.descriptors.NullDefaultValue import org.jetbrains.kotlin.load.java.descriptors.StringDefaultValue -import org.jetbrains.kotlin.load.java.structure.* +import org.jetbrains.kotlin.load.java.structure.JavaClassifierType +import org.jetbrains.kotlin.load.java.structure.JavaType import org.jetbrains.kotlin.load.java.typeEnhancement.* import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.types.AbstractStrictEqualityTypeChecker -import org.jetbrains.kotlin.types.Variance +import org.jetbrains.kotlin.types.RawType import org.jetbrains.kotlin.utils.addToStdlib.safeAs import org.jetbrains.kotlin.utils.extractRadix @@ -56,60 +53,23 @@ internal class IndexedJavaTypeQualifiers(private val data: Array>`, indices go as follows: `0 - A<...>, 1 - B, 2 - C, 3 - D, 4 - E`, // which corresponds to the left-to-right breadth-first walk of the tree representation of the type. // For flexible types, both bounds are indexed in the same way: `(A..C)` gives `0 - (A..C), 1 - B and D`. -private fun JavaType?.enhancePossiblyFlexible( +private fun ConeKotlinType.enhancePossiblyFlexible( session: FirSession, - javaTypeParameterStack: JavaTypeParameterStack, annotations: List, qualifiers: IndexedJavaTypeQualifiers, index: Int ): FirResolvedTypeRef { - val type = this - val arguments = this?.typeArguments().orEmpty() - val enhanced = when (type) { - is JavaClassifierType -> { - val lowerResult = type.enhanceInflexibleType( - session, javaTypeParameterStack, annotations, arguments, TypeComponentPosition.FLEXIBLE_LOWER, qualifiers, index - ) - val upperResult = type.enhanceInflexibleType( - session, javaTypeParameterStack, annotations, arguments, TypeComponentPosition.FLEXIBLE_UPPER, qualifiers, index - ) - - when { - type.isRaw -> ConeRawType(lowerResult, upperResult) - else -> coneFlexibleOrSimpleType( - session, lowerResult, upperResult, isNotNullTypeParameter = qualifiers(index).isNotNullTypeParameter - ) - } - } - is JavaArrayType -> { - val baseEnhanced = type.toNotNullConeKotlinType(session, javaTypeParameterStack) - - val upperBound = if (baseEnhanced.typeArguments.isNotEmpty()) { - val typeArgument = baseEnhanced.typeArguments.first() as ConeKotlinType - baseEnhanced.withArguments(arrayOf(ConeKotlinTypeProjectionOut(typeArgument))) - } else { - baseEnhanced - } - coneFlexibleOrSimpleType( - session, baseEnhanced, - upperBound.withNullability(ConeNullability.NULLABLE), - isNotNullTypeParameter = false - ) - } - else -> { - type.toNotNullConeKotlinType(session, javaTypeParameterStack) - } - } + val enhanced = enhanceConeKotlinType(session, qualifiers, index) return buildResolvedTypeRef { this.type = enhanced @@ -117,9 +77,34 @@ private fun JavaType?.enhancePossiblyFlexible( } } -private fun JavaType?.subtreeSize(): Int { - if (this !is JavaClassifierType) return 1 - return 1 + typeArguments.sumBy { it?.subtreeSize() ?: 0 } +private fun ConeKotlinType.enhanceConeKotlinType( + session: FirSession, + qualifiers: IndexedJavaTypeQualifiers, + index: Int +): ConeKotlinType { + return when (this) { + is ConeFlexibleType -> { + val lowerResult = lowerBound.enhanceInflexibleType( + session, TypeComponentPosition.FLEXIBLE_LOWER, qualifiers, index + ) + val upperResult = upperBound.enhanceInflexibleType( + session, TypeComponentPosition.FLEXIBLE_UPPER, qualifiers, index + ) + + when (this) { + is ConeRawType -> ConeRawType(lowerResult, upperResult) + else -> coneFlexibleOrSimpleType( + session, lowerResult, upperResult, isNotNullTypeParameter = qualifiers(index).isNotNullTypeParameter + ) + } + } + is ConeSimpleKotlinType -> enhanceInflexibleType(session, TypeComponentPosition.INFLEXIBLE, qualifiers, index) + else -> this + } +} + +private fun ConeKotlinType.subtreeSize(): Int { + return 1 + typeArguments.sumBy { ((it as? ConeKotlinType)?.subtreeSize() ?: 0) + 1 } } private fun coneFlexibleOrSimpleType( @@ -164,155 +149,43 @@ 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 -// ErasedUpperBound(T : F) = UpperBound(F) // UB(T) is another type parameter F -private fun FirTypeParameter.getErasedUpperBound( - // Calculation of `potentiallyRecursiveTypeParameter.upperBounds` may recursively depend on `this.getErasedUpperBound` - // E.g. `class A` - // To prevent recursive calls return defaultValue() instead - potentiallyRecursiveTypeParameter: FirTypeParameter? = null, - defaultValue: (() -> ConeKotlinType) = { ConeKotlinErrorType("Can't compute erased upper bound of type parameter `$this`") } -): ConeKotlinType { - if (this === potentiallyRecursiveTypeParameter) return defaultValue() - - val firstUpperBound = this.bounds.first().coneTypeUnsafe() - - return getErasedVersionOfFirstUpperBound(firstUpperBound, mutableSetOf(this, potentiallyRecursiveTypeParameter), defaultValue) -} - -private fun getErasedVersionOfFirstUpperBound( - firstUpperBound: ConeKotlinType, - alreadyVisitedParameters: MutableSet, - defaultValue: () -> ConeKotlinType -): ConeKotlinType = - when (firstUpperBound) { - is ConeClassLikeType -> - firstUpperBound.withArguments(firstUpperBound.typeArguments.map { ConeStarProjection }.toTypedArray()) - - is ConeFlexibleType -> { - val lowerBound = - getErasedVersionOfFirstUpperBound(firstUpperBound.lowerBound, alreadyVisitedParameters, defaultValue) - .lowerBoundIfFlexible() - if (firstUpperBound.upperBound is ConeTypeParameterType) { - // Avoid exponential complexity - ConeFlexibleType( - lowerBound, - lowerBound.withNullability(ConeNullability.NULLABLE) - ) - } else { - ConeFlexibleType( - lowerBound, - getErasedVersionOfFirstUpperBound(firstUpperBound.upperBound, alreadyVisitedParameters, defaultValue) - ) - } - } - is ConeTypeParameterType -> { - val current = firstUpperBound.lookupTag.typeParameterSymbol.fir - - if (alreadyVisitedParameters.add(current)) { - val nextUpperBound = current.bounds.first().coneTypeUnsafe() - getErasedVersionOfFirstUpperBound(nextUpperBound, alreadyVisitedParameters, defaultValue) - } else { - defaultValue() - } - } - else -> error("Unexpected kind of firstUpperBound: $firstUpperBound [${firstUpperBound::class}]") - } - - -fun computeProjection( +private fun ConeKotlinType.enhanceInflexibleType( session: FirSession, - parameter: FirTypeParameter, - attr: TypeComponentPosition, - erasedUpperBound: ConeKotlinType = parameter.getErasedUpperBound() -) = when (attr) { - // Raw(List) => (List..List<*>) - // Raw(Enum) => (Enum>..Enum>) - // In the last case upper bound is equal to star projection `Enum<*>`, - // but we want to keep matching tree structure of flexible bounds (at least they should have the same size) - TypeComponentPosition.FLEXIBLE_LOWER -> { - // T : String -> String - // in T : String -> String - // T : Enum -> Enum<*> - erasedUpperBound - } - TypeComponentPosition.FLEXIBLE_UPPER, TypeComponentPosition.INFLEXIBLE -> { - if (!parameter.variance.allowsOutPosition) - // in T -> Comparable - session.builtinTypes.nothingType.type - else if (erasedUpperBound is ConeClassLikeType && - erasedUpperBound.lookupTag.toSymbol(session)!!.firUnsafe().typeParameters.isNotEmpty() - ) - // T : Enum -> out Enum<*> - ConeKotlinTypeProjectionOut(erasedUpperBound) - else - // T : String -> * - ConeStarProjection - } -} - -private fun JavaClassifierType.enhanceInflexibleType( - session: FirSession, - javaTypeParameterStack: JavaTypeParameterStack, - annotations: List, - arguments: List, position: TypeComponentPosition, qualifiers: IndexedJavaTypeQualifiers, index: Int ): ConeKotlinType { - val originalTag = when (val classifier = classifier) { - is JavaClass -> { - val classId = classifier.classId!! - var mappedId = JavaToKotlinClassMap.mapJavaToKotlin(classId.asSingleFqName()) - if (mappedId != null) { - if (position == TypeComponentPosition.FLEXIBLE_LOWER) { - mappedId = mappedId.readOnlyToMutable() ?: mappedId - } - } - val kotlinClassId = mappedId ?: classId - ConeClassLikeLookupTagImpl(kotlinClassId) - } - is JavaTypeParameter -> javaTypeParameterStack[classifier].toLookupTag() - else -> return toNotNullConeKotlinType(session, javaTypeParameterStack) + require(this !is ConeFlexibleType) { + "$this should not be flexible" } + if (this !is ConeLookupTagBasedType) return this + + val originalTag = lookupTag val effectiveQualifiers = qualifiers(index) val enhancedTag = originalTag.enhanceMutability(effectiveQualifiers, position) - val enhancedArguments = if (isRaw) { - val firClassifier = originalTag.toSymbol(session)!!.firUnsafe() - firClassifier.typeParameters.map { - val fir = it - val erasedUpperBound = fir.getErasedUpperBound { - firClassifier.defaultType().withArguments(firClassifier.typeParameters.map { ConeStarProjection }.toTypedArray()) - } - computeProjection(session, fir, position, erasedUpperBound) - } + val enhancedArguments = if (this is RawType) { + // TODO: Support enhancing for raw types + typeArguments } else { var globalArgIndex = index + 1 - arguments.mapIndexed { localArgIndex, arg -> - if (arg is JavaWildcardType) { + typeArguments.mapIndexed { localArgIndex, arg -> + if (arg.kind != ProjectionKind.INVARIANT) { globalArgIndex++ - arg.toConeProjection( - session, - javaTypeParameterStack, - ((originalTag as? FirBasedSymbol<*>)?.fir as? FirCallableMemberDeclaration<*>)?.typeParameters?.getOrNull(localArgIndex) - ) + arg } else { - val argEnhancedTypeRef = - arg.enhancePossiblyFlexible(session, javaTypeParameterStack, annotations, qualifiers, globalArgIndex) + require(arg is ConeKotlinType) { "Should be invariant type: $arg" } globalArgIndex += arg.subtreeSize() - argEnhancedTypeRef.type.type.toTypeProjection(Variance.INVARIANT) + arg.enhanceConeKotlinType(session, qualifiers, globalArgIndex) } - } + }.toTypedArray() } val enhancedNullability = getEnhancedNullability(effectiveQualifiers, position) - val enhancedType = enhancedTag.constructType(enhancedArguments.toTypedArray(), enhancedNullability) + val enhancedType = enhancedTag.constructType(enhancedArguments, enhancedNullability) // TODO: why all of these is needed // val enhancement = if (effectiveQualifiers.isNotNullTypeParameter) NotNullTypeParameter(enhancedType) else enhancedType diff --git a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/scopes/JavaOverrideChecker.kt b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/scopes/JavaOverrideChecker.kt index 2f34402d08a..f0f4c27f58c 100644 --- a/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/scopes/JavaOverrideChecker.kt +++ b/compiler/fir/java/src/org/jetbrains/kotlin/fir/java/scopes/JavaOverrideChecker.kt @@ -13,7 +13,7 @@ import org.jetbrains.kotlin.fir.declarations.FirSimpleFunction import org.jetbrains.kotlin.fir.declarations.modality import org.jetbrains.kotlin.fir.java.JavaTypeParameterStack import org.jetbrains.kotlin.fir.java.enhancement.readOnlyToMutable -import org.jetbrains.kotlin.fir.java.toNotNullConeKotlinType +import org.jetbrains.kotlin.fir.java.toConeKotlinTypeProbablyFlexible import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor import org.jetbrains.kotlin.fir.scopes.impl.FirAbstractOverrideChecker import org.jetbrains.kotlin.fir.typeContext @@ -32,7 +32,7 @@ class JavaOverrideChecker internal constructor( return candidateType.lookupTag.classId.let { it.readOnlyToMutable() ?: it } == baseType.lookupTag.classId.let { it.readOnlyToMutable() ?: it } } if (candidateType is ConeClassLikeType && baseType is ConeTypeParameterType) { - val boundType = baseType.lookupTag.typeParameterSymbol.fir.bounds.singleOrNull()?.toNotNullConeKotlinType( + val boundType = baseType.lookupTag.typeParameterSymbol.fir.bounds.singleOrNull()?.toConeKotlinTypeProbablyFlexible( session, javaTypeParameterStack ) if (boundType != null) { @@ -49,8 +49,8 @@ class JavaOverrideChecker internal constructor( override fun isEqualTypes(candidateTypeRef: FirTypeRef, baseTypeRef: FirTypeRef, substitutor: ConeSubstitutor) = isEqualTypes( - candidateTypeRef.toNotNullConeKotlinType(session, javaTypeParameterStack), - baseTypeRef.toNotNullConeKotlinType(session, javaTypeParameterStack), + candidateTypeRef.toConeKotlinTypeProbablyFlexible(session, javaTypeParameterStack), + baseTypeRef.toConeKotlinTypeProbablyFlexible(session, javaTypeParameterStack), substitutor ) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/TypeUtils.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/TypeUtils.kt index f162fd71b33..1c6d8c4910c 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/TypeUtils.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/types/TypeUtils.kt @@ -189,10 +189,10 @@ fun ConeClassLikeLookupTag.constructClassType( return ConeClassLikeTypeImpl(this, typeArguments, isNullable) } -fun ConeClassifierLookupTag.constructType(typeArguments: Array, isNullable: Boolean): ConeLookupTagBasedType { +fun ConeClassifierLookupTag.constructType(typeArguments: Array, isNullable: Boolean): ConeLookupTagBasedType { return when (this) { is ConeTypeParameterLookupTag -> ConeTypeParameterTypeImpl(this, isNullable) is ConeClassLikeLookupTag -> this.constructClassType(typeArguments, isNullable) else -> error("! ${this::class}") } -} \ No newline at end of file +} diff --git a/compiler/fir/resolve/testData/resolve/expresssions/genericDiagnostic.txt b/compiler/fir/resolve/testData/resolve/expresssions/genericDiagnostic.txt index 1e490e2a819..add029a2d52 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/genericDiagnostic.txt +++ b/compiler/fir/resolve/testData/resolve/expresssions/genericDiagnostic.txt @@ -16,7 +16,7 @@ FILE: test.kt private final val DERIVED_FACTORY: R|DiagnosticFactory0| = R|/DiagnosticFactory0.DiagnosticFactory0|() private get(): R|DiagnosticFactory0| public final fun createViaFactory(d: R|EmptyDiagnostic|): R|kotlin/Unit| { - lval casted: R|Diagnostic| = R|/DERIVED_FACTORY|.R|FakeOverride|>|(R|/d|) + lval casted: R|Diagnostic!>| = R|/DERIVED_FACTORY|.R|FakeOverride!>|>|(R|/d|) lval element: R|DerivedElement| = R|/casted|.R|/Diagnostic.element| R|/Fix.Fix|(R|/element|) } diff --git a/compiler/fir/resolve/testData/resolve/stdlib/j+k/flexibleWildcard.kt b/compiler/fir/resolve/testData/resolve/stdlib/j+k/flexibleWildcard.kt new file mode 100644 index 00000000000..87de7548731 --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/stdlib/j+k/flexibleWildcard.kt @@ -0,0 +1,13 @@ +// FILE: ContainerUtil.java +import java.util.*; +public class ContainerUtil { + public static List flatten(Iterable> collections) { + return null; + } +} +// FILE: main.kt + +fun main(x: MutableCollection>) { + val y = ContainerUtil.flatten(x) + y[0].length +} diff --git a/compiler/fir/resolve/testData/resolve/stdlib/j+k/flexibleWildcard.txt b/compiler/fir/resolve/testData/resolve/stdlib/j+k/flexibleWildcard.txt new file mode 100644 index 00000000000..c72516f6fa2 --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/stdlib/j+k/flexibleWildcard.txt @@ -0,0 +1,5 @@ +FILE: main.kt + public final fun main(x: R|kotlin/collections/MutableCollection>|): R|kotlin/Unit| { + lval y: R|ft!>, kotlin/collections/List!>?>!| = Q|ContainerUtil|.R|/ContainerUtil.flatten|!|>(R|/x|) + R|/y|.R|FakeOverride!|>|(Int(0)).R|kotlin/String.length| + } diff --git a/compiler/fir/resolve/testData/resolveWithStdlib/hashTableWithForEach.txt b/compiler/fir/resolve/testData/resolveWithStdlib/hashTableWithForEach.txt index ec8d51af5ba..6b5402c0120 100644 --- a/compiler/fir/resolve/testData/resolveWithStdlib/hashTableWithForEach.txt +++ b/compiler/fir/resolve/testData/resolveWithStdlib/hashTableWithForEach.txt @@ -13,7 +13,7 @@ FILE: hashTableWithForEach.kt public get(): R|kotlin/collections/MutableSet>| { when () { R|/DEBUG| -> { - ^ Q|java/util/Collections|.R|java/util/Collections.unmodifiableSet||>(R|kotlin/collections/mutableSetOf||>().R|kotlin/apply|>|>( = apply@fun R|kotlin/collections/MutableSet>|.(): R|kotlin/Unit| { + ^ Q|java/util/Collections|.R|java/util/Collections.unmodifiableSet|, kotlin/collections/MutableMap.MutableEntry?>!|>(R|kotlin/collections/mutableSetOf||>().R|kotlin/apply|>|>( = apply@fun R|kotlin/collections/MutableSet>|.(): R|kotlin/Unit| { this@R|/SomeHashTable|.R|FakeOverride|( = forEach@fun (key: R|K|, value: R|V|): R|kotlin/Unit| { ^ this@R|special/anonymous|.R|FakeOverride|(R|/SomeHashTable.Entry.Entry|(R|/key|, R|/value|)) } diff --git a/compiler/fir/resolve/testData/resolveWithStdlib/j+k/MapCompute.txt b/compiler/fir/resolve/testData/resolveWithStdlib/j+k/MapCompute.txt index 2afe1118d4a..9d1c2a522c9 100644 --- a/compiler/fir/resolve/testData/resolveWithStdlib/j+k/MapCompute.txt +++ b/compiler/fir/resolve/testData/resolveWithStdlib/j+k/MapCompute.txt @@ -1,7 +1,7 @@ FILE: MapCompute.kt public final fun R|kotlin/collections/MutableMap>|.initAndAdd(key: R|kotlin/String|, value: R|D|): R|kotlin/Unit| { - this@R|/initAndAdd|.R|FakeOverride?|>|(R|/key|, = compute@fun (_: R|kotlin/String|, maybeValues: R|kotlin/collections/MutableSet|): R|kotlin/collections/MutableSet| { - lval setOfValues: R|kotlin/collections/MutableSet| = when (lval : R|kotlin/collections/MutableSet| = R|/maybeValues|) { + this@R|/initAndAdd|.R|FakeOverride?|>|(R|/key|, = compute@fun (_: R|ft!|, maybeValues: R|ft, kotlin/collections/MutableSet?>!|): R|ft, kotlin/collections/MutableSet?>!| { + lval setOfValues: R|kotlin/collections/MutableSet| = when (lval : R|ft, kotlin/collections/MutableSet?>!| = R|/maybeValues|) { ==($subj$, Null(null)) -> { R|kotlin/collections/mutableSetOf|() } diff --git a/compiler/fir/resolve/testData/resolveWithStdlib/j+k/MyIterable.txt b/compiler/fir/resolve/testData/resolveWithStdlib/j+k/MyIterable.txt index 5809c1b1e1c..dfe4107b431 100644 --- a/compiler/fir/resolve/testData/resolveWithStdlib/j+k/MyIterable.txt +++ b/compiler/fir/resolve/testData/resolveWithStdlib/j+k/MyIterable.txt @@ -8,5 +8,5 @@ FILE: test.kt } public final fun test(some: R|kotlin/collections/Iterable|): R|kotlin/Unit| { lval it: R|kotlin/collections/Iterator| = R|/some|.R|FakeOverride|>|() - lval split: R|java/util/Spliterator| = R|/some|.R|FakeOverride|>|() + lval split: R|java/util/Spliterator!>| = R|/some|.R|FakeOverride!>|>|() } diff --git a/compiler/fir/resolve/testData/resolveWithStdlib/j+k/MyMap.txt b/compiler/fir/resolve/testData/resolveWithStdlib/j+k/MyMap.txt index bde692821a1..b77a2c43aa1 100644 --- a/compiler/fir/resolve/testData/resolveWithStdlib/j+k/MyMap.txt +++ b/compiler/fir/resolve/testData/resolveWithStdlib/j+k/MyMap.txt @@ -28,7 +28,7 @@ FILE: test.kt ) lval otherResult: R|kotlin/String| = R|/map|.R|FakeOverride|(String(key), String(value)) lval anotherResult: R|kotlin/String?| = R|/map|.R|FakeOverride|(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| diff --git a/compiler/fir/resolve/testData/resolveWithStdlib/j+k/capturedFlexible.txt b/compiler/fir/resolve/testData/resolveWithStdlib/j+k/capturedFlexible.txt index ddb7d313c91..8feedf5b318 100644 --- a/compiler/fir/resolve/testData/resolveWithStdlib/j+k/capturedFlexible.txt +++ b/compiler/fir/resolve/testData/resolveWithStdlib/j+k/capturedFlexible.txt @@ -1,4 +1,4 @@ FILE: capturedFlexible.kt public final fun foo(z: R|java/util/zip/ZipFile|): R|kotlin/Unit| { - R|/z|.R|java/util/zip/ZipFile.entries|().R|kotlin/sequences/asSequence|() + R|/z|.R|java/util/zip/ZipFile.entries|().R|kotlin/sequences/asSequence|!)|>() } diff --git a/compiler/fir/resolve/testData/resolveWithStdlib/j+k/typeParameterUse.txt b/compiler/fir/resolve/testData/resolveWithStdlib/j+k/typeParameterUse.txt index e4f74861b68..ea985b1cc2e 100644 --- a/compiler/fir/resolve/testData/resolveWithStdlib/j+k/typeParameterUse.txt +++ b/compiler/fir/resolve/testData/resolveWithStdlib/j+k/typeParameterUse.txt @@ -1,4 +1,4 @@ FILE: useSite.kt public final fun foo(holder: R|U|, box: R|Box|): R|kotlin/Int| { - ^foo R|/holder|.R|/U.getValue|(R|/box|) + ^foo R|/holder|.R|/U.getValue|!|>(R|/box|) } diff --git a/compiler/fir/resolve/testData/resolveWithStdlib/typeAliasWithForEach.txt b/compiler/fir/resolve/testData/resolveWithStdlib/typeAliasWithForEach.txt index 57372045c04..bebd6f0d54f 100644 --- a/compiler/fir/resolve/testData/resolveWithStdlib/typeAliasWithForEach.txt +++ b/compiler/fir/resolve/testData/resolveWithStdlib/typeAliasWithForEach.txt @@ -10,7 +10,7 @@ FILE: typeAliasWithForEach.kt public final typealias Arguments = R|kotlin/collections/Map| 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| { + this@R|/deepCopy|.R|FakeOverride|( = forEach@fun (key: R|ft!|, value: R|ft!|): R|kotlin/Unit| { R|/result|.R|kotlin/collections/set|!|, R|ft!|>(R|/key|, R|/ArgsInfoImpl.ArgsInfoImpl|(R|/value|)) } ) diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java index 6dff802afdc..a8a18992ae5 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsTestGenerated.java @@ -1726,4 +1726,35 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest { } } } + + @TestMetadata("compiler/fir/resolve/testData/resolve/stdlib") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Stdlib extends AbstractFirDiagnosticsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInStdlib() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/stdlib"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @TestMetadata("compiler/fir/resolve/testData/resolve/stdlib/j+k") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class J_k extends AbstractFirDiagnosticsTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInJ_k() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/stdlib/j+k"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @TestMetadata("flexibleWildcard.kt") + public void testFlexibleWildcard() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/stdlib/j+k/flexibleWildcard.kt"); + } + } + } } diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java index fd54972989b..74038ed0400 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithLightTreeTestGenerated.java @@ -1726,4 +1726,35 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos } } } + + @TestMetadata("compiler/fir/resolve/testData/resolve/stdlib") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Stdlib extends AbstractFirDiagnosticsWithLightTreeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInStdlib() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/stdlib"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @TestMetadata("compiler/fir/resolve/testData/resolve/stdlib/j+k") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class J_k extends AbstractFirDiagnosticsWithLightTreeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInJ_k() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/stdlib/j+k"), Pattern.compile("^([^.]+)\\.kt$"), null, true); + } + + @TestMetadata("flexibleWildcard.kt") + public void testFlexibleWildcard() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/stdlib/j+k/flexibleWildcard.kt"); + } + } + } } diff --git a/compiler/testData/diagnostics/tests/j+k/wrongVarianceInJava.fir.kt b/compiler/testData/diagnostics/tests/j+k/wrongVarianceInJava.fir.kt index 9d6c3b79428..f9f04ca3148 100644 --- a/compiler/testData/diagnostics/tests/j+k/wrongVarianceInJava.fir.kt +++ b/compiler/testData/diagnostics/tests/j+k/wrongVarianceInJava.fir.kt @@ -20,5 +20,5 @@ class In { fun test() { A.foo().x() checkType { _() } - A.bar().y(null) + A.bar().y(null) } diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/array.fir.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/array.fir.kt index 6947757570d..59c87e88853 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/array.fir.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/array.fir.kt @@ -21,11 +21,11 @@ fun test() { val platformJ = J.staticJ platformNN[0] - platformN[0] + platformN[0] platformJ[0] platformNN[0] = 1 - platformN[0] = 1 + platformN[0] = 1 platformJ[0] = 1 } diff --git a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/primitiveArray.fir.kt b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/primitiveArray.fir.kt index 9821a82d704..2b30ddadf5d 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/primitiveArray.fir.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/nullabilityWarnings/primitiveArray.fir.kt @@ -21,11 +21,11 @@ fun test() { val platformJ = J.staticJ platformNN[0] - platformN[0] + platformN[0] platformJ[0] platformNN[0] = 1 - platformN[0] = 1 + platformN[0] = 1 platformJ[0] = 1 } diff --git a/compiler/testData/ir/irText/stubs/builtinMap.fir.txt b/compiler/testData/ir/irText/stubs/builtinMap.fir.txt index cb633236b0a..cad2915612e 100644 --- a/compiler/testData/ir/irText/stubs/builtinMap.fir.txt +++ b/compiler/testData/ir/irText/stubs/builtinMap.fir.txt @@ -16,19 +16,19 @@ FILE fqName: fileName:/builtinMap.kt pair: GET_VAR 'pair: kotlin.Pair.plus, V1 of .plus> declared in .plus' type=kotlin.Pair.plus, V1 of .plus> origin=null BRANCH if: CONST Boolean type=kotlin.Boolean value=true - then: CALL 'public final fun apply (block: kotlin.Function1): T of kotlin.apply [inline] declared in kotlin' type=java.util.LinkedHashMap.plus, V1 of .plus> origin=null - : java.util.LinkedHashMap.plus, V1 of .plus> - $receiver: CONSTRUCTOR_CALL 'public constructor (p0: kotlin.collections.Map, out V of >?) declared in java.util.LinkedHashMap' type=java.util.LinkedHashMap.plus, V1 of .plus> origin=null - : K1 of .plus - : V1 of .plus + then: CALL 'public final fun apply (block: kotlin.Function1): T of kotlin.apply [inline] declared in kotlin' type=java.util.LinkedHashMap.plus?, V1 of .plus?> origin=null + : java.util.LinkedHashMap.plus?, V1 of .plus?> + $receiver: CONSTRUCTOR_CALL 'public constructor (p0: kotlin.collections.Map?, out V of ?>?) declared in java.util.LinkedHashMap' type=java.util.LinkedHashMap.plus?, V1 of .plus?> origin=null + : K1 of .plus? + : V1 of .plus? p0: GET_VAR ': kotlin.collections.Map.plus, V1 of .plus> declared in .plus' type=kotlin.collections.Map.plus, V1 of .plus> origin=null - block: FUN_EXPR type=kotlin.Function1.plus, V1 of .plus>, kotlin.Unit> origin=LAMBDA - 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: FUN_EXPR type=kotlin.Function1.plus?, V1 of .plus?>, kotlin.Unit> origin=LAMBDA + 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 RETURN type=kotlin.Nothing from='local final fun (): kotlin.Unit declared in .plus' 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 + $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 p1: CALL 'public final fun (): V1 of .plus declared in kotlin.Pair' type=V1 of .plus origin=null diff --git a/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInDestructuringAssignment.fir.txt b/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInDestructuringAssignment.fir.txt index 1a833a74212..a7e0fc5fc77 100644 --- a/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInDestructuringAssignment.fir.txt +++ b/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInDestructuringAssignment.fir.txt @@ -130,57 +130,57 @@ FILE fqName: fileName:/enhancedNullabilityInDestructuringAssignment.kt y: GET_VAR 'val y: kotlin.Int [val] declared in .test1' type=kotlin.Int origin=null FUN name:test2 visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY - VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:.Q? [val] - CALL 'public open fun notNullComponents (): .Q? [operator] declared in .J' type=.Q? origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:.Q? [val] + CALL 'public open fun notNullComponents (): .Q? [operator] declared in .J' type=.Q? origin=null VAR name:x type:kotlin.String [val] CALL 'public final fun component1 (): kotlin.String [operator] declared in .Q' type=kotlin.String origin=null - $this: GET_VAR 'val tmp_1: .Q? [val] declared in .test2' type=.Q? origin=null - VAR name:y type:kotlin.String [val] - CALL 'public final fun component2 (): kotlin.String [operator] declared in .Q' type=kotlin.String origin=null - $this: GET_VAR 'val tmp_1: .Q? [val] declared in .test2' type=.Q? origin=null + $this: GET_VAR 'val tmp_1: .Q? [val] declared in .test2' type=.Q? origin=null + VAR name:y type:kotlin.String? [val] + CALL 'public final fun component2 (): kotlin.String? [operator] declared in .Q' type=kotlin.String? origin=null + $this: GET_VAR 'val tmp_1: .Q? [val] declared in .test2' type=.Q? origin=null CALL 'public final fun use (x: kotlin.Any, y: kotlin.Any): kotlin.Unit declared in ' type=kotlin.Unit origin=null x: GET_VAR 'val x: kotlin.String [val] declared in .test2' type=kotlin.String origin=null - y: GET_VAR 'val y: kotlin.String [val] declared in .test2' type=kotlin.String origin=null + y: GET_VAR 'val y: kotlin.String? [val] declared in .test2' type=kotlin.String? origin=null FUN name:test2Desugared visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY - VAR name:tmp type:.Q? [val] - CALL 'public open fun notNullComponents (): .Q? [operator] declared in .J' type=.Q? origin=null + VAR name:tmp type:.Q? [val] + CALL 'public open fun notNullComponents (): .Q? [operator] declared in .J' type=.Q? origin=null VAR name:x type:kotlin.String [val] CALL 'public final fun component1 (): kotlin.String [operator] declared in .Q' type=kotlin.String origin=null - $this: GET_VAR 'val tmp: .Q? [val] declared in .test2Desugared' type=.Q? origin=null - VAR name:y type:kotlin.String [val] - CALL 'public final fun component2 (): kotlin.String [operator] declared in .Q' type=kotlin.String origin=null - $this: GET_VAR 'val tmp: .Q? [val] declared in .test2Desugared' type=.Q? origin=null + $this: GET_VAR 'val tmp: .Q? [val] declared in .test2Desugared' type=.Q? origin=null + VAR name:y type:kotlin.String? [val] + CALL 'public final fun component2 (): kotlin.String? [operator] declared in .Q' type=kotlin.String? origin=null + $this: GET_VAR 'val tmp: .Q? [val] declared in .test2Desugared' type=.Q? origin=null CALL 'public final fun use (x: kotlin.Any, y: kotlin.Any): kotlin.Unit declared in ' type=kotlin.Unit origin=null x: GET_VAR 'val x: kotlin.String [val] declared in .test2Desugared' type=kotlin.String origin=null - y: GET_VAR 'val y: kotlin.String [val] declared in .test2Desugared' type=kotlin.String origin=null + y: GET_VAR 'val y: kotlin.String? [val] declared in .test2Desugared' type=kotlin.String? origin=null FUN name:test3 visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY - VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:.Q [val] - CALL 'public open fun notNullQAndComponents (): .Q [operator] declared in .J' type=.Q origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:.Q [val] + CALL 'public open fun notNullQAndComponents (): .Q [operator] declared in .J' type=.Q origin=null VAR name:x type:kotlin.String [val] CALL 'public final fun component1 (): kotlin.String [operator] declared in .Q' type=kotlin.String origin=null - $this: GET_VAR 'val tmp_2: .Q [val] declared in .test3' type=.Q origin=null - VAR name:y type:kotlin.String [val] - CALL 'public final fun component2 (): kotlin.String [operator] declared in .Q' type=kotlin.String origin=null - $this: GET_VAR 'val tmp_2: .Q [val] declared in .test3' type=.Q origin=null + $this: GET_VAR 'val tmp_2: .Q [val] declared in .test3' type=.Q origin=null + VAR name:y type:kotlin.String? [val] + CALL 'public final fun component2 (): kotlin.String? [operator] declared in .Q' type=kotlin.String? origin=null + $this: GET_VAR 'val tmp_2: .Q [val] declared in .test3' type=.Q origin=null CALL 'public final fun use (x: kotlin.Any, y: kotlin.Any): kotlin.Unit declared in ' type=kotlin.Unit origin=null x: GET_VAR 'val x: kotlin.String [val] declared in .test3' type=kotlin.String origin=null - y: GET_VAR 'val y: kotlin.String [val] declared in .test3' type=kotlin.String origin=null + y: GET_VAR 'val y: kotlin.String? [val] declared in .test3' type=kotlin.String? origin=null FUN name:test4 visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY - VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:kotlin.collections.IndexedValue<.P> [val] - CALL 'public final fun first (): T of kotlin.collections.first declared in kotlin.collections' type=kotlin.collections.IndexedValue<.P> origin=null - : kotlin.collections.IndexedValue<.P> - $receiver: CALL 'public final fun withIndex (): kotlin.collections.Iterable> declared in kotlin.collections' type=kotlin.collections.Iterable.P>> origin=null - : .P - $receiver: CALL 'public open fun listOfNotNull (): kotlin.collections.List<.P>? [operator] declared in .J' type=kotlin.collections.List<.P>? origin=null + VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:kotlin.collections.IndexedValue<.P?> [val] + CALL 'public final fun first (): T of kotlin.collections.first declared in kotlin.collections' type=kotlin.collections.IndexedValue<.P?> origin=null + : kotlin.collections.IndexedValue<.P?> + $receiver: CALL 'public final fun withIndex (): kotlin.collections.Iterable> declared in kotlin.collections' type=kotlin.collections.Iterable.P?>> origin=null + : .P? + $receiver: CALL 'public open fun listOfNotNull (): kotlin.collections.List<.P?>? [operator] declared in .J' type=kotlin.collections.List<.P?>? origin=null VAR name:x type:kotlin.Int [val] CALL 'public final fun component1 (): kotlin.Int [operator] declared in kotlin.collections.IndexedValue' type=kotlin.Int origin=null - $this: GET_VAR 'val tmp_3: kotlin.collections.IndexedValue<.P> [val] declared in .test4' type=kotlin.collections.IndexedValue<.P> origin=null - VAR name:y type:.P [val] - CALL 'public final fun component2 (): .P [operator] declared in kotlin.collections.IndexedValue' type=.P origin=null - $this: GET_VAR 'val tmp_3: kotlin.collections.IndexedValue<.P> [val] declared in .test4' type=kotlin.collections.IndexedValue<.P> origin=null + $this: GET_VAR 'val tmp_3: kotlin.collections.IndexedValue<.P?> [val] declared in .test4' type=kotlin.collections.IndexedValue<.P?> origin=null + VAR name:y type:.P? [val] + CALL 'public final fun component2 (): .P? [operator] declared in kotlin.collections.IndexedValue' type=.P? origin=null + $this: GET_VAR 'val tmp_3: kotlin.collections.IndexedValue<.P?> [val] declared in .test4' type=kotlin.collections.IndexedValue<.P?> origin=null CALL 'public final fun use (x: kotlin.Any, y: kotlin.Any): kotlin.Unit declared in ' type=kotlin.Unit origin=null x: GET_VAR 'val x: kotlin.Int [val] declared in .test4' type=kotlin.Int origin=null - y: GET_VAR 'val y: .P [val] declared in .test4' type=.P origin=null + y: GET_VAR 'val y: .P? [val] declared in .test4' type=.P? origin=null diff --git a/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInForLoop.fir.txt b/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInForLoop.fir.txt index a659b43cd10..7fb4282ed0d 100644 --- a/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInForLoop.fir.txt +++ b/compiler/testData/ir/irText/types/nullChecks/enhancedNullabilityInForLoop.fir.txt @@ -5,54 +5,54 @@ FILE fqName: fileName:/enhancedNullabilityInForLoop.kt FUN name:testForInListUnused visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY BLOCK type=kotlin.Unit origin=FOR_LOOP - VAR FOR_LOOP_ITERATOR name:tmp_0 type:kotlin.collections.MutableIterator<.P> [val] - CALL 'public abstract fun iterator (): kotlin.collections.MutableIterator<.P> [operator] declared in kotlin.collections.MutableCollection' type=kotlin.collections.MutableIterator<.P> origin=FOR_LOOP_ITERATOR - $this: CALL 'public open fun listOfNotNull (): kotlin.collections.List<.P>? [operator] declared in .J' type=kotlin.collections.List<.P>? origin=null + VAR FOR_LOOP_ITERATOR name:tmp_0 type:kotlin.collections.MutableIterator<.P?> [val] + CALL 'public abstract fun iterator (): kotlin.collections.MutableIterator<.P?> [operator] declared in kotlin.collections.MutableCollection' type=kotlin.collections.MutableIterator<.P?> origin=FOR_LOOP_ITERATOR + $this: CALL 'public open fun listOfNotNull (): kotlin.collections.List<.P?>? [operator] declared in .J' type=kotlin.collections.List<.P?>? origin=null WHILE label=null origin=FOR_LOOP_INNER_WHILE condition: CALL 'public abstract fun hasNext (): kotlin.Boolean [operator] declared in kotlin.collections.Iterator' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT - $this: GET_VAR 'val tmp_0: kotlin.collections.MutableIterator<.P> [val] declared in .testForInListUnused' type=kotlin.collections.MutableIterator<.P> origin=null + $this: GET_VAR 'val tmp_0: kotlin.collections.MutableIterator<.P?> [val] declared in .testForInListUnused' type=kotlin.collections.MutableIterator<.P?> origin=null body: BLOCK type=kotlin.Unit origin=FOR_LOOP_INNER_WHILE - VAR FOR_LOOP_VARIABLE name:x type:.P [val] - CALL 'public abstract fun next (): T of kotlin.collections.MutableIterator [operator] declared in kotlin.collections.Iterator' type=.P origin=FOR_LOOP_NEXT - $this: GET_VAR 'val tmp_0: kotlin.collections.MutableIterator<.P> [val] declared in .testForInListUnused' type=kotlin.collections.MutableIterator<.P> origin=null + VAR FOR_LOOP_VARIABLE name:x type:.P? [val] + CALL 'public abstract fun next (): T of kotlin.collections.MutableIterator [operator] declared in kotlin.collections.Iterator' type=.P? origin=FOR_LOOP_NEXT + $this: GET_VAR 'val tmp_0: kotlin.collections.MutableIterator<.P?> [val] declared in .testForInListUnused' type=kotlin.collections.MutableIterator<.P?> origin=null FUN name:testForInListDestructured visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY BLOCK type=kotlin.Unit origin=FOR_LOOP - VAR FOR_LOOP_ITERATOR name:tmp_1 type:kotlin.collections.MutableIterator<.P> [val] - CALL 'public abstract fun iterator (): kotlin.collections.MutableIterator<.P> [operator] declared in kotlin.collections.MutableCollection' type=kotlin.collections.MutableIterator<.P> origin=FOR_LOOP_ITERATOR - $this: CALL 'public open fun listOfNotNull (): kotlin.collections.List<.P>? [operator] declared in .J' type=kotlin.collections.List<.P>? origin=null + VAR FOR_LOOP_ITERATOR name:tmp_1 type:kotlin.collections.MutableIterator<.P?> [val] + CALL 'public abstract fun iterator (): kotlin.collections.MutableIterator<.P?> [operator] declared in kotlin.collections.MutableCollection' type=kotlin.collections.MutableIterator<.P?> origin=FOR_LOOP_ITERATOR + $this: CALL 'public open fun listOfNotNull (): kotlin.collections.List<.P?>? [operator] declared in .J' type=kotlin.collections.List<.P?>? origin=null WHILE label=null origin=FOR_LOOP_INNER_WHILE condition: CALL 'public abstract fun hasNext (): kotlin.Boolean [operator] declared in kotlin.collections.Iterator' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT - $this: GET_VAR 'val tmp_1: kotlin.collections.MutableIterator<.P> [val] declared in .testForInListDestructured' type=kotlin.collections.MutableIterator<.P> origin=null + $this: GET_VAR 'val tmp_1: kotlin.collections.MutableIterator<.P?> [val] declared in .testForInListDestructured' type=kotlin.collections.MutableIterator<.P?> origin=null body: BLOCK type=kotlin.Unit origin=FOR_LOOP_INNER_WHILE - VAR FOR_LOOP_VARIABLE name: type:.P [val] - CALL 'public abstract fun next (): T of kotlin.collections.MutableIterator [operator] declared in kotlin.collections.Iterator' type=.P origin=FOR_LOOP_NEXT - $this: GET_VAR 'val tmp_1: kotlin.collections.MutableIterator<.P> [val] declared in .testForInListDestructured' type=kotlin.collections.MutableIterator<.P> origin=null + VAR FOR_LOOP_VARIABLE name: type:.P? [val] + CALL 'public abstract fun next (): T of kotlin.collections.MutableIterator [operator] declared in kotlin.collections.Iterator' type=.P? origin=FOR_LOOP_NEXT + $this: GET_VAR 'val tmp_1: kotlin.collections.MutableIterator<.P?> [val] declared in .testForInListDestructured' type=kotlin.collections.MutableIterator<.P?> origin=null VAR name:x type:kotlin.Int [val] CALL 'public final fun component1 (): kotlin.Int declared in .P' type=kotlin.Int origin=null - $this: GET_VAR 'val : .P [val] declared in .testForInListDestructured' type=.P origin=null + $this: GET_VAR 'val : .P? [val] declared in .testForInListDestructured' type=.P? origin=null VAR name:y type:kotlin.Int [val] CALL 'public final fun component2 (): kotlin.Int declared in .P' type=kotlin.Int origin=null - $this: GET_VAR 'val : .P [val] declared in .testForInListDestructured' type=.P origin=null + $this: GET_VAR 'val : .P? [val] declared in .testForInListDestructured' type=.P? origin=null FUN name:testDesugaredForInList visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY - VAR name:iterator type:kotlin.collections.MutableIterator<.P> [val] - CALL 'public abstract fun iterator (): kotlin.collections.MutableIterator<.P> [operator] declared in kotlin.collections.MutableCollection' type=kotlin.collections.MutableIterator<.P> origin=null - $this: CALL 'public open fun listOfNotNull (): kotlin.collections.List<.P>? [operator] declared in .J' type=kotlin.collections.List<.P>? origin=null + VAR name:iterator type:kotlin.collections.MutableIterator<.P?> [val] + CALL 'public abstract fun iterator (): kotlin.collections.MutableIterator<.P?> [operator] declared in kotlin.collections.MutableCollection' type=kotlin.collections.MutableIterator<.P?> origin=null + $this: CALL 'public open fun listOfNotNull (): kotlin.collections.List<.P?>? [operator] declared in .J' type=kotlin.collections.List<.P?>? origin=null WHILE label=null origin=WHILE_LOOP condition: CALL 'public abstract fun hasNext (): kotlin.Boolean [operator] declared in kotlin.collections.Iterator' type=kotlin.Boolean origin=null - $this: GET_VAR 'val iterator: kotlin.collections.MutableIterator<.P> [val] declared in .testDesugaredForInList' type=kotlin.collections.MutableIterator<.P> origin=null + $this: GET_VAR 'val iterator: kotlin.collections.MutableIterator<.P?> [val] declared in .testDesugaredForInList' type=kotlin.collections.MutableIterator<.P?> origin=null body: BLOCK type=kotlin.Unit origin=WHILE_LOOP - VAR name:x type:.P [val] - CALL 'public abstract fun next (): T of kotlin.collections.MutableIterator [operator] declared in kotlin.collections.Iterator' type=.P origin=null - $this: GET_VAR 'val iterator: kotlin.collections.MutableIterator<.P> [val] declared in .testDesugaredForInList' type=kotlin.collections.MutableIterator<.P> origin=null + VAR name:x type:.P? [val] + CALL 'public abstract fun next (): T of kotlin.collections.MutableIterator [operator] declared in kotlin.collections.Iterator' type=.P? origin=null + $this: GET_VAR 'val iterator: kotlin.collections.MutableIterator<.P?> [val] declared in .testDesugaredForInList' type=kotlin.collections.MutableIterator<.P?> origin=null FUN name:testForInArrayUnused visibility:public modality:FINAL <> (j:.J) returnType:kotlin.Unit VALUE_PARAMETER name:j index:0 type:.J BLOCK_BODY BLOCK type=kotlin.Unit origin=FOR_LOOP VAR FOR_LOOP_ITERATOR name:tmp_2 type:kotlin.collections.Iterator<.P?> [val] CALL 'public final fun iterator (): kotlin.collections.Iterator<.P?> [operator] declared in kotlin.Array' type=kotlin.collections.Iterator<.P?> origin=null - $this: CALL 'public open fun arrayOfNotNull (): kotlin.Array.P?>? [operator] declared in .J' type=kotlin.Array.P?>? origin=null + $this: CALL 'public open fun arrayOfNotNull (): kotlin.Array.P?> [operator] declared in .J' type=kotlin.Array.P?> origin=null $this: GET_VAR 'j: .J declared in .testForInArrayUnused' type=.J origin=null WHILE label=null origin=FOR_LOOP_INNER_WHILE condition: CALL 'public abstract fun hasNext (): kotlin.Boolean [operator] declared in kotlin.collections.Iterator' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT @@ -64,27 +64,27 @@ FILE fqName: fileName:/enhancedNullabilityInForLoop.kt FUN name:testForInListUse visibility:public modality:FINAL <> () returnType:kotlin.Unit BLOCK_BODY BLOCK type=kotlin.Unit origin=FOR_LOOP - VAR FOR_LOOP_ITERATOR name:tmp_3 type:kotlin.collections.MutableIterator<.P> [val] - CALL 'public abstract fun iterator (): kotlin.collections.MutableIterator<.P> [operator] declared in kotlin.collections.MutableCollection' type=kotlin.collections.MutableIterator<.P> origin=FOR_LOOP_ITERATOR - $this: CALL 'public open fun listOfNotNull (): kotlin.collections.List<.P>? [operator] declared in .J' type=kotlin.collections.List<.P>? origin=null + VAR FOR_LOOP_ITERATOR name:tmp_3 type:kotlin.collections.MutableIterator<.P?> [val] + CALL 'public abstract fun iterator (): kotlin.collections.MutableIterator<.P?> [operator] declared in kotlin.collections.MutableCollection' type=kotlin.collections.MutableIterator<.P?> origin=FOR_LOOP_ITERATOR + $this: CALL 'public open fun listOfNotNull (): kotlin.collections.List<.P?>? [operator] declared in .J' type=kotlin.collections.List<.P?>? origin=null WHILE label=null origin=FOR_LOOP_INNER_WHILE condition: CALL 'public abstract fun hasNext (): kotlin.Boolean [operator] declared in kotlin.collections.Iterator' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT - $this: GET_VAR 'val tmp_3: kotlin.collections.MutableIterator<.P> [val] declared in .testForInListUse' type=kotlin.collections.MutableIterator<.P> origin=null + $this: GET_VAR 'val tmp_3: kotlin.collections.MutableIterator<.P?> [val] declared in .testForInListUse' type=kotlin.collections.MutableIterator<.P?> origin=null body: BLOCK type=kotlin.Unit origin=FOR_LOOP_INNER_WHILE - VAR FOR_LOOP_VARIABLE name:x type:.P [val] - CALL 'public abstract fun next (): T of kotlin.collections.MutableIterator [operator] declared in kotlin.collections.Iterator' type=.P origin=FOR_LOOP_NEXT - $this: GET_VAR 'val tmp_3: kotlin.collections.MutableIterator<.P> [val] declared in .testForInListUse' type=kotlin.collections.MutableIterator<.P> origin=null + VAR FOR_LOOP_VARIABLE name:x type:.P? [val] + CALL 'public abstract fun next (): T of kotlin.collections.MutableIterator [operator] declared in kotlin.collections.Iterator' type=.P? origin=FOR_LOOP_NEXT + $this: GET_VAR 'val tmp_3: kotlin.collections.MutableIterator<.P?> [val] declared in .testForInListUse' type=kotlin.collections.MutableIterator<.P?> origin=null CALL 'public final fun use (s: .P): kotlin.Unit declared in ' type=kotlin.Unit origin=null - s: GET_VAR 'val x: .P [val] declared in .testForInListUse' type=.P origin=null + s: GET_VAR 'val x: .P? [val] declared in .testForInListUse' type=.P? origin=null CALL 'public open fun use (s: .P): kotlin.Unit [operator] declared in .J' type=kotlin.Unit origin=null - s: GET_VAR 'val x: .P [val] declared in .testForInListUse' type=.P origin=null + s: GET_VAR 'val x: .P? [val] declared in .testForInListUse' type=.P? origin=null FUN name:testForInArrayUse visibility:public modality:FINAL <> (j:.J) returnType:kotlin.Unit VALUE_PARAMETER name:j index:0 type:.J BLOCK_BODY BLOCK type=kotlin.Unit origin=FOR_LOOP VAR FOR_LOOP_ITERATOR name:tmp_4 type:kotlin.collections.Iterator<.P?> [val] CALL 'public final fun iterator (): kotlin.collections.Iterator<.P?> [operator] declared in kotlin.Array' type=kotlin.collections.Iterator<.P?> origin=null - $this: CALL 'public open fun arrayOfNotNull (): kotlin.Array.P?>? [operator] declared in .J' type=kotlin.Array.P?>? origin=null + $this: CALL 'public open fun arrayOfNotNull (): kotlin.Array.P?> [operator] declared in .J' type=kotlin.Array.P?> origin=null $this: GET_VAR 'j: .J declared in .testForInArrayUse' type=.J origin=null WHILE label=null origin=FOR_LOOP_INNER_WHILE condition: CALL 'public abstract fun hasNext (): kotlin.Boolean [operator] declared in kotlin.collections.Iterator' type=kotlin.Boolean origin=FOR_LOOP_HAS_NEXT diff --git a/compiler/testData/loadJava/compiledJava/ClassWithTypePRefNext.fir.txt b/compiler/testData/loadJava/compiledJava/ClassWithTypePRefNext.fir.txt index dce3f8b3100..14a0ca28f25 100644 --- a/compiler/testData/loadJava/compiledJava/ClassWithTypePRefNext.fir.txt +++ b/compiler/testData/loadJava/compiledJava/ClassWithTypePRefNext.fir.txt @@ -1,4 +1,4 @@ -public open class ClassWithTypePRefNext, kotlin/collections/MutableIterable

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

?>!|, P>(): R|test/ClassWithTypePRefNext| +public open class ClassWithTypePRefNext!>, kotlin/collections/Iterable!>?>!|, P> : R|kotlin/Any| { + public constructor!>, kotlin/collections/Iterable!>?>!|, P>(): R|test/ClassWithTypePRefNext| } diff --git a/compiler/testData/loadJava/compiledJava/ClassWithTypePRefSelf.fir.txt b/compiler/testData/loadJava/compiledJava/ClassWithTypePRefSelf.fir.txt index ecf087ad28d..a39791bd955 100644 --- a/compiler/testData/loadJava/compiledJava/ClassWithTypePRefSelf.fir.txt +++ b/compiler/testData/loadJava/compiledJava/ClassWithTypePRefSelf.fir.txt @@ -1,4 +1,4 @@ -public final class ClassWithTypePRefSelf

, kotlin/Enum

?>!|> : R|kotlin/Any| { - public constructor

, kotlin/Enum

?>!|>(): R|test/ClassWithTypePRefSelf

| +public final class ClassWithTypePRefSelf

!>, kotlin/Enum!>?>!|> : R|kotlin/Any| { + public constructor

!>, kotlin/Enum!>?>!|>(): R|test/ClassWithTypePRefSelf

| } diff --git a/compiler/testData/loadJava/compiledJava/ClassWithTypePRefSelfAndClass.fir.txt b/compiler/testData/loadJava/compiledJava/ClassWithTypePRefSelfAndClass.fir.txt index 3bceb76953f..b0cbb2e56a2 100644 --- a/compiler/testData/loadJava/compiledJava/ClassWithTypePRefSelfAndClass.fir.txt +++ b/compiler/testData/loadJava/compiledJava/ClassWithTypePRefSelfAndClass.fir.txt @@ -1,4 +1,4 @@ -public final class ClassWithTypePRefSelfAndClass

, test/ClassWithTypePRefSelfAndClass

?>!|> : R|kotlin/Any| { - public constructor

, test/ClassWithTypePRefSelfAndClass

?>!|>(): R|test/ClassWithTypePRefSelfAndClass

| +public final class ClassWithTypePRefSelfAndClass

!>, test/ClassWithTypePRefSelfAndClass!>?>!|> : R|kotlin/Any| { + public constructor

!>, test/ClassWithTypePRefSelfAndClass!>?>!|>(): R|test/ClassWithTypePRefSelfAndClass

| } diff --git a/compiler/testData/loadJava/compiledJava/RemoveRedundantProjectionKind.fir.txt b/compiler/testData/loadJava/compiledJava/RemoveRedundantProjectionKind.fir.txt index c83477aa9de..a4202ae9e70 100644 --- a/compiler/testData/loadJava/compiledJava/RemoveRedundantProjectionKind.fir.txt +++ b/compiler/testData/loadJava/compiledJava/RemoveRedundantProjectionKind.fir.txt @@ -1,6 +1,6 @@ public abstract interface RemoveRedundantProjectionKind : R|kotlin/Any| { - public abstract operator fun f(collection: R|ft, kotlin/collections/Collection?>!|): R|kotlin/Unit| + public abstract operator fun f(collection: R|ft!>, kotlin/collections/Collection!>?>!|): R|kotlin/Unit| - public abstract operator fun f(comparator: R|ft, kotlin/Comparable?>!|): R|kotlin/Unit| + public abstract operator fun f(comparator: R|ft!>, kotlin/Comparable!>?>!|): R|kotlin/Unit| } diff --git a/compiler/testData/loadJava/compiledJava/WildcardBounds.fir.txt b/compiler/testData/loadJava/compiledJava/WildcardBounds.fir.txt index a9d9eff9a71..954eeb1d56a 100644 --- a/compiler/testData/loadJava/compiledJava/WildcardBounds.fir.txt +++ b/compiler/testData/loadJava/compiledJava/WildcardBounds.fir.txt @@ -1,5 +1,5 @@ public open class WildcardBounds : R|kotlin/Any| { - public/*package*/ open operator fun foo(x: R|ft, test/WildcardBounds.A?>!|, y: R|ft, test/WildcardBounds.A?>!|): R|kotlin/Unit| + public/*package*/ open operator fun foo(x: R|ft!>, test/WildcardBounds.A!>?>!|, y: R|ft!>, test/WildcardBounds.A!>?>!|): R|kotlin/Unit| public constructor(): R|test/WildcardBounds| diff --git a/compiler/testData/loadJava/compiledJava/kotlinSignature/MethodWithMappedClasses.fir.txt b/compiler/testData/loadJava/compiledJava/kotlinSignature/MethodWithMappedClasses.fir.txt index 52571fcf562..f5c6f5224d8 100644 --- a/compiler/testData/loadJava/compiledJava/kotlinSignature/MethodWithMappedClasses.fir.txt +++ b/compiler/testData/loadJava/compiledJava/kotlinSignature/MethodWithMappedClasses.fir.txt @@ -1,7 +1,7 @@ public open class MethodWithMappedClasses : R|kotlin/Any| { - public open operator fun copy(dest: R|ft, kotlin/collections/List?>!|, src: R|ft!>, kotlin/collections/List!>?>!|): R|kotlin/Unit| + public open operator fun copy(dest: R|ft!>, kotlin/collections/List!>?>!|, src: R|ft!>, kotlin/collections/List!>?>!|): R|kotlin/Unit| - public open operator fun copyMap(dest: R|ft!, in T>, kotlin/collections/Map!, in T>?>!|, src: R|ft!, ft!>, kotlin/collections/Map!, ft!>?>!|): R|kotlin/Unit| + public open operator fun copyMap(dest: R|ft!, in ft!>, kotlin/collections/Map!, in ft!>?>!|, src: R|ft!, ft!>, kotlin/collections/Map!, ft!>?>!|): R|kotlin/Unit| public constructor(): R|test/MethodWithMappedClasses| diff --git a/compiler/testData/loadJava/compiledJava/kotlinSignature/MethodWithTypeParameters.fir.txt b/compiler/testData/loadJava/compiledJava/kotlinSignature/MethodWithTypeParameters.fir.txt index e61ae453517..0e1bf41bbe7 100644 --- a/compiler/testData/loadJava/compiledJava/kotlinSignature/MethodWithTypeParameters.fir.txt +++ b/compiler/testData/loadJava/compiledJava/kotlinSignature/MethodWithTypeParameters.fir.txt @@ -1,5 +1,5 @@ public open class MethodWithTypeParameters : R|kotlin/Any| { - public open operator fun !|, R|ft, kotlin/collections/MutableList?>!|> foo(a: R|ft!|, b: R|ft, kotlin/collections/List?>!|, list: R|ft, kotlin/collections/List?>!|): R|kotlin/Unit| + public open operator fun !|, R|ft!>, kotlin/collections/List!>?>!|> foo(a: R|ft!|, b: R|ft!>, kotlin/collections/List!>?>!|, list: R|ft!>, kotlin/collections/List!>?>!|): R|kotlin/Unit| public constructor(): R|test/MethodWithTypeParameters| diff --git a/compiler/testData/loadJava/compiledJava/kotlinSignature/PropertyArrayTypes.fir.txt b/compiler/testData/loadJava/compiledJava/kotlinSignature/PropertyArrayTypes.fir.txt index 45d98a11b3a..3a33b325092 100644 --- a/compiler/testData/loadJava/compiledJava/kotlinSignature/PropertyArrayTypes.fir.txt +++ b/compiler/testData/loadJava/compiledJava/kotlinSignature/PropertyArrayTypes.fir.txt @@ -1,5 +1,5 @@ public open class PropertyArrayTypes : R|kotlin/Any| { - public open field arrayOfArrays: R|ft!>, kotlin/Array!>?>!>, kotlin/Array!>, kotlin/Array!>?>!>?>!| + public open field arrayOfArrays: R|ft!>, kotlin/Array!>?>!>, kotlin/Array!>, kotlin/Array!>?>!>?>!| public open field array: R|ft!>, kotlin/Array!>?>!| diff --git a/compiler/testData/loadJava/compiledJava/kotlinSignature/error/WrongTypeParameterBoundStructure1.fir.txt b/compiler/testData/loadJava/compiledJava/kotlinSignature/error/WrongTypeParameterBoundStructure1.fir.txt index 9eef640f07a..b2ca818e7bb 100644 --- a/compiler/testData/loadJava/compiledJava/kotlinSignature/error/WrongTypeParameterBoundStructure1.fir.txt +++ b/compiler/testData/loadJava/compiledJava/kotlinSignature/error/WrongTypeParameterBoundStructure1.fir.txt @@ -1,5 +1,5 @@ public open class WrongTypeParameterBoundStructure1 : R|kotlin/Any| { - public open operator fun !|, R|ft, kotlin/collections/MutableList?>!|> foo(a: R|ft!|, b: R|ft, kotlin/collections/List?>!|): R|kotlin/Unit| + public open operator fun !|, R|ft!>, kotlin/collections/List!>?>!|> foo(a: R|ft!|, b: R|ft!>, kotlin/collections/List!>?>!|): R|kotlin/Unit| public constructor(): R|test/WrongTypeParameterBoundStructure1| diff --git a/compiler/testData/loadJava/compiledJava/library/Max.fir.txt b/compiler/testData/loadJava/compiledJava/library/Max.fir.txt index bdcecbba93b..ff87bb6a815 100644 --- a/compiler/testData/loadJava/compiledJava/library/Max.fir.txt +++ b/compiler/testData/loadJava/compiledJava/library/Max.fir.txt @@ -1,5 +1,5 @@ public open class Max : R|kotlin/Any| { - public open operator fun !|, R|ft, kotlin/Comparable?>!|> max(coll: R|ft, kotlin/collections/Collection?>!|): R|ft!| + public open operator fun !|, R|ft!>, kotlin/Comparable!>?>!|> max(coll: R|ft!>, kotlin/collections/Collection!>?>!|): R|ft!| public constructor(): R|test/Max| diff --git a/compiler/testData/loadJava/compiledJava/mutability/ReadOnlyExtendsWildcard.fir.txt b/compiler/testData/loadJava/compiledJava/mutability/ReadOnlyExtendsWildcard.fir.txt index 9f3748c0878..34d2f3850e3 100644 --- a/compiler/testData/loadJava/compiledJava/mutability/ReadOnlyExtendsWildcard.fir.txt +++ b/compiler/testData/loadJava/compiledJava/mutability/ReadOnlyExtendsWildcard.fir.txt @@ -1,6 +1,6 @@ public abstract interface ReadOnlyExtendsWildcard : R|kotlin/Any| { public abstract operator fun bar(): R|kotlin/Unit| - public abstract operator fun foo(@R|kotlin/annotations/jvm/ReadOnly|() x: R|ft, kotlin/collections/List?>!|, @R|org/jetbrains/annotations/NotNull|() y: R|kotlin/Comparable|): R|kotlin/Unit| + public abstract operator fun foo(@R|kotlin/annotations/jvm/ReadOnly|() x: R|ft!>, kotlin/collections/List!>?>!|, @R|org/jetbrains/annotations/NotNull|() y: R|kotlin/Comparable!>|): R|kotlin/Unit| } diff --git a/compiler/testData/loadJava/compiledJava/notNull/NotNullIntArray.fir.txt b/compiler/testData/loadJava/compiledJava/notNull/NotNullIntArray.fir.txt index f8266ca439c..c2f8d6feb27 100644 --- a/compiler/testData/loadJava/compiledJava/notNull/NotNullIntArray.fir.txt +++ b/compiler/testData/loadJava/compiledJava/notNull/NotNullIntArray.fir.txt @@ -1,5 +1,5 @@ public open class NotNullIntArray : R|kotlin/Any| { - @R|org/jetbrains/annotations/NotNull|() public open operator fun hi(): R|ft!| + @R|org/jetbrains/annotations/NotNull|() public open operator fun hi(): R|kotlin/IntArray| public constructor(): R|test/NotNullIntArray| diff --git a/compiler/testData/loadJava/compiledJava/notNull/NotNullObjectArray.fir.txt b/compiler/testData/loadJava/compiledJava/notNull/NotNullObjectArray.fir.txt index bb637000cf0..505b6d0cc28 100644 --- a/compiler/testData/loadJava/compiledJava/notNull/NotNullObjectArray.fir.txt +++ b/compiler/testData/loadJava/compiledJava/notNull/NotNullObjectArray.fir.txt @@ -1,5 +1,5 @@ public open class NotNullObjectArray : R|kotlin/Any| { - @R|org/jetbrains/annotations/NotNull|() public open operator fun hi(): R|ft!>, kotlin/Array!>?>!| + @R|org/jetbrains/annotations/NotNull|() public open operator fun hi(): R|ft!>, kotlin/Array!>>| public constructor(): R|test/NotNullObjectArray| diff --git a/compiler/testData/loadJava/compiledJava/sam/GenericInterfaceParameterWithSelfBound.fir.txt b/compiler/testData/loadJava/compiledJava/sam/GenericInterfaceParameterWithSelfBound.fir.txt index 41565ef837d..a648ded85e0 100644 --- a/compiler/testData/loadJava/compiledJava/sam/GenericInterfaceParameterWithSelfBound.fir.txt +++ b/compiler/testData/loadJava/compiledJava/sam/GenericInterfaceParameterWithSelfBound.fir.txt @@ -1,4 +1,4 @@ -public abstract interface GenericInterfaceParameterWithSelfBound, test/GenericInterfaceParameterWithSelfBound?>!|> : R|kotlin/Any| { +public abstract interface GenericInterfaceParameterWithSelfBound!>, test/GenericInterfaceParameterWithSelfBound!>?>!|> : R|kotlin/Any| { public abstract operator fun method(t: R|ft!|): R|ft!| } diff --git a/compiler/testData/loadJava/compiledJava/sam/GenericInterfaceParametersWithBounds.fir.txt b/compiler/testData/loadJava/compiledJava/sam/GenericInterfaceParametersWithBounds.fir.txt index a5b5a46b8d6..81b758a2322 100644 --- a/compiler/testData/loadJava/compiledJava/sam/GenericInterfaceParametersWithBounds.fir.txt +++ b/compiler/testData/loadJava/compiledJava/sam/GenericInterfaceParametersWithBounds.fir.txt @@ -1,4 +1,4 @@ -public abstract interface GenericInterfaceParametersWithBounds, kotlin/Comparable?>!|, R|ft!|, B : R|ft, kotlin/collections/MutableList?>!|> : R|kotlin/Any| { +public abstract interface GenericInterfaceParametersWithBounds!>, kotlin/Comparable!>?>!|, R|ft!|, B : R|ft!>, kotlin/collections/List!>?>!|> : R|kotlin/Any| { public abstract operator fun method(a: R|ft!>, kotlin/Array!>?>!|, b: R|ft!|): R|kotlin/Unit| } diff --git a/compiler/testData/loadJava/compiledJava/sam/GenericMethodParameters.fir.txt b/compiler/testData/loadJava/compiledJava/sam/GenericMethodParameters.fir.txt index ab6629ac72d..657edbfaf2d 100644 --- a/compiler/testData/loadJava/compiledJava/sam/GenericMethodParameters.fir.txt +++ b/compiler/testData/loadJava/compiledJava/sam/GenericMethodParameters.fir.txt @@ -1,4 +1,4 @@ public abstract interface GenericMethodParameters : R|kotlin/Any| { - public abstract operator fun !|, B : R|ft, kotlin/collections/MutableList?>!|> method(a: R|ft!>, kotlin/Array!>?>!|, b: R|ft!|): R|kotlin/Unit| + public abstract operator fun !|, B : R|ft!>, kotlin/collections/List!>?>!|> method(a: R|ft!>, kotlin/Array!>?>!|, b: R|ft!|): R|kotlin/Unit| } diff --git a/compiler/testData/loadJava/compiledJava/sam/adapters/NonTrivialFunctionType.fir.txt b/compiler/testData/loadJava/compiledJava/sam/adapters/NonTrivialFunctionType.fir.txt index 3edf860cc5a..7bfb33d66ed 100644 --- a/compiler/testData/loadJava/compiledJava/sam/adapters/NonTrivialFunctionType.fir.txt +++ b/compiler/testData/loadJava/compiledJava/sam/adapters/NonTrivialFunctionType.fir.txt @@ -5,7 +5,7 @@ public open class NonTrivialFunctionType : R|kotlin/Any| { public open operator fun wildcardUnbound(comparator: R|ft, java/util/Comparator<*>?>!|): R|kotlin/Unit| - public open operator fun wildcardBound(comparator: R|ft, java/util/Comparator?>!|): R|kotlin/Unit| + public open operator fun wildcardBound(comparator: R|ft!>, java/util/Comparator!>?>!|): R|kotlin/Unit| public constructor(): R|test/NonTrivialFunctionType| diff --git a/compiler/testData/loadJava/compiledJava/sam/adapters/TypeParameterOfMethod.fir.txt b/compiler/testData/loadJava/compiledJava/sam/adapters/TypeParameterOfMethod.fir.txt index f68fb29544b..ae77d4b9651 100644 --- a/compiler/testData/loadJava/compiledJava/sam/adapters/TypeParameterOfMethod.fir.txt +++ b/compiler/testData/loadJava/compiledJava/sam/adapters/TypeParameterOfMethod.fir.txt @@ -3,7 +3,7 @@ public open class TypeParameterOfMethod : R|kotlin/Any| { public open static operator fun !|> max2(comparator: R|ft!>, java/util/Comparator!>?>!|, value1: R|ft!|, value2: R|ft!|): R|ft!| - public open static operator fun !|, B : R|ft, kotlin/collections/MutableList?>!|> method(a: R|ft!>, java/util/Comparator!>?>!|, b: R|ft!|): R|kotlin/Unit| + public open static operator fun !|, B : R|ft!>, kotlin/collections/List!>?>!|> method(a: R|ft!>, java/util/Comparator!>?>!|, b: R|ft!|): R|kotlin/Unit| public constructor(): R|test/TypeParameterOfMethod|