repl: fix two anonymous functions
This commit is contained in:
@@ -62,7 +62,6 @@ public class ClosureAnnotator {
|
||||
this.files = files;
|
||||
}
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
mapFilesToNamespaces(files);
|
||||
prepareAnonymousClasses();
|
||||
@@ -241,7 +240,12 @@ public class ClosureAnnotator {
|
||||
|
||||
@Override
|
||||
public void visitJetFile(JetFile file) {
|
||||
nameStack.push(JetPsiUtil.getFQName(file).getFqName().replace('.', '/'));
|
||||
if (file.isScript()) {
|
||||
nameStack.push(classNameForScriptPsi(file.getScript()).getInternalName());
|
||||
}
|
||||
else {
|
||||
nameStack.push(JetPsiUtil.getFQName(file).getFqName().replace('.', '/'));
|
||||
}
|
||||
file.acceptChildren(this);
|
||||
nameStack.pop();
|
||||
}
|
||||
|
||||
@@ -135,9 +135,13 @@ public class GenerationState {
|
||||
return getFactory().forNamespace(fqName, namespace);
|
||||
}
|
||||
|
||||
public void compileCorrectFiles(@NotNull CompilationErrorHandler errorHandler) {
|
||||
private void beforeCompile() {
|
||||
markUsed();
|
||||
|
||||
injector.getClosureAnnotator().init();
|
||||
}
|
||||
|
||||
public void compileCorrectFiles(@NotNull CompilationErrorHandler errorHandler) {
|
||||
for (JetFile file : this.files) {
|
||||
if (file.isScript()) {
|
||||
injector.getClosureAnnotator().registerClassNameForScript(file.getScript(), ScriptCodegen.SCRIPT_DEFAULT_CLASS_NAME);
|
||||
@@ -146,6 +150,8 @@ public class GenerationState {
|
||||
|
||||
injector.getScriptCodegen().registerEarlierScripts(Collections.<Pair<ScriptDescriptor, JvmClassName>>emptyList());
|
||||
|
||||
beforeCompile();
|
||||
|
||||
MultiMap<FqName, JetFile> namespaceGrouping = new MultiMap<FqName, JetFile>();
|
||||
for (JetFile file : this.files) {
|
||||
if (file == null) throw new IllegalArgumentException("A null file given for compilation");
|
||||
@@ -162,12 +168,12 @@ public class GenerationState {
|
||||
@NotNull JvmClassName className,
|
||||
@NotNull List<Pair<ScriptDescriptor, JvmClassName>> earlierScripts,
|
||||
@NotNull CompilationErrorHandler errorHandler) {
|
||||
markUsed();
|
||||
|
||||
injector.getScriptCodegen().registerEarlierScripts(earlierScripts);
|
||||
|
||||
injector.getClosureAnnotator().registerClassNameForScript(script, className);
|
||||
|
||||
beforeCompile();
|
||||
|
||||
generateNamespace(
|
||||
JetPsiUtil.getFQName((JetFile) script.getContainingFile()),
|
||||
Collections.singleton((JetFile) script.getContainingFile()),
|
||||
|
||||
@@ -67,8 +67,6 @@ public class InjectorForJetTypeMapper {
|
||||
|
||||
jetTypeMapper.init();
|
||||
|
||||
closureAnnotator.init();
|
||||
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
|
||||
@@ -121,8 +121,6 @@ public class InjectorForJvmCodegen {
|
||||
|
||||
intrinsics.init();
|
||||
|
||||
closureAnnotator.init();
|
||||
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
|
||||
@@ -249,6 +249,7 @@ public class DescriptorRenderer implements Renderer<DeclarationDescriptor> {
|
||||
declarationDescriptor.accept(rootVisitor, stringBuilder);
|
||||
|
||||
if (stringBuilder.length() == 0) {
|
||||
// don't use toString here because render may be called from toString
|
||||
stringBuilder.append(declarationDescriptor.getClass().getName() + "@" + System.identityHashCode(declarationDescriptor));
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
>>> { -> }; 21
|
||||
21
|
||||
>>> { -> }; 22
|
||||
22
|
||||
@@ -87,5 +87,10 @@ public class ReplInterpreterTest {
|
||||
testFile("functionReferencesPrev.repl");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void twoClosures() {
|
||||
testFile("twoClosures.repl");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user