[FIR] Create error type instead of implicit type for incorrect functional types

This commit is contained in:
Dmitriy Novozhilov
2019-11-11 12:08:56 +03:00
parent cf61a6c30f
commit 2f2aa4ae83
4 changed files with 23 additions and 1 deletions
@@ -856,7 +856,7 @@ class RawFirBuilder(session: FirSession, val stubMode: Boolean) : BaseFirBuilder
isNullable,
unwrappedElement.receiverTypeReference.convertSafe(),
// TODO: probably implicit type should not be here
unwrappedElement.returnTypeReference.toFirOrImplicitType()
unwrappedElement.returnTypeReference.toFirOrErrorType()
)
for (valueParameter in unwrappedElement.parameters) {
functionType.valueParameters += valueParameter.convert<FirValueParameter>()
@@ -0,0 +1,7 @@
fun foo(func: (Int).Int -> Int) {}
fun test() {
<!INAPPLICABLE_CANDIDATE!>foo<!> {
this + <!UNRESOLVED_REFERENCE!>it<!>
}
}
@@ -0,0 +1,10 @@
FILE: incorrectFunctionalType.kt
public final fun foo(func: R|kotlin/Int.() -> class error: Incomplete code|, Int: <implicit>): R|kotlin/Unit|
fun <anonymous>(): R|kotlin/Unit| {
}
public final fun test(): R|kotlin/Unit| {
<Inapplicable(PARAMETER_MAPPING_ERROR): [/foo]>#(<L> = foo@fun <implicit>.<anonymous>(): R|kotlin/String| {
this#.R|kotlin/plus|(<Unresolved name: it>#)
}
)
}
@@ -240,6 +240,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest {
runTest("compiler/fir/resolve/testData/resolve/arguments/fieldPlusAssign.kt");
}
@TestMetadata("incorrectFunctionalType.kt")
public void testIncorrectFunctionalType() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/arguments/incorrectFunctionalType.kt");
}
@TestMetadata("invoke.kt")
public void testInvoke() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/arguments/invoke.kt");