FIR DFA: smartcast variable to Nothing? on null assignment
In order to make resolution still work for members not available from `Nothing`, we track the type without `Nothing?` and use that for resolution instead.
This commit is contained in:
committed by
teamcityserver
parent
7e2f15f532
commit
4726dcce40
Vendored
+6
-3
@@ -1,3 +1,4 @@
|
||||
// FIR_IDE_IGNORE
|
||||
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
|
||||
// SKIP_TXT
|
||||
|
||||
@@ -10,13 +11,15 @@ fun case_1(value_1: Any?) {
|
||||
// TESTCASE NUMBER: 2
|
||||
fun case_2(value_1: Int?) {
|
||||
funWithReturnsAndInvertCondition(value_1 != null)
|
||||
println(value_1<!UNSAFE_CALL!>.<!>inc())
|
||||
println(value_1.inc()) // inc resolves to compiler/tests-spec/testData/diagnostics/helpers/classes.kt which accepts `Class?`
|
||||
println(value_1<!UNSAFE_CALL!>.<!>unaryPlus())
|
||||
}
|
||||
|
||||
// TESTCASE NUMBER: 3
|
||||
fun case_3(value_1: Int?) {
|
||||
funWithReturns(value_1 == null)
|
||||
println(value_1<!UNSAFE_CALL!>.<!>inc())
|
||||
println(value_1.inc()) // inc resolves to compiler/tests-spec/testData/diagnostics/helpers/classes.kt which accepts `Class?`
|
||||
println(value_1<!UNSAFE_CALL!>.<!>unaryPlus())
|
||||
}
|
||||
|
||||
// TESTCASE NUMBER: 4
|
||||
@@ -43,7 +46,7 @@ object case_7_object {
|
||||
}
|
||||
fun case_7() {
|
||||
funWithReturns(case_7_object.prop_1 == null)
|
||||
case_7_object.prop_1<!UNSAFE_CALL!>.<!>inc()
|
||||
case_7_object.prop_1.inc() // inc resolves to compiler/tests-spec/testData/diagnostics/helpers/classes.kt which accepts `Class?`
|
||||
}
|
||||
|
||||
// TESTCASE NUMBER: 8
|
||||
|
||||
+3
@@ -1,3 +1,4 @@
|
||||
// FIR_IDE_IGNORE
|
||||
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
|
||||
// SKIP_TXT
|
||||
|
||||
@@ -20,12 +21,14 @@ fun case_1(value_1: Any?) {
|
||||
fun case_2(value_1: Int?) {
|
||||
funWithReturnsAndInvertCondition(value_1 != null)
|
||||
println(value_1<!UNSAFE_CALL!>.<!>inc())
|
||||
println(value_1<!UNSAFE_CALL!>.<!>unaryPlus())
|
||||
}
|
||||
|
||||
// TESTCASE NUMBER: 3
|
||||
fun case_3(value_1: Int?) {
|
||||
funWithReturns(value_1 == null)
|
||||
println(value_1<!UNSAFE_CALL!>.<!>inc())
|
||||
println(value_1<!UNSAFE_CALL!>.<!>unaryPlus())
|
||||
}
|
||||
|
||||
// TESTCASE NUMBER: 4
|
||||
|
||||
Vendored
+1
-1
@@ -116,7 +116,7 @@ fun case_5(value_1: Number?, value_2: String?) {
|
||||
fun case_6(value_1: Number, value_2: String?, value_3: Any?) {
|
||||
when (value_3.case_6(value_1, value_2)) {
|
||||
true -> {
|
||||
println(value_3<!UNSAFE_CALL!>.<!>equals(""))
|
||||
println(value_3.equals("")) // OK because `value_3` is `Nothing?` and `equals` resolves to `kotlin/text/equals`, which has `String?` as receiver type.
|
||||
println(value_2<!UNSAFE_CALL!>.<!>length)
|
||||
}
|
||||
false -> {
|
||||
|
||||
+1
-1
@@ -126,7 +126,7 @@ fun case_5(value_1: Number?, value_2: String?) {
|
||||
fun case_6(value_1: Number, value_2: String?, value_3: Any?) {
|
||||
when (value_3.case_6(value_1, value_2)) {
|
||||
true -> {
|
||||
println(value_3.equals(""))
|
||||
println(value_3.equals("")) // OK because `value_3` is `Nothing?` and `equals` resolves to `kotlin/text/equals`, which has `String?` as receiver type.
|
||||
println(value_2<!UNSAFE_CALL!>.<!>length)
|
||||
}
|
||||
false -> {
|
||||
|
||||
Reference in New Issue
Block a user