no report 'UNNECESSARY_NOT_NULL_ASSERTION' on error types
This commit is contained in:
+1
-1
@@ -885,7 +885,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
return typeInfo;
|
return typeInfo;
|
||||||
}
|
}
|
||||||
DataFlowInfo dataFlowInfo = typeInfo.getDataFlowInfo();
|
DataFlowInfo dataFlowInfo = typeInfo.getDataFlowInfo();
|
||||||
if (isKnownToBeNotNull(baseExpression, context)) {
|
if (isKnownToBeNotNull(baseExpression, context) && !ErrorUtils.isErrorType(type)) {
|
||||||
context.trace.report(UNNECESSARY_NOT_NULL_ASSERTION.on(operationSign, type));
|
context.trace.report(UNNECESSARY_NOT_NULL_ASSERTION.on(operationSign, type));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
package a
|
||||||
|
|
||||||
|
fun foo() {
|
||||||
|
bar()!!
|
||||||
|
}
|
||||||
|
|
||||||
|
fun bar() = <!UNRESOLVED_REFERENCE!>aa<!>
|
||||||
@@ -2098,6 +2098,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
|
|||||||
doTest("compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt362.kt");
|
doTest("compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt362.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("noUnnecessaryNotNullAssertionOnErrorType.kt")
|
||||||
|
public void testNoUnnecessaryNotNullAssertionOnErrorType() throws Exception {
|
||||||
|
doTest("compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/noUnnecessaryNotNullAssertionOnErrorType.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("NullableNothingIsExactlyNull.kt")
|
@TestMetadata("NullableNothingIsExactlyNull.kt")
|
||||||
public void testNullableNothingIsExactlyNull() throws Exception {
|
public void testNullableNothingIsExactlyNull() throws Exception {
|
||||||
doTest("compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/NullableNothingIsExactlyNull.kt");
|
doTest("compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/NullableNothingIsExactlyNull.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user