mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-04-04 15:51:54 +00:00
Write script descriptor type to ASM_TYPE slice
#KT-20707 Fixed
This commit is contained in:
@@ -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();
|
||||
|
||||
10
compiler/testData/codegen/script/kt20707.kts
vendored
Normal file
10
compiler/testData/codegen/script/kt20707.kts
vendored
Normal 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
|
||||
8
compiler/testData/repl/controlFlow/kt15407.repl
vendored
Normal file
8
compiler/testData/repl/controlFlow/kt15407.repl
vendored
Normal 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
|
||||
@@ -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");
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user