diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java index 3cfdbc0e86e..204ef9574bb 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java @@ -15523,6 +15523,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag runTest("compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt51016.kt"); } + @Test + @TestMetadata("kt52364.kt") + public void testKt52364() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt52364.kt"); + } + @Test @TestMetadata("nullableEmptyIntersection.kt") public void testNullableEmptyIntersection() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java index 62607b5920f..2740162fcaa 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java @@ -15523,6 +15523,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti runTest("compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt51016.kt"); } + @Test + @TestMetadata("kt52364.kt") + public void testKt52364() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt52364.kt"); + } + @Test @TestMetadata("nullableEmptyIntersection.kt") public void testNullableEmptyIntersection() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java index cb0f707759a..950b09fbfd3 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java @@ -15523,6 +15523,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac runTest("compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt51016.kt"); } + @Test + @TestMetadata("kt52364.kt") + public void testKt52364() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt52364.kt"); + } + @Test @TestMetadata("nullableEmptyIntersection.kt") public void testNullableEmptyIntersection() throws Exception { diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt52364.kt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt52364.kt new file mode 100644 index 00000000000..6acc28f5a5c --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt52364.kt @@ -0,0 +1,16 @@ +// FIR_IDENTICAL +// WITH_STDLIB + +import kotlin.reflect.KProperty + +class FieldStyle2(val index: Int? = 0) + +interface Foo { + fun > getProperty(): Type? = null +} + +class A { + fun foo(thisRef: T, property: KProperty<*>): FieldStyle2 { + return FieldStyle2(thisRef.getProperty()) + } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt52364.txt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt52364.txt new file mode 100644 index 00000000000..f4cfc9e6fb6 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt52364.txt @@ -0,0 +1,24 @@ +package + +public final class A { + public constructor A() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final fun foo(/*0*/ thisRef: T, /*1*/ property: kotlin.reflect.KProperty<*>): FieldStyle2 + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public final class FieldStyle2 { + public constructor FieldStyle2(/*0*/ index: kotlin.Int? = ...) + public final val index: kotlin.Int? + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public interface Foo { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun > getProperty(): Type? + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index f1f0d950188..2fb738f0622 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -15529,6 +15529,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt51016.kt"); } + @Test + @TestMetadata("kt52364.kt") + public void testKt52364() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt52364.kt"); + } + @Test @TestMetadata("nullableEmptyIntersection.kt") public void testNullableEmptyIntersection() throws Exception { diff --git a/core/compiler.common/src/org/jetbrains/kotlin/types/model/TypeSystemContext.kt b/core/compiler.common/src/org/jetbrains/kotlin/types/model/TypeSystemContext.kt index f1685a85fb3..076621648ed 100644 --- a/core/compiler.common/src/org/jetbrains/kotlin/types/model/TypeSystemContext.kt +++ b/core/compiler.common/src/org/jetbrains/kotlin/types/model/TypeSystemContext.kt @@ -392,10 +392,10 @@ interface TypeSystemInferenceExtensionContext : TypeSystemContext, TypeSystemBui "One of the passed type should be an interface" } @Suppress("NAME_SHADOWING") - val firstType = firstType.withNullability(false).eraseContainingTypeParameters() + val firstType = firstType.eraseContainingTypeParameters() @Suppress("NAME_SHADOWING") - val secondType = secondType.withNullability(false).eraseContainingTypeParameters() + val secondType = secondType.eraseContainingTypeParameters() // interface A // interface B: A @@ -414,14 +414,14 @@ interface TypeSystemInferenceExtensionContext : TypeSystemContext, TypeSystemBui val typeCheckerState = newTypeCheckerState(errorTypesEqualToAnything = true, stubTypesEqualToAnything = true) for (i in expandedTypes.indices) { - val firstType = expandedTypes[i] + val firstType = expandedTypes[i].withNullability(false) val firstTypeConstructor = firstType.typeConstructor() if (!firstType.mayCauseEmptyIntersection()) continue for (j in i + 1 until expandedTypes.size) { - val secondType = expandedTypes[j] + val secondType = expandedTypes[j].withNullability(false) val secondTypeConstructor = secondType.typeConstructor() if (!secondType.mayCauseEmptyIntersection())