Passing "stubs" flag to K2JVMCompileEnvironmentConfiguration to avoid checking compiler special mode.
This commit is contained in:
@@ -70,10 +70,11 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments, K2JVMComp
|
||||
}
|
||||
|
||||
JetCoreEnvironment environment = JetCoreEnvironment.createCoreEnvironmentForJVM(rootDisposable, compilerConfiguration, mode);
|
||||
boolean builtins = mode == CompilerSpecialMode.BUILTINS;
|
||||
K2JVMCompileEnvironmentConfiguration configuration = new K2JVMCompileEnvironmentConfiguration(
|
||||
environment, messageCollector, arguments.script, mode == CompilerSpecialMode.BUILTINS
|
||||
environment, messageCollector, arguments.script, builtins
|
||||
? BuiltinsScopeExtensionMode.ONLY_STANDARD_CLASSES
|
||||
: BuiltinsScopeExtensionMode.ALL);
|
||||
: BuiltinsScopeExtensionMode.ALL, builtins);
|
||||
|
||||
messageCollector.report(CompilerMessageSeverity.LOGGING, "Configuring the compilation environment",
|
||||
CompilerMessageLocation.NO_LOCATION);
|
||||
|
||||
@@ -148,7 +148,7 @@ public class CompileEnvironmentUtil {
|
||||
|
||||
GenerationState generationState = KotlinToJVMBytecodeCompiler
|
||||
.analyzeAndGenerate(new K2JVMCompileEnvironmentConfiguration(scriptEnvironment, messageCollector, false,
|
||||
BuiltinsScopeExtensionMode.ALL), false);
|
||||
BuiltinsScopeExtensionMode.ALL, false), false);
|
||||
if (generationState == null) {
|
||||
throw new CompileEnvironmentException("Module script " + moduleScriptFile + " analyze failed");
|
||||
}
|
||||
|
||||
+8
-2
@@ -29,18 +29,20 @@ public class K2JVMCompileEnvironmentConfiguration extends CompileEnvironmentConf
|
||||
private final JetCoreEnvironment environment;
|
||||
private final boolean script;
|
||||
private final BuiltinsScopeExtensionMode builtinsScopeExtensionMode;
|
||||
private final boolean stubs;
|
||||
|
||||
/**
|
||||
* NOTE: It's very important to call dispose for every object of this class or there will be memory leaks.
|
||||
*
|
||||
* @see Disposer
|
||||
*/
|
||||
public K2JVMCompileEnvironmentConfiguration(@NotNull JetCoreEnvironment environment,
|
||||
@NotNull MessageCollector messageCollector, boolean script, BuiltinsScopeExtensionMode builtinsScopeExtensionMode) {
|
||||
public K2JVMCompileEnvironmentConfiguration(@NotNull JetCoreEnvironment environment, @NotNull MessageCollector messageCollector,
|
||||
boolean script, BuiltinsScopeExtensionMode builtinsScopeExtensionMode, boolean stubs) {
|
||||
super(messageCollector);
|
||||
this.environment = environment;
|
||||
this.script = script;
|
||||
this.builtinsScopeExtensionMode = builtinsScopeExtensionMode;
|
||||
this.stubs = stubs;
|
||||
}
|
||||
|
||||
public JetCoreEnvironment getEnvironment() {
|
||||
@@ -55,4 +57,8 @@ public class K2JVMCompileEnvironmentConfiguration extends CompileEnvironmentConf
|
||||
public BuiltinsScopeExtensionMode getBuiltinsScopeExtensionMode() {
|
||||
return builtinsScopeExtensionMode;
|
||||
}
|
||||
|
||||
public boolean isStubs() {
|
||||
return stubs;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-4
@@ -30,17 +30,16 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.cli.common.CompilerPlugin;
|
||||
import org.jetbrains.jet.cli.common.CompilerPluginContext;
|
||||
import org.jetbrains.jet.codegen.*;
|
||||
import org.jetbrains.jet.cli.common.messages.AnalyzerWithCompilerReport;
|
||||
import org.jetbrains.jet.cli.common.messages.CompilerMessageLocation;
|
||||
import org.jetbrains.jet.cli.common.messages.CompilerMessageSeverity;
|
||||
import org.jetbrains.jet.codegen.*;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.psi.JetPsiUtil;
|
||||
import org.jetbrains.jet.lang.resolve.java.CompilerSpecialMode;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.AnalyzerScriptParameter;
|
||||
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.plugin.JetLanguage;
|
||||
import org.jetbrains.jet.plugin.JetMainDetector;
|
||||
@@ -259,7 +258,7 @@ public class KotlinToJVMBytecodeCompiler {
|
||||
|
||||
@Nullable
|
||||
public static GenerationState analyzeAndGenerate(K2JVMCompileEnvironmentConfiguration configuration) {
|
||||
return analyzeAndGenerate(configuration, configuration.getEnvironment().getCompilerSpecialMode() == CompilerSpecialMode.BUILTINS);
|
||||
return analyzeAndGenerate(configuration, configuration.isStubs());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
Reference in New Issue
Block a user