diff --git a/plugins/kotlin/fir/test/org/jetbrains/kotlin/idea/fir/quickfix/HighLevelQuickFixTestGenerated.java b/plugins/kotlin/fir/test/org/jetbrains/kotlin/idea/fir/quickfix/HighLevelQuickFixTestGenerated.java index 268cae21c759..1e426a80bc52 100644 --- a/plugins/kotlin/fir/test/org/jetbrains/kotlin/idea/fir/quickfix/HighLevelQuickFixTestGenerated.java +++ b/plugins/kotlin/fir/test/org/jetbrains/kotlin/idea/fir/quickfix/HighLevelQuickFixTestGenerated.java @@ -2529,16 +2529,6 @@ public abstract class HighLevelQuickFixTestGenerated extends AbstractHighLevelQu runTest("../idea/tests/testData/quickfix/typeMismatch/casts/typeMismatch4.kt"); } - @TestMetadata("typeMismatchDefNonNullable1.kt") - public void testTypeMismatchDefNonNullable1() throws Exception { - runTest("../idea/tests/testData/quickfix/typeMismatch/casts/typeMismatchDefNonNullable1.kt"); - } - - @TestMetadata("typeMismatchDefNonNullable2.kt") - public void testTypeMismatchDefNonNullable2() throws Exception { - runTest("../idea/tests/testData/quickfix/typeMismatch/casts/typeMismatchDefNonNullable2.kt"); - } - @TestMetadata("typeMismatchLongNameRuntime.kt") public void testTypeMismatchLongNameRuntime() throws Exception { runTest("../idea/tests/testData/quickfix/typeMismatch/casts/typeMismatchLongNameRuntime.kt"); diff --git a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeParameterTypeFix.kt b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeParameterTypeFix.kt index 47206bfa8108..ee1f5e4376cd 100644 --- a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeParameterTypeFix.kt +++ b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/quickfix/ChangeParameterTypeFix.kt @@ -19,7 +19,6 @@ import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.types.KotlinType -import org.jetbrains.kotlin.types.isDefinitelyNotNullType class ChangeParameterTypeFix(element: KtParameter, type: KotlinType) : KotlinQuickFixAction(element) { private val typePresentation = IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_NO_ANNOTATIONS.renderType(type) diff --git a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixFactoryForTypeMismatchError.kt b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixFactoryForTypeMismatchError.kt index eb9309a956ea..51e942e10a36 100644 --- a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixFactoryForTypeMismatchError.kt +++ b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/quickfix/QuickFixFactoryForTypeMismatchError.kt @@ -9,6 +9,7 @@ import org.jetbrains.kotlin.backend.jvm.ir.psiElement import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.isKFunctionType import org.jetbrains.kotlin.config.LanguageFeature +import org.jetbrains.kotlin.descriptors.CallableDescriptor import org.jetbrains.kotlin.descriptors.DeclarationDescriptorWithSource import org.jetbrains.kotlin.diagnostics.Diagnostic import org.jetbrains.kotlin.diagnostics.Errors @@ -22,7 +23,6 @@ import org.jetbrains.kotlin.idea.intentions.reflectToRegularFunctionType import org.jetbrains.kotlin.idea.project.languageVersionSettings import org.jetbrains.kotlin.idea.util.approximateWithResolvableType import org.jetbrains.kotlin.idea.util.getResolutionScope -import org.jetbrains.kotlin.idea.util.module import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.collectDescendantsOfType @@ -153,33 +153,10 @@ class QuickFixFactoryForTypeMismatchError : KotlinIntentionActionsFactory() { return qualifiedOrThis } - // Check if the type is a definitely non-nullable type (`T & Any`) - // or contains a definitely non-nullable type as a type argument (e.g., `Collection`) - fun KotlinType.containsDefinitelyNotNullComponent(): Boolean { - if (isDefinitelyNotNullType) return true - return arguments.any { it.type.containsDefinitelyNotNullComponent() } - } - - // Suggest replacing type argument `T` with its expected definitely non-nullable subtype `T & Any`. - // Types that contain DNN types as arguments (like `(Mutable)Collection`) are currently not supported. - if (diagnosticElement is KtReferenceExpression && - expectedType.isDefinitelyNotNullType && - diagnosticElement.module?.languageVersionSettings?.supportsFeature(LanguageFeature.DefinitelyNonNullableTypes) == true - ) { - val descriptor = context[BindingContext.REFERENCE_TARGET, diagnosticElement]?.safeAs() - val parameter = descriptor?.psiElement?.safeAs() - val parentParameterList = parameter?.parent as? KtParameterList - if (parameter != null && parentParameterList != null) { - actions.add(ChangeParameterTypeFix(parameter, expectedType)) - } - } - // We don't want to cast a cast or type-asserted expression. - // We also don't want to cast a potentially nullable type `T` to its definitely non-nullable subtype `T & Any` as it is unsafe. if (diagnostic.factory != Errors.SIGNED_CONSTANT_CONVERTED_TO_UNSIGNED && diagnosticElement !is KtBinaryExpressionWithTypeRHS && - diagnosticElement.parent !is KtBinaryExpressionWithTypeRHS && - !expectedType.containsDefinitelyNotNullComponent() + diagnosticElement.parent !is KtBinaryExpressionWithTypeRHS ) { actions.add(CastExpressionFix(diagnosticElement.getTopMostQualifiedForSelectorIfAny(), expectedType)) } @@ -208,6 +185,23 @@ class QuickFixFactoryForTypeMismatchError : KotlinIntentionActionsFactory() { actions.add(createFix(callable, typeToInsert)) } + // Suggest replacing the parameter type `T` with its expected definitely non-nullable subtype `T & Any`. + // Types that contain DNN types as arguments (like `(Mutable)Collection`) are currently not supported. + if (diagnosticElement is KtReferenceExpression && expectedType.isDefinitelyNotNullType) { + val descriptor = context[BindingContext.REFERENCE_TARGET, diagnosticElement]?.safeAs() + when (val declaration = QuickFixUtil.safeGetDeclaration(descriptor)) { + is KtParameter -> { + // Check the parent parameter list to avoid creating actions for loop iterators + if (declaration.parent is KtParameterList) { + actions.add(ChangeParameterTypeFix(declaration, expectedType)) + } + } + is KtProperty -> { + addChangeTypeFix(declaration, expectedType, ::ChangeVariableTypeFix) + } + } + } + // Property initializer type mismatch property type: val property = PsiTreeUtil.getParentOfType(diagnosticElement, KtProperty::class.java) if (property != null) { 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 a820182ad2f4..5312686c7a1d 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 @@ -13988,16 +13988,6 @@ public abstract class QuickFixTestGenerated extends AbstractQuickFixTest { runTest("testData/quickfix/typeMismatch/casts/typeMismatch4.kt"); } - @TestMetadata("typeMismatchDefNonNullable1.kt") - public void testTypeMismatchDefNonNullable1() throws Exception { - runTest("testData/quickfix/typeMismatch/casts/typeMismatchDefNonNullable1.kt"); - } - - @TestMetadata("typeMismatchDefNonNullable2.kt") - public void testTypeMismatchDefNonNullable2() throws Exception { - runTest("testData/quickfix/typeMismatch/casts/typeMismatchDefNonNullable2.kt"); - } - @TestMetadata("typeMismatchLongNameRuntime.kt") public void testTypeMismatchLongNameRuntime() throws Exception { runTest("testData/quickfix/typeMismatch/casts/typeMismatchLongNameRuntime.kt"); @@ -14110,6 +14100,49 @@ public abstract class QuickFixTestGenerated extends AbstractQuickFixTest { } } + @RunWith(JUnit3RunnerWithInners.class) + @TestMetadata("testData/quickfix/typeMismatch/definitelyNonNullableTypes") + public static class DefinitelyNonNullableTypes extends AbstractQuickFixTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + @TestMetadata("changeFunctionParameterType1.kt") + public void testChangeFunctionParameterType1() throws Exception { + runTest("testData/quickfix/typeMismatch/definitelyNonNullableTypes/changeFunctionParameterType1.kt"); + } + + @TestMetadata("changeFunctionParameterType2.kt") + public void testChangeFunctionParameterType2() throws Exception { + runTest("testData/quickfix/typeMismatch/definitelyNonNullableTypes/changeFunctionParameterType2.kt"); + } + + @TestMetadata("changePrimaryConstructorParameterType.kt") + public void testChangePrimaryConstructorParameterType() throws Exception { + runTest("testData/quickfix/typeMismatch/definitelyNonNullableTypes/changePrimaryConstructorParameterType.kt"); + } + + @TestMetadata("changeVariableType1.kt") + public void testChangeVariableType1() throws Exception { + runTest("testData/quickfix/typeMismatch/definitelyNonNullableTypes/changeVariableType1.kt"); + } + + @TestMetadata("changeVariableType2.kt") + public void testChangeVariableType2() throws Exception { + runTest("testData/quickfix/typeMismatch/definitelyNonNullableTypes/changeVariableType2.kt"); + } + + @TestMetadata("explicitCast1.kt") + public void testExplicitCast1() throws Exception { + runTest("testData/quickfix/typeMismatch/definitelyNonNullableTypes/explicitCast1.kt"); + } + + @TestMetadata("explicitCast2.kt") + public void testExplicitCast2() throws Exception { + runTest("testData/quickfix/typeMismatch/definitelyNonNullableTypes/explicitCast2.kt"); + } + } + @RunWith(JUnit3RunnerWithInners.class) @TestMetadata("testData/quickfix/typeMismatch/fixOverloadedOperator") public static class FixOverloadedOperator extends AbstractQuickFixTest { @@ -14188,16 +14221,6 @@ public abstract class QuickFixTestGenerated extends AbstractQuickFixTest { runTest("testData/quickfix/typeMismatch/parameterTypeMismatch/changeFunctionParameterType4.kt"); } - @TestMetadata("changeFunctionParameterTypeDefNonNullable1.kt") - public void testChangeFunctionParameterTypeDefNonNullable1() throws Exception { - runTest("testData/quickfix/typeMismatch/parameterTypeMismatch/changeFunctionParameterTypeDefNonNullable1.kt"); - } - - @TestMetadata("changeFunctionParameterTypeDefNonNullable2.kt") - public void testChangeFunctionParameterTypeDefNonNullable2() throws Exception { - runTest("testData/quickfix/typeMismatch/parameterTypeMismatch/changeFunctionParameterTypeDefNonNullable2.kt"); - } - @TestMetadata("changeFunctionParameterTypeWithComment.kt") public void testChangeFunctionParameterTypeWithComment() throws Exception { runTest("testData/quickfix/typeMismatch/parameterTypeMismatch/changeFunctionParameterTypeWithComment.kt"); diff --git a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/casts/typeMismatchDefNonNullable2.kt b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/casts/typeMismatchDefNonNullable2.kt deleted file mode 100644 index 54fbd6ca6181..000000000000 --- a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/casts/typeMismatchDefNonNullable2.kt +++ /dev/null @@ -1,8 +0,0 @@ -// "class org.jetbrains.kotlin.idea.quickfix.CastExpressionFix" "false" -// LANGUAGE_VERSION: 1.7 -// ERROR: Type mismatch: inferred type is Collection but Collection was expected -fun foo(x: Collection) {} - -fun bar(x: Collection) { - foo(x) -} diff --git a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/parameterTypeMismatch/changeFunctionParameterTypeDefNonNullable1.kt b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/definitelyNonNullableTypes/changeFunctionParameterType1.kt similarity index 85% rename from plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/parameterTypeMismatch/changeFunctionParameterTypeDefNonNullable1.kt rename to plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/definitelyNonNullableTypes/changeFunctionParameterType1.kt index ce904fa83517..af3610476a1c 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/parameterTypeMismatch/changeFunctionParameterTypeDefNonNullable1.kt +++ b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/definitelyNonNullableTypes/changeFunctionParameterType1.kt @@ -1,5 +1,5 @@ // "Change parameter 'x' type of function 'bar' to 'T & Any'" "true" -// LANGUAGE_VERSION: 1.7 +// LANGUAGE_VERSION: 1.8 package a fun foo(x: T & Any) {} diff --git a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/parameterTypeMismatch/changeFunctionParameterTypeDefNonNullable1.kt.after b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/definitelyNonNullableTypes/changeFunctionParameterType1.kt.after similarity index 86% rename from plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/parameterTypeMismatch/changeFunctionParameterTypeDefNonNullable1.kt.after rename to plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/definitelyNonNullableTypes/changeFunctionParameterType1.kt.after index 20bbf736dc87..58bdc721f2d2 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/parameterTypeMismatch/changeFunctionParameterTypeDefNonNullable1.kt.after +++ b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/definitelyNonNullableTypes/changeFunctionParameterType1.kt.after @@ -1,5 +1,5 @@ // "Change parameter 'x' type of function 'bar' to 'T & Any'" "true" -// LANGUAGE_VERSION: 1.7 +// LANGUAGE_VERSION: 1.8 package a fun foo(x: T & Any) {} diff --git a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/parameterTypeMismatch/changeFunctionParameterTypeDefNonNullable2.kt b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/definitelyNonNullableTypes/changeFunctionParameterType2.kt similarity index 85% rename from plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/parameterTypeMismatch/changeFunctionParameterTypeDefNonNullable2.kt rename to plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/definitelyNonNullableTypes/changeFunctionParameterType2.kt index b50eb2b94279..3849fff1261c 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/parameterTypeMismatch/changeFunctionParameterTypeDefNonNullable2.kt +++ b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/definitelyNonNullableTypes/changeFunctionParameterType2.kt @@ -2,9 +2,10 @@ // ERROR: Type mismatch: inferred type is List but List was expected // ACTION: Add 'Any' as upper bound for T to make it non-nullable // ACTION: Add 'x =' to argument +// ACTION: Cast expression 'x' to 'List' // ACTION: Change parameter 'x' type of function 'foo' to 'List' // ACTION: Create function 'foo' -// LANGUAGE_VERSION: 1.7 +// LANGUAGE_VERSION: 1.8 package a fun foo(x: List) {} diff --git a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/definitelyNonNullableTypes/changePrimaryConstructorParameterType.kt b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/definitelyNonNullableTypes/changePrimaryConstructorParameterType.kt new file mode 100644 index 000000000000..f0123d01005b --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/definitelyNonNullableTypes/changePrimaryConstructorParameterType.kt @@ -0,0 +1,11 @@ +// "Change parameter 'x' type of primary constructor of class 'Foo' to 'T & Any'" "true" +// LANGUAGE_VERSION: 1.8 +package a + +class Foo(val x: T) { + fun foo(y: T & Any) {} +} + +fun Foo.bar(z: T) { + foo(x) +} diff --git a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/definitelyNonNullableTypes/changePrimaryConstructorParameterType.kt.after b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/definitelyNonNullableTypes/changePrimaryConstructorParameterType.kt.after new file mode 100644 index 000000000000..a7109f0e800c --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/definitelyNonNullableTypes/changePrimaryConstructorParameterType.kt.after @@ -0,0 +1,11 @@ +// "Change parameter 'x' type of primary constructor of class 'Foo' to 'T & Any'" "true" +// LANGUAGE_VERSION: 1.8 +package a + +class Foo(val x: T & Any) { + fun foo(y: T & Any) {} +} + +fun Foo.bar(z: T) { + foo(x) +} diff --git a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/definitelyNonNullableTypes/changeVariableType1.kt b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/definitelyNonNullableTypes/changeVariableType1.kt new file mode 100644 index 000000000000..9fafd8430f81 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/definitelyNonNullableTypes/changeVariableType1.kt @@ -0,0 +1,10 @@ +// "Change type of 'z' to 'T & Any'" "true" +// LANGUAGE_VERSION: 1.8 +package a + +fun foo(x: T & Any) {} + +fun bar(x: T & Any) { + val z: T = x + foo(z) +} diff --git a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/definitelyNonNullableTypes/changeVariableType1.kt.after b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/definitelyNonNullableTypes/changeVariableType1.kt.after new file mode 100644 index 000000000000..627d863121db --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/definitelyNonNullableTypes/changeVariableType1.kt.after @@ -0,0 +1,10 @@ +// "Change type of 'z' to 'T & Any'" "true" +// LANGUAGE_VERSION: 1.8 +package a + +fun foo(x: T & Any) {} + +fun bar(x: T & Any) { + val z: T & Any = x + foo(z) +} diff --git a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/casts/typeMismatchDefNonNullable1.kt b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/definitelyNonNullableTypes/changeVariableType2.kt similarity index 50% rename from plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/casts/typeMismatchDefNonNullable1.kt rename to plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/definitelyNonNullableTypes/changeVariableType2.kt index 2711e32a0f2b..7bc871654af5 100644 --- a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/casts/typeMismatchDefNonNullable1.kt +++ b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/definitelyNonNullableTypes/changeVariableType2.kt @@ -1,8 +1,11 @@ -// "class org.jetbrains.kotlin.idea.quickfix.CastExpressionFix" "false" -// LANGUAGE_VERSION: 1.7 +// "Change type of 'z' to 'T & Any'" "true" // ERROR: Type mismatch: inferred type is T but T & Any was expected +// LANGUAGE_VERSION: 1.8 +package a + fun foo(x: T & Any) {} fun bar(x: T) { - foo(x) + val z: T = x + foo(z) } diff --git a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/definitelyNonNullableTypes/changeVariableType2.kt.after b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/definitelyNonNullableTypes/changeVariableType2.kt.after new file mode 100644 index 000000000000..d3dd00ffe794 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/definitelyNonNullableTypes/changeVariableType2.kt.after @@ -0,0 +1,11 @@ +// "Change type of 'z' to 'T & Any'" "true" +// ERROR: Type mismatch: inferred type is T but T & Any was expected +// LANGUAGE_VERSION: 1.8 +package a + +fun foo(x: T & Any) {} + +fun bar(x: T) { + val z: T & Any = x + foo(z) +} diff --git a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/definitelyNonNullableTypes/explicitCast1.kt b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/definitelyNonNullableTypes/explicitCast1.kt new file mode 100644 index 000000000000..7d9c8b5f2c4d --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/definitelyNonNullableTypes/explicitCast1.kt @@ -0,0 +1,7 @@ +// "Cast expression 'x' to 'T & Any'" "true" +// LANGUAGE_VERSION: 1.8 +fun foo(x: T & Any) {} + +fun bar(x: T) { + foo(x) +} diff --git a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/definitelyNonNullableTypes/explicitCast1.kt.after b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/definitelyNonNullableTypes/explicitCast1.kt.after new file mode 100644 index 000000000000..d0f13adcd33d --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/definitelyNonNullableTypes/explicitCast1.kt.after @@ -0,0 +1,7 @@ +// "Cast expression 'x' to 'T & Any'" "true" +// LANGUAGE_VERSION: 1.8 +fun foo(x: T & Any) {} + +fun bar(x: T) { + foo(x as (T & Any)) +} diff --git a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/definitelyNonNullableTypes/explicitCast2.kt b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/definitelyNonNullableTypes/explicitCast2.kt new file mode 100644 index 000000000000..ca6cecd77656 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/definitelyNonNullableTypes/explicitCast2.kt @@ -0,0 +1,7 @@ +// "Cast expression 'x' to 'Collection'" "true" +// LANGUAGE_VERSION: 1.8 +fun foo(x: Collection) {} + +fun bar(x: Collection) { + foo(x) +} diff --git a/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/definitelyNonNullableTypes/explicitCast2.kt.after b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/definitelyNonNullableTypes/explicitCast2.kt.after new file mode 100644 index 000000000000..120ffd0b82e6 --- /dev/null +++ b/plugins/kotlin/idea/tests/testData/quickfix/typeMismatch/definitelyNonNullableTypes/explicitCast2.kt.after @@ -0,0 +1,7 @@ +// "Cast expression 'x' to 'Collection'" "true" +// LANGUAGE_VERSION: 1.8 +fun foo(x: Collection) {} + +fun bar(x: Collection) { + foo(x as Collection) +}