Do not report UNNECESSARY_SAFE_CALL on ErrorType
This commit is contained in:
committed by
TeamCityServer
parent
59551eb037
commit
e2b7aba086
+6
@@ -686,6 +686,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
|||||||
runTest("compiler/testData/diagnostics/tests/SafeCallOnSuperReceiver.kt");
|
runTest("compiler/testData/diagnostics/tests/SafeCallOnSuperReceiver.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("SafeCallUnknownType.kt")
|
||||||
|
public void testSafeCallUnknownType() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/SafeCallUnknownType.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("Serializable.kt")
|
@TestMetadata("Serializable.kt")
|
||||||
public void testSerializable() throws Exception {
|
public void testSerializable() throws Exception {
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices
|
|||||||
import org.jetbrains.kotlin.types.expressions.KotlinTypeInfo
|
import org.jetbrains.kotlin.types.expressions.KotlinTypeInfo
|
||||||
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.createTypeInfo
|
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.createTypeInfo
|
||||||
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.noTypeInfo
|
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.noTypeInfo
|
||||||
|
import org.jetbrains.kotlin.types.isError
|
||||||
import org.jetbrains.kotlin.types.refinement.TypeRefinement
|
import org.jetbrains.kotlin.types.refinement.TypeRefinement
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@@ -534,15 +535,17 @@ class CallExpressionResolver(
|
|||||||
} ?: false
|
} ?: false
|
||||||
|
|
||||||
fun reportUnnecessarySafeCall(
|
fun reportUnnecessarySafeCall(
|
||||||
trace: BindingTrace, type: KotlinType,
|
trace: BindingTrace,
|
||||||
callOperationNode: ASTNode, explicitReceiver: Receiver?
|
type: KotlinType,
|
||||||
) = trace.report(
|
callOperationNode: ASTNode,
|
||||||
|
explicitReceiver: Receiver?
|
||||||
|
) {
|
||||||
if (explicitReceiver is ExpressionReceiver && explicitReceiver.expression is KtSuperExpression) {
|
if (explicitReceiver is ExpressionReceiver && explicitReceiver.expression is KtSuperExpression) {
|
||||||
UNEXPECTED_SAFE_CALL.on(callOperationNode.psi)
|
trace.report(UNEXPECTED_SAFE_CALL.on(callOperationNode.psi))
|
||||||
} else {
|
} else if (!type.isError) {
|
||||||
UNNECESSARY_SAFE_CALL.on(callOperationNode.psi, type)
|
trace.report(UNNECESSARY_SAFE_CALL.on(callOperationNode.psi, type))
|
||||||
}
|
}
|
||||||
)
|
}
|
||||||
|
|
||||||
private fun checkNestedClassAccess(
|
private fun checkNestedClassAccess(
|
||||||
expression: KtQualifiedExpression,
|
expression: KtQualifiedExpression,
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
import com.unknown
|
||||||
|
|
||||||
|
fun ff() {
|
||||||
|
val a = <!UNRESOLVED_REFERENCE!>unknown<!>()
|
||||||
|
val b = a?.plus(42)
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
// !WITH_NEW_INFERENCE
|
||||||
|
import <!UNRESOLVED_REFERENCE!>com<!>.<!DEBUG_INFO_MISSING_UNRESOLVED!>unknown<!>
|
||||||
|
|
||||||
|
fun ff() {
|
||||||
|
val a = <!UNRESOLVED_REFERENCE!>unknown<!>()
|
||||||
|
val <!UNUSED_VARIABLE!>b<!> = <!TYPE_MISMATCH{OI}!><!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>a<!>?.<!DEBUG_INFO_MISSING_UNRESOLVED!>plus<!>(42)<!>
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public fun ff(): kotlin.Unit
|
||||||
Generated
+6
@@ -686,6 +686,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
|||||||
runTest("compiler/testData/diagnostics/tests/SafeCallOnSuperReceiver.kt");
|
runTest("compiler/testData/diagnostics/tests/SafeCallOnSuperReceiver.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("SafeCallUnknownType.kt")
|
||||||
|
public void testSafeCallUnknownType() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/SafeCallUnknownType.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("Serializable.kt")
|
@TestMetadata("Serializable.kt")
|
||||||
public void testSerializable() throws Exception {
|
public void testSerializable() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user