fab6cec93a
This makes it more consistent and fixes some overlooked corner cases. Also it was decided on the last equality applicability DM (KT-62646) that we'd like `is`/`!is`/`as`/`as?` to work similarly to `===`/`!==`. Also note that it now gives a clearer explaination of why some corner cases work the way they do. For example, `FirPsiDiagnosticTestGenerated.testLambdaInLhsOfTypeOperatorCall` yields `UNCHECKED_CAST` instead of `CAST_NEVER_SUCCEEDS`, because `toTypeInfo()` replaces all type arguments with star projections, even when the argument is not a type parameter. This is because it has been desided to work this way in KT-57779. In `FirPsiOldFrontendDiagnosticsTestGenerated..NeverSucceeds#testNoGenericsRelated` the diagnostic is introduced, because `t2 as FC1` and `FC1` is a final class with no `T5` supertype. `UNCHECKED_CAST` in `FirPsiOldFrontendDiagnosticsTestGenerated.testSmartCast` disappeared, because previously we didn't take smartcasts into account. Note that `FirPsiOldFrontendDiagnosticsTestGenerated.testMappedSubtypes` is a false positive. It appears because `isSubtypeOf()` doesn't take into account platform types in supertypes of the given types (doesn't map them).
85 lines
1.8 KiB
Kotlin
Vendored
85 lines
1.8 KiB
Kotlin
Vendored
// !DUMP_CFG
|
|
class A {
|
|
fun foo() {}
|
|
}
|
|
|
|
class B {
|
|
fun bar() {}
|
|
}
|
|
|
|
fun <T> T.with(block: T.() -> Unit) {}
|
|
|
|
fun Any?.test_1() {
|
|
if (this is A) {
|
|
this.foo()
|
|
foo()
|
|
} else {
|
|
this.<!UNRESOLVED_REFERENCE!>foo<!>()
|
|
<!UNRESOLVED_REFERENCE!>foo<!>()
|
|
}
|
|
this.<!UNRESOLVED_REFERENCE!>foo<!>()
|
|
<!UNRESOLVED_REFERENCE!>foo<!>()
|
|
}
|
|
|
|
fun Any?.test_2() {
|
|
if (this !is A) {
|
|
this.<!UNRESOLVED_REFERENCE!>foo<!>()
|
|
<!UNRESOLVED_REFERENCE!>foo<!>()
|
|
} else {
|
|
this.foo()
|
|
foo()
|
|
}
|
|
this.<!UNRESOLVED_REFERENCE!>foo<!>()
|
|
<!UNRESOLVED_REFERENCE!>foo<!>()
|
|
}
|
|
|
|
fun test_3(a: Any, b: Any, c: Any) {
|
|
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>with<!>(a) wa@{
|
|
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>with<!>(b) wb@{
|
|
with(c) wc@{
|
|
this@wb as A
|
|
this@wb.foo()
|
|
foo()
|
|
}
|
|
this.<!UNRESOLVED_REFERENCE!>foo<!>()
|
|
<!UNRESOLVED_REFERENCE!>foo<!>()
|
|
}
|
|
}
|
|
}
|
|
|
|
fun Any?.test_4() {
|
|
if (this !is A) {
|
|
this.<!UNRESOLVED_REFERENCE!>foo<!>()
|
|
<!UNRESOLVED_REFERENCE!>foo<!>()
|
|
this.<!UNRESOLVED_REFERENCE!>bar<!>()
|
|
<!UNRESOLVED_REFERENCE!>bar<!>()
|
|
} else if (this !is B) {
|
|
this.<!UNRESOLVED_REFERENCE!>bar<!>()
|
|
<!UNRESOLVED_REFERENCE!>bar<!>()
|
|
this.foo()
|
|
foo()
|
|
} else {
|
|
this.foo()
|
|
foo()
|
|
this.bar()
|
|
bar()
|
|
}
|
|
this.<!UNRESOLVED_REFERENCE!>foo<!>()
|
|
<!UNRESOLVED_REFERENCE!>foo<!>()
|
|
this.<!UNRESOLVED_REFERENCE!>bar<!>()
|
|
<!UNRESOLVED_REFERENCE!>bar<!>()
|
|
}
|
|
|
|
fun Any.test_5(): Int = when {
|
|
this is List<*> -> size
|
|
this is String -> length
|
|
else -> 0
|
|
}
|
|
|
|
fun Any.test_6() {
|
|
this as List<*>
|
|
size
|
|
this <!CAST_NEVER_SUCCEEDS!>as<!> String
|
|
length
|
|
}
|