More precise diagnostics of smart cast impossible #KT-7240 Fixed
This commit is contained in:
@@ -92,7 +92,7 @@ public object RuntimeAssertionsTypeChecker : AdditionalTypeChecker {
|
||||
expressionType,
|
||||
object : RuntimeAssertionInfo.DataFlowExtras {
|
||||
override val canBeNull: Boolean
|
||||
get() = c.dataFlowInfo.getNullability(dataFlowValue).canBeNull()
|
||||
get() = c.dataFlowInfo.getPredictableNullability(dataFlowValue).canBeNull()
|
||||
override val possibleTypes: Set<KotlinType>
|
||||
get() = c.dataFlowInfo.getPossibleTypes(dataFlowValue)
|
||||
override val presentableText: String
|
||||
|
||||
+2
-2
@@ -71,7 +71,7 @@ public class JavaNullabilityWarningsChecker : AdditionalTypeChecker {
|
||||
if (TypeUtils.noExpectedType(expectedType)) return
|
||||
|
||||
val expectedMustNotBeNull = expectedType.mustNotBeNull()
|
||||
if (dataFlowInfo.getNullability(dataFlowValue) == Nullability.NOT_NULL) return
|
||||
if (dataFlowInfo.getPredictableNullability(dataFlowValue) == Nullability.NOT_NULL) return
|
||||
|
||||
val actualMayBeNull = expressionType.mayBeNull()
|
||||
|
||||
@@ -155,7 +155,7 @@ public class JavaNullabilityWarningsChecker : AdditionalTypeChecker {
|
||||
}
|
||||
|
||||
private fun <T: Any> doIfNotNull(dataFlowValue: DataFlowValue, c: ResolutionContext<*>, body: () -> T): T? {
|
||||
if (c.dataFlowInfo.getNullability(dataFlowValue).canBeNull()
|
||||
if (c.dataFlowInfo.getPredictableNullability(dataFlowValue).canBeNull()
|
||||
&& dataFlowValue.type.mustNotBeNull() == ErrorsJvm.NullabilityInformationSource.JAVA) {
|
||||
return body()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user