diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/FunctionDescriptorResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/FunctionDescriptorResolver.kt index 9d30768dedb..e9b1be0fcc3 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/FunctionDescriptorResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/FunctionDescriptorResolver.kt @@ -336,12 +336,12 @@ class FunctionDescriptorResolver( for (i in valueParameters.indices) { val valueParameter = valueParameters[i] val typeReference = valueParameter.typeReference - val expectedType = expectedParameterTypes?.let { if (i < it.size) it[i] else null } + val expectedType = expectedParameterTypes?.let { if (i < it.size) it[i] else null }?.takeUnless { TypeUtils.noExpectedType(it) } val type: KotlinType if (typeReference != null) { type = typeResolver.resolveType(parameterScope, typeReference, trace, true) - if (expectedType != null && !TypeUtils.noExpectedType(expectedType)) { + if (expectedType != null) { if (!KotlinTypeChecker.DEFAULT.isSubtypeOf(expectedType, type)) { trace.report(EXPECTED_PARAMETER_TYPE_MISMATCH.on(valueParameter, expectedType)) } diff --git a/compiler/testData/diagnostics/tests/functionLiterals/kt16016.kt b/compiler/testData/diagnostics/tests/functionLiterals/kt16016.kt new file mode 100644 index 00000000000..5dca17550b6 --- /dev/null +++ b/compiler/testData/diagnostics/tests/functionLiterals/kt16016.kt @@ -0,0 +1,6 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE +val la = { a -> } +val las = { a: Int -> } + +val larg = { a -> }(123) +val twoarg = { a, b: String, c -> }(123, "asdf", 123) \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/functionLiterals/kt16016.txt b/compiler/testData/diagnostics/tests/functionLiterals/kt16016.txt new file mode 100644 index 00000000000..afdcb89bf56 --- /dev/null +++ b/compiler/testData/diagnostics/tests/functionLiterals/kt16016.txt @@ -0,0 +1,6 @@ +package + +public val la: (???) -> kotlin.Unit +public val larg: kotlin.Unit +public val las: (kotlin.Int) -> kotlin.Unit +public val twoarg: kotlin.Unit \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index c9ce97f54a1..f960468bc2f 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -8209,6 +8209,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { doTest(fileName); } + @TestMetadata("kt16016.kt") + public void testKt16016() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/functionLiterals/kt16016.kt"); + doTest(fileName); + } + @TestMetadata("kt2906.kt") public void testKt2906() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/functionLiterals/kt2906.kt");