[Analysis API] Handle missed cases in PsiElement.getExpectedType()
^KTIJ-24256
This commit is contained in:
committed by
teamcity
parent
7dd438cb9e
commit
3d0bca5ca1
+3
@@ -0,0 +1,3 @@
|
||||
fun test() {
|
||||
if (!a<caret>v)
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
expression: av
|
||||
expected type: null
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
class A {
|
||||
operator fun get(p1: Int) {}
|
||||
operator fun set(p1: String, p2: Int, value: Int) {}
|
||||
|
||||
fun d() = this[a<caret>v]
|
||||
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
expression: av
|
||||
expected type: KtUsualClassType:
|
||||
annotationsList: []
|
||||
ownTypeArguments: []
|
||||
type: kotlin/Int
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// IGNORE_FE10
|
||||
class A {
|
||||
operator fun <T> get(key: T) {}
|
||||
}
|
||||
|
||||
fun test(a: A) {
|
||||
a[a<caret>v]
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
expression: av
|
||||
expected type: KtTypeParameterType:
|
||||
annotationsList: []
|
||||
type: T
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
class A {
|
||||
operator fun get(p1: Int) {}
|
||||
operator fun set(p1: String, p2: Int, value: Int) {}
|
||||
|
||||
fun d() {
|
||||
this[a<caret>v, 2] = 1
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
expression: av
|
||||
expected type: KtUsualClassType:
|
||||
annotationsList: []
|
||||
ownTypeArguments: []
|
||||
type: kotlin/String
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
class A {
|
||||
operator fun <T> set(key: T, value: T) {}
|
||||
}
|
||||
|
||||
fun test(a: A) {
|
||||
a[a<caret>v] = 1
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
expression: av
|
||||
expected type: KtUsualClassType:
|
||||
annotationsList: []
|
||||
ownTypeArguments: []
|
||||
type: kotlin/Int
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
enum class E {
|
||||
A
|
||||
B
|
||||
}
|
||||
|
||||
fun foo(e: E) {
|
||||
when(e) {
|
||||
a<caret>v -> null
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
expression: av
|
||||
expected type: KtUsualClassType:
|
||||
annotationsList: []
|
||||
ownTypeArguments: []
|
||||
type: E
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
fun foo() {
|
||||
when() {
|
||||
a<caret>v -> null
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
expression: av
|
||||
expected type: KtUsualClassType:
|
||||
annotationsList: []
|
||||
ownTypeArguments: []
|
||||
type: kotlin/Boolean
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun foo() {
|
||||
val result: Int = a<caret>v ?: 1
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
expression: av
|
||||
expected type: KtUsualClassType:
|
||||
annotationsList: []
|
||||
ownTypeArguments: []
|
||||
type: kotlin/Int?
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun foo() {
|
||||
a<caret>v ?: 1
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
expression: av
|
||||
expected type: KtUsualClassType:
|
||||
annotationsList: []
|
||||
ownTypeArguments: []
|
||||
type: kotlin/Int?
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun foo(i: Int?) {
|
||||
val result: Int = i ?: a<caret>v
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
expression: av
|
||||
expected type: KtUsualClassType:
|
||||
annotationsList: []
|
||||
ownTypeArguments: []
|
||||
type: kotlin/Int
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun foo(i: Int?) {
|
||||
i ?: a<caret>v
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
expression: av
|
||||
expected type: KtUsualClassType:
|
||||
annotationsList: []
|
||||
ownTypeArguments: []
|
||||
type: kotlin/Int
|
||||
-4
@@ -1,4 +0,0 @@
|
||||
expression: av
|
||||
expected type: KtTypeErrorType:
|
||||
annotationsList: []
|
||||
type: ERROR_TYPE
|
||||
+1
-3
@@ -1,4 +1,2 @@
|
||||
expression: av
|
||||
expected type: KtClassErrorType:
|
||||
annotationsList: []
|
||||
type: ERROR_TYPE
|
||||
expected type: null
|
||||
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
expression: ab
|
||||
expected type: KtTypeParameterType:
|
||||
annotationsList: []
|
||||
type: T
|
||||
+3
-2
@@ -1,4 +1,5 @@
|
||||
expression: ab
|
||||
expected type: KtTypeParameterType:
|
||||
expected type: KtUsualClassType:
|
||||
annotationsList: []
|
||||
type: T
|
||||
ownTypeArguments: []
|
||||
type: kotlin/Int
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
fun x() {
|
||||
1 toCall a<caret>v
|
||||
}
|
||||
|
||||
infix fun <T> T.toCall(y: T) {}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
expression: av
|
||||
expected type: KtUsualClassType:
|
||||
annotationsList: []
|
||||
ownTypeArguments: []
|
||||
type: kotlin/Int
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun foo(): Int {
|
||||
a<caret>v
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
expression: av
|
||||
expected type: null
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// WITH_STDLIB
|
||||
// IGNORE_FE10
|
||||
fun foo(list: List<Int>) {
|
||||
val result: List<String> = list.map { a<caret>v }
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
expression: av
|
||||
expected type: KtUsualClassType:
|
||||
annotationsList: []
|
||||
ownTypeArguments: []
|
||||
type: kotlin/String
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// WITH_STDLIB
|
||||
fun foo(list: List<Int>) {
|
||||
val result: List<Int> = list.map { mapOf(a<caret>v) }
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
expression: av
|
||||
expected type: KtUsualClassType:
|
||||
annotationsList: []
|
||||
ownTypeArguments: [
|
||||
KtTypeParameterType:
|
||||
annotationsList: []
|
||||
type: K
|
||||
KtTypeParameterType:
|
||||
annotationsList: []
|
||||
type: V
|
||||
]
|
||||
type: kotlin/Pair<K, V>
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
// WITH_STDLIB
|
||||
fun foo(list: List<Int>) {
|
||||
val result = list.map { a<caret>v }
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
expression: av
|
||||
expected type: KtTypeParameterType:
|
||||
annotationsList: []
|
||||
type: R
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
fun foo() {
|
||||
val result: Int = try {
|
||||
a<caret>v
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
expression: av
|
||||
expected type: KtUsualClassType:
|
||||
annotationsList: []
|
||||
ownTypeArguments: []
|
||||
type: kotlin/Int
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
fun foo() {
|
||||
try {
|
||||
a<caret>v
|
||||
}
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
expression: av
|
||||
expected type: null
|
||||
-4
@@ -1,4 +0,0 @@
|
||||
expression: av
|
||||
expected type: KtTypeErrorType:
|
||||
annotationsList: []
|
||||
type: ERROR_TYPE
|
||||
+1
-3
@@ -1,4 +1,2 @@
|
||||
expression: av
|
||||
expected type: KtClassErrorType:
|
||||
annotationsList: []
|
||||
type: ERROR_TYPE
|
||||
expected type: null
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun foo() {
|
||||
val result = if (true) 1 else a<caret>v
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
expression: av
|
||||
expected type: KtUsualClassType:
|
||||
annotationsList: []
|
||||
ownTypeArguments: []
|
||||
type: kotlin/Int
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
fun foo() {
|
||||
val result = if (true) {
|
||||
1
|
||||
} else {
|
||||
a<caret>v
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
expression: av
|
||||
expected type: KtUsualClassType:
|
||||
annotationsList: []
|
||||
ownTypeArguments: []
|
||||
type: kotlin/Int
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun foo() {
|
||||
if (true) a<caret>v else 1
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
expression: av
|
||||
expected type: KtUsualClassType:
|
||||
annotationsList: []
|
||||
ownTypeArguments: []
|
||||
type: kotlin/Int
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
enum class E {
|
||||
A
|
||||
B
|
||||
}
|
||||
|
||||
fun foo(e: E) {
|
||||
val result = when(e) {
|
||||
E.A -> 1
|
||||
E.B -> a<caret>v
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
expression: av
|
||||
expected type: KtUsualClassType:
|
||||
annotationsList: []
|
||||
ownTypeArguments: []
|
||||
type: kotlin/Int
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
enum class E {
|
||||
A
|
||||
B
|
||||
}
|
||||
|
||||
fun foo(e: E) {
|
||||
val result = when(e) {
|
||||
E.A -> { 1 }
|
||||
E.B -> { a<caret>v }
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
expression: av
|
||||
expected type: KtUsualClassType:
|
||||
annotationsList: []
|
||||
ownTypeArguments: []
|
||||
type: kotlin/Int
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
enum class E {
|
||||
A
|
||||
B
|
||||
C
|
||||
D
|
||||
}
|
||||
|
||||
fun foo(e: E) = when (e) {
|
||||
E.A -> 1
|
||||
E.B -> ""
|
||||
E.C -> a<caret>v
|
||||
E.D -> unresolved
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
expression: av
|
||||
expected type: KtUsualClassType:
|
||||
annotationsList: []
|
||||
ownTypeArguments: []
|
||||
type: kotlin/Any
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// IGNORE_FE10
|
||||
class A {
|
||||
operator fun <T> set(key: Int, value: T) {}
|
||||
}
|
||||
|
||||
fun test(a: A) {
|
||||
<expr>a[1]</expr> = ""
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
expression: a[1]
|
||||
type: kotlin.String
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
expression: xy
|
||||
expected type: (T) -> R
|
||||
functionClassKind: kotlin.FunctionN
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
expression: xy
|
||||
expected type: (T) -> R
|
||||
expected type: (kotlin.Int) -> R
|
||||
functionClassKind: kotlin.FunctionN
|
||||
|
||||
Reference in New Issue
Block a user