Built-ins can now be initialized on demand

This commit is contained in:
Andrey Breslav
2013-06-17 19:06:24 +04:00
committed by Alexander Udalov
parent 30daf0aded
commit 25a5025c58
6 changed files with 4 additions and 58 deletions
@@ -124,8 +124,6 @@ public class JetCoreEnvironment {
}
JetScriptDefinitionProvider.getInstance(project).addScriptDefinitions(configuration.getList(CommonConfigurationKeys.SCRIPT_DEFINITIONS_KEY));
KotlinBuiltIns.initialize();
}
public CompilerConfiguration getConfiguration() {
@@ -72,9 +72,7 @@ public class KotlinBuiltIns {
private static volatile boolean initializing;
private static Throwable initializationFailed;
// This method must be called at least once per application run, on any project
// before any type checking is run
public static synchronized void initialize() {
private static synchronized void initialize() {
if (instance == null) {
if (initializationFailed != null) {
throw new RuntimeException(
@@ -98,7 +96,7 @@ public class KotlinBuiltIns {
}
}
@NotNull // This asserts that initialize() is called before any resolution happens
@NotNull
public static KotlinBuiltIns getInstance() {
if (initializing) {
synchronized (KotlinBuiltIns.class) {
@@ -107,7 +105,7 @@ public class KotlinBuiltIns {
}
}
if (instance == null) {
throw new IllegalStateException("Initialize standard library first");
initialize();
}
return instance;
}