[FIR] Test for KT-37431

This commit is contained in:
anastasiia.spaseeva
2020-03-16 13:42:47 +03:00
parent 1b479c49a8
commit 0e26194a27
3 changed files with 75 additions and 0 deletions
@@ -0,0 +1,40 @@
/*
* UNEXPECTED BEHAVIOUR
* ISSUES: KT-37431
*/
class Case1() {
fun foo() {
val x = sequence<String> {
val y = this
//this is Case1 instead of SequenceScope<String>
<!UNRESOLVED_REFERENCE!>yield<!>("") // UNRESOLVED_REFERENCE
this.<!UNRESOLVED_REFERENCE!>yield<!>("") //UNRESOLVED_REFERENCE
this as SequenceScope<String>
yield("") // resolved to SequenceScope.yield
this.yield("") // resolved to SequenceScope.yield
}
}
}
fun case2() {
val x = sequence<String> {
val y = this
<!UNRESOLVED_REFERENCE!>yield<!>("") // UNRESOLVED_REFERENCE
this.<!UNRESOLVED_REFERENCE!>yield<!>("") //UNRESOLVED_REFERENCE
this as SequenceScope<String>
<!UNRESOLVED_REFERENCE!>yield<!>("") // UNRESOLVED_REFERENCE
this.<!UNRESOLVED_REFERENCE!>yield<!>("") // UNRESOLVED_REFERENCE
}
}
@@ -0,0 +1,30 @@
FILE: receiverResolutionInLambda.kt
public final class Case1 : R|kotlin/Any| {
public constructor(): R|Case1| {
super<R|kotlin/Any|>()
}
public final fun foo(): R|kotlin/Unit| {
lval x: R|kotlin/sequences/Sequence<kotlin/String>| = R|kotlin/sequences/sequence|<R|kotlin/String|>(<L> = sequence@fun <anonymous>(): R|kotlin/Unit| {
lval y: R|Case1| = this@R|/Case1|
<Unresolved name: yield>#(String())
this@R|/Case1|.<Unresolved name: yield>#(String())
(this@R|/Case1| as R|kotlin/sequences/SequenceScope<kotlin/String>|)
this@R|/Case1|.R|FakeOverride<kotlin/sequences/SequenceScope.yield: R|kotlin/Unit|>|(String())
this@R|/Case1|.R|FakeOverride<kotlin/sequences/SequenceScope.yield: R|kotlin/Unit|>|(String())
}
)
}
}
public final fun case2(): R|kotlin/Unit| {
lval x: R|kotlin/sequences/Sequence<kotlin/String>| = R|kotlin/sequences/sequence|<R|kotlin/String|>(<L> = sequence@fun <anonymous>(): <ERROR TYPE REF: Unresolved name: yield> {
lval y: R|ERROR CLASS: Unresolved this@null| = this#
<Unresolved name: yield>#(String())
this#.<Unresolved name: yield>#(String())
(this# as R|kotlin/sequences/SequenceScope<kotlin/String>|)
<Unresolved name: yield>#(String())
^ this#.<Unresolved name: yield>#(String())
}
)
}
@@ -743,6 +743,11 @@ public class FirDiagnosticsWithStdlibTestGenerated extends AbstractFirDiagnostic
runTest("compiler/fir/resolve/testData/resolveWithStdlib/problems/qualifierPriority.kt");
}
@TestMetadata("receiverResolutionInLambda.kt")
public void testReceiverResolutionInLambda() throws Exception {
runTest("compiler/fir/resolve/testData/resolveWithStdlib/problems/receiverResolutionInLambda.kt");
}
@TestMetadata("weakHashMap.kt")
public void testWeakHashMap() throws Exception {
runTest("compiler/fir/resolve/testData/resolveWithStdlib/problems/weakHashMap.kt");