diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestGenerated.java index 48b52692805..36ca6647f4a 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestGenerated.java @@ -19071,6 +19071,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte runTest("compiler/testData/diagnostics/tests/regressions/propertyWithExtensionTypeInvoke.kt"); } + @TestMetadata("resolveCollectionLiteralInsideLambda.kt") + public void testResolveCollectionLiteralInsideLambda() throws Exception { + runTest("compiler/testData/diagnostics/tests/regressions/resolveCollectionLiteralInsideLambda.kt"); + } + @TestMetadata("resolveSubclassOfList.kt") public void testResolveSubclassOfList() throws Exception { runTest("compiler/testData/diagnostics/tests/regressions/resolveSubclassOfList.kt"); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/CollectionLiteralResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/CollectionLiteralResolver.kt index 6b357d83556..4a98fa90c94 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/CollectionLiteralResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/CollectionLiteralResolver.kt @@ -23,7 +23,7 @@ import org.jetbrains.kotlin.resolve.BindingContext.COLLECTION_LITERAL_CALL import org.jetbrains.kotlin.resolve.calls.CallResolver import org.jetbrains.kotlin.resolve.calls.util.CallMaker import org.jetbrains.kotlin.types.KotlinType -import org.jetbrains.kotlin.types.TypeUtils.NO_EXPECTED_TYPE +import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext import org.jetbrains.kotlin.types.expressions.KotlinTypeInfo import org.jetbrains.kotlin.types.expressions.typeInfoFactory.createTypeInfo @@ -94,7 +94,7 @@ class CollectionLiteralResolver( } private fun getArrayFunctionCallName(expectedType: KotlinType): Name { - if (NO_EXPECTED_TYPE === expectedType || + if (TypeUtils.noExpectedType(expectedType) || !(KotlinBuiltIns.isPrimitiveArray(expectedType) || KotlinBuiltIns.isUnsignedArrayType(expectedType)) ) { return ArrayFqNames.ARRAY_OF_FUNCTION diff --git a/compiler/testData/diagnostics/tests/regressions/resolveCollectionLiteralInsideLambda.fir.kt b/compiler/testData/diagnostics/tests/regressions/resolveCollectionLiteralInsideLambda.fir.kt new file mode 100644 index 00000000000..00fae356ed0 --- /dev/null +++ b/compiler/testData/diagnostics/tests/regressions/resolveCollectionLiteralInsideLambda.fir.kt @@ -0,0 +1,7 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + +fun foo(l: () -> Unit) {} +fun bar(l: () -> String) {} + +val a = foo { [] } +val b = bar { [] } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/regressions/resolveCollectionLiteralInsideLambda.kt b/compiler/testData/diagnostics/tests/regressions/resolveCollectionLiteralInsideLambda.kt new file mode 100644 index 00000000000..a3fa7cfc78c --- /dev/null +++ b/compiler/testData/diagnostics/tests/regressions/resolveCollectionLiteralInsideLambda.kt @@ -0,0 +1,7 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + +fun foo(l: () -> Unit) {} +fun bar(l: () -> String) {} + +val a = foo { [] } +val b = bar { [] } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/regressions/resolveCollectionLiteralInsideLambda.txt b/compiler/testData/diagnostics/tests/regressions/resolveCollectionLiteralInsideLambda.txt new file mode 100644 index 00000000000..edb024773b7 --- /dev/null +++ b/compiler/testData/diagnostics/tests/regressions/resolveCollectionLiteralInsideLambda.txt @@ -0,0 +1,6 @@ +package + +public val a: kotlin.Unit +public val b: kotlin.Unit +public fun bar(/*0*/ l: () -> kotlin.String): kotlin.Unit +public fun foo(/*0*/ l: () -> kotlin.Unit): kotlin.Unit diff --git a/compiler/tests-gen/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index 0b9c4617760..427baf31113 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -19083,6 +19083,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTestWithFirVali runTest("compiler/testData/diagnostics/tests/regressions/propertyWithExtensionTypeInvoke.kt"); } + @TestMetadata("resolveCollectionLiteralInsideLambda.kt") + public void testResolveCollectionLiteralInsideLambda() throws Exception { + runTest("compiler/testData/diagnostics/tests/regressions/resolveCollectionLiteralInsideLambda.kt"); + } + @TestMetadata("resolveSubclassOfList.kt") public void testResolveSubclassOfList() throws Exception { runTest("compiler/testData/diagnostics/tests/regressions/resolveSubclassOfList.kt"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java index 8f13c7f2b56..0f50aa981ae 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java @@ -19073,6 +19073,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing runTest("compiler/testData/diagnostics/tests/regressions/propertyWithExtensionTypeInvoke.kt"); } + @TestMetadata("resolveCollectionLiteralInsideLambda.kt") + public void testResolveCollectionLiteralInsideLambda() throws Exception { + runTest("compiler/testData/diagnostics/tests/regressions/resolveCollectionLiteralInsideLambda.kt"); + } + @TestMetadata("resolveSubclassOfList.kt") public void testResolveSubclassOfList() throws Exception { runTest("compiler/testData/diagnostics/tests/regressions/resolveSubclassOfList.kt");