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 8845304e298..995ee6736aa 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 @@ -28177,6 +28177,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti runTest("compiler/testData/diagnostics/tests/subtyping/kt3159.kt"); } + @Test + @TestMetadata("kt47148.kt") + public void testKt47148() throws Exception { + runTest("compiler/testData/diagnostics/tests/subtyping/kt47148.kt"); + } + @Test @TestMetadata("kt-1457.kt") public void testKt_1457() 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 49e4f497292..d0dc46c12bc 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 @@ -28177,6 +28177,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac runTest("compiler/testData/diagnostics/tests/subtyping/kt3159.kt"); } + @Test + @TestMetadata("kt47148.kt") + public void testKt47148() throws Exception { + runTest("compiler/testData/diagnostics/tests/subtyping/kt47148.kt"); + } + @Test @TestMetadata("kt-1457.kt") public void testKt_1457() throws Exception { diff --git a/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/NewCommonSuperTypeCalculator.kt b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/NewCommonSuperTypeCalculator.kt index 07d8644b8e9..37ec9e26c45 100644 --- a/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/NewCommonSuperTypeCalculator.kt +++ b/compiler/resolution.common/src/org/jetbrains/kotlin/resolve/calls/NewCommonSuperTypeCalculator.kt @@ -175,7 +175,7 @@ object NewCommonSuperTypeCalculator { "There should be at least one non-stub type to compute common supertype but there are: $types" } - val nonStubTypeVariables = types.filter { !it.isStubType() } + val nonStubTypeVariables = types.filter { !it.isStubTypeForBuilderInference() } val areAllNonStubTypesNothing = nonStubTypeVariables.isNotEmpty() && nonStubTypeVariables.all { it.isNothing() } if (nonStubTypeVariables.size == 1 && !areAllNonStubTypesNothing) return nonStubTypeVariables.single() diff --git a/compiler/testData/diagnostics/tests/subtyping/kt47148.fir.kt b/compiler/testData/diagnostics/tests/subtyping/kt47148.fir.kt new file mode 100644 index 00000000000..f5baf42ca57 --- /dev/null +++ b/compiler/testData/diagnostics/tests/subtyping/kt47148.fir.kt @@ -0,0 +1,10 @@ +// WITH_RUNTIME + +interface Visitor { + fun visit(key: String): T +} +val str1: String? = null +val str2: String? = null +fun visit(arg: Visitor): T = str1?.let { return@visit arg.visit(it) } + ?: str2?.let { return@visit arg.visit(it) } + ?: error("error") \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/subtyping/kt47148.kt b/compiler/testData/diagnostics/tests/subtyping/kt47148.kt new file mode 100644 index 00000000000..8056e797188 --- /dev/null +++ b/compiler/testData/diagnostics/tests/subtyping/kt47148.kt @@ -0,0 +1,10 @@ +// WITH_RUNTIME + +interface Visitor { + fun visit(key: String): T +} +val str1: String? = null +val str2: String? = null +fun visit(arg: Visitor): T = str1?.let { return@visit arg.visit(it) } + ?: str2?.let { return@visit arg.visit(it) } + ?: error("error") \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/subtyping/kt47148.txt b/compiler/testData/diagnostics/tests/subtyping/kt47148.txt new file mode 100644 index 00000000000..ff7ae967601 --- /dev/null +++ b/compiler/testData/diagnostics/tests/subtyping/kt47148.txt @@ -0,0 +1,12 @@ +package + +public val str1: kotlin.String? = null +public val str2: kotlin.String? = null +public fun visit(/*0*/ arg: Visitor): T + +public interface Visitor { + 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 abstract fun visit(/*0*/ key: kotlin.String): T +} 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 f4e171db409..07c09f32c6a 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 @@ -28273,6 +28273,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/subtyping/kt3159.kt"); } + @Test + @TestMetadata("kt47148.kt") + public void testKt47148() throws Exception { + runTest("compiler/testData/diagnostics/tests/subtyping/kt47148.kt"); + } + @Test @TestMetadata("kt-1457.kt") public void testKt_1457() throws Exception { diff --git a/idea/idea-frontend-fir/idea-fir-low-level-api/tests/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java b/idea/idea-frontend-fir/idea-fir-low-level-api/tests/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java index a4616ac21f2..b6c95329496 100644 --- a/idea/idea-frontend-fir/idea-fir-low-level-api/tests/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java +++ b/idea/idea-frontend-fir/idea-fir-low-level-api/tests/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java @@ -24638,6 +24638,11 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag runTest("compiler/testData/diagnostics/tests/subtyping/kt3159.kt"); } + @TestMetadata("kt47148.kt") + public void testKt47148() throws Exception { + runTest("compiler/testData/diagnostics/tests/subtyping/kt47148.kt"); + } + @TestMetadata("kt-1457.kt") public void testKt_1457() throws Exception { runTest("compiler/testData/diagnostics/tests/subtyping/kt-1457.kt");