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
This commit is contained in:
@@ -219,28 +219,28 @@ CLASS IR_EXTERNAL_DECLARATION_STUB CLASS name:Int modality:FINAL visibility:publ
|
||||
PROPERTY IR_EXTERNAL_DECLARATION_STUB name:MAX_VALUE visibility:public modality:FINAL [const,val]
|
||||
FIELD IR_EXTERNAL_DECLARATION_STUB name:MAX_VALUE type:kotlin.Int visibility:public [final]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=<unbound IrClassSymbolImpl> value=2147483647
|
||||
CONST Int type=kotlin.Int value=2147483647
|
||||
FUN IR_EXTERNAL_DECLARATION_STUB name:<get-MAX_VALUE> visibility:public modality:FINAL <> ($this:kotlin.Int.Companion) returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY IR_EXTERNAL_DECLARATION_STUB name:MAX_VALUE visibility:public modality:FINAL [const,val]
|
||||
$this: VALUE_PARAMETER IR_EXTERNAL_DECLARATION_STUB name:<this> type:kotlin.Int.Companion
|
||||
PROPERTY IR_EXTERNAL_DECLARATION_STUB name:MIN_VALUE visibility:public modality:FINAL [const,val]
|
||||
FIELD IR_EXTERNAL_DECLARATION_STUB name:MIN_VALUE type:kotlin.Int visibility:public [final]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=<unbound IrClassSymbolImpl> value=-2147483648
|
||||
CONST Int type=kotlin.Int value=-2147483648
|
||||
FUN IR_EXTERNAL_DECLARATION_STUB name:<get-MIN_VALUE> visibility:public modality:FINAL <> ($this:kotlin.Int.Companion) returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY IR_EXTERNAL_DECLARATION_STUB name:MIN_VALUE visibility:public modality:FINAL [const,val]
|
||||
$this: VALUE_PARAMETER IR_EXTERNAL_DECLARATION_STUB name:<this> type:kotlin.Int.Companion
|
||||
PROPERTY IR_EXTERNAL_DECLARATION_STUB name:SIZE_BITS visibility:public modality:FINAL [const,val]
|
||||
FIELD IR_EXTERNAL_DECLARATION_STUB name:SIZE_BITS type:kotlin.Int visibility:public [final]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=<unbound IrClassSymbolImpl> value=32
|
||||
CONST Int type=kotlin.Int value=32
|
||||
FUN IR_EXTERNAL_DECLARATION_STUB name:<get-SIZE_BITS> visibility:public modality:FINAL <> ($this:kotlin.Int.Companion) returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY IR_EXTERNAL_DECLARATION_STUB name:SIZE_BITS visibility:public modality:FINAL [const,val]
|
||||
$this: VALUE_PARAMETER IR_EXTERNAL_DECLARATION_STUB name:<this> type:kotlin.Int.Companion
|
||||
PROPERTY IR_EXTERNAL_DECLARATION_STUB name:SIZE_BYTES visibility:public modality:FINAL [const,val]
|
||||
FIELD IR_EXTERNAL_DECLARATION_STUB name:SIZE_BYTES type:kotlin.Int visibility:public [final]
|
||||
EXPRESSION_BODY
|
||||
CONST Int type=<unbound IrClassSymbolImpl> value=4
|
||||
CONST Int type=kotlin.Int value=4
|
||||
FUN IR_EXTERNAL_DECLARATION_STUB name:<get-SIZE_BYTES> visibility:public modality:FINAL <> ($this:kotlin.Int.Companion) returnType:kotlin.Int
|
||||
correspondingProperty: PROPERTY IR_EXTERNAL_DECLARATION_STUB name:SIZE_BYTES visibility:public modality:FINAL [const,val]
|
||||
$this: VALUE_PARAMETER IR_EXTERNAL_DECLARATION_STUB name:<this> type:kotlin.Int.Companion
|
||||
|
||||
Reference in New Issue
Block a user