[FIR] Disable not null checks on dynamics
It looks like K1 doesn't do them.
And it's not particularly bad because
in the ideal world we'd have dynamics
with variable upper bound so that
in `dynamic?.let { it }` `it` would
be `Nothing..Any` (smartcasting to
`Any` is not correct because `dynamic`
can be passed into anything, but `Any`
can not).
^KT-63071
This commit is contained in:
committed by
Space Team
parent
875e2b0cd6
commit
d5fa755e63
+9
-2
@@ -943,6 +943,7 @@ open class FirExpressionsResolveTransformer(transformer: FirAbstractBodyResolveT
|
||||
return transformOtherChildren(transformer, ResolutionMode.ContextIndependent)
|
||||
}
|
||||
|
||||
@OptIn(UnresolvedExpressionTypeAccess::class)
|
||||
override fun transformCheckNotNullCall(
|
||||
checkNotNullCall: FirCheckNotNullCall,
|
||||
data: ResolutionMode,
|
||||
@@ -955,7 +956,10 @@ open class FirExpressionsResolveTransformer(transformer: FirAbstractBodyResolveT
|
||||
return checkNotNullCall
|
||||
}
|
||||
|
||||
dataFlowAnalyzer.enterCheckNotNullCall()
|
||||
if (checkNotNullCall.arguments.firstOrNull()?.coneTypeOrNull !is ConeDynamicType) {
|
||||
dataFlowAnalyzer.enterCheckNotNullCall()
|
||||
}
|
||||
|
||||
checkNotNullCall
|
||||
.transformAnnotations(transformer, ResolutionMode.ContextIndependent)
|
||||
.replaceArgumentList(checkNotNullCall.argumentList.transform(transformer, ResolutionMode.ContextDependent))
|
||||
@@ -964,7 +968,10 @@ open class FirExpressionsResolveTransformer(transformer: FirAbstractBodyResolveT
|
||||
components.syntheticCallGenerator.generateCalleeForCheckNotNullCall(checkNotNullCall, resolutionContext), data
|
||||
)
|
||||
|
||||
dataFlowAnalyzer.exitCheckNotNullCall(result, data.forceFullCompletion)
|
||||
if (checkNotNullCall.arguments.firstOrNull()?.coneTypeOrNull !is ConeDynamicType) {
|
||||
dataFlowAnalyzer.exitCheckNotNullCall(result, data.forceFullCompletion)
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ fun test(d: dynamic) {
|
||||
d!!.<!DEBUG_INFO_DYNAMIC!>onAnyVal<!>
|
||||
}
|
||||
run {
|
||||
d!!.<!UNRESOLVED_REFERENCE!>onAnyVal<!> = 1
|
||||
d!!.<!DEBUG_INFO_DYNAMIC!>onAnyVal<!> = 1
|
||||
}
|
||||
|
||||
d.<!DEBUG_INFO_DYNAMIC!>onNullableAnyVal<!> = 1
|
||||
|
||||
+2
-2
@@ -13,7 +13,7 @@ fun test(d: dynamic) {
|
||||
|
||||
}
|
||||
run {
|
||||
d!!.<!UNRESOLVED_REFERENCE!>onAnyVar<!> = 1
|
||||
d!!.<!DEBUG_INFO_DYNAMIC!>onAnyVar<!> = 1
|
||||
}
|
||||
|
||||
d.<!DEBUG_INFO_DYNAMIC!>onNullableAnyVar<!> = 1
|
||||
@@ -22,7 +22,7 @@ fun test(d: dynamic) {
|
||||
|
||||
d.<!DEBUG_INFO_DYNAMIC!>onDynamicVar<!> = 1
|
||||
|
||||
d?.<!DYNAMIC_RECEIVER_EXPECTED_BUT_WAS_NON_DYNAMIC!>onDynamicVar<!> = 1
|
||||
d?.<!DEBUG_INFO_DYNAMIC!>onDynamicVar<!> = 1
|
||||
|
||||
(d as String).onStringVar
|
||||
(d as Any).onAnyVar
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ fun test(d: dynamic) {
|
||||
d.<!DEBUG_INFO_DYNAMIC!>onString<!>()
|
||||
|
||||
d.<!DEBUG_INFO_DYNAMIC!>onDynamic<!>()
|
||||
d?.<!DYNAMIC_RECEIVER_EXPECTED_BUT_WAS_NON_DYNAMIC!>onDynamic<!>()
|
||||
d?.<!DEBUG_INFO_DYNAMIC!>onDynamic<!>()
|
||||
|
||||
(d as String).onString()
|
||||
(d as Any).onAny()
|
||||
|
||||
Reference in New Issue
Block a user