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:
Tianyu Geng
2021-12-07 15:19:05 -08:00
committed by teamcity
parent a5844b754e
commit 2f393cdd02
14 changed files with 102 additions and 2 deletions
@@ -0,0 +1,7 @@
fun test(a: Any) {
if (a is String) {
takeString(<expr>a</expr>)
}
}
fun takeString(s: String) {}
@@ -0,0 +1,2 @@
expression: a
type: kotlin.String
@@ -0,0 +1,5 @@
fun test(a: Any) {
if (a is String) {
<expr>a</expr>.length
}
}
@@ -0,0 +1,2 @@
expression: a
type: kotlin.String
@@ -0,0 +1,2 @@
expression: a
type: kotlin.Any
@@ -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()
}
}
@@ -0,0 +1,2 @@
expression: a
type: (A&B)
@@ -0,0 +1,2 @@
expression: a
type: kotlin.Any
@@ -0,0 +1,5 @@
fun test(a: Any) {
if (a is String) {
<expr>a</expr>
}
}
@@ -0,0 +1,2 @@
expression: a
type: kotlin.String