FIR IDE: Use KtFirExpressionTypeProvider.getExpectedType() in

ReplaceCallFix.
This commit is contained in:
Mark Punzalan
2021-03-19 00:01:54 +00:00
committed by Ilya Kirillov
parent e9298d1d71
commit 062adf21de
18 changed files with 118 additions and 25 deletions
@@ -0,0 +1,6 @@
// "Replace with safe (?.) call" "true"
// WITH_RUNTIME
class T(s: String?) {
var i = s<caret>.length
}
/* FIR_COMPARISON */
@@ -0,0 +1,6 @@
// "Replace with safe (?.) call" "true"
// WITH_RUNTIME
class T(s: String?) {
var i = s?.length
}
/* FIR_COMPARISON */
@@ -0,0 +1,6 @@
// "Replace with safe (?.) call" "true"
// WITH_RUNTIME
class T(s: String?) {
var i = s?.length ?: <caret>
}
/* FIR_COMPARISON */
+1 -2
View File
@@ -5,5 +5,4 @@ fun foo(a: String?) {
// comment2
.<caret>length
}
// FIR_IDENTICAL
/* FIR_COMPARISON */
/* FIR_COMPARISON */
@@ -5,5 +5,4 @@ fun foo(a: String?) {
// comment2
?.length
}
// FIR_IDENTICAL
/* FIR_COMPARISON */
/* FIR_COMPARISON */
@@ -0,0 +1,8 @@
// "Replace with safe (?.) call" "true"
// WITH_RUNTIME
fun foo(a: String?) {
val b = a // comment1
// comment2
?.length ?: <caret>
}
/* FIR_COMPARISON */
@@ -0,0 +1,9 @@
// "Replace with safe (?.) call" "true"
// WITH_RUNTIME
// ERROR: Type mismatch: inferred type is Int? but Int was expected
// Note: There should be no error in FIR but errors are not currently checked for FIR
class T {
fun foo(s: String?): Int = s<caret>.length
}
/* FIR_COMPARISON */
@@ -0,0 +1,9 @@
// "Replace with safe (?.) call" "true"
// WITH_RUNTIME
// ERROR: Type mismatch: inferred type is Int? but Int was expected
// Note: There should be no error in FIR but errors are not currently checked for FIR
class T {
fun foo(s: String?): Int = s?.length
}
/* FIR_COMPARISON */
@@ -0,0 +1,9 @@
// "Replace with safe (?.) call" "true"
// WITH_RUNTIME
// ERROR: Type mismatch: inferred type is Int? but Int was expected
// Note: There should be no error in FIR but errors are not currently checked for FIR
class T {
fun foo(s: String?): Int = s?.length ?: <caret>
}
/* FIR_COMPARISON */
@@ -0,0 +1,6 @@
// "Replace with safe (?.) call" "true"
// WITH_RUNTIME
class T {
fun foo(s: String?) = s<caret>.length
}
/* FIR_COMPARISON */
@@ -0,0 +1,6 @@
// "Replace with safe (?.) call" "true"
// WITH_RUNTIME
class T {
fun foo(s: String?) = s?.length
}
/* FIR_COMPARISON */
@@ -0,0 +1,6 @@
// "Replace with safe (?.) call" "true"
// WITH_RUNTIME
class T {
fun foo(s: String?) = s?.length ?: <caret>
}
/* FIR_COMPARISON */
+1 -2
View File
@@ -4,5 +4,4 @@ fun foo(a: String?) {
val b = a
.<caret>length
}
// FIR_IDENTICAL
/* FIR_COMPARISON */
/* FIR_COMPARISON */
@@ -4,5 +4,4 @@ fun foo(a: String?) {
val b = a
?.length
}
// FIR_IDENTICAL
/* FIR_COMPARISON */
/* FIR_COMPARISON */
@@ -0,0 +1,7 @@
// "Replace with safe (?.) call" "true"
// WITH_RUNTIME
fun foo(a: String?) {
val b = a
?.length ?: <caret>
}
/* FIR_COMPARISON */