[FIR] Implement UNRESOLVED_REFERENCE_WRONG_RECEIVER

This commit is contained in:
Ivan Kochurkin
2021-08-10 16:40:51 +03:00
committed by Space
parent 34cc7e5199
commit 84c5f58cab
129 changed files with 322 additions and 481 deletions
@@ -16,6 +16,6 @@ FILE: lambdaAsReceiver.kt
fun <anonymous>(): R|kotlin/String| <inline=Unknown> {
^ String()
}
.<Inapplicable(INAPPLICABLE_WRONG_RECEIVER): /bar>#()
.<None of the following candidates is applicable because of receiver type mismatch: [/bar]>#()
String().R|/bar|()
}
@@ -9,6 +9,6 @@ fun main1() {
}
fun main2() {
{ "" }.<!INAPPLICABLE_CANDIDATE!>bar<!>()
{ "" }.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>bar<!>()
"".bar()
}
@@ -29,7 +29,7 @@ FILE: lambdaArgInScopeFunction.kt
}
) }
R|<local>/lambda|.R|/checkType|<R|(() -> KotlinClass)?|>(<L> = checkType@fun R|CheckTypeInv<kotlin/Function0<KotlinClass>?>|.<anonymous>(): R|kotlin/Unit| <inline=NoInline> {
this@R|special/anonymous|.<Inapplicable(INAPPLICABLE_WRONG_RECEIVER): /_>#<R|(kotlin/Unit) -> KotlinClass?|>()
this@R|special/anonymous|.<None of the following candidates is applicable because of receiver type mismatch: [/_]>#<R|(kotlin/Unit) -> KotlinClass?|>()
}
)
}
@@ -50,7 +50,7 @@ FILE: lambdaArgInScopeFunction.kt
}
)
R|<local>/lambda|.R|/checkType|<R|() -> KotlinClass|>(<L> = checkType@fun R|CheckTypeInv<kotlin/Function0<KotlinClass>>|.<anonymous>(): R|kotlin/Unit| <inline=NoInline> {
this@R|special/anonymous|.<Inapplicable(INAPPLICABLE_WRONG_RECEIVER): /_>#<R|(kotlin/Unit) -> KotlinClass?|>()
this@R|special/anonymous|.<None of the following candidates is applicable because of receiver type mismatch: [/_]>#<R|(kotlin/Unit) -> KotlinClass?|>()
}
)
}
@@ -21,7 +21,7 @@ fun case1(kotlinClass: KotlinClass?) {
{it}
}
lambda.checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Function1<Unit, KotlinClass?>>() }
lambda.checkType { <!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><Function1<Unit, KotlinClass?>>() }
}
// TESTCASE NUMBER: 2
fun case2(kotlinClass: KotlinClass) {
@@ -36,5 +36,5 @@ fun case2(kotlinClass: KotlinClass) {
{it}
}
lambda.checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Function1<Unit, KotlinClass?>>() }
lambda.checkType { <!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><Function1<Unit, KotlinClass?>>() }
}
@@ -29,11 +29,11 @@ FILE: KotlinClass.kt
}
)
R|<local>/invalidType|.R|/checkType|<R|(JavaClass) -> kotlin/Boolean|>(<L> = checkType@fun R|CheckTypeInv<kotlin/Function1<JavaClass, kotlin/Boolean>>|.<anonymous>(): R|kotlin/Unit| <inline=NoInline> {
this@R|special/anonymous|.<Inapplicable(INAPPLICABLE_WRONG_RECEIVER): /_>#<R|(kotlin/Nothing) -> kotlin/Boolean|>()
this@R|special/anonymous|.<None of the following candidates is applicable because of receiver type mismatch: [/_]>#<R|(kotlin/Nothing) -> kotlin/Boolean|>()
}
)
R|/Case1.Case1|(R|<local>/javaClass|).R|/Case1.x|.R|/checkType|<R|(KotlinClass) -> kotlin/Boolean|>(<L> = checkType@fun R|CheckTypeInv<kotlin/Function1<KotlinClass, kotlin/Boolean>>|.<anonymous>(): R|kotlin/Unit| <inline=NoInline> {
this@R|special/anonymous|.<Inapplicable(INAPPLICABLE_WRONG_RECEIVER): /_>#<R|(kotlin/Nothing) -> kotlin/Boolean|>()
this@R|special/anonymous|.<None of the following candidates is applicable because of receiver type mismatch: [/_]>#<R|(kotlin/Nothing) -> kotlin/Boolean|>()
}
)
}
@@ -122,11 +122,11 @@ FILE: KotlinClass.kt
}
)
R|<local>/invalidType|.R|/checkType|<R|(KotlinClass) -> kotlin/Boolean|>(<L> = checkType@fun R|CheckTypeInv<kotlin/Function1<KotlinClass, kotlin/Boolean>>|.<anonymous>(): R|kotlin/Unit| <inline=NoInline> {
this@R|special/anonymous|.<Inapplicable(INAPPLICABLE_WRONG_RECEIVER): /_>#<R|(kotlin/Nothing) -> kotlin/Boolean|>()
this@R|special/anonymous|.<None of the following candidates is applicable because of receiver type mismatch: [/_]>#<R|(kotlin/Nothing) -> kotlin/Boolean|>()
}
)
R|/Case2.Case2|(R|<local>/kotlinClass|).R|/Case2.x|.R|/checkType|<R|(KotlinClass) -> kotlin/Boolean|>(<L> = checkType@fun R|CheckTypeInv<kotlin/Function1<KotlinClass, kotlin/Boolean>>|.<anonymous>(): R|kotlin/Unit| <inline=NoInline> {
this@R|special/anonymous|.<Inapplicable(INAPPLICABLE_WRONG_RECEIVER): /_>#<R|(kotlin/Nothing) -> kotlin/Boolean|>()
this@R|special/anonymous|.<None of the following candidates is applicable because of receiver type mismatch: [/_]>#<R|(kotlin/Nothing) -> kotlin/Boolean|>()
}
)
}
@@ -26,9 +26,9 @@ fun case1(javaClass: JavaClass?) {
validType.checkType { _<Function1<JavaClass, Boolean>>() } //ok
invalidType.checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Function1<Nothing, Boolean>>() } //(!!!)
invalidType.checkType { <!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><Function1<Nothing, Boolean>>() } //(!!!)
Case1(javaClass).x.checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Function1<Nothing, Boolean>>() } //(!!!)
Case1(javaClass).x.checkType { <!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><Function1<Nothing, Boolean>>() } //(!!!)
}
class Case1(val javaClass: JavaClass?) {
@@ -55,9 +55,9 @@ fun case2(kotlinClass: KotlinClass?) {
validType.checkType { _<Function1<KotlinClass, Boolean>>() } //ok
invalidType.checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Function1<Nothing, Boolean>>() } //(!!!)
invalidType.checkType { <!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><Function1<Nothing, Boolean>>() } //(!!!)
Case2(kotlinClass).x.checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Function1<Nothing, Boolean>>() } //(!!!)
Case2(kotlinClass).x.checkType { <!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><Function1<Nothing, Boolean>>() } //(!!!)
}
class Case2(val kotlinClass: KotlinClass?) {
@@ -4,7 +4,7 @@ FILE: orInWhenBranch.kt
public final fun test_1(a: R|kotlin/Any?|): R|kotlin/Unit| {
when (R|<local>/a|) {
($subj$ is R|kotlin/String|) || ($subj$ is R|kotlin/Any|) -> {
R|<local>/a|.<Inapplicable(INAPPLICABLE_WRONG_RECEIVER): /foo>#()
R|<local>/a|.<None of the following candidates is applicable because of receiver type mismatch: [/foo]>#()
}
}
@@ -12,7 +12,7 @@ FILE: orInWhenBranch.kt
public final fun test_2(a: R|kotlin/Any?|): R|kotlin/Unit| {
when () {
(R|<local>/a| is R|kotlin/String|) || (R|<local>/a| is R|kotlin/Any|) -> {
R|<local>/a|.<Inapplicable(INAPPLICABLE_WRONG_RECEIVER): /foo>#()
R|<local>/a|.<None of the following candidates is applicable because of receiver type mismatch: [/foo]>#()
}
}
@@ -20,7 +20,7 @@ FILE: orInWhenBranch.kt
public final fun test_3(a: R|kotlin/Any?|, b: R|kotlin/Boolean|): R|kotlin/Unit| {
when (R|<local>/a|) {
($subj$ is R|kotlin/String|) || ==($subj$, R|<local>/b|) -> {
R|<local>/a|.<Inapplicable(INAPPLICABLE_WRONG_RECEIVER): /foo>#()
R|<local>/a|.<None of the following candidates is applicable because of receiver type mismatch: [/foo]>#()
}
}
@@ -28,7 +28,7 @@ FILE: orInWhenBranch.kt
public final fun test_4(a: R|kotlin/Any?|, b: R|kotlin/Boolean|): R|kotlin/Unit| {
when () {
(R|<local>/a| is R|kotlin/String|) || R|<local>/b| -> {
R|<local>/a|.<Inapplicable(INAPPLICABLE_WRONG_RECEIVER): /foo>#()
R|<local>/a|.<None of the following candidates is applicable because of receiver type mismatch: [/foo]>#()
}
}
@@ -4,24 +4,24 @@ fun String.foo() {}
fun test_1(a: Any?) {
when (a) {
is String, is Any -> a.<!INAPPLICABLE_CANDIDATE!>foo<!>() // Should be Bad
is String, is Any -> a.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>foo<!>() // Should be Bad
}
}
fun test_2(a: Any?) {
if (a is String || a is Any) {
a.<!INAPPLICABLE_CANDIDATE!>foo<!>() // Should be Bad
a.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>foo<!>() // Should be Bad
}
}
fun test_3(a: Any?, b: Boolean) {
when (a) {
is String, b -> a.<!INAPPLICABLE_CANDIDATE!>foo<!>() // Should be Bad
is String, b -> a.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>foo<!>() // Should be Bad
}
}
fun test_4(a: Any?, b: Boolean) {
if (a is String || b) {
a.<!INAPPLICABLE_CANDIDATE!>foo<!>() // Should be Bad
a.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>foo<!>() // Should be Bad
}
}