Handle nested when with subject properly

Hack: callee expression for when with subject variable is the subject
variable declaration. This solves the problem that all sub-calls in the
expression are implicitly considered to have a single common lexical
scope (and 'when (val x = ...)' introduces a new lexical scope, which
contains 'x').
This commit is contained in:
Dmitry Petrov
2018-06-08 11:25:17 +03:00
parent 758548603e
commit ae929d0f08
7 changed files with 88 additions and 20 deletions
@@ -22475,6 +22475,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
runTest("compiler/testData/diagnostics/tests/when/withSubjectVariable/invisibleOutsideOfWhen.kt");
}
@TestMetadata("nestedWhenWithSubject.kt")
public void testNestedWhenWithSubject() throws Exception {
runTest("compiler/testData/diagnostics/tests/when/withSubjectVariable/nestedWhenWithSubject.kt");
}
@TestMetadata("reassignmentToWhenSubjectVariable.kt")
public void testReassignmentToWhenSubjectVariable() throws Exception {
runTest("compiler/testData/diagnostics/tests/when/withSubjectVariable/reassignmentToWhenSubjectVariable.kt");
@@ -22475,6 +22475,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
runTest("compiler/testData/diagnostics/tests/when/withSubjectVariable/invisibleOutsideOfWhen.kt");
}
@TestMetadata("nestedWhenWithSubject.kt")
public void testNestedWhenWithSubject() throws Exception {
runTest("compiler/testData/diagnostics/tests/when/withSubjectVariable/nestedWhenWithSubject.kt");
}
@TestMetadata("reassignmentToWhenSubjectVariable.kt")
public void testReassignmentToWhenSubjectVariable() throws Exception {
runTest("compiler/testData/diagnostics/tests/when/withSubjectVariable/reassignmentToWhenSubjectVariable.kt");