From 0e26194a2792bf379c5b3ac3f0da0469ce7f1b75 Mon Sep 17 00:00:00 2001 From: "anastasiia.spaseeva" Date: Mon, 16 Mar 2020 13:42:47 +0300 Subject: [PATCH] [FIR] Test for KT-37431 --- .../problems/receiverResolutionInLambda.kt | 40 +++++++++++++++++++ .../problems/receiverResolutionInLambda.txt | 30 ++++++++++++++ ...FirDiagnosticsWithStdlibTestGenerated.java | 5 +++ 3 files changed, 75 insertions(+) create mode 100644 compiler/fir/resolve/testData/resolveWithStdlib/problems/receiverResolutionInLambda.kt create mode 100644 compiler/fir/resolve/testData/resolveWithStdlib/problems/receiverResolutionInLambda.txt diff --git a/compiler/fir/resolve/testData/resolveWithStdlib/problems/receiverResolutionInLambda.kt b/compiler/fir/resolve/testData/resolveWithStdlib/problems/receiverResolutionInLambda.kt new file mode 100644 index 00000000000..2e91f6af44d --- /dev/null +++ b/compiler/fir/resolve/testData/resolveWithStdlib/problems/receiverResolutionInLambda.kt @@ -0,0 +1,40 @@ +/* + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-37431 + */ + +class Case1() { + + fun foo() { + val x = sequence { + + val y = this + //this is Case1 instead of SequenceScope + yield("") // UNRESOLVED_REFERENCE + + this.yield("") //UNRESOLVED_REFERENCE + + this as SequenceScope + + yield("") // resolved to SequenceScope.yield + + this.yield("") // resolved to SequenceScope.yield + } + } +} + +fun case2() { + val x = sequence { + + val y = this + yield("") // UNRESOLVED_REFERENCE + + this.yield("") //UNRESOLVED_REFERENCE + + this as SequenceScope + + yield("") // UNRESOLVED_REFERENCE + + this.yield("") // UNRESOLVED_REFERENCE + } +} \ No newline at end of file diff --git a/compiler/fir/resolve/testData/resolveWithStdlib/problems/receiverResolutionInLambda.txt b/compiler/fir/resolve/testData/resolveWithStdlib/problems/receiverResolutionInLambda.txt new file mode 100644 index 00000000000..9812b902dc5 --- /dev/null +++ b/compiler/fir/resolve/testData/resolveWithStdlib/problems/receiverResolutionInLambda.txt @@ -0,0 +1,30 @@ +FILE: receiverResolutionInLambda.kt + public final class Case1 : R|kotlin/Any| { + public constructor(): R|Case1| { + super() + } + + public final fun foo(): R|kotlin/Unit| { + lval x: R|kotlin/sequences/Sequence| = R|kotlin/sequences/sequence|( = sequence@fun (): R|kotlin/Unit| { + lval y: R|Case1| = this@R|/Case1| + #(String()) + this@R|/Case1|.#(String()) + (this@R|/Case1| as R|kotlin/sequences/SequenceScope|) + this@R|/Case1|.R|FakeOverride|(String()) + this@R|/Case1|.R|FakeOverride|(String()) + } + ) + } + + } + public final fun case2(): R|kotlin/Unit| { + lval x: R|kotlin/sequences/Sequence| = R|kotlin/sequences/sequence|( = sequence@fun (): { + lval y: R|ERROR CLASS: Unresolved this@null| = this# + #(String()) + this#.#(String()) + (this# as R|kotlin/sequences/SequenceScope|) + #(String()) + ^ this#.#(String()) + } + ) + } diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithStdlibTestGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithStdlibTestGenerated.java index aedaffb527d..68ceb41fb2f 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithStdlibTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsWithStdlibTestGenerated.java @@ -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");