GenerationState is constructed with BindingContext, not full AnalyzeExhaust
This commit is contained in:
@@ -18,7 +18,6 @@ package org.jetbrains.jet.codegen.state;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.codegen.*;
|
||||
import org.jetbrains.jet.codegen.binding.CodegenBinding;
|
||||
import org.jetbrains.jet.codegen.intrinsics.IntrinsicMethods;
|
||||
@@ -67,15 +66,15 @@ public class GenerationState {
|
||||
|
||||
private final boolean generateNotNullParamAssertions;
|
||||
|
||||
public GenerationState(Project project, ClassBuilderFactory builderFactory, AnalyzeExhaust analyzeExhaust, List<JetFile> files) {
|
||||
this(project, builderFactory, Progress.DEAF, analyzeExhaust, files, BuiltinToJavaTypesMapping.ENABLED, true, false);
|
||||
public GenerationState(Project project, ClassBuilderFactory builderFactory, BindingContext bindingContext, List<JetFile> files) {
|
||||
this(project, builderFactory, Progress.DEAF, bindingContext, files, BuiltinToJavaTypesMapping.ENABLED, true, false);
|
||||
}
|
||||
|
||||
public GenerationState(
|
||||
@NotNull Project project,
|
||||
ClassBuilderFactory builderFactory,
|
||||
@NotNull Progress progress,
|
||||
@NotNull AnalyzeExhaust exhaust,
|
||||
@NotNull BindingContext bindingContext,
|
||||
@NotNull List<JetFile> files,
|
||||
@NotNull BuiltinToJavaTypesMapping builtinToJavaTypesMapping,
|
||||
boolean generateNotNullAssertions,
|
||||
@@ -86,8 +85,8 @@ public class GenerationState {
|
||||
this.files = files;
|
||||
this.classBuilderMode = builderFactory.getClassBuilderMode();
|
||||
|
||||
bindingTrace = new DelegatingBindingTrace(exhaust.getBindingContext(), "trace in GenerationState");
|
||||
bindingContext = bindingTrace.getBindingContext();
|
||||
bindingTrace = new DelegatingBindingTrace(bindingContext, "trace in GenerationState");
|
||||
this.bindingContext = bindingTrace.getBindingContext();
|
||||
|
||||
this.typeMapper = new JetTypeMapper(bindingTrace, builtinToJavaTypesMapping == BuiltinToJavaTypesMapping.ENABLED, classBuilderMode);
|
||||
|
||||
|
||||
+1
-1
@@ -346,7 +346,7 @@ public class KotlinToJVMBytecodeCompiler {
|
||||
}
|
||||
};
|
||||
GenerationState generationState = new GenerationState(
|
||||
project, ClassBuilderFactories.binaries(stubs), backendProgress, exhaust, environment.getSourceFiles(),
|
||||
project, ClassBuilderFactories.binaries(stubs), backendProgress, exhaust.getBindingContext(), environment.getSourceFiles(),
|
||||
configuration.get(JVMConfigurationKeys.BUILTIN_TO_JAVA_TYPES_MAPPING_KEY, BuiltinToJavaTypesMapping.ENABLED),
|
||||
configuration.get(JVMConfigurationKeys.GENERATE_NOT_NULL_ASSERTIONS, false),
|
||||
configuration.get(JVMConfigurationKeys.GENERATE_NOT_NULL_PARAMETER_ASSERTIONS, false)
|
||||
|
||||
@@ -224,8 +224,9 @@ public class ReplInterpreter {
|
||||
earierScripts.add(Pair.create(earlierLine.getScriptDescriptor(), earlierLine.getClassName()));
|
||||
}
|
||||
|
||||
BindingContext bindingContext = AnalyzeExhaust.success(trace.getBindingContext(), injector.getModuleConfiguration()).getBindingContext();
|
||||
GenerationState generationState = new GenerationState(psiFile.getProject(), ClassBuilderFactories.binaries(false),
|
||||
AnalyzeExhaust.success(trace.getBindingContext(), injector.getModuleConfiguration()), Collections.singletonList(psiFile));
|
||||
bindingContext, Collections.singletonList(psiFile));
|
||||
generationState.getScriptCodegen().compileScript(psiFile.getScript(), scriptClassName, earierScripts,
|
||||
CompilationErrorHandler.THROW_EXCEPTION);
|
||||
|
||||
|
||||
@@ -216,7 +216,7 @@ public class JetLightClass extends AbstractLightClass implements JetJavaMirrorMa
|
||||
}
|
||||
|
||||
try {
|
||||
GenerationState state = new GenerationState(project, builderFactory, exhaust, Collections.singletonList(file));
|
||||
GenerationState state = new GenerationState(project, builderFactory, exhaust.getBindingContext(), Collections.singletonList(file));
|
||||
GenerationStrategy strategy = new LightClassGenerationStrategy(this, stubStack, answer);
|
||||
|
||||
strategy.compileCorrectFiles(state, CompilationErrorHandler.THROW_EXCEPTION);
|
||||
|
||||
@@ -358,7 +358,7 @@ public abstract class CodegenTestCase extends UsefulTestCase {
|
||||
AnalyzingUtils.throwExceptionOnErrors(analyzeExhaust.getBindingContext());
|
||||
CompilerConfiguration configuration = environment.getConfiguration();
|
||||
GenerationState state = new GenerationState(
|
||||
environment.getProject(), classBuilderFactory, Progress.DEAF, analyzeExhaust, files.getPsiFiles(),
|
||||
environment.getProject(), classBuilderFactory, Progress.DEAF, analyzeExhaust.getBindingContext(), files.getPsiFiles(),
|
||||
configuration.get(JVMConfigurationKeys.BUILTIN_TO_JAVA_TYPES_MAPPING_KEY, BuiltinToJavaTypesMapping.ENABLED),
|
||||
configuration.get(JVMConfigurationKeys.GENERATE_NOT_NULL_ASSERTIONS, true),
|
||||
configuration.get(JVMConfigurationKeys.GENERATE_NOT_NULL_PARAMETER_ASSERTIONS, true)
|
||||
|
||||
@@ -58,7 +58,7 @@ public class GenerationUtils {
|
||||
@NotNull
|
||||
public static GenerationState compileFilesGetGenerationState(@NotNull Project project, @NotNull AnalyzeExhaust analyzeExhaust, @NotNull List<JetFile> files) {
|
||||
analyzeExhaust.throwIfError();
|
||||
GenerationState state = new GenerationState(project, ClassBuilderFactories.TEST, analyzeExhaust, files);
|
||||
GenerationState state = new GenerationState(project, ClassBuilderFactories.TEST, analyzeExhaust.getBindingContext(), files);
|
||||
GenerationStrategy.STANDARD.compileCorrectFiles(state, CompilationErrorHandler.THROW_EXCEPTION);
|
||||
return state;
|
||||
}
|
||||
|
||||
@@ -87,11 +87,11 @@ public class BytecodeToolwindow extends JPanel implements Disposable {
|
||||
|
||||
GenerationState state;
|
||||
try {
|
||||
AnalyzeExhaust binding = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile(jetFile);
|
||||
if (binding.isError()) {
|
||||
return printStackTraceToString(binding.getError());
|
||||
AnalyzeExhaust exhaust = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile(jetFile);
|
||||
if (exhaust.isError()) {
|
||||
return printStackTraceToString(exhaust.getError());
|
||||
}
|
||||
state = new GenerationState(jetFile.getProject(), ClassBuilderFactories.TEXT, binding, Collections.singletonList(jetFile));
|
||||
state = new GenerationState(jetFile.getProject(), ClassBuilderFactories.TEXT, exhaust.getBindingContext(), Collections.singletonList(jetFile));
|
||||
GenerationStrategy.STANDARD.compileCorrectFiles(state, CompilationErrorHandler.THROW_EXCEPTION);
|
||||
}
|
||||
catch (ProcessCanceledException e) {
|
||||
|
||||
Reference in New Issue
Block a user