diff --git a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/quickfix/MakeUpperBoundNonNullableFix.kt b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/quickfix/MakeUpperBoundNonNullableFix.kt index a3a65c60f489..7c8cea7d4304 100644 --- a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/quickfix/MakeUpperBoundNonNullableFix.kt +++ b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/quickfix/MakeUpperBoundNonNullableFix.kt @@ -147,7 +147,9 @@ open class MakeUpperBoundNonNullableFix( } for ((actualProjection, expectedProjection) in actual.arguments.zip(expected.arguments)) { - result.addAll(extractPotentiallyFixableTypesForExpectedType(actualProjection.type, expectedProjection.type)) + if (!actualProjection.isStarProjection && !expectedProjection.isStarProjection) { + result.addAll(extractPotentiallyFixableTypesForExpectedType(actualProjection.type, expectedProjection.type)) + } } return result diff --git a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java index d753e366f69a..5efc373ff6f0 100644 --- a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java +++ b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/quickfix/QuickFixTestGenerated.java @@ -9181,6 +9181,11 @@ public abstract class QuickFixTestGenerated extends AbstractQuickFixTest { KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); } + @TestMetadata("noStackOverflowOnStarProjection.kt") + public void testNoStackOverflowOnStarProjection() throws Exception { + runTest("testData/quickfix/makeUpperBoundNonNullable/noStackOverflowOnStarProjection.kt"); + } + @TestMetadata("typeMismatchAny1.kt") public void testTypeMismatchAny1() throws Exception { runTest("testData/quickfix/makeUpperBoundNonNullable/typeMismatchAny1.kt"); diff --git a/plugins/kotlin/idea/tests/testData/quickfix/makeUpperBoundNonNullable/noStackOverflowOnStarProjection.kt b/plugins/kotlin/idea/tests/testData/quickfix/makeUpperBoundNonNullable/noStackOverflowOnStarProjection.kt new file mode 100644 index 000000000000..a5c700ae05f4 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/quickfix/makeUpperBoundNonNullable/noStackOverflowOnStarProjection.kt @@ -0,0 +1,18 @@ +// "Add 'Any' as upper bound for T to make it non-nullable" "false" +// ERROR: Type mismatch: inferred type is Enum<*> but Enum> was expected +// ERROR: Type mismatch: inferred type is Enum<*> but Enum> was expected +// ACTION: Change parameter 'enumClass' type of primary constructor of class 'Foo' to 'Class>' +// ACTION: Create function 'Foo' +// ACTION: Create secondary constructor +// ACTION: Introduce import alias +// LANGUAGE_VERSION: 1.7 + +class Test + +class Foo>(private val enumClass: Class) { + fun test() {} +} + +fun bar() { + Foo(Test::class as Class>).test() +}