CANNOT_INFER_PARAMETER_TYPE reporting improvement
This commit is contained in:
+4
-1
@@ -23,6 +23,7 @@ import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.*;
|
||||
import org.jetbrains.jet.lang.resolve.calls.CallResolverUtil;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
@@ -236,11 +237,13 @@ public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor {
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (expectedType == null || expectedType == CallResolverUtil.DONT_CARE || expectedType == CallResolverUtil.CANT_INFER) {
|
||||
context.trace.report(CANNOT_INFER_PARAMETER_TYPE.on(declaredParameter));
|
||||
}
|
||||
if (expectedType != null) {
|
||||
type = expectedType;
|
||||
}
|
||||
else {
|
||||
context.trace.report(CANNOT_INFER_PARAMETER_TYPE.on(declaredParameter));
|
||||
type = ErrorUtils.createErrorType("Cannot be inferred");
|
||||
}
|
||||
}
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package aa
|
||||
|
||||
fun <T, R> foo(block: (T)-> R) = block
|
||||
|
||||
fun test1() {
|
||||
<!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>foo<!> {
|
||||
<!CANNOT_INFER_PARAMETER_TYPE!>x<!> -> // here we have 'cannot infer parameter type' error
|
||||
43
|
||||
}
|
||||
}
|
||||
|
||||
fun bar(<!UNUSED_PARAMETER!>f<!>: (<!UNRESOLVED_REFERENCE!>A<!>)->Unit) {}
|
||||
|
||||
fun test2() {
|
||||
bar { a -> } // here we don't have 'cannot infer parameter type' error
|
||||
}
|
||||
@@ -2265,6 +2265,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/diagnostics/tests/inference/reportingImprovements"), "kt", true);
|
||||
}
|
||||
|
||||
@TestMetadata("cannotInferParameterTypeWithInference.kt")
|
||||
public void testCannotInferParameterTypeWithInference() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/inference/reportingImprovements/cannotInferParameterTypeWithInference.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("NoAmbiguityForDifferentFunctionTypes.kt")
|
||||
public void testNoAmbiguityForDifferentFunctionTypes() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/inference/reportingImprovements/NoAmbiguityForDifferentFunctionTypes.kt");
|
||||
|
||||
Reference in New Issue
Block a user