From cc74d63a98c70c85688d215a95dff1407b10dc74 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Fri, 14 Jul 2017 20:07:01 +0300 Subject: [PATCH] Rework how built-in types are loaded in compiler for JVM In TopDownAnalyzerFacadeForJVM, we now always use the "load built-ins from module dependencies" behavior that was previously only enabled with the dedicated CLI argument -Xload-builtins-from-dependencies. However, sometimes we compile code without kotlin-stdlib in the classpath, and we don't want everything to crash because some standard type like kotlin.Unit hasn't been found. To mitigate this, we add another module at the end of the dependencies list, namely a "fallback built-ins" module. This module loads all built-in declarations from the compiler's class loader, as was done by default previously. This prevents the compiler from crashing if any built-in declaration is not found, but compiling the code against built-ins found in the compiler is still discouraged, so we report an error if anything is resolved to a declaration from this module, via a new checker MissingBuiltInDeclarationChecker. Also introduce a new CLI argument -Xsuppress-missing-builtins-error specifically to suppress this error and to allow compiling code against compiler's own built-ins. #KT-19227 Fixed #KT-28198 Fixed Original commit: ed867578178e3477198cdd9a6a19526add120027 --- .../test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt index 39af6b884b6..80563561f5e 100644 --- a/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt +++ b/jps/jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt @@ -227,7 +227,7 @@ open class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() { } fun testSourcePackageLongPrefix() { - initProject() + initProject(JVM_MOCK_RUNTIME) val buildResult = buildAllModules() buildResult.assertSuccessful() val warnings = buildResult.getMessages(BuildMessage.Kind.WARNING) @@ -236,7 +236,7 @@ open class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() { } fun testSourcePackagePrefixWithInnerClasses() { - initProject() + initProject(JVM_MOCK_RUNTIME) buildAllModules().assertSuccessful() }