FE1.0 Analysis API: get smartcast if available with getKtExpressionType
The current implementation still does not work with multicast. In addition, it appears FE1.0 does not attempt smart cast if it's not used.
This commit is contained in:
+7
@@ -0,0 +1,7 @@
|
||||
fun test(a: Any) {
|
||||
if (a is String) {
|
||||
takeString(<expr>a</expr>)
|
||||
}
|
||||
}
|
||||
|
||||
fun takeString(s: String) {}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
expression: a
|
||||
type: kotlin.String
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
fun test(a: Any) {
|
||||
if (a is String) {
|
||||
<expr>a</expr>.length
|
||||
}
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
expression: a
|
||||
type: kotlin.String
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
expression: a
|
||||
type: kotlin.Any
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
interface A
|
||||
interface B
|
||||
|
||||
fun <T> T.take() where T: A, T: B {}
|
||||
|
||||
fun test(a: Any) {
|
||||
if (a is A && a is B) {
|
||||
<expr>a</expr>.take()
|
||||
}
|
||||
}
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
expression: a
|
||||
type: (A&B)
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
expression: a
|
||||
type: kotlin.Any
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
fun test(a: Any) {
|
||||
if (a is String) {
|
||||
<expr>a</expr>
|
||||
}
|
||||
}
|
||||
analysis/analysis-api/testData/components/expressionTypeProvider/expressionType/smartcast_unused.txt
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
expression: a
|
||||
type: kotlin.String
|
||||
Reference in New Issue
Block a user