提交 1f5cc059 编写于 作者: D Derek Alexander 提交者: Stanislav Erokhin

Fix compiler failure related NO_EXPECTED_TYPE

Changes to turn KT-16016 into a compiler diagnostic error rather than a
stack trace

#KT-16016 Fixed
上级 ace3bfbb
......@@ -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))
}
......
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
val la = { <!CANNOT_INFER_PARAMETER_TYPE, UNUSED_ANONYMOUS_PARAMETER!>a<!> -> }
val las = { <!UNUSED_ANONYMOUS_PARAMETER!>a<!>: Int -> }
val larg = { <!CANNOT_INFER_PARAMETER_TYPE, UNUSED_ANONYMOUS_PARAMETER!>a<!> -> }(123)
val twoarg = { <!CANNOT_INFER_PARAMETER_TYPE, UNUSED_ANONYMOUS_PARAMETER!>a<!>, <!UNUSED_ANONYMOUS_PARAMETER!>b<!>: String, <!CANNOT_INFER_PARAMETER_TYPE, UNUSED_ANONYMOUS_PARAMETER!>c<!> -> }(123, "asdf", 123)
\ No newline at end of file
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
......@@ -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");
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册