diff --git a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/ConeTypes.kt b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/ConeTypes.kt index 3a343d8152e..8c6dab67a1d 100644 --- a/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/ConeTypes.kt +++ b/compiler/fir/cones/src/org/jetbrains/kotlin/fir/types/ConeTypes.kt @@ -173,18 +173,13 @@ data class ConeTypeVariableType( override val typeArguments: Array get() = emptyArray() } -class ConeDefinitelyNotNullType private constructor(val original: ConeKotlinType) : ConeSimpleKotlinType(), DefinitelyNotNullTypeMarker { +data class ConeDefinitelyNotNullType(val original: ConeKotlinType) : ConeSimpleKotlinType(), DefinitelyNotNullTypeMarker { override val typeArguments: Array get() = original.typeArguments override val nullability: ConeNullability get() = ConeNullability.NOT_NULL - companion object { - fun create(original: ConeKotlinType): ConeDefinitelyNotNullType { - if (original is ConeFlexibleType) return create(original.lowerBound) - return ConeDefinitelyNotNullType(original) - } - } + companion object } class ConeRawType(lowerBound: ConeKotlinType, upperBound: ConeKotlinType) : ConeFlexibleType(lowerBound, upperBound), RawTypeMarker 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 7509b5afff3..77204bcbd3b 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 @@ -138,7 +138,7 @@ private fun coneFlexibleOrSimpleType( type is ConeTypeParameterType || type.isNullable } ) { - return ConeDefinitelyNotNullType.create(lowerBound) + return ConeDefinitelyNotNullType.create(lowerBound) ?: lowerBound } } return lowerBound 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 6e3b1c56484..63e361303e9 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 @@ -269,7 +269,7 @@ fun T.withArguments(arguments: Array this is ConeClassLikeTypeImpl -> ConeClassLikeTypeImpl(lookupTag, arguments, nullability.isNullable) as T - is ConeDefinitelyNotNullType -> ConeDefinitelyNotNullType.create(original.withArguments(arguments)) as T + is ConeDefinitelyNotNullType -> ConeDefinitelyNotNullType.create(original.withArguments(arguments))!! as T else -> error("Not supported: $this: ${this.render()}") } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ConeInferenceContext.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ConeInferenceContext.kt index f66f57e5717..11df93630e8 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ConeInferenceContext.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ConeInferenceContext.kt @@ -12,7 +12,6 @@ import org.jetbrains.kotlin.fir.symbols.StandardClassIds import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirClassifierSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol -import org.jetbrains.kotlin.fir.symbols.invoke import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl @@ -144,8 +143,8 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo } - if (this is DefinitelyNotNullTypeMarker - && this.original().containsInternal(predicate, visited) + if (this is ConeDefinitelyNotNullType + && this.original.containsInternal(predicate, visited) ) { return true } @@ -198,11 +197,18 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo } override fun KotlinTypeMarker.makeDefinitelyNotNullOrNotNull(): KotlinTypeMarker { - return this.withNullability(false) //TODO("not implemented") + require(this is ConeKotlinType) + return makeDefinitelyNotNullOrNotNull() } override fun SimpleTypeMarker.makeSimpleTypeDefinitelyNotNullOrNotNull(): SimpleTypeMarker { - return this.withNullability(false) //TODO("not implemented") + require(this is ConeKotlinType) + return makeDefinitelyNotNullOrNotNull() as SimpleTypeMarker + } + + private fun ConeKotlinType.makeDefinitelyNotNullOrNotNull(): ConeKotlinType { + // TODO: add intersection types, see fun SimpleType.makeSimpleTypeDefinitelyNotNullOrNotNull() in SpecialTypes.kt + return ConeDefinitelyNotNullType.create(this) ?: this.withNullability(false) as ConeKotlinType } override fun createCapturedType( @@ -273,7 +279,7 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo TypeSubstitutorMarker { override fun substituteType(type: ConeKotlinType): ConeKotlinType? { val new = map[type.typeConstructor()] ?: return null - return makeNullableIfNeed(type.isMarkedNullable, (new as ConeKotlinType).approximateIntegerLiteralType()) + return (new as ConeKotlinType).approximateIntegerLiteralType().updateNullabilityIfNeeded(type) } } } @@ -298,7 +304,6 @@ interface ConeInferenceContext : TypeSystemInferenceExtensionContext, ConeTypeCo return type } - override fun createErrorTypeWithCustomConstructor(debugName: String, constructor: TypeConstructorMarker): KotlinTypeMarker { return ConeKotlinErrorType("$debugName c: $constructor") } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/substitution/Substitutors.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/substitution/Substitutors.kt index 47520ade2e3..97fed82b9c7 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/substitution/Substitutors.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/substitution/Substitutors.kt @@ -28,9 +28,12 @@ abstract class AbstractConeSubstitutor : ConeSubstitutor() { return wrapProjection(projection, newType) } - fun makeNullableIfNeed(isNullable: Boolean, type: ConeKotlinType?): ConeKotlinType? { - if (!isNullable) return type - return type?.withNullability(ConeNullability.NULLABLE) + fun ConeKotlinType?.updateNullabilityIfNeeded(originalType: ConeKotlinType): ConeKotlinType? { + return when { + originalType is ConeDefinitelyNotNullType -> this?.withNullability(ConeNullability.NOT_NULL) + originalType.isMarkedNullable -> this?.withNullability(ConeNullability.NULLABLE) + else -> this + } } override fun substituteOrNull(type: ConeKotlinType): ConeKotlinType? { @@ -65,8 +68,9 @@ abstract class AbstractConeSubstitutor : ConeSubstitutor() { return ConeIntersectionType(substitutedTypes) } - private fun ConeDefinitelyNotNullType.substituteOriginal(): ConeDefinitelyNotNullType? { - return ConeDefinitelyNotNullType.create(substituteOrNull(original)?.withNullability(ConeNullability.NOT_NULL) ?: original) + private fun ConeDefinitelyNotNullType.substituteOriginal(): ConeKotlinType? { + val substituted = substituteOrNull(original)?.withNullability(ConeNullability.NOT_NULL) ?: return null + return ConeDefinitelyNotNullType.create(substituted) ?: substituted } private fun ConeFlexibleType.substituteBounds(): ConeFlexibleType? { @@ -128,6 +132,6 @@ data class ChainedSubstitutor(private val first: ConeSubstitutor, private val se data class ConeSubstitutorByMap(val substitution: Map) : AbstractConeSubstitutor() { override fun substituteType(type: ConeKotlinType): ConeKotlinType? { if (type !is ConeTypeParameterType) return null - return makeNullableIfNeed(type.isMarkedNullable, substitution[type.lookupTag.symbol]) + return substitution[type.lookupTag.symbol].updateNullabilityIfNeeded(type) } } diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassSubstitutionScope.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassSubstitutionScope.kt index 1a80f88911b..600a62b4818 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassSubstitutionScope.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/scopes/impl/FirClassSubstitutionScope.kt @@ -227,6 +227,7 @@ class FirClassSubstitutionScope( baseFunction.status, fakeOverrideSymbol ).apply { + annotations += baseFunction.annotations resolvePhase = baseFunction.resolvePhase valueParameters += baseFunction.valueParameters.zip( newParameterTypes ?: List(baseFunction.valueParameters.size) { null } @@ -296,6 +297,7 @@ class FirClassSubstitutionScope( baseProperty.status ).apply { resolvePhase = baseProperty.resolvePhase + annotations += baseProperty.annotations } } return symbol @@ -315,6 +317,7 @@ class FirClassSubstitutionScope( name, symbol, isVar, baseField.status ).apply { resolvePhase = baseField.resolvePhase + annotations += baseField.annotations } } return symbol 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 6c009256553..d391f207244 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 @@ -38,3 +38,19 @@ fun ConeInferenceContext.intersectTypesOrNull(types: List): Cone else -> ConeTypeIntersector.intersectTypes(this, types) } } + +fun ConeDefinitelyNotNullType.Companion.create(original: ConeKotlinType): ConeDefinitelyNotNullType? { + return when { + original is ConeDefinitelyNotNullType -> original + makesSenseToBeDefinitelyNotNull(original) -> ConeDefinitelyNotNullType(original.lowerBoundIfFlexible()) + else -> null + } +} + +fun makesSenseToBeDefinitelyNotNull(type: ConeKotlinType): Boolean = + type.canHaveUndefinedNullability() // TODO: also check nullability + +fun ConeKotlinType.canHaveUndefinedNullability(): Boolean = + this is ConeTypeVariableType || + this is ConeTypeParameterType || + this is ConeCapturedType diff --git a/compiler/fir/resolve/testData/resolve/expresssions/genericDiagnostic.txt b/compiler/fir/resolve/testData/resolve/expresssions/genericDiagnostic.txt index 04ac6b0e6a4..2d125c19844 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/genericDiagnostic.txt +++ b/compiler/fir/resolve/testData/resolve/expresssions/genericDiagnostic.txt @@ -6,7 +6,7 @@ FILE: test.kt } public final fun create(d: R|Diagnostic|): R|kotlin/Unit| { - lval element: R|DerivedElement!!| = R|/d|.R|/Diagnostic.element| + lval element: R|DerivedElement| = R|/d|.R|/Diagnostic.element| R|/Fix.Fix|(R|/element|) } public final fun createGeneric(d: R|Diagnostic|): R|kotlin/Unit| { @@ -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 element: R|DerivedElement!!| = R|/casted|.R|/Diagnostic.element| + 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/arrayFilterCapturedType.kt b/compiler/fir/resolve/testData/resolve/stdlib/arrayFilterCapturedType.kt new file mode 100644 index 00000000000..54ee2e82ec4 --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/stdlib/arrayFilterCapturedType.kt @@ -0,0 +1,3 @@ +fun test(elements: Array) { + val filtered = elements.filterNotNull() +} diff --git a/compiler/fir/resolve/testData/resolve/stdlib/arrayFilterCapturedType.txt b/compiler/fir/resolve/testData/resolve/stdlib/arrayFilterCapturedType.txt new file mode 100644 index 00000000000..5e4e8048ce0 --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/stdlib/arrayFilterCapturedType.txt @@ -0,0 +1,4 @@ +FILE: arrayFilterCapturedType.kt + public final fun test(elements: R|kotlin/Array|): R|kotlin/Unit| { + lval filtered: R|kotlin/collections/List| = R|/elements|.R|kotlin/collections/filterNotNull|() + } diff --git a/compiler/fir/resolve/testData/resolve/stdlib/problems/classLiteralForParameter.kt b/compiler/fir/resolve/testData/resolve/stdlib/classLiteralForParameter.kt similarity index 100% rename from compiler/fir/resolve/testData/resolve/stdlib/problems/classLiteralForParameter.kt rename to compiler/fir/resolve/testData/resolve/stdlib/classLiteralForParameter.kt diff --git a/compiler/fir/resolve/testData/resolve/stdlib/problems/classLiteralForParameter.txt b/compiler/fir/resolve/testData/resolve/stdlib/classLiteralForParameter.txt similarity index 100% rename from compiler/fir/resolve/testData/resolve/stdlib/problems/classLiteralForParameter.txt rename to compiler/fir/resolve/testData/resolve/stdlib/classLiteralForParameter.txt diff --git a/compiler/fir/resolve/testData/resolve/stdlib/problems/arrayFilterCapturedType.kt b/compiler/fir/resolve/testData/resolve/stdlib/problems/arrayFilterCapturedType.kt deleted file mode 100644 index 54b76401f75..00000000000 --- a/compiler/fir/resolve/testData/resolve/stdlib/problems/arrayFilterCapturedType.kt +++ /dev/null @@ -1,3 +0,0 @@ -fun test(elements: Array) { - val filtered = elements.filterNotNull() -} diff --git a/compiler/fir/resolve/testData/resolve/stdlib/problems/arrayFilterCapturedType.txt b/compiler/fir/resolve/testData/resolve/stdlib/problems/arrayFilterCapturedType.txt deleted file mode 100644 index 95c35ff8f3c..00000000000 --- a/compiler/fir/resolve/testData/resolve/stdlib/problems/arrayFilterCapturedType.txt +++ /dev/null @@ -1,4 +0,0 @@ -FILE: arrayFilterCapturedType.kt - public final fun test(elements: R|kotlin/Array|): R|kotlin/Unit| { - lval filtered: = R|/elements|.#() - } diff --git a/compiler/fir/resolve/testData/resolve/stdlib/problems/toSortedMapWithComparator.kt b/compiler/fir/resolve/testData/resolve/stdlib/problems/toSortedMapWithComparator.kt deleted file mode 100644 index bb946ff0d30..00000000000 --- a/compiler/fir/resolve/testData/resolve/stdlib/problems/toSortedMapWithComparator.kt +++ /dev/null @@ -1,3 +0,0 @@ -fun test(map: Map>) { - val sortedMap = map.toSortedMap(nullsLast()) -} diff --git a/compiler/fir/resolve/testData/resolve/stdlib/problems/toSortedMapWithComparator.txt b/compiler/fir/resolve/testData/resolve/stdlib/problems/toSortedMapWithComparator.txt deleted file mode 100644 index 21d1aa1d6aa..00000000000 --- a/compiler/fir/resolve/testData/resolve/stdlib/problems/toSortedMapWithComparator.txt +++ /dev/null @@ -1,4 +0,0 @@ -FILE: toSortedMapWithComparator.kt - public final fun test(map: R|kotlin/collections/Map>|): R|kotlin/Unit| { - lval sortedMap: = R|/map|.#(R|kotlin/comparisons/nullsLast|()) - } diff --git a/compiler/fir/resolve/testData/resolve/stdlib/toSortedMapWithComparator.kt b/compiler/fir/resolve/testData/resolve/stdlib/toSortedMapWithComparator.kt new file mode 100644 index 00000000000..3f1359bade4 --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/stdlib/toSortedMapWithComparator.kt @@ -0,0 +1,3 @@ +fun test(map: Map>) { + val sortedMap = map.toSortedMap(nullsLast()) +} diff --git a/compiler/fir/resolve/testData/resolve/stdlib/toSortedMapWithComparator.txt b/compiler/fir/resolve/testData/resolve/stdlib/toSortedMapWithComparator.txt new file mode 100644 index 00000000000..54aa3f32b98 --- /dev/null +++ b/compiler/fir/resolve/testData/resolve/stdlib/toSortedMapWithComparator.txt @@ -0,0 +1,4 @@ +FILE: toSortedMapWithComparator.kt + public final fun test(map: R|kotlin/collections/Map>|): R|kotlin/Unit| { + lval sortedMap: R|java/util/SortedMap>| = R|/map|.R|kotlin/collections/toSortedMap||>(R|kotlin/comparisons/nullsLast|()) + } diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithStdlibTestGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithStdlibTestGenerated.java index ac575580072..f53e3f0d35e 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithStdlibTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithStdlibTestGenerated.java @@ -38,6 +38,11 @@ public class FirDiagnosticsWithStdlibTestGenerated extends AbstractFirDiagnostic runTest("compiler/fir/resolve/testData/resolve/stdlib/anonymousInDelegate.kt"); } + @TestMetadata("arrayFilterCapturedType.kt") + public void testArrayFilterCapturedType() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/stdlib/arrayFilterCapturedType.kt"); + } + @TestMetadata("arrayFirstOrNull.kt") public void testArrayFirstOrNull() throws Exception { runTest("compiler/fir/resolve/testData/resolve/stdlib/arrayFirstOrNull.kt"); @@ -53,6 +58,11 @@ public class FirDiagnosticsWithStdlibTestGenerated extends AbstractFirDiagnostic runTest("compiler/fir/resolve/testData/resolve/stdlib/backingField.kt"); } + @TestMetadata("classLiteralForParameter.kt") + public void testClassLiteralForParameter() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/stdlib/classLiteralForParameter.kt"); + } + @TestMetadata("companionLoad.kt") public void testCompanionLoad() throws Exception { runTest("compiler/fir/resolve/testData/resolve/stdlib/companionLoad.kt"); @@ -198,6 +208,11 @@ public class FirDiagnosticsWithStdlibTestGenerated extends AbstractFirDiagnostic runTest("compiler/fir/resolve/testData/resolve/stdlib/simpleLazy.kt"); } + @TestMetadata("toSortedMapWithComparator.kt") + public void testToSortedMapWithComparator() throws Exception { + runTest("compiler/fir/resolve/testData/resolve/stdlib/toSortedMapWithComparator.kt"); + } + @TestMetadata("topLevelResolve.kt") public void testTopLevelResolve() throws Exception { runTest("compiler/fir/resolve/testData/resolve/stdlib/topLevelResolve.kt"); @@ -592,16 +607,6 @@ public class FirDiagnosticsWithStdlibTestGenerated extends AbstractFirDiagnostic KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/stdlib/problems"), Pattern.compile("^([^.]+)\\.kt$"), null, true); } - @TestMetadata("arrayFilterCapturedType.kt") - public void testArrayFilterCapturedType() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/stdlib/problems/arrayFilterCapturedType.kt"); - } - - @TestMetadata("classLiteralForParameter.kt") - public void testClassLiteralForParameter() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/stdlib/problems/classLiteralForParameter.kt"); - } - @TestMetadata("cloneArray.kt") public void testCloneArray() throws Exception { runTest("compiler/fir/resolve/testData/resolve/stdlib/problems/cloneArray.kt"); @@ -617,11 +622,6 @@ public class FirDiagnosticsWithStdlibTestGenerated extends AbstractFirDiagnostic runTest("compiler/fir/resolve/testData/resolve/stdlib/problems/inapplicableRemoveAll.kt"); } - @TestMetadata("toSortedMapWithComparator.kt") - public void testToSortedMapWithComparator() throws Exception { - runTest("compiler/fir/resolve/testData/resolve/stdlib/problems/toSortedMapWithComparator.kt"); - } - @TestMetadata("tryWithLambdaInside.kt") public void testTryWithLambdaInside() throws Exception { runTest("compiler/fir/resolve/testData/resolve/stdlib/problems/tryWithLambdaInside.kt"); diff --git a/compiler/testData/diagnostics/tests/generics/nullability/expressionsBoundsViolation.fir.kt b/compiler/testData/diagnostics/tests/generics/nullability/expressionsBoundsViolation.fir.kt index 03e3a5d44db..1575e634da8 100644 --- a/compiler/testData/diagnostics/tests/generics/nullability/expressionsBoundsViolation.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/nullability/expressionsBoundsViolation.fir.kt @@ -7,10 +7,10 @@ fun foo1(x: E) {} fun E.foo2() {} fun bar(x: F) { - A(x) + A(x) A(x) - foo1(x) + foo1(x) foo1(x) x.foo2() diff --git a/compiler/testData/diagnostics/tests/generics/nullability/smartCastsValueArgument.fir.kt b/compiler/testData/diagnostics/tests/generics/nullability/smartCastsValueArgument.fir.kt index 7a9fb30501c..8c40082a63f 100644 --- a/compiler/testData/diagnostics/tests/generics/nullability/smartCastsValueArgument.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/nullability/smartCastsValueArgument.fir.kt @@ -45,7 +45,7 @@ fun foo(x: T) { bar2(x) bar3(x) - bar1(y) + bar1(y) bar2(y) bar3(y) } diff --git a/compiler/testData/diagnostics/tests/generics/nullability/tpBoundsViolation.fir.kt b/compiler/testData/diagnostics/tests/generics/nullability/tpBoundsViolation.fir.kt index 5bfe4abd488..0f97d2ba9e1 100644 --- a/compiler/testData/diagnostics/tests/generics/nullability/tpBoundsViolation.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/nullability/tpBoundsViolation.fir.kt @@ -38,7 +38,7 @@ class A { x4.checkType { _() } foo1(w) - foo1(w) + foo1(w) foo2(w) val x6 = foo2(w) diff --git a/compiler/testData/diagnostics/tests/generics/nullability/useAsValueArgument.fir.kt b/compiler/testData/diagnostics/tests/generics/nullability/useAsValueArgument.fir.kt index 7892ecac4e7..3f2568af980 100644 --- a/compiler/testData/diagnostics/tests/generics/nullability/useAsValueArgument.fir.kt +++ b/compiler/testData/diagnostics/tests/generics/nullability/useAsValueArgument.fir.kt @@ -13,6 +13,6 @@ fun foo(x: T) { bar1(x) bar2(x) - bar3(x) + bar3(x) bar4(x) } diff --git a/compiler/testData/diagnostics/tests/inference/nullableTypeArgumentWithNotNullUpperBound.fir.kt b/compiler/testData/diagnostics/tests/inference/nullableTypeArgumentWithNotNullUpperBound.fir.kt index 94716e1b394..017be489027 100644 --- a/compiler/testData/diagnostics/tests/inference/nullableTypeArgumentWithNotNullUpperBound.fir.kt +++ b/compiler/testData/diagnostics/tests/inference/nullableTypeArgumentWithNotNullUpperBound.fir.kt @@ -1,5 +1,5 @@ fun foo(x: Array, y: Array) { - val xo = outA(x) + val xo = outA(x) val yo = inA(y) var f: Array = xo diff --git a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/notnullTypesFromJavaWithSmartcast.fir.kt b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/notnullTypesFromJavaWithSmartcast.fir.kt index cc63bf707ec..f56a999dbba 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/notnullTypesFromJavaWithSmartcast.fir.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndSmartCasts/notnullTypesFromJavaWithSmartcast.fir.kt @@ -16,5 +16,5 @@ fun test() { value = JClass.getNotNullT() } - value.hashCode() // unsafe call error + value.hashCode() // unsafe call error } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/platformTypes/notNullTypeParameter/substitutionInSuperType.fir.kt b/compiler/testData/diagnostics/tests/platformTypes/notNullTypeParameter/substitutionInSuperType.fir.kt index 7027ad2ac42..b40ce52152f 100644 --- a/compiler/testData/diagnostics/tests/platformTypes/notNullTypeParameter/substitutionInSuperType.fir.kt +++ b/compiler/testData/diagnostics/tests/platformTypes/notNullTypeParameter/substitutionInSuperType.fir.kt @@ -36,6 +36,6 @@ fun test() { B1().bar(null) B2().bar(null) - C1().bar(null) + C1().bar(null) } diff --git a/compiler/testData/ir/irText/expressions/implicitCastToNonNull.fir.txt b/compiler/testData/ir/irText/expressions/implicitCastToNonNull.fir.txt index 1e18a8581de..bf1e0dd4106 100644 --- a/compiler/testData/ir/irText/expressions/implicitCastToNonNull.fir.txt +++ b/compiler/testData/ir/irText/expressions/implicitCastToNonNull.fir.txt @@ -27,7 +27,7 @@ FILE fqName: fileName:/implicitCastToNonNull.kt BRANCH if: CONST Boolean type=kotlin.Boolean value=true then: CALL 'public abstract fun (): kotlin.Int declared in kotlin.CharSequence' type=kotlin.Int origin=null - $this: GET_VAR 'x: T of .test2 declared in .test2' type=kotlin.Any origin=null + $this: GET_VAR 'x: T of .test2 declared in .test2' type=T of .test2 origin=null FUN name:test3 visibility:public modality:FINAL (x:kotlin.Any) returnType:kotlin.Int [inline] TYPE_PARAMETER name:T index:0 variance: superTypes:[kotlin.CharSequence?] VALUE_PARAMETER name:x index:0 type:kotlin.Any @@ -70,4 +70,4 @@ FILE fqName: fileName:/implicitCastToNonNull.kt arg1: CONST Null type=kotlin.Nothing? value=null then: CALL 'public abstract fun invoke (p1: S of .test5): kotlin.Unit [operator] declared in kotlin.Function1' type=kotlin.Unit origin=null $this: GET_VAR 'fn: kotlin.Function1.test5, kotlin.Unit> declared in .test5' type=kotlin.Function1.test5, kotlin.Unit> origin=null - p1: GET_VAR 'x: T of .test5 declared in .test5' type=kotlin.Any origin=null + p1: GET_VAR 'x: T of .test5 declared in .test5' type=T of .test5 origin=null diff --git a/compiler/testData/ir/irText/expressions/kt30796.fir.txt b/compiler/testData/ir/irText/expressions/kt30796.fir.txt index bb77bef494e..69f20437930 100644 --- a/compiler/testData/ir/irText/expressions/kt30796.fir.txt +++ b/compiler/testData/ir/irText/expressions/kt30796.fir.txt @@ -11,10 +11,10 @@ FILE fqName: fileName:/kt30796.kt VALUE_PARAMETER name:value2 index:1 type:T of .test BLOCK_BODY VAR name:x1 type:kotlin.Any [val] - BLOCK type=kotlin.Any origin=ELVIS + BLOCK type=T of .test origin=ELVIS VAR IR_TEMPORARY_VARIABLE name:tmp_0 type:T of .test [val] GET_VAR 'value: T of .test declared in .test' type=T of .test origin=null - WHEN type=kotlin.Any origin=ELVIS + WHEN type=T of .test origin=ELVIS BRANCH if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ arg0: GET_VAR 'val tmp_0: T of .test [val] declared in .test' type=T of .test origin=null @@ -22,20 +22,20 @@ FILE fqName: fileName:/kt30796.kt then: CONST Int type=kotlin.Int value=42 BRANCH if: CONST Boolean type=kotlin.Boolean value=true - then: GET_VAR 'val tmp_0: T of .test [val] declared in .test' type=kotlin.Any origin=null + then: GET_VAR 'val tmp_0: T of .test [val] declared in .test' type=T of .test origin=null VAR name:x2 type:kotlin.Any [val] - BLOCK type=kotlin.Any origin=ELVIS + BLOCK type=T of .test origin=ELVIS VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:T of .test [val] GET_VAR 'value: T of .test declared in .test' type=T of .test origin=null - WHEN type=kotlin.Any origin=ELVIS + WHEN type=T of .test origin=ELVIS BRANCH if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ arg0: GET_VAR 'val tmp_1: T of .test [val] declared in .test' type=T of .test origin=null arg1: CONST Null type=kotlin.Nothing? value=null - then: BLOCK type=kotlin.Any origin=ELVIS + then: BLOCK type=T of .test origin=ELVIS VAR IR_TEMPORARY_VARIABLE name:tmp_2 type:T of .test [val] GET_VAR 'value2: T of .test declared in .test' type=T of .test origin=null - WHEN type=kotlin.Any origin=ELVIS + WHEN type=T of .test origin=ELVIS BRANCH if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ arg0: GET_VAR 'val tmp_2: T of .test [val] declared in .test' type=T of .test origin=null @@ -43,12 +43,12 @@ FILE fqName: fileName:/kt30796.kt then: CONST Int type=kotlin.Int value=42 BRANCH if: CONST Boolean type=kotlin.Boolean value=true - then: GET_VAR 'val tmp_2: T of .test [val] declared in .test' type=kotlin.Any origin=null + then: GET_VAR 'val tmp_2: T of .test [val] declared in .test' type=T of .test origin=null BRANCH if: CONST Boolean type=kotlin.Boolean value=true - then: GET_VAR 'val tmp_1: T of .test [val] declared in .test' type=kotlin.Any origin=null + then: GET_VAR 'val tmp_1: T of .test [val] declared in .test' type=T of .test origin=null VAR name:x3 type:kotlin.Any [val] - BLOCK type=kotlin.Any origin=ELVIS + BLOCK type=T of .test origin=ELVIS VAR IR_TEMPORARY_VARIABLE name:tmp_3 type:T of .test [val] BLOCK type=T of .test origin=ELVIS VAR IR_TEMPORARY_VARIABLE name:tmp_4 type:T of .test [val] @@ -61,8 +61,8 @@ FILE fqName: fileName:/kt30796.kt then: GET_VAR 'value2: T of .test declared in .test' type=T of .test origin=null BRANCH if: CONST Boolean type=kotlin.Boolean value=true - then: GET_VAR 'val tmp_4: T of .test [val] declared in .test' type=kotlin.Any origin=null - WHEN type=kotlin.Any origin=ELVIS + then: GET_VAR 'val tmp_4: T of .test [val] declared in .test' type=T of .test origin=null + WHEN type=T of .test origin=ELVIS BRANCH if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ arg0: GET_VAR 'val tmp_3: T of .test [val] declared in .test' type=T of .test origin=null @@ -70,9 +70,9 @@ FILE fqName: fileName:/kt30796.kt then: CONST Int type=kotlin.Int value=42 BRANCH if: CONST Boolean type=kotlin.Boolean value=true - then: GET_VAR 'val tmp_3: T of .test [val] declared in .test' type=kotlin.Any origin=null + then: GET_VAR 'val tmp_3: T of .test [val] declared in .test' type=T of .test origin=null VAR name:x4 type:kotlin.Any [val] - BLOCK type=kotlin.Any origin=ELVIS + BLOCK type=T of .test origin=ELVIS VAR IR_TEMPORARY_VARIABLE name:tmp_5 type:T of .test [val] BLOCK type=T of .test origin=ELVIS VAR IR_TEMPORARY_VARIABLE name:tmp_6 type:T of .test [val] @@ -85,8 +85,8 @@ FILE fqName: fileName:/kt30796.kt then: GET_VAR 'value2: T of .test declared in .test' type=T of .test origin=null BRANCH if: CONST Boolean type=kotlin.Boolean value=true - then: GET_VAR 'val tmp_6: T of .test [val] declared in .test' type=kotlin.Any origin=null - WHEN type=kotlin.Any origin=ELVIS + then: GET_VAR 'val tmp_6: T of .test [val] declared in .test' type=T of .test origin=null + WHEN type=T of .test origin=ELVIS BRANCH if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ arg0: GET_VAR 'val tmp_5: T of .test [val] declared in .test' type=T of .test origin=null @@ -94,7 +94,7 @@ FILE fqName: fileName:/kt30796.kt then: CONST Int type=kotlin.Int value=42 BRANCH if: CONST Boolean type=kotlin.Boolean value=true - then: GET_VAR 'val tmp_5: T of .test [val] declared in .test' type=kotlin.Any origin=null + then: GET_VAR 'val tmp_5: T of .test [val] declared in .test' type=T of .test origin=null VAR name:x5 type:kotlin.Any [val] BLOCK type=kotlin.Int origin=ELVIS VAR IR_TEMPORARY_VARIABLE name:tmp_7 type:kotlin.Nothing [val] @@ -110,32 +110,32 @@ FILE fqName: fileName:/kt30796.kt if: CONST Boolean type=kotlin.Boolean value=true then: GET_VAR 'val tmp_7: kotlin.Nothing [val] declared in .test' type=kotlin.Nothing origin=null VAR name:x6 type:kotlin.Any [val] - BLOCK type=kotlin.Any origin=ELVIS - VAR IR_TEMPORARY_VARIABLE name:tmp_8 type:kotlin.Any [val] - BLOCK type=kotlin.Any origin=ELVIS + BLOCK type=T of .test origin=ELVIS + VAR IR_TEMPORARY_VARIABLE name:tmp_8 type:T of .test [val] + BLOCK type=T of .test origin=ELVIS VAR IR_TEMPORARY_VARIABLE name:tmp_9 type:T of .test [val] GET_VAR 'value: T of .test declared in .test' type=T of .test origin=null - WHEN type=kotlin.Any origin=ELVIS + WHEN type=T of .test origin=ELVIS BRANCH if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ arg0: GET_VAR 'val tmp_9: T of .test [val] declared in .test' type=T of .test origin=null arg1: CONST Null type=kotlin.Nothing? value=null - then: CALL 'public final fun magic (): T of .magic declared in ' type=kotlin.Any origin=null - : kotlin.Any + then: CALL 'public final fun magic (): T of .magic declared in ' type=T of .test origin=null + : T of .test BRANCH if: CONST Boolean type=kotlin.Boolean value=true - then: GET_VAR 'val tmp_9: T of .test [val] declared in .test' type=kotlin.Any origin=null - WHEN type=kotlin.Any origin=ELVIS + then: GET_VAR 'val tmp_9: T of .test [val] declared in .test' type=T of .test origin=null + WHEN type=T of .test origin=ELVIS BRANCH if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ - arg0: GET_VAR 'val tmp_8: kotlin.Any [val] declared in .test' type=kotlin.Any origin=null + arg0: GET_VAR 'val tmp_8: T of .test [val] declared in .test' type=T of .test origin=null arg1: CONST Null type=kotlin.Nothing? value=null then: CONST Int type=kotlin.Int value=42 BRANCH if: CONST Boolean type=kotlin.Boolean value=true - then: GET_VAR 'val tmp_8: kotlin.Any [val] declared in .test' type=kotlin.Any origin=null + then: GET_VAR 'val tmp_8: T of .test [val] declared in .test' type=T of .test origin=null VAR name:x7 type:kotlin.Any [val] - BLOCK type=kotlin.Any origin=ELVIS + BLOCK type=T of .test origin=ELVIS VAR IR_TEMPORARY_VARIABLE name:tmp_10 type:T of .test [val] BLOCK type=T of .test origin=ELVIS VAR IR_TEMPORARY_VARIABLE name:tmp_11 type:kotlin.Nothing [val] @@ -150,7 +150,7 @@ FILE fqName: fileName:/kt30796.kt BRANCH if: CONST Boolean type=kotlin.Boolean value=true then: GET_VAR 'val tmp_11: kotlin.Nothing [val] declared in .test' type=kotlin.Nothing origin=null - WHEN type=kotlin.Any origin=ELVIS + WHEN type=T of .test origin=ELVIS BRANCH if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ arg0: GET_VAR 'val tmp_10: T of .test [val] declared in .test' type=T of .test origin=null @@ -158,4 +158,4 @@ FILE fqName: fileName:/kt30796.kt then: CONST Int type=kotlin.Int value=42 BRANCH if: CONST Boolean type=kotlin.Boolean value=true - then: GET_VAR 'val tmp_10: T of .test [val] declared in .test' type=kotlin.Any origin=null + then: GET_VAR 'val tmp_10: T of .test [val] declared in .test' type=T of .test origin=null