Write script descriptor type to ASM_TYPE slice

#KT-20707 Fixed
This commit is contained in:
Mikhael Bogdanov
2017-10-10 13:26:24 +02:00
parent eb32f5478a
commit a79c2bf999
5 changed files with 39 additions and 2 deletions

View File

@@ -193,8 +193,15 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid {
@Override
public void visitScript(@NotNull KtScript script) {
classStack.push(bindingContext.get(SCRIPT, script));
nameStack.push(AsmUtil.internalNameByFqNameWithoutInnerClasses(script.getFqName()));
ClassDescriptor scriptDescriptor = bindingContext.get(SCRIPT, script);
// working around a problem with shallow analysis
if (scriptDescriptor == null) return;
String scriptInternalName = AsmUtil.internalNameByFqNameWithoutInnerClasses(script.getFqName());
recordClosure(scriptDescriptor, scriptInternalName);
classStack.push(scriptDescriptor);
nameStack.push(scriptInternalName);
script.acceptChildren(this);
nameStack.pop();
classStack.pop();

View File

@@ -0,0 +1,10 @@
enum class Build { Debug, Release }
fun applySomething(build: Build) = when (build) {
Build.Debug -> "OK"
Build.Release -> "fail"
}
val rv = applySomething(Build.Debug)
// expected: rv: OK

View File

@@ -0,0 +1,8 @@
>>> enum class Build { Debug, Release }
>>> fun applySomething(build: Build) = when (build) {
... Build.Debug -> "OK"
... Build.Release -> "fail"
...}
>>> applySomething(Build.Debug)
OK

View File

@@ -78,6 +78,12 @@ public class ScriptCodegenTestGenerated extends AbstractScriptCodegenTest {
doTest(fileName);
}
@TestMetadata("kt20707.kts")
public void testKt20707() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/script/kt20707.kts");
doTest(fileName);
}
@TestMetadata("localDelegatedProperty.kts")
public void testLocalDelegatedProperty() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/script/localDelegatedProperty.kts");

View File

@@ -245,6 +245,12 @@ public class ReplInterpreterTestGenerated extends AbstractReplInterpreterTest {
doTest(fileName);
}
@TestMetadata("kt15407.repl")
public void testKt15407() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/repl/controlFlow/kt15407.repl");
doTest(fileName);
}
@TestMetadata("loopWithWrongLabel.repl")
public void testLoopWithWrongLabel() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/repl/controlFlow/loopWithWrongLabel.repl");