mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-03-25 15:51:36 +00:00
Compare commits
2 Commits
1.4.30
...
get-script
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
106ea55afc | ||
|
|
977d170d11 |
11
.bunch
11
.bunch
@@ -1,6 +1,7 @@
|
||||
202
|
||||
201
|
||||
193_201
|
||||
as40_193_201
|
||||
as41_201
|
||||
as42
|
||||
202
|
||||
203_202
|
||||
193
|
||||
as40_193
|
||||
as41
|
||||
as42_202
|
||||
488
ChangeLog.md
488
ChangeLog.md
@@ -1,491 +1,5 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 1.4.32
|
||||
|
||||
### IDE
|
||||
|
||||
- [`KT-43824`](https://youtrack.jetbrains.com/issue/KT-43824) KtLightClassForSourceDeclaration#isInheritor works in a different way than java implementation
|
||||
- [`KT-45287`](https://youtrack.jetbrains.com/issue/KT-45287) LightClasses: `KtLightSimpleModifierList` is no more a parent of `KtLightAnnotationForSourceEntry`
|
||||
- [`KT-45291`](https://youtrack.jetbrains.com/issue/KT-45291) LightClasses: can't get annotations for constructor val-parameter
|
||||
- [`KT-45417`](https://youtrack.jetbrains.com/issue/KT-45417) ULC leakage of primitive type annotations
|
||||
|
||||
### Tools. CLI
|
||||
|
||||
- [`KT-44758`](https://youtrack.jetbrains.com/issue/KT-44758) kotlin-compiler-embeddable dependency includes unshaded `fastutil` package
|
||||
- [`KT-45007`](https://youtrack.jetbrains.com/issue/KT-45007) Concurrent Kotlin script compilation/execution results in NullPointerException in KeyedExtensionCollector.getPoint()
|
||||
|
||||
|
||||
## 1.4.31
|
||||
|
||||
|
||||
### Compiler
|
||||
|
||||
- [`KT-39776`](https://youtrack.jetbrains.com/issue/KT-39776) 2020.3+: Unresolved reference to Kotlin stdlib function
|
||||
|
||||
### IDE. Gradle Integration
|
||||
|
||||
- [`KT-44845`](https://youtrack.jetbrains.com/issue/KT-44845) After update to Kotlin 1.4.30 all external dependencies is unresolved in IDE with kotlin.mpp.enableGranularSourceSetsMetadata=true
|
||||
|
||||
### IDE. Gradle. Script
|
||||
|
||||
- [`KTIJ-11137`](https://youtrack.jetbrains.com/issue/KTIJ-1137) build.gradle.kts: Fatal error during save/load standalone scripts settings
|
||||
- [`KTIJ-898`](https://youtrack.jetbrains.com/issue/KTIJ-898) Unable to import with Kotlin DSL buildscript - NullPointerException in KotlinDslScriptModelProcessorKt.toListOfScriptModels
|
||||
|
||||
### IDE. Multiplatform
|
||||
|
||||
- [`KTIJ-1200`](https://youtrack.jetbrains.com/issue/KTIJ-1200) KotlinIconProviderKt.addExpectActualMarker takes up to 180+ seconds
|
||||
|
||||
### IDE
|
||||
|
||||
#### Fixes
|
||||
|
||||
- [`KT-44697`](https://youtrack.jetbrains.com/issue/KT-44697) New JVM IR backend notification - narrow its triggering to Kotlin projects
|
||||
- [`KT-44523`](https://youtrack.jetbrains.com/issue/KT-44523) IDE notification for trying new JVM backend
|
||||
- [`KTIJ-696`](https://youtrack.jetbrains.com/issue/KTIJ-696) Freeze during startup of IDEA with intellij project with Kotlin (211-1.4.10-release-IJ1440)
|
||||
|
||||
## 1.4.30
|
||||
|
||||
### Android
|
||||
|
||||
- [`KT-42383`](https://youtrack.jetbrains.com/issue/KT-42383) HMPP: Bad IDEA dependencies: Missing dependency from p1:jvmAndAndroid to p2:jvmAndAndroid
|
||||
|
||||
### Backend. Native
|
||||
|
||||
- [`KT-38772`](https://youtrack.jetbrains.com/issue/KT-38772) Native: support non-reified type parameters in typeOf
|
||||
- [`KT-42234`](https://youtrack.jetbrains.com/issue/KT-42234) Move LLVM optimization parameters into konan.properties
|
||||
- [`KT-42649`](https://youtrack.jetbrains.com/issue/KT-42649) IndexOutOfBoundsException during InlineClassTransformer lowering
|
||||
- [`KT-42942`](https://youtrack.jetbrains.com/issue/KT-42942) Native: optimize peak backend memory by clearing BindingContext after psi2ir
|
||||
- [`KT-43198`](https://youtrack.jetbrains.com/issue/KT-43198) Native: support `init` blocks inside inline classes
|
||||
|
||||
### Compiler
|
||||
|
||||
#### New Features
|
||||
|
||||
- [`KT-28055`](https://youtrack.jetbrains.com/issue/KT-28055) Support `init` blocks inside inline classes
|
||||
- [`KT-28056`](https://youtrack.jetbrains.com/issue/KT-28056) Consider supporting non-public primary constructors for inline classes
|
||||
- [`KT-41265`](https://youtrack.jetbrains.com/issue/KT-41265) Support noarg compiler plugin for JVM IR
|
||||
- [`KT-42094`](https://youtrack.jetbrains.com/issue/KT-42094) Allow open callable members in expect interfaces
|
||||
- [`KT-43129`](https://youtrack.jetbrains.com/issue/KT-43129) FIR: Support OverloadResolutionByLambdaReturnType
|
||||
- [`KT-43592`](https://youtrack.jetbrains.com/issue/KT-43592) Promote JVM IR compiler backend to Beta
|
||||
- [`KT-43919`](https://youtrack.jetbrains.com/issue/KT-43919) Support loading Java annotations on base classes and implementing interfaces' type arguments
|
||||
- [`KT-44021`](https://youtrack.jetbrains.com/issue/KT-44021) Enable JVM IR backend by default in 1.5
|
||||
|
||||
#### Performance Improvements
|
||||
|
||||
- [`KT-41352`](https://youtrack.jetbrains.com/issue/KT-41352) JVM IR: reduce bytecode size in for loops and range checks with 'until' by not using inclusive end
|
||||
- [`KT-41644`](https://youtrack.jetbrains.com/issue/KT-41644) NI: Infinite compilation
|
||||
- [`KT-42791`](https://youtrack.jetbrains.com/issue/KT-42791) OutOfMemoryError on compilation using kotlin 1.4 on a class with a lot of type inference
|
||||
- [`KT-42920`](https://youtrack.jetbrains.com/issue/KT-42920) NI: Improve performance around adding constraints
|
||||
|
||||
#### Fixes
|
||||
|
||||
- [`KT-11454`](https://youtrack.jetbrains.com/issue/KT-11454) Load annotations on TYPE_USE/TYPE_PARAMETER positions from Java class-files
|
||||
- [`KT-11732`](https://youtrack.jetbrains.com/issue/KT-11732) Verify error for generic interface method invocation with default parameters
|
||||
- [`KT-14612`](https://youtrack.jetbrains.com/issue/KT-14612) "ISE: Recursive call in a lazy value" during processing of a (weakly) recursive type alias
|
||||
- [`KT-18344`](https://youtrack.jetbrains.com/issue/KT-18344) Upper bound of a typealias type parameter is not reported correctly if it contains the typealias itself
|
||||
- [`KT-18768`](https://youtrack.jetbrains.com/issue/KT-18768) @Notnull annotation from Java does not work with varargs
|
||||
- [`KT-20548`](https://youtrack.jetbrains.com/issue/KT-20548) java.lang.IllegalStateException: Illegal class container on simple Java code parsing
|
||||
- [`KT-22465`](https://youtrack.jetbrains.com/issue/KT-22465) Excessive synthetic method for private setter from superclass
|
||||
- [`KT-23816`](https://youtrack.jetbrains.com/issue/KT-23816) Inline classes: constants and annotations
|
||||
- [`KT-24158`](https://youtrack.jetbrains.com/issue/KT-24158) AE: No receiver found on incomplete code with $-signs
|
||||
- [`KT-24392`](https://youtrack.jetbrains.com/issue/KT-24392) Nullability of Java arrays is read incorrectly if @Nullable annotation has both targets TYPE_USE and VALUE_PARAMETER
|
||||
- [`KT-26229`](https://youtrack.jetbrains.com/issue/KT-26229) Lambda/anonymous function argument in parentheses is not supported for callsInPlace effect
|
||||
- [`KT-29735`](https://youtrack.jetbrains.com/issue/KT-29735) KNPE at `KtEnumEntrySuperclassReferenceExpression.getReferencedElement` with explicit type argument inside enum member constructor
|
||||
- [`KT-31389`](https://youtrack.jetbrains.com/issue/KT-31389) ClassFormatError with companion object in annotation with @JvmStatic
|
||||
- [`KT-31907`](https://youtrack.jetbrains.com/issue/KT-31907) ISE: UNIT_EXPECTED_TYPE on parsing array literal inside lambda with Unit return type
|
||||
- [`KT-32228`](https://youtrack.jetbrains.com/issue/KT-32228) Inconsistent boxing/unboxing for inline classes when interface is specialized by object expression
|
||||
- [`KT-32450`](https://youtrack.jetbrains.com/issue/KT-32450) Inline class incorrectly gets re-wrapped when provided to a function
|
||||
- [`KT-35849`](https://youtrack.jetbrains.com/issue/KT-35849) Missing nullability assertion on lambda return value if expected type has generic return value type
|
||||
- [`KT-35902`](https://youtrack.jetbrains.com/issue/KT-35902) Kotlin generates a private parameterless constructor for constructors taking inline class arguments with default values
|
||||
- [`KT-36399`](https://youtrack.jetbrains.com/issue/KT-36399) Gradually support TYPE_USE nullability annotations read from class-files
|
||||
- [`KT-36769`](https://youtrack.jetbrains.com/issue/KT-36769) JVM IR: Missing LVT entries for inline function (default) parameters at call site
|
||||
- [`KT-36982`](https://youtrack.jetbrains.com/issue/KT-36982) JVM IR: SAM adapter classes are generated as synthetic
|
||||
- [`KT-37007`](https://youtrack.jetbrains.com/issue/KT-37007) JVM IR: extraneous property accessors are generated in multifile facade for InlineOnly property
|
||||
- [`KT-37317`](https://youtrack.jetbrains.com/issue/KT-37317) [FIR] Add support of extension functions in postponed lambda completion
|
||||
- [`KT-38400`](https://youtrack.jetbrains.com/issue/KT-38400) FIR: interface abstract is preferred to Any method in super resolve
|
||||
- [`KT-38536`](https://youtrack.jetbrains.com/issue/KT-38536) JVM IR: bound adapted function references are not inlined
|
||||
- [`KT-38656`](https://youtrack.jetbrains.com/issue/KT-38656) FIR: determine overridden member visibility properly
|
||||
- [`KT-38901`](https://youtrack.jetbrains.com/issue/KT-38901) FIR: Make behavior of integer literals overflow consistent with FE 1.0
|
||||
- [`KT-39709`](https://youtrack.jetbrains.com/issue/KT-39709) [FIR] False positive UNINITIALIZED_VARIABLE in presence of complex graph with jumps
|
||||
- [`KT-39923`](https://youtrack.jetbrains.com/issue/KT-39923) Result.Failure will get wrapped with Success when using with RxJava
|
||||
- [`KT-40198`](https://youtrack.jetbrains.com/issue/KT-40198) '$default' methods in 'kotlin/test/AssertionsKt' generated as non-synthetic by JVM_IR
|
||||
- [`KT-40200`](https://youtrack.jetbrains.com/issue/KT-40200) IDE: Multiple top-level main functions in different files: broken highlighting, "No descriptor resolved for FUN"
|
||||
- [`KT-40262`](https://youtrack.jetbrains.com/issue/KT-40262) ACC_DEPRECATED flag not generated for property getter delegate in multifile class facade in JVM_IR
|
||||
- [`KT-40282`](https://youtrack.jetbrains.com/issue/KT-40282) Inline class wrapping Any gets double boxed
|
||||
- [`KT-40464`](https://youtrack.jetbrains.com/issue/KT-40464) JVM_IR does not generate LINENUMBER at closing brace of (suspend) lambda
|
||||
- [`KT-40500`](https://youtrack.jetbrains.com/issue/KT-40500) Warnings reporting by Java nullability annotations doesn't work for not top-level types
|
||||
- [`KT-40926`](https://youtrack.jetbrains.com/issue/KT-40926) IDE import actions do not add required import for convention `invoke()` extension call
|
||||
- [`KT-40948`](https://youtrack.jetbrains.com/issue/KT-40948) IllegalAccessError while initializing val property in EXACTLY_ONCE lambda that is passed to another function
|
||||
- [`KT-40991`](https://youtrack.jetbrains.com/issue/KT-40991) NI: UNRESOLVED_REFERENCE_WRONG_RECEIVER instead of FUNCTION_EXPECTED with convention `invoke` call
|
||||
- [`KT-41163`](https://youtrack.jetbrains.com/issue/KT-41163) Double wrapped value in Result class after map operation
|
||||
- [`KT-41284`](https://youtrack.jetbrains.com/issue/KT-41284) Spring CGLIB proxies break auto-generated data class componentN and copy methods when using JVM IR
|
||||
- [`KT-41468`](https://youtrack.jetbrains.com/issue/KT-41468) JVM IR: IllegalAccessError on access to abstract base member from another package, from anonymous object inside abstract class
|
||||
- [`KT-41491`](https://youtrack.jetbrains.com/issue/KT-41491) UNRESOLVED_REFERENCE_WRONG_RECEIVER instead of FUNCTION_EXPECTED when invoking non-functional value as a function
|
||||
- [`KT-41493`](https://youtrack.jetbrains.com/issue/KT-41493) JVM IR: names of classes for local delegated variables contain the variable name twice
|
||||
- [`KT-41792`](https://youtrack.jetbrains.com/issue/KT-41792) [FIR] Introduce & use ConeAttribute.UnsafeVariance
|
||||
- [`KT-41793`](https://youtrack.jetbrains.com/issue/KT-41793) [FIR] Make captured types accessible at the end of resolve
|
||||
- [`KT-41809`](https://youtrack.jetbrains.com/issue/KT-41809) JVM IR: name for internal $default method doesn't include module name
|
||||
- [`KT-41810`](https://youtrack.jetbrains.com/issue/KT-41810) JVM IR: Deprecated(HIDDEN) class is incorrectly generated as synthetic
|
||||
- [`KT-41841`](https://youtrack.jetbrains.com/issue/KT-41841) JVM IR: delegates for private functions with default arguments are generated in multifile classes
|
||||
- [`KT-41857`](https://youtrack.jetbrains.com/issue/KT-41857) Flaky 'ConcurrentModificationException' through `kotlin.serialization.DescriptorSerializer`
|
||||
- [`KT-41903`](https://youtrack.jetbrains.com/issue/KT-41903) JVM IR: do not generate LineNumberTable in auto-generated members of data classes
|
||||
- [`KT-41911`](https://youtrack.jetbrains.com/issue/KT-41911) JVM IR: nested big-arity function calls are not lowered
|
||||
- [`KT-41957`](https://youtrack.jetbrains.com/issue/KT-41957) JVM IR: step into suspend function goes to the first line of the file
|
||||
- [`KT-41960`](https://youtrack.jetbrains.com/issue/KT-41960) JVM IR: smart step into members implemented with delegation to interface doesn't work
|
||||
- [`KT-41961`](https://youtrack.jetbrains.com/issue/KT-41961) JVM IR: line numbers are not generated in JvmMultifileClass facade declarations
|
||||
- [`KT-41962`](https://youtrack.jetbrains.com/issue/KT-41962) JVM IR: intermittent -1 line numbers in the state machine cause double stepping in the debugger
|
||||
- [`KT-42001`](https://youtrack.jetbrains.com/issue/KT-42001) Cannot resolve symbol: AssertionError: Module <sdk 1.8> is not contained in his own dependencies
|
||||
- [`KT-42002`](https://youtrack.jetbrains.com/issue/KT-42002) JVM / IR: IllegalStateException: "No mapping for symbol: VAR IR_TEMPORARY_VARIABLE" caused by named arguments
|
||||
- [`KT-42021`](https://youtrack.jetbrains.com/issue/KT-42021) JVM / IR: "IndexOutOfBoundsException: Index 0 out of bounds for length 0" during IR lowering with suspend conversion
|
||||
- [`KT-42033`](https://youtrack.jetbrains.com/issue/KT-42033) JVM IR: accidental override in Map subclass with custom implementations of some members
|
||||
- [`KT-42036`](https://youtrack.jetbrains.com/issue/KT-42036) IR: "AssertionError: TypeAliasDescriptor expected: deserialized class Nothing" when referencing typealias with @UnsafeVariance
|
||||
- [`KT-42043`](https://youtrack.jetbrains.com/issue/KT-42043) JVM IR: Don't generate collection stubs when implementing methods with more specific return types
|
||||
- [`KT-42044`](https://youtrack.jetbrains.com/issue/KT-42044) Compiler error when lambda with contract surrounded with parentheses
|
||||
- [`KT-42114`](https://youtrack.jetbrains.com/issue/KT-42114) JVM_IR generates stub for 'removeIf' in abstract classes implementing 'List' and 'Set'
|
||||
- [`KT-42115`](https://youtrack.jetbrains.com/issue/KT-42115) JVM_IR doesn't generate 'next' and 'hasNext' method in an abstract class implementing 'ListIterator'
|
||||
- [`KT-42116`](https://youtrack.jetbrains.com/issue/KT-42116) FIR: Java accessor function should not exist in scope together with relevant property
|
||||
- [`KT-42117`](https://youtrack.jetbrains.com/issue/KT-42117) IR-based evaluator cannot handle Java static final fields
|
||||
- [`KT-42118`](https://youtrack.jetbrains.com/issue/KT-42118) FIR2IR: field-targeted annotation is placed on a property, not on a field
|
||||
- [`KT-42130`](https://youtrack.jetbrains.com/issue/KT-42130) FIR: type variable is observed after when condition analysis
|
||||
- [`KT-42132`](https://youtrack.jetbrains.com/issue/KT-42132) FIR2IR: companion function reference has no dispatch receiver
|
||||
- [`KT-42137`](https://youtrack.jetbrains.com/issue/KT-42137) JVM IR: AbstractMethodError on complex hierarchy where implementation comes from another supertype and has a more specific type
|
||||
- [`KT-42186`](https://youtrack.jetbrains.com/issue/KT-42186) JVM / IR: Infinite cycle in for expression when unsigned bytes are used in decreasing loop range
|
||||
- [`KT-42251`](https://youtrack.jetbrains.com/issue/KT-42251) JVM / IR: "IllegalStateException: Descriptor can be left only if it is last" when comparing the i-th element of the container of Int? and `i` with change
|
||||
- [`KT-42253`](https://youtrack.jetbrains.com/issue/KT-42253) JVM IR: NoSuchFieldError on local delegated property in inline function whose call site happens before declaration in the source
|
||||
- [`KT-42281`](https://youtrack.jetbrains.com/issue/KT-42281) JVM / IR: AnalyzerException when comparing Int and array that cast to Any in if condition
|
||||
- [`KT-42340`](https://youtrack.jetbrains.com/issue/KT-42340) FIR2IR: duplicating fake overrides
|
||||
- [`KT-42344`](https://youtrack.jetbrains.com/issue/KT-42344) IR-based evaluator doesn't support "annotation in annotation"
|
||||
- [`KT-42346`](https://youtrack.jetbrains.com/issue/KT-42346) FIR: double-vararg in IR while resolving collection literal as Java annotation argument
|
||||
- [`KT-42348`](https://youtrack.jetbrains.com/issue/KT-42348) FIR: false UNINITIALIZED_VARIABLE in local class
|
||||
- [`KT-42350`](https://youtrack.jetbrains.com/issue/KT-42350) FIR: false UNINITIALIZED_VARIABLE after initialization in try block
|
||||
- [`KT-42351`](https://youtrack.jetbrains.com/issue/KT-42351) FIR: false HIDDEN in enum entry member call
|
||||
- [`KT-42354`](https://youtrack.jetbrains.com/issue/KT-42354) JVM / IR: "AssertionError: Unexpected IR element found during code generation" with KProperty `get` invocation
|
||||
- [`KT-42359`](https://youtrack.jetbrains.com/issue/KT-42359) FIR2IR: cannot mangle type parameter
|
||||
- [`KT-42373`](https://youtrack.jetbrains.com/issue/KT-42373) FIR2IR: local object nested class has no parent if forward-referenced by nested class supertype
|
||||
- [`KT-42384`](https://youtrack.jetbrains.com/issue/KT-42384) FIR (BE): top-level field has no parent class in BE
|
||||
- [`KT-42496`](https://youtrack.jetbrains.com/issue/KT-42496) FIR resolve: synthetic property is written but has no setter
|
||||
- [`KT-42517`](https://youtrack.jetbrains.com/issue/KT-42517) FIR: exception in BE for recursive inline call
|
||||
- [`KT-42530`](https://youtrack.jetbrains.com/issue/KT-42530) "AssertionError: No type for resolved lambda argument" on attempting to assign a Pair to a couple of values in a scratch file
|
||||
- [`KT-42601`](https://youtrack.jetbrains.com/issue/KT-42601) [FIR] Inherited declaration clash for stdlib inheritors
|
||||
- [`KT-42622`](https://youtrack.jetbrains.com/issue/KT-42622) NI: IllegalStateException for if expression with method reference inside flow
|
||||
- [`KT-42642`](https://youtrack.jetbrains.com/issue/KT-42642) ISE: No `getProgressionLastElement` for progression type IntProgressionType
|
||||
- [`KT-42650`](https://youtrack.jetbrains.com/issue/KT-42650) JVM IR: extraneous nullability annotation on a generic function of a flexible type
|
||||
- [`KT-42656`](https://youtrack.jetbrains.com/issue/KT-42656) FIR2IR: unsupported callable reference for Java field
|
||||
- [`KT-42725`](https://youtrack.jetbrains.com/issue/KT-42725) Debugger steps into core library inline functions in chained calls
|
||||
- [`KT-42758`](https://youtrack.jetbrains.com/issue/KT-42758) JVM / IR: Deserialized object that overrides readResolve() is not reference equal to the singleton instance
|
||||
- [`KT-42770`](https://youtrack.jetbrains.com/issue/KT-42770) FIR: duplicating signatures in mangler (typealias for functional type)
|
||||
- [`KT-42771`](https://youtrack.jetbrains.com/issue/KT-42771) FIR: duplicating signature in mangler (data class with delegate)
|
||||
- [`KT-42814`](https://youtrack.jetbrains.com/issue/KT-42814) FIR: false UNINITIALIZED_VARIABLE in local function after if...else
|
||||
- [`KT-42844`](https://youtrack.jetbrains.com/issue/KT-42844) FIR: Property write in init block resolved to parameter write
|
||||
- [`KT-42846`](https://youtrack.jetbrains.com/issue/KT-42846) JVM_IR: NPE on function reference to @JvmStatic method in a different file
|
||||
- [`KT-42933`](https://youtrack.jetbrains.com/issue/KT-42933) JVM / IR: "AnalyzerException: Expected an object reference, but found I" with local delegate in inline class
|
||||
- [`KT-43006`](https://youtrack.jetbrains.com/issue/KT-43006) JVM/JVM_IR: do not generate no-arg constructor for constructor with default arguments if there are inline class types in the signature
|
||||
- [`KT-43017`](https://youtrack.jetbrains.com/issue/KT-43017) JVM / IR: AssertionError when callable reference passed into a function requiring a suspendable function
|
||||
- [`KT-43051`](https://youtrack.jetbrains.com/issue/KT-43051) JVM IR: extraneous methods overridding default (Java 8) collection methods in inline class that extends MutableList
|
||||
- [`KT-43067`](https://youtrack.jetbrains.com/issue/KT-43067) Inner class declaration inside inline class should be prohibited
|
||||
- [`KT-43068`](https://youtrack.jetbrains.com/issue/KT-43068) JVM IR: no generic signatures for explicitly written methods in a List subclass, whose signature coincides with MutableList methods
|
||||
- [`KT-43132`](https://youtrack.jetbrains.com/issue/KT-43132) JVM / IR: Method name '<get-...>' in class '...$screenTexts$1$1' cannot be represented in dex format.
|
||||
- [`KT-43145`](https://youtrack.jetbrains.com/issue/KT-43145) JVM IR: $default methods in multi-file facades are generated as non-synthetic final
|
||||
- [`KT-43156`](https://youtrack.jetbrains.com/issue/KT-43156) FIR: false UNINITIALIZED_VARIABLE after initialization in `synchronized` block
|
||||
- [`KT-43196`](https://youtrack.jetbrains.com/issue/KT-43196) JVM: extra non-static member is generated for extension property in inline class
|
||||
- [`KT-43199`](https://youtrack.jetbrains.com/issue/KT-43199) JVM IR: synthetic flag for deprecated-hidden is not generated for DeprecatedSinceKotlin and deprecation from override
|
||||
- [`KT-43207`](https://youtrack.jetbrains.com/issue/KT-43207) JVM IR: no collection stub for `iterator` is generated on extending AbstractCollection
|
||||
- [`KT-43217`](https://youtrack.jetbrains.com/issue/KT-43217) JVM_IR: Multiple FAKE_OVERRIDES for java methods using @NonNull Double and java double
|
||||
- [`KT-43225`](https://youtrack.jetbrains.com/issue/KT-43225) Confusing message of warning NULLABLE_TYPE_PARAMETER_AGAINST_NOT_NULL_TYPE_PARAMETER
|
||||
- [`KT-43226`](https://youtrack.jetbrains.com/issue/KT-43226) "Incompatible stack heights" with non-local return to outer lambda inside suspend lambda
|
||||
- [`KT-43242`](https://youtrack.jetbrains.com/issue/KT-43242) JVM / IR: "AnalyzerException: Expected I, but found R" caused by `when` inside object with @Nullable Integer subject
|
||||
- [`KT-43249`](https://youtrack.jetbrains.com/issue/KT-43249) Wrong code generated for suspend lambdas with inline class parameters
|
||||
- [`KT-43286`](https://youtrack.jetbrains.com/issue/KT-43286) JVM IR: IAE "Inline class types should have the same representation: Lkotlin/UInt; != I" on smart cast of unsigned type value with JVM target 1.8
|
||||
- [`KT-43326`](https://youtrack.jetbrains.com/issue/KT-43326) JVM_IR: No deprecated flag for getter of deprecated interface property copied to DefaultImpls
|
||||
- [`KT-43327`](https://youtrack.jetbrains.com/issue/KT-43327) JVM_IR: No deprecated or synthetic flag for accessors of deprecated-hidden property of unsigned type
|
||||
- [`KT-43332`](https://youtrack.jetbrains.com/issue/KT-43332) FIR: Smart casts lead to false-positive ambiguity
|
||||
- [`KT-43370`](https://youtrack.jetbrains.com/issue/KT-43370) JVM IR: No deprecated flag for getter of deprecated property copied via delegation by interface
|
||||
- [`KT-43459`](https://youtrack.jetbrains.com/issue/KT-43459) JVM_IR. Wrong signature for synthetic $annotations method for extension property on nullable primitive
|
||||
- [`KT-43478`](https://youtrack.jetbrains.com/issue/KT-43478) NI: "IndexOutOfBoundsException: Index: 3, Size: 3" caused by `is` check with raw type inside `if` condition with `when` inside
|
||||
- [`KT-43519`](https://youtrack.jetbrains.com/issue/KT-43519) JVM_IR. External functions generated differently in multi file facades
|
||||
- [`KT-43524`](https://youtrack.jetbrains.com/issue/KT-43524) JVM_IR. Missed deprecation flag on companion @JvmStatic property accessor
|
||||
- [`KT-43525`](https://youtrack.jetbrains.com/issue/KT-43525) Prohibit JvmOverloads on declarations with inline class types in parameters
|
||||
- [`KT-43536`](https://youtrack.jetbrains.com/issue/KT-43536) JVM IR: IllegalStateException is not caught by runCatching under Deferred.await() with kotlinx.coroutines
|
||||
- [`KT-43562`](https://youtrack.jetbrains.com/issue/KT-43562) JVM IR: incorrect mangling for Collection.size in unsigned arrays
|
||||
- [`KT-43584`](https://youtrack.jetbrains.com/issue/KT-43584) [FIR] Java annotations with named arguments aren't loaded correctly
|
||||
- [`KT-43587`](https://youtrack.jetbrains.com/issue/KT-43587) Invalid default parameter value in expect actual declaration on jvm
|
||||
- [`KT-43630`](https://youtrack.jetbrains.com/issue/KT-43630) "AssertionError: Number of arguments should not be less than number of parameters" during capturing intersection raw type with star projection
|
||||
- [`KT-43698`](https://youtrack.jetbrains.com/issue/KT-43698) NoSuchMethodError for inline class implementing interface with @JvmDefault methods, -Xjvm-default=enable
|
||||
- [`KT-43741`](https://youtrack.jetbrains.com/issue/KT-43741) Report error on inline class implementing 'kotlin.Cloneable'
|
||||
- [`KT-43845`](https://youtrack.jetbrains.com/issue/KT-43845) org.jetbrains.kotlin.codegen.CompilationException: Back-end (JVM) Internal error: Failed to generate expression: KtBlockExpression
|
||||
- [`KT-43956`](https://youtrack.jetbrains.com/issue/KT-43956) NI: "Error type encountered – UninferredParameterTypeConstructor" on "try" and other constructs with code block as a value
|
||||
- [`KT-44055`](https://youtrack.jetbrains.com/issue/KT-44055) Left uninferred type parameter for callable references inside special calls
|
||||
- [`KT-44113`](https://youtrack.jetbrains.com/issue/KT-44113) Compiler frontend exception: Number of arguments should not be less than number of parameters, but: parameters=2, args=1
|
||||
- [`KT-44145`](https://youtrack.jetbrains.com/issue/KT-44145) No highlighting for not initialized base constructor and NoSuchMethodError in Android plugin
|
||||
- [`KT-44540`](https://youtrack.jetbrains.com/issue/KT-44540) Regression in 1.4.30 in intellij-community: type mismatch for generic function call with generic Java class
|
||||
- [`KT-44563`](https://youtrack.jetbrains.com/issue/KT-44563) Type Inference loosing type annotations in lambda type expectation for function calls with block parameters
|
||||
|
||||
### IDE
|
||||
|
||||
#### New Features
|
||||
|
||||
- [`KT-44075`](https://youtrack.jetbrains.com/issue/KT-44075) Sealed interfaces: New Kotlin Class/File menu update
|
||||
|
||||
#### Fixes
|
||||
|
||||
- [`KT-29454`](https://youtrack.jetbrains.com/issue/KT-29454) Light class with unexpected name when using obfuscated library
|
||||
- [`KT-31553`](https://youtrack.jetbrains.com/issue/KT-31553) Complete Statement: Wrong auto-insertion of closing curly brace for a code block
|
||||
- [`KT-33466`](https://youtrack.jetbrains.com/issue/KT-33466) IDE generates incorrect `external override` with body for overriding `open external` method
|
||||
- [`KT-39458`](https://youtrack.jetbrains.com/issue/KT-39458) Add CLI support for UL classes
|
||||
- [`KT-40403`](https://youtrack.jetbrains.com/issue/KT-40403) UAST: PsiMethod for invoked extension function/property misses `@receiver:` annotations
|
||||
- [`KT-41406`](https://youtrack.jetbrains.com/issue/KT-41406) Kotlin doesn't report annotations for type arguments (no way to add `@Nls`, `@NonNls` annotations to String collections in Kotlin)
|
||||
- [`KT-41420`](https://youtrack.jetbrains.com/issue/KT-41420) UAST does not return information about type annotations
|
||||
- [`KT-42194`](https://youtrack.jetbrains.com/issue/KT-42194) OOME: Java heap space from incremental compilation
|
||||
- [`KT-42754`](https://youtrack.jetbrains.com/issue/KT-42754) MPP: no smart cast for Common nullable property used in platform module
|
||||
- [`KT-42821`](https://youtrack.jetbrains.com/issue/KT-42821) MPP, IDE: Platform-specific errors are reported even when build doesn't target that platform
|
||||
- [`KT-44116`](https://youtrack.jetbrains.com/issue/KT-44116) Add language version 1.5 to the compiler configuration preferences
|
||||
- [`KT-44523`](https://youtrack.jetbrains.com/issue/KT-44523) IDE notification for trying new JVM backend
|
||||
- [`KT-44543`](https://youtrack.jetbrains.com/issue/KT-44543) Kotlin's LowMemoryWatcher leaks on Kotlin plugin unload
|
||||
|
||||
### IDE. Android
|
||||
|
||||
- [`KT-42381`](https://youtrack.jetbrains.com/issue/KT-42381) MPP: Bad IDEA dependencies: JVM module depending on built artifact instead of sources of module with Android Plugin applied
|
||||
|
||||
### IDE. Completion
|
||||
|
||||
- [`KT-44016`](https://youtrack.jetbrains.com/issue/KT-44016) Code completion: support for "sealed interface"
|
||||
- [`KT-44250`](https://youtrack.jetbrains.com/issue/KT-44250) Code completion does not work in when expression with sealed type argument
|
||||
|
||||
### IDE. Gradle. Script
|
||||
|
||||
- [`KT-39105`](https://youtrack.jetbrains.com/issue/KT-39105) AE “JvmBuiltins has not been initialized properly” after creating new Gradle/Kotlin-based project via old Project Wizard
|
||||
|
||||
### IDE. Inspections and Intentions
|
||||
|
||||
#### New Features
|
||||
|
||||
- [`KT-22666`](https://youtrack.jetbrains.com/issue/KT-22666) "Create enum constant" quick fix could be provided
|
||||
- [`KT-24556`](https://youtrack.jetbrains.com/issue/KT-24556) Add Remove quick fix for "Expression under 'when' is never equal to null"
|
||||
- [`KT-34121`](https://youtrack.jetbrains.com/issue/KT-34121) Report unused result of data class `copy` method
|
||||
- [`KT-34533`](https://youtrack.jetbrains.com/issue/KT-34533) INLINE_CLASS_CONSTRUCTOR_NOT_FINAL_READ_ONLY_PARAMETER: Add quickfix "Add val to parameter"
|
||||
- [`KT-35215`](https://youtrack.jetbrains.com/issue/KT-35215) Quickfix for CONST_VAL_NOT_TOP_LEVEL_OR_OBJECT to remove `const` modifier
|
||||
- [`KT-40251`](https://youtrack.jetbrains.com/issue/KT-40251) Intention action to evaluate compile time expression
|
||||
- [`KT-44017`](https://youtrack.jetbrains.com/issue/KT-44017) Sealed interfaces: Java side Inspection "implementation of Kotlin sealed interface is forbidden"
|
||||
- [`KT-43941`](https://youtrack.jetbrains.com/issue/KT-43941) Sealed interfaces: intention to extend class/interface
|
||||
- [`KT-44043`](https://youtrack.jetbrains.com/issue/KT-44043) Sealed interfaces: quickfix to move class/interface to proper location
|
||||
|
||||
#### Fixes
|
||||
|
||||
- [`KT-20420`](https://youtrack.jetbrains.com/issue/KT-20420) Intention "Put arguments/parameters on separate lines" doesn't respect the "Place ')' on new line" Kotlin code style setting
|
||||
- [`KT-21799`](https://youtrack.jetbrains.com/issue/KT-21799) Quickfix "Change function signature" for receiver type doesn't change it
|
||||
- [`KT-22665`](https://youtrack.jetbrains.com/issue/KT-22665) "Create object" quick fix produce wrong code for enum
|
||||
- [`KT-23934`](https://youtrack.jetbrains.com/issue/KT-23934) IntelliJ suggest "merge map to joinToString" even when such action is impossible due to suspending actions in map
|
||||
- [`KT-30894`](https://youtrack.jetbrains.com/issue/KT-30894) Wrong results of intention "Add names to call arguments" when backticked argument starts from digit
|
||||
- [`KT-31523`](https://youtrack.jetbrains.com/issue/KT-31523) ReplaceWith introduces additional argument name for lambda when named argument is used on call-site
|
||||
- [`KT-31833`](https://youtrack.jetbrains.com/issue/KT-31833) JavaMapForEachInspection should report for expression with implicit receiver
|
||||
- [`KT-33096`](https://youtrack.jetbrains.com/issue/KT-33096) Turn 'MapGetWithNotNullAssertionOperator' into an intention
|
||||
- [`KT-33212`](https://youtrack.jetbrains.com/issue/KT-33212) False positive "map.put() should be converted to assignment" inspection when class inherited from MutableMap has "set" method
|
||||
- [`KT-34270`](https://youtrack.jetbrains.com/issue/KT-34270) False negative "Join declaration and assignment" with constructor call
|
||||
- [`KT-34859`](https://youtrack.jetbrains.com/issue/KT-34859) False positive "Should be replaced with Kotlin function" inspection for Character.toString(int) function
|
||||
- [`KT-34959`](https://youtrack.jetbrains.com/issue/KT-34959) False positive "Redundant overriding method" with different implemented/overridden signatures
|
||||
- [`KT-35051`](https://youtrack.jetbrains.com/issue/KT-35051) False positive "Remove redundant backticks" if variable inside the string and isn't followed by space
|
||||
- [`KT-35097`](https://youtrack.jetbrains.com/issue/KT-35097) False positive "Call replaceable with binary operator" on explicit 'equals' call on a platform type value
|
||||
- [`KT-35165`](https://youtrack.jetbrains.com/issue/KT-35165) "Replace 'if' with elvis operator": don't suggest if val initializer is a complex expression
|
||||
- [`KT-35346`](https://youtrack.jetbrains.com/issue/KT-35346) False positive 'Make internal' suggestion for function inside interface
|
||||
- [`KT-35357`](https://youtrack.jetbrains.com/issue/KT-35357) "Move lambda argument out of parentheses" does not preserve block comments
|
||||
- [`KT-38349`](https://youtrack.jetbrains.com/issue/KT-38349) Invalid suggestion to fold to elvis when having a var-variable
|
||||
- [`KT-40704`](https://youtrack.jetbrains.com/issue/KT-40704) False negative "Redundant semicolon" at start of line
|
||||
- [`KT-40861`](https://youtrack.jetbrains.com/issue/KT-40861) "Convert to secondary constructor" intention expected on class name
|
||||
- [`KT-40879`](https://youtrack.jetbrains.com/issue/KT-40879) False positive "Redundant 'inner' modifier" when calling another inner class with empty constructor
|
||||
- [`KT-40985`](https://youtrack.jetbrains.com/issue/KT-40985) "Remove explicit type arguments" is suggested when type has an annotation
|
||||
- [`KT-41223`](https://youtrack.jetbrains.com/issue/KT-41223) False positive "Redundant inner modifier" inspection ignores constructor arguments of object expressions
|
||||
- [`KT-41246`](https://youtrack.jetbrains.com/issue/KT-41246) False positive "Receiver parameter is never used" with anonymous function expression
|
||||
- [`KT-41298`](https://youtrack.jetbrains.com/issue/KT-41298) "Remove redundant 'with' call" intention works incorrectly with non-local returns and single-expression functions
|
||||
- [`KT-41311`](https://youtrack.jetbrains.com/issue/KT-41311) False positive "Redundant inner modifier" when deriving from a nested Java class
|
||||
- [`KT-41499`](https://youtrack.jetbrains.com/issue/KT-41499) "Convert receiver to parameter" produces code with incorrect order of generic type and function invocation in case of generic function with lambda as a parameter
|
||||
- [`KT-41680`](https://youtrack.jetbrains.com/issue/KT-41680) False positive "Redundant inner modifier" when deriving from class with non-empty constructor and value passed to it from enclosing class
|
||||
- [`KT-42201`](https://youtrack.jetbrains.com/issue/KT-42201) Add Opt-In action doesn't work if there is already OptIn annotation
|
||||
- [`KT-42255`](https://youtrack.jetbrains.com/issue/KT-42255) "Replace elvis expression with 'if' expression" intention shouldn't introduce unnecessary variable if 'error' expression is used
|
||||
|
||||
### IDE. JS
|
||||
|
||||
- [`KT-43760`](https://youtrack.jetbrains.com/issue/KT-43760) KJS: Debugging Kotlin code for Node.js runtime doesn't work
|
||||
|
||||
### IDE. Misc
|
||||
|
||||
- [`KT-44018`](https://youtrack.jetbrains.com/issue/KT-44018) Sealed interfaces: IDE side implementation for hierarchy provider
|
||||
|
||||
### IDE. Multiplatform
|
||||
|
||||
- [`KT-40814`](https://youtrack.jetbrains.com/issue/KT-40814) MISSING_DEPENDENCY_CLASS when consuming native-shared library in a source-set with fewer targets than library has
|
||||
|
||||
### IDE. Run Configurations
|
||||
|
||||
- [`KT-34535`](https://youtrack.jetbrains.com/issue/KT-34535) Unable to run common tests on Android via gutter icon in a multiplatform project
|
||||
|
||||
### IDE. Scratch
|
||||
|
||||
- [`KT-25038`](https://youtrack.jetbrains.com/issue/KT-25038) Scratch: Destructuring declaration produces an unresolved reference
|
||||
- [`KT-43415`](https://youtrack.jetbrains.com/issue/KT-43415) Kotlin scratch file could not be run and could lead to dead lock
|
||||
|
||||
### IDE. Script
|
||||
|
||||
- [`KT-44117`](https://youtrack.jetbrains.com/issue/KT-44117) IDE / Scripts: custom kotlin script definitions aren't loaded
|
||||
|
||||
### JavaScript
|
||||
|
||||
#### Fixes
|
||||
|
||||
- [`KT-31072`](https://youtrack.jetbrains.com/issue/KT-31072) Don't use non-reified arguments to specialize type operations in IR inliner
|
||||
- [`KT-39964`](https://youtrack.jetbrains.com/issue/KT-39964) Throwable incorrectly implements constructor for (null, cause) args in K/JS-IR
|
||||
- [`KT-40090`](https://youtrack.jetbrains.com/issue/KT-40090) KJS: IR. Invalid behaviour for optional parameters (redundant tail undefined parameters)
|
||||
- [`KT-40686`](https://youtrack.jetbrains.com/issue/KT-40686) KJS: Uncaught ReferenceError caused by external class as type inside eventListener in init block
|
||||
- [`KT-40771`](https://youtrack.jetbrains.com/issue/KT-40771) KJS / IR: "ReferenceError: Metadata is not defined" caused by default parameter value in inner class constructor
|
||||
- [`KT-41032`](https://youtrack.jetbrains.com/issue/KT-41032) KJS / IR: "AssertionError: Assertion failed" caused by class that is delegated to inherited interface
|
||||
- [`KT-41076`](https://youtrack.jetbrains.com/issue/KT-41076) KJS / IR: "AssertionError: Assertion failed" caused by overridden extensiion function in child class
|
||||
- [`KT-41771`](https://youtrack.jetbrains.com/issue/KT-41771) KJS / IR: IndexOutOfBoundsException "Index 0 out of bounds for length 0" caused by inline class with List in primary constructor and vararg in secondary
|
||||
- [`KT-42025`](https://youtrack.jetbrains.com/issue/KT-42025) KJS / IR: IrConstructorCallImpl: No such type argument slot: 0
|
||||
- [`KT-42112`](https://youtrack.jetbrains.com/issue/KT-42112) KJS: StackOverflowError on @JsExport in case of name clash with function with Enum parameter with star-projection
|
||||
- [`KT-42262`](https://youtrack.jetbrains.com/issue/KT-42262) KJS: `break`-statements without label are ignored in a `when`
|
||||
- [`KT-42357`](https://youtrack.jetbrains.com/issue/KT-42357) KotlinJS - external class constructor with vararg does not correctly handle spread operator.
|
||||
- [`KT-42364`](https://youtrack.jetbrains.com/issue/KT-42364) KJS: Properties of interface delegate are non-configurable
|
||||
- [`KT-43212`](https://youtrack.jetbrains.com/issue/KT-43212) JS IR: support `init` blocks inside inline classes
|
||||
- [`KT-43222`](https://youtrack.jetbrains.com/issue/KT-43222) KJS IR: prototype lazy initialization for top-level properties like in JVM
|
||||
- [`KT-43313`](https://youtrack.jetbrains.com/issue/KT-43313) KJS / IR: "Can't find name for declaration FUN" for secondary constructor
|
||||
- [`KT-43901`](https://youtrack.jetbrains.com/issue/KT-43901) Call to enum values() method from enum companion object leads to non-initialized enum instances
|
||||
|
||||
### KMM Plugin
|
||||
|
||||
- [`KT-41677`](https://youtrack.jetbrains.com/issue/KT-41677) Could not launch iOS project with custom display name
|
||||
- [`KT-42463`](https://youtrack.jetbrains.com/issue/KT-42463) Launch common tests for Android on local JVM via run gutter
|
||||
- [`KT-43188`](https://youtrack.jetbrains.com/issue/KT-43188) NoSuchMethodError in New Module Wizard of KMM Project
|
||||
|
||||
### Libraries
|
||||
|
||||
- [`KT-41112`](https://youtrack.jetbrains.com/issue/KT-41112) Docs: add more details about bit shift operations
|
||||
- [`KT-41278`](https://youtrack.jetbrains.com/issue/KT-41278) map.entries.contains can return false if the argument is not MutableEntry
|
||||
- [`KT-41356`](https://youtrack.jetbrains.com/issue/KT-41356) Incorrect documentation for `rangeTo` function
|
||||
- [`KT-44456`](https://youtrack.jetbrains.com/issue/KT-44456) Introduce locale-agnostic API for case conversions
|
||||
- [`KT-44458`](https://youtrack.jetbrains.com/issue/KT-44458) Introduce new Char-to-code and Char-to-digit conversions
|
||||
|
||||
### Middle-end. IR
|
||||
|
||||
- [`KT-41765`](https://youtrack.jetbrains.com/issue/KT-41765) [Native/IR] Could not resolveFakeOverride()
|
||||
- [`KT-42054`](https://youtrack.jetbrains.com/issue/KT-42054) Psi2ir: "RuntimeException: IrSimpleFunctionSymbolImpl is already bound" when using result of function with overload resolution by lambda return type
|
||||
|
||||
### Native
|
||||
|
||||
- [`KT-44219`](https://youtrack.jetbrains.com/issue/KT-44219) 1.4.30-M1: Non-reified type parameters with recursive bounds are not supported yet
|
||||
- [`KT-44271`](https://youtrack.jetbrains.com/issue/KT-44271) [Kotlin/Native] Incorrect linking when targeting linux_x64 from mingw_x64 host
|
||||
|
||||
### Native. C and ObjC Import
|
||||
|
||||
- [`KT-42412`](https://youtrack.jetbrains.com/issue/KT-42412) [C-interop] Modality of generated property accessors is always FINAL
|
||||
|
||||
### Native. ObjC Export
|
||||
|
||||
- [`KT-38530`](https://youtrack.jetbrains.com/issue/KT-38530) Native: values() method of enum classes is not exposed to Objective-C/Swift
|
||||
- [`KT-43599`](https://youtrack.jetbrains.com/issue/KT-43599) K/N: Unbound symbols not allowed
|
||||
|
||||
### Native. Platform libraries
|
||||
|
||||
- [`KT-43597`](https://youtrack.jetbrains.com/issue/KT-43597) Support for Xcode 12.2 SDK
|
||||
|
||||
### Native. Platforms
|
||||
|
||||
- [`KT-43276`](https://youtrack.jetbrains.com/issue/KT-43276) Support watchos_x64 target
|
||||
|
||||
### Native. Runtime
|
||||
|
||||
- [`KT-42822`](https://youtrack.jetbrains.com/issue/KT-42822) Kotlin/Native Worker leaks ObjC/Swift autorelease references (and indirectly bridged K/N references) on Darwin targets
|
||||
|
||||
### Native. Stdlib
|
||||
|
||||
- [`KT-42172`](https://youtrack.jetbrains.com/issue/KT-42172) Kotlin/Native: StableRef.dispose race condition on Kotlin deinitRuntime
|
||||
- [`KT-42428`](https://youtrack.jetbrains.com/issue/KT-42428) Inconsistent behavior of map.entries on Kotlin.Native
|
||||
|
||||
### Reflection
|
||||
|
||||
- [`KT-34024`](https://youtrack.jetbrains.com/issue/KT-34024) "KotlinReflectionInternalError: Inconsistent number of parameters" with `javaMethod` on suspending functions with inline class in function signature or inside the function
|
||||
|
||||
### Tools. CLI
|
||||
|
||||
- [`KT-43294`](https://youtrack.jetbrains.com/issue/KT-43294) Support `-no-stdlib` option for the `kotlin` runner
|
||||
- [`KT-43406`](https://youtrack.jetbrains.com/issue/KT-43406) JVM: produce deterministic jar files if -d option value is a .jar file
|
||||
|
||||
### Tools. CLI. Native
|
||||
|
||||
- [`KT-40670`](https://youtrack.jetbrains.com/issue/KT-40670) Allow to override konan.properties via CLI
|
||||
|
||||
### Tools. Compiler Plugins
|
||||
|
||||
- [`KT-41764`](https://youtrack.jetbrains.com/issue/KT-41764) KJS /IR IllegalStateException: "Symbol for public kotlin/arrayOf is unbound" with serialization plugin
|
||||
- [`KT-42976`](https://youtrack.jetbrains.com/issue/KT-42976) kotlinx.serialization + JVM IR: NPE on annotation with @SerialInfo
|
||||
- [`KT-43725`](https://youtrack.jetbrains.com/issue/KT-43725) Prohibit inner and local classes in kotlin-noarg
|
||||
|
||||
### Tools. Gradle
|
||||
|
||||
- [`KT-38692`](https://youtrack.jetbrains.com/issue/KT-38692) KaptGenerateStubs Gradle task will not clean up outputs when sources are empty and not an incremental build
|
||||
- [`KT-40140`](https://youtrack.jetbrains.com/issue/KT-40140) kotlin-android plugin eagerly creates several Gradle tasks
|
||||
- [`KT-41295`](https://youtrack.jetbrains.com/issue/KT-41295) Kotlin Gradle Plugin 1.4.20 Configuration Caching bug due to friendPath provider
|
||||
- [`KT-42058`](https://youtrack.jetbrains.com/issue/KT-42058) Support moduleName option in Kotlin Gradle plugin for JVM
|
||||
- [`KT-43054`](https://youtrack.jetbrains.com/issue/KT-43054) Implementation of `AbstractKotlinTarget#buildAdhocComponentsFromKotlinVariants` breaks configuration caching
|
||||
- [`KT-43489`](https://youtrack.jetbrains.com/issue/KT-43489) Incremental compilation - unable to find history files causing full recompilation
|
||||
- [`KT-43740`](https://youtrack.jetbrains.com/issue/KT-43740) Gradle out-of-process runner fails with unclear diagnostics if build directory does not exist
|
||||
- [`KT-43895`](https://youtrack.jetbrains.com/issue/KT-43895) Fix cacheability warnings for the Kotlin plugins
|
||||
|
||||
### Tools. Gradle. JS
|
||||
|
||||
- [`KT-42400`](https://youtrack.jetbrains.com/issue/KT-42400) Kotlin/JS: Gradle DSL: customField() is rejected in Groovy build.gradle
|
||||
- [`KT-42462`](https://youtrack.jetbrains.com/issue/KT-42462) NPM dependency declaration with Groovy interpolated string
|
||||
- [`KT-42954`](https://youtrack.jetbrains.com/issue/KT-42954) Kotlin/JS: IDE import after changing `kotlin.js.externals.output.format` does not re-generate externals
|
||||
- [`KT-43535`](https://youtrack.jetbrains.com/issue/KT-43535) Common webpack configuration breaks on lambda serialization in some cases
|
||||
- [`KT-43668`](https://youtrack.jetbrains.com/issue/KT-43668) PackageJson task use file dependencies as is (files and directories), but only files necessary
|
||||
- [`KT-43793`](https://youtrack.jetbrains.com/issue/KT-43793) nodeArgs in NodeJsExec task
|
||||
- [`KT-43842`](https://youtrack.jetbrains.com/issue/KT-43842) KJS: Invalid `output.library` support for `null` value
|
||||
- [`KT-44104`](https://youtrack.jetbrains.com/issue/KT-44104) KJS / Gradle: An ability to pass jvm args to K2JSDce process
|
||||
|
||||
### Tools. Gradle. Multiplatform
|
||||
|
||||
- [`KT-42269`](https://youtrack.jetbrains.com/issue/KT-42269) Setup default dependsOn edges for Android source sets
|
||||
- [`KT-42413`](https://youtrack.jetbrains.com/issue/KT-42413) [MPP/gradle] `withJava` breaks build on 1.4.20-M1
|
||||
- [`KT-43141`](https://youtrack.jetbrains.com/issue/KT-43141) Gradle / Configuration cache: NPE from org.jetbrains.kotlin.gradle.tasks.KotlinCompileCommon.getKotlinOptions() on reusing configuration cache for task compileCommonMainKotlinMetadata
|
||||
- [`KT-43329`](https://youtrack.jetbrains.com/issue/KT-43329) Gradle / Configuration cache: IAE “Parameter specified as non-null is null: method KotlinMetadataTargetConfiguratorKt.isCompatibilityMetadataVariantEnabled, parameter $this$isCompatibilityMetadataVariantEnabled” on reusing configuration cache for task compileKotlinMetadata
|
||||
- [`KT-44298`](https://youtrack.jetbrains.com/issue/KT-44298) Kotlin 1.4.20+ MPP "root" module publication does not include the source JAR that used to be published in the -metadata modules
|
||||
|
||||
### Tools. Gradle. Native
|
||||
|
||||
- [`KT-39564`](https://youtrack.jetbrains.com/issue/KT-39564) Make kotlin-native Gradle tasks Cacheable
|
||||
- [`KT-42485`](https://youtrack.jetbrains.com/issue/KT-42485) Fail on cinterop: clang_indexTranslationUnit returned 1
|
||||
- [`KT-42550`](https://youtrack.jetbrains.com/issue/KT-42550) Adding subspec dependency with git location failed
|
||||
- [`KT-42849`](https://youtrack.jetbrains.com/issue/KT-42849) Gradle / Configuration cache: tasks nativeMetadataJar, runReleaseExecutableNative, runDebugExecutableNative are unsupported and fails on reusing configuration cache
|
||||
- [`KT-42938`](https://youtrack.jetbrains.com/issue/KT-42938) CocoaPods Gradle plugin: podBuildDependencies doesn't properly report xcodebuild failures
|
||||
- [`KT-43151`](https://youtrack.jetbrains.com/issue/KT-43151) Gradle / Configuration cache: UPAE “lateinit property binary has not been initialized” on reusing configuration cache for linkDebugExecutableNative, linkDebugTestNative, linkReleaseExecutableNative tasks
|
||||
- [`KT-43516`](https://youtrack.jetbrains.com/issue/KT-43516) Failed to resolve Kotin library [Multiple Multiplatform modules]
|
||||
|
||||
### Tools. Incremental Compile
|
||||
|
||||
- [`KT-42937`](https://youtrack.jetbrains.com/issue/KT-42937) another compilation fail (problem with compilation caches?)
|
||||
|
||||
### Tools. JPS
|
||||
|
||||
- [`KT-39536`](https://youtrack.jetbrains.com/issue/KT-39536) JPS compilation fails with IOException "storage is already closed"
|
||||
|
||||
### Tools. Parcelize
|
||||
|
||||
- [`KT-41553`](https://youtrack.jetbrains.com/issue/KT-41553) JVM IR, Parcelize: IrStarProjectionImpl cannot be cast to class IrTypeProjection
|
||||
|
||||
### Tools. Scripts
|
||||
|
||||
- [`KT-43534`](https://youtrack.jetbrains.com/issue/KT-43534) Allow running "main.kts" script that does not end in a "main.kts" filename (would allow kotlin scripting on GitHub Actions)
|
||||
- [`KT-43176`](https://youtrack.jetbrains.com/issue/KT-43176) NoSuchMethodError: 'int Script.access$getAValue$p(Script) for not-inlined functions
|
||||
- [`KT-43294`](https://youtrack.jetbrains.com/issue/KT-43294) Support `-no-stdlib` option for the `kotlin` runner
|
||||
|
||||
### Tools. kapt
|
||||
|
||||
- [`KT-34340`](https://youtrack.jetbrains.com/issue/KT-34340) Incremental annotation processor recompile all files (only if KAPT enabled).
|
||||
- [`KT-36667`](https://youtrack.jetbrains.com/issue/KT-36667) Kapt: Add a flag to strip kotlin.Metadata() annotations from stubs
|
||||
- [`KT-40493`](https://youtrack.jetbrains.com/issue/KT-40493) KAPT does not support aggregating annotations processors in incremental mode
|
||||
- [`KT-40882`](https://youtrack.jetbrains.com/issue/KT-40882) Kapt stub generation is non-deterministic for incremental compilation
|
||||
- [`KT-41788`](https://youtrack.jetbrains.com/issue/KT-41788) NullPointerException: Random crashes of build using gradle and kapt because of not calling Processor.init()
|
||||
- [`KT-42182`](https://youtrack.jetbrains.com/issue/KT-42182) KAPT: Does not consider generated sources for incremental compilation.
|
||||
|
||||
|
||||
## 1.4.20
|
||||
|
||||
### Android
|
||||
@@ -2876,4 +2390,4 @@
|
||||
### [ChangeLog-1.3.X](ChangeLog-1.3.X.md)
|
||||
### [ChangeLog-1.2.X](ChangeLog-1.2.X.md)
|
||||
### [ChangeLog-1.1.X](ChangeLog-1.1.X.md)
|
||||
### [ChangeLog-1.0.X](ChangeLog-1.0.X.md)
|
||||
### [ChangeLog-1.0.X](ChangeLog-1.0.X.md)
|
||||
@@ -19,7 +19,6 @@ package org.jetbrains.kotlin.incremental
|
||||
import com.intellij.util.io.EnumeratorStringDescriptor
|
||||
import org.jetbrains.kotlin.incremental.storage.*
|
||||
import org.jetbrains.kotlin.metadata.ProtoBuf
|
||||
import org.jetbrains.kotlin.metadata.deserialization.Flags
|
||||
import org.jetbrains.kotlin.metadata.deserialization.NameResolver
|
||||
import org.jetbrains.kotlin.metadata.deserialization.TypeTable
|
||||
import org.jetbrains.kotlin.metadata.deserialization.supertypes
|
||||
@@ -35,15 +34,12 @@ interface IncrementalCacheCommon {
|
||||
val thisWithDependentCaches: Iterable<AbstractIncrementalCache<*>>
|
||||
fun classesFqNamesBySources(files: Iterable<File>): Collection<FqName>
|
||||
fun getSubtypesOf(className: FqName): Sequence<FqName>
|
||||
fun getSupertypesOf(className: FqName): Sequence<FqName>
|
||||
fun getSourceFileIfClass(fqName: FqName): File?
|
||||
fun markDirty(removedAndCompiledSources: Collection<File>)
|
||||
fun clearCacheForRemovedClasses(changesCollector: ChangesCollector)
|
||||
fun getComplementaryFilesRecursive(dirtyFiles: Collection<File>): Collection<File>
|
||||
fun updateComplementaryFiles(dirtyFiles: Collection<File>, expectActualTracker: ExpectActualTrackerImpl)
|
||||
fun dump(): String
|
||||
|
||||
fun isSealed(className: FqName): Boolean?
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -54,7 +50,6 @@ abstract class AbstractIncrementalCache<ClassName>(
|
||||
protected val pathConverter: FileToPathConverter
|
||||
) : BasicMapsOwner(workingDir), IncrementalCacheCommon {
|
||||
companion object {
|
||||
private val CLASS_ATTRIBUTES = "class-attributes"
|
||||
private val SUBTYPES = "subtypes"
|
||||
private val SUPERTYPES = "supertypes"
|
||||
private val CLASS_FQ_NAME_TO_SOURCE = "class-fq-name-to-source"
|
||||
@@ -76,7 +71,6 @@ abstract class AbstractIncrementalCache<ClassName>(
|
||||
result
|
||||
}
|
||||
|
||||
internal val classAttributesMap = registerMap(ClassAttributesMap(CLASS_ATTRIBUTES.storageFile))
|
||||
private val subtypesMap = registerMap(SubtypesMap(SUBTYPES.storageFile))
|
||||
private val supertypesMap = registerMap(SupertypesMap(SUPERTYPES.storageFile))
|
||||
protected val classFqNameToSourceMap = registerMap(ClassFqNameToSourceMap(CLASS_FQ_NAME_TO_SOURCE.storageFile, pathConverter))
|
||||
@@ -96,14 +90,6 @@ abstract class AbstractIncrementalCache<ClassName>(
|
||||
override fun getSubtypesOf(className: FqName): Sequence<FqName> =
|
||||
subtypesMap[className].asSequence()
|
||||
|
||||
override fun getSupertypesOf(className: FqName): Sequence<FqName> {
|
||||
return supertypesMap[className].asSequence()
|
||||
}
|
||||
|
||||
override fun isSealed(className: FqName): Boolean? {
|
||||
return classAttributesMap[className]?.isSealed
|
||||
}
|
||||
|
||||
override fun getSourceFileIfClass(fqName: FqName): File? =
|
||||
classFqNameToSourceMap[fqName]
|
||||
|
||||
@@ -132,7 +118,6 @@ abstract class AbstractIncrementalCache<ClassName>(
|
||||
|
||||
supertypesMap[child] = parents
|
||||
classFqNameToSourceMap[child] = srcFile
|
||||
classAttributesMap[child] = ICClassesAttributes(ProtoBuf.Modality.SEALED == Flags.MODALITY.get(proto.flags))
|
||||
}
|
||||
|
||||
protected fun removeAllFromClassStorage(removedClasses: Collection<FqName>, changesCollector: ChangesCollector) {
|
||||
@@ -167,17 +152,14 @@ abstract class AbstractIncrementalCache<ClassName>(
|
||||
}
|
||||
}
|
||||
|
||||
removedFqNames.forEach {
|
||||
classFqNameToSourceMap.remove(it)
|
||||
classAttributesMap.remove(it)
|
||||
}
|
||||
removedFqNames.forEach { classFqNameToSourceMap.remove(it) }
|
||||
}
|
||||
|
||||
protected class ClassFqNameToSourceMap(
|
||||
storageFile: File,
|
||||
private val pathConverter: FileToPathConverter
|
||||
) : BasicStringMap<String>(storageFile, EnumeratorStringDescriptor(), PathStringDescriptor) {
|
||||
|
||||
) :
|
||||
BasicStringMap<String>(storageFile, EnumeratorStringDescriptor(), PathStringDescriptor) {
|
||||
operator fun set(fqName: FqName, sourceFile: File) {
|
||||
storage[fqName.asString()] = pathConverter.toPath(sourceFile)
|
||||
}
|
||||
|
||||
@@ -19,14 +19,12 @@ package org.jetbrains.kotlin.incremental
|
||||
import org.jetbrains.kotlin.metadata.ProtoBuf
|
||||
import org.jetbrains.kotlin.metadata.deserialization.Flags
|
||||
import org.jetbrains.kotlin.metadata.deserialization.NameResolver
|
||||
import org.jetbrains.kotlin.metadata.deserialization.supertypes
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.protobuf.MessageLite
|
||||
import org.jetbrains.kotlin.serialization.deserialization.getClassId
|
||||
|
||||
class ChangesCollector {
|
||||
private val removedMembers = hashMapOf<FqName, MutableSet<String>>()
|
||||
private val changedParents = hashMapOf<FqName, MutableSet<FqName>>()
|
||||
private val changedMembers = hashMapOf<FqName, MutableSet<String>>()
|
||||
private val areSubclassesAffected = hashMapOf<FqName, Boolean>()
|
||||
|
||||
@@ -49,10 +47,6 @@ class ChangesCollector {
|
||||
changes.add(ChangeInfo.SignatureChanged(fqName, areSubclassesAffected))
|
||||
}
|
||||
|
||||
for ((fqName, changedParents) in changedParents) {
|
||||
changes.add(ChangeInfo.ParentsChanged(fqName, changedParents))
|
||||
}
|
||||
|
||||
return changes
|
||||
}
|
||||
|
||||
@@ -85,12 +79,12 @@ class ChangesCollector {
|
||||
}
|
||||
|
||||
if (oldData == null) {
|
||||
newData!!.collectAll(isRemoved = false, isAdded = true, collectAllMembersForNewClass = collectAllMembersForNewClass)
|
||||
newData!!.collectAll(isRemoved = false, collectAllMembersForNewClass = collectAllMembersForNewClass)
|
||||
return
|
||||
}
|
||||
|
||||
if (newData == null) {
|
||||
oldData.collectAll(isRemoved = true, isAdded = false)
|
||||
oldData.collectAll(isRemoved = true)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -104,7 +98,6 @@ class ChangesCollector {
|
||||
collectSignature(oldData, diff.areSubclassesAffected)
|
||||
}
|
||||
collectChangedMembers(fqName, diff.changedMembersNames)
|
||||
addChangedParents(fqName, diff.changedSupertypes)
|
||||
}
|
||||
is PackagePartProtoData -> {
|
||||
collectSignature(oldData, areSubclassesAffected = true)
|
||||
@@ -128,11 +121,10 @@ class ChangesCollector {
|
||||
private fun <T> T.getNonPrivateNames(nameResolver: NameResolver, vararg members: T.() -> List<MessageLite>): Set<String> =
|
||||
members.flatMap { this.it().filterNot { it.isPrivate }.names(nameResolver) }.toSet()
|
||||
|
||||
//TODO remember all sealed parent classes
|
||||
private fun ProtoData.collectAll(isRemoved: Boolean, isAdded: Boolean, collectAllMembersForNewClass: Boolean = false) =
|
||||
private fun ProtoData.collectAll(isRemoved: Boolean, collectAllMembersForNewClass: Boolean = false) =
|
||||
when (this) {
|
||||
is PackagePartProtoData -> collectAllFromPackage(isRemoved)
|
||||
is ClassProtoData -> collectAllFromClass(isRemoved, isAdded, collectAllMembersForNewClass)
|
||||
is ClassProtoData -> collectAllFromClass(isRemoved, collectAllMembersForNewClass)
|
||||
}
|
||||
|
||||
private fun PackagePartProtoData.collectAllFromPackage(isRemoved: Boolean) {
|
||||
@@ -151,7 +143,7 @@ class ChangesCollector {
|
||||
}
|
||||
}
|
||||
|
||||
private fun ClassProtoData.collectAllFromClass(isRemoved: Boolean, isAdded: Boolean, collectAllMembersForNewClass: Boolean = false) {
|
||||
private fun ClassProtoData.collectAllFromClass(isRemoved: Boolean, collectAllMembersForNewClass: Boolean = false) {
|
||||
val classFqName = nameResolver.getClassId(proto.fqName).asSingleFqName()
|
||||
val kind = Flags.CLASS_KIND.get(proto.flags)
|
||||
|
||||
@@ -170,23 +162,6 @@ class ChangesCollector {
|
||||
|
||||
collectSignature(classFqName, areSubclassesAffected = true)
|
||||
}
|
||||
|
||||
if (isRemoved || isAdded) {
|
||||
collectChangedParents(classFqName, proto.supertypeList)
|
||||
}
|
||||
}
|
||||
|
||||
private fun addChangedParents(fqName: FqName, parents: Collection<FqName>) {
|
||||
if (parents.isNotEmpty()) {
|
||||
changedParents.getOrPut(fqName) { HashSet() }.addAll(parents)
|
||||
}
|
||||
}
|
||||
|
||||
private fun ClassProtoData.collectChangedParents(fqName: FqName, parents: Collection<ProtoBuf.Type>) {
|
||||
val changedParentsFqNames = parents.map { type ->
|
||||
nameResolver.getClassId(type.className).asSingleFqName()
|
||||
}
|
||||
addChangedParents(fqName, changedParentsFqNames)
|
||||
}
|
||||
|
||||
private fun ClassProtoData.getNonPrivateMemberNames(): Set<String> {
|
||||
|
||||
@@ -145,7 +145,6 @@ open class IncrementalJvmCache(
|
||||
}
|
||||
protoMap.remove(className, changesCollector)
|
||||
classFqNameToSourceMap.remove(className.fqNameForClassNameWithoutDollars)
|
||||
classAttributesMap.remove(className.fqNameForClassNameWithoutDollars)
|
||||
internalNameToSource.remove(className.internalName)
|
||||
|
||||
// TODO NO_CHANGES? (delegates only)
|
||||
@@ -272,7 +271,6 @@ open class IncrementalJvmCache(
|
||||
|
||||
private inner class ProtoMap(storageFile: File) : BasicStringMap<ProtoMapValue>(storageFile, ProtoMapValueExternalizer) {
|
||||
|
||||
@Synchronized
|
||||
fun process(kotlinClass: LocalFileKotlinClass, changesCollector: ChangesCollector) {
|
||||
return put(kotlinClass, changesCollector)
|
||||
}
|
||||
@@ -284,12 +282,10 @@ open class IncrementalJvmCache(
|
||||
// from files compiled during last round.
|
||||
// However there is no need to compare old and new data in this case
|
||||
// (also that would fail with exception).
|
||||
@Synchronized
|
||||
fun storeModuleMapping(className: JvmClassName, bytes: ByteArray) {
|
||||
storage[className.internalName] = ProtoMapValue(isPackageFacade = false, bytes = bytes, strings = emptyArray())
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
private fun put(kotlinClass: LocalFileKotlinClass, changesCollector: ChangesCollector) {
|
||||
val header = kotlinClass.classHeader
|
||||
|
||||
@@ -312,7 +308,6 @@ open class IncrementalJvmCache(
|
||||
operator fun get(className: JvmClassName): ProtoMapValue? =
|
||||
storage[className.internalName]
|
||||
|
||||
@Synchronized
|
||||
fun remove(className: JvmClassName, changesCollector: ChangesCollector) {
|
||||
val key = className.internalName
|
||||
val oldValue = storage[key] ?: return
|
||||
@@ -329,8 +324,6 @@ open class IncrementalJvmCache(
|
||||
|
||||
private inner class JavaSourcesProtoMap(storageFile: File) :
|
||||
BasicStringMap<SerializedJavaClass>(storageFile, JavaClassProtoMapValueExternalizer) {
|
||||
|
||||
@Synchronized
|
||||
fun process(jvmClassName: JvmClassName, newData: SerializedJavaClass, changesCollector: ChangesCollector) {
|
||||
val key = jvmClassName.internalName
|
||||
val oldData = storage[key]
|
||||
@@ -342,7 +335,6 @@ open class IncrementalJvmCache(
|
||||
)
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun remove(className: JvmClassName, changesCollector: ChangesCollector) {
|
||||
val key = className.internalName
|
||||
val oldValue = storage[key] ?: return
|
||||
@@ -382,7 +374,6 @@ open class IncrementalJvmCache(
|
||||
operator fun contains(className: JvmClassName): Boolean =
|
||||
className.internalName in storage
|
||||
|
||||
@Synchronized
|
||||
fun process(kotlinClass: LocalFileKotlinClass, changesCollector: ChangesCollector) {
|
||||
val key = kotlinClass.className.internalName
|
||||
val oldMap = storage[key] ?: emptyMap()
|
||||
@@ -399,7 +390,6 @@ open class IncrementalJvmCache(
|
||||
}
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun remove(className: JvmClassName) {
|
||||
storage.remove(className.internalName)
|
||||
}
|
||||
@@ -532,7 +522,6 @@ open class IncrementalJvmCache(
|
||||
return result
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun process(kotlinClass: LocalFileKotlinClass, changesCollector: ChangesCollector) {
|
||||
val key = kotlinClass.className.internalName
|
||||
val oldMap = storage[key] ?: emptyMap()
|
||||
@@ -558,7 +547,6 @@ open class IncrementalJvmCache(
|
||||
private fun functionNameBySignature(signature: String): String =
|
||||
signature.substringBefore("(")
|
||||
|
||||
@Synchronized
|
||||
fun remove(className: JvmClassName) {
|
||||
storage.remove(className.internalName)
|
||||
}
|
||||
@@ -580,7 +568,6 @@ sealed class ChangeInfo(val fqName: FqName) {
|
||||
|
||||
class SignatureChanged(fqName: FqName, val areSubclassesAffected: Boolean) : ChangeInfo(fqName)
|
||||
|
||||
class ParentsChanged(fqName: FqName, val parentsChanged: Collection<FqName>) : ChangeInfo(fqName)
|
||||
|
||||
protected open fun toStringProperties(): String = "fqName = $fqName"
|
||||
|
||||
|
||||
@@ -136,8 +136,7 @@ fun LookupStorage.update(
|
||||
|
||||
data class DirtyData(
|
||||
val dirtyLookupSymbols: Collection<LookupSymbol> = emptyList(),
|
||||
val dirtyClassesFqNames: Collection<FqName> = emptyList(),
|
||||
val dirtyClassesFqNamesForceRecompile: Collection<FqName> = emptyList()
|
||||
val dirtyClassesFqNames: Collection<FqName> = emptyList()
|
||||
)
|
||||
|
||||
fun ChangesCollector.getDirtyData(
|
||||
@@ -147,9 +146,6 @@ fun ChangesCollector.getDirtyData(
|
||||
val dirtyLookupSymbols = HashSet<LookupSymbol>()
|
||||
val dirtyClassesFqNames = HashSet<FqName>()
|
||||
|
||||
val sealedParents = HashMap<FqName, MutableSet<FqName>>()
|
||||
val notSealedParents = HashSet<FqName>()
|
||||
|
||||
for (change in changes()) {
|
||||
reporter.reportVerbose { "Process $change" }
|
||||
|
||||
@@ -174,35 +170,10 @@ fun ChangesCollector.getDirtyData(
|
||||
}
|
||||
|
||||
fqNames.mapTo(dirtyLookupSymbols) { LookupSymbol(SAM_LOOKUP_NAME.asString(), it.asString()) }
|
||||
} else if (change is ChangeInfo.ParentsChanged) {
|
||||
fun FqName.isSealed(): Boolean {
|
||||
if (notSealedParents.contains(this)) return false
|
||||
if (sealedParents.containsKey(this)) return true
|
||||
return isSealed(this, caches).also { sealed ->
|
||||
if (sealed) {
|
||||
sealedParents[this] = HashSet()
|
||||
} else {
|
||||
notSealedParents.add(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
change.parentsChanged.forEach { parent ->
|
||||
if (parent.isSealed()) {
|
||||
sealedParents.getOrPut(parent) { HashSet() }.add(change.fqName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val forceRecompile = HashSet<FqName>().apply {
|
||||
addAll(sealedParents.keys)
|
||||
//we should recompile all inheritors with parent sealed class: add known subtypes
|
||||
addAll(sealedParents.keys.flatMap { withSubtypes(it, caches) })
|
||||
//we should recompile all inheritors with parent sealed class: add new subtypes
|
||||
addAll(sealedParents.values.flatten())
|
||||
}
|
||||
|
||||
return DirtyData(dirtyLookupSymbols, dirtyClassesFqNames, forceRecompile)
|
||||
return DirtyData(dirtyLookupSymbols, dirtyClassesFqNames)
|
||||
}
|
||||
|
||||
fun mapLookupSymbolsToFiles(
|
||||
@@ -246,11 +217,6 @@ fun mapClassesFqNamesToFiles(
|
||||
return fqNameToAffectedFiles.values.flattenTo(HashSet())
|
||||
}
|
||||
|
||||
fun isSealed(
|
||||
fqName: FqName,
|
||||
caches: Iterable<IncrementalCacheCommon>
|
||||
): Boolean = caches.any { it.isSealed(fqName) ?: false }
|
||||
|
||||
fun withSubtypes(
|
||||
typeFqName: FqName,
|
||||
caches: Iterable<IncrementalCacheCommon>
|
||||
|
||||
@@ -28,14 +28,12 @@ import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.protobuf.MessageLite
|
||||
import org.jetbrains.kotlin.serialization.deserialization.ProtoEnumFlags
|
||||
import org.jetbrains.kotlin.serialization.deserialization.descriptorVisibility
|
||||
import org.jetbrains.kotlin.serialization.deserialization.getClassId
|
||||
import java.util.*
|
||||
|
||||
data class Difference(
|
||||
val isClassAffected: Boolean = false,
|
||||
val areSubclassesAffected: Boolean = false,
|
||||
val changedMembersNames: Set<String> = emptySet(),
|
||||
val changedSupertypes: Set<FqName> = emptySet()
|
||||
val changedMembersNames: Set<String> = emptySet()
|
||||
)
|
||||
|
||||
sealed class ProtoData
|
||||
@@ -189,7 +187,6 @@ class DifferenceCalculatorForClass(
|
||||
|
||||
var isClassAffected = false
|
||||
var areSubclassesAffected = false
|
||||
val changedSupertypes = HashSet<FqName>()
|
||||
val names = hashSetOf<String>()
|
||||
val classIsSealed = newProto.isSealed && oldProto.isSealed
|
||||
|
||||
@@ -250,21 +247,12 @@ class DifferenceCalculatorForClass(
|
||||
ProtoBufClassKind.FLAGS,
|
||||
ProtoBufClassKind.FQ_NAME,
|
||||
ProtoBufClassKind.TYPE_PARAMETER_LIST,
|
||||
ProtoBufClassKind.SUPERTYPE_LIST,
|
||||
ProtoBufClassKind.SUPERTYPE_ID_LIST,
|
||||
ProtoBufClassKind.JS_EXT_CLASS_ANNOTATION_LIST -> {
|
||||
isClassAffected = true
|
||||
areSubclassesAffected = true
|
||||
}
|
||||
|
||||
ProtoBufClassKind.SUPERTYPE_LIST,
|
||||
ProtoBufClassKind.SUPERTYPE_ID_LIST -> {
|
||||
isClassAffected = true
|
||||
areSubclassesAffected = true
|
||||
|
||||
val oldSupertypes = oldProto.supertypeList.map { oldNameResolver.getClassId(it.className).asSingleFqName() }
|
||||
val newSupertypes = newProto.supertypeList.map { newNameResolver.getClassId(it.className).asSingleFqName() }
|
||||
val changed = (oldSupertypes union newSupertypes) subtract (oldSupertypes intersect newSupertypes)
|
||||
changedSupertypes.addAll(changed)
|
||||
}
|
||||
ProtoBufClassKind.JVM_EXT_CLASS_MODULE_NAME,
|
||||
ProtoBufClassKind.JS_EXT_CLASS_CONTAINING_FILE_ID -> {
|
||||
// TODO
|
||||
@@ -293,7 +281,7 @@ class DifferenceCalculatorForClass(
|
||||
}
|
||||
}
|
||||
|
||||
return Difference(isClassAffected, areSubclassesAffected, names, changedSupertypes)
|
||||
return Difference(isClassAffected, areSubclassesAffected, names)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ open class BasicMapsOwner(val cachesDir: File) {
|
||||
protected val String.storageFile: File
|
||||
get() = File(cachesDir, this + "." + CACHE_EXTENSION)
|
||||
|
||||
@Synchronized
|
||||
protected fun <K, V, M : BasicMap<K, V>> registerMap(map: M): M {
|
||||
maps.add(map)
|
||||
return map
|
||||
@@ -48,7 +47,6 @@ open class BasicMapsOwner(val cachesDir: File) {
|
||||
forEachMapSafe("flush") { it.flush(memoryCachesOnly) }
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
private fun forEachMapSafe(actionName: String, action: (BasicMap<*, *>) -> Unit) {
|
||||
val actionExceptions = LinkedHashMap<String, Exception>()
|
||||
maps.forEach {
|
||||
@@ -68,6 +66,5 @@ open class BasicMapsOwner(val cachesDir: File) {
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
@Synchronized
|
||||
fun dump(): String = maps.joinToString("\n\n") { it.dump() }
|
||||
}
|
||||
@@ -17,11 +17,9 @@
|
||||
package org.jetbrains.kotlin.incremental.storage
|
||||
|
||||
import com.intellij.util.io.DataExternalizer
|
||||
import com.intellij.util.io.IOUtil
|
||||
import com.intellij.util.io.KeyDescriptor
|
||||
import com.intellij.util.io.PersistentHashMap
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
|
||||
|
||||
/**
|
||||
@@ -32,6 +30,7 @@ class CachingLazyStorage<K, V>(
|
||||
private val keyDescriptor: KeyDescriptor<K>,
|
||||
private val valueExternalizer: DataExternalizer<V>
|
||||
) : LazyStorage<K, V> {
|
||||
@Volatile
|
||||
private var storage: PersistentHashMap<K, V>? = null
|
||||
|
||||
@Synchronized
|
||||
@@ -81,10 +80,8 @@ class CachingLazyStorage<K, V>(
|
||||
try {
|
||||
storage?.close()
|
||||
} finally {
|
||||
PersistentHashMap.deleteFilesStartingWith(storageFile)
|
||||
storage = null
|
||||
if (!IOUtil.deleteAllFilesStartingWith(storageFile)) {
|
||||
throw IOException("Could not delete internal storage: ${storageFile.absolutePath}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.incremental.storage
|
||||
|
||||
import com.intellij.util.io.DataExternalizer
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import java.io.DataInput
|
||||
import java.io.DataOutput
|
||||
import java.io.File
|
||||
|
||||
internal data class ICClassesAttributes(val isSealed: Boolean)
|
||||
|
||||
internal object ICClassesAttributesExternalizer : DataExternalizer<ICClassesAttributes> {
|
||||
override fun read(input: DataInput): ICClassesAttributes {
|
||||
return ICClassesAttributes(input.readBoolean())
|
||||
}
|
||||
|
||||
override fun save(output: DataOutput, value: ICClassesAttributes) {
|
||||
output.writeBoolean(value.isSealed)
|
||||
}
|
||||
}
|
||||
|
||||
internal open class ClassAttributesMap(
|
||||
storageFile: File
|
||||
) : BasicStringMap<ICClassesAttributes>(storageFile, ICClassesAttributesExternalizer) {
|
||||
override fun dumpValue(value: ICClassesAttributes): String = value.toString()
|
||||
|
||||
operator fun set(key: FqName, value: ICClassesAttributes) {
|
||||
storage[key.asString()] = value
|
||||
}
|
||||
|
||||
operator fun get(key: FqName): ICClassesAttributes? = storage[key.asString()]
|
||||
|
||||
fun remove(key: FqName) {
|
||||
storage.remove(key.asString())
|
||||
}
|
||||
}
|
||||
@@ -20,18 +20,18 @@ import org.jetbrains.kotlin.incremental.dumpCollection
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import java.io.File
|
||||
|
||||
internal open class ClassOneToManyMap(storageFile: File) : BasicStringMap<Collection<String>>(storageFile, StringCollectionExternalizer) {
|
||||
internal open class ClassOneToManyMap(
|
||||
storageFile: File
|
||||
) : BasicStringMap<Collection<String>>(storageFile, StringCollectionExternalizer) {
|
||||
override fun dumpValue(value: Collection<String>): String = value.dumpCollection()
|
||||
|
||||
@Synchronized
|
||||
fun add(key: FqName, value: FqName) {
|
||||
storage.append(key.asString(), listOf(value.asString()))
|
||||
}
|
||||
|
||||
operator fun get(key: FqName): Collection<FqName> =
|
||||
storage[key.asString()]?.map(::FqName) ?: setOf()
|
||||
storage[key.asString()]?.map(::FqName) ?: setOf()
|
||||
|
||||
@Synchronized
|
||||
operator fun set(key: FqName, values: Collection<FqName>) {
|
||||
if (values.isEmpty()) {
|
||||
remove(key)
|
||||
@@ -41,14 +41,10 @@ internal open class ClassOneToManyMap(storageFile: File) : BasicStringMap<Collec
|
||||
storage[key.asString()] = values.map(FqName::asString)
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun remove(key: FqName) {
|
||||
storage.remove(key.asString())
|
||||
}
|
||||
|
||||
// Access to caches could be done from multiple threads (e.g. JPS worker and RMI). The underlying collection is already synchronized,
|
||||
// thus we need synchronization of this method and all modification methods.
|
||||
@Synchronized
|
||||
fun removeValues(key: FqName, removed: Set<FqName>) {
|
||||
val notRemoved = this[key].filter { it !in removed }
|
||||
this[key] = notRemoved
|
||||
|
||||
@@ -25,7 +25,8 @@ internal class DirtyClassesJvmNameMap(storageFile: File) : AbstractDirtyClassesM
|
||||
internal class DirtyClassesFqNameMap(storageFile: File) : AbstractDirtyClassesMap<FqName>(FqNameTransformer, storageFile)
|
||||
|
||||
internal abstract class AbstractDirtyClassesMap<Name>(
|
||||
private val nameTransformer: NameTransformer<Name>, storageFile: File
|
||||
private val nameTransformer: NameTransformer<Name>,
|
||||
storageFile: File
|
||||
) : BasicStringMap<Boolean>(storageFile, BooleanDataDescriptor.INSTANCE) {
|
||||
fun markDirty(className: Name) {
|
||||
storage[nameTransformer.asString(className)] = true
|
||||
@@ -36,10 +37,10 @@ internal abstract class AbstractDirtyClassesMap<Name>(
|
||||
}
|
||||
|
||||
fun getDirtyOutputClasses(): Collection<Name> =
|
||||
storage.keys.map { nameTransformer.asName(it) }
|
||||
storage.keys.map { nameTransformer.asName(it) }
|
||||
|
||||
fun isDirty(className: Name): Boolean =
|
||||
storage.contains(nameTransformer.asString(className))
|
||||
storage.contains(nameTransformer.asString(className))
|
||||
|
||||
override fun dumpValue(value: Boolean) = ""
|
||||
}
|
||||
|
||||
@@ -17,11 +17,9 @@
|
||||
package org.jetbrains.kotlin.incremental.storage
|
||||
|
||||
import com.intellij.util.io.DataExternalizer
|
||||
import com.intellij.util.io.IOUtil
|
||||
import com.intellij.util.io.KeyDescriptor
|
||||
import com.intellij.util.io.PersistentHashMap
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
|
||||
|
||||
class NonCachingLazyStorage<K, V>(
|
||||
@@ -29,6 +27,7 @@ class NonCachingLazyStorage<K, V>(
|
||||
private val keyDescriptor: KeyDescriptor<K>,
|
||||
private val valueExternalizer: DataExternalizer<V>
|
||||
) : LazyStorage<K, V> {
|
||||
@Volatile
|
||||
private var storage: PersistentHashMap<K, V>? = null
|
||||
|
||||
@Synchronized
|
||||
@@ -77,12 +76,11 @@ class NonCachingLazyStorage<K, V>(
|
||||
override fun clean() {
|
||||
try {
|
||||
storage?.close()
|
||||
} finally {
|
||||
storage = null
|
||||
if (!IOUtil.deleteAllFilesStartingWith(storageFile)) {
|
||||
throw IOException("Could not delete internal storage: ${storageFile.absolutePath}")
|
||||
}
|
||||
} catch (ignored: Throwable) {
|
||||
}
|
||||
|
||||
PersistentHashMap.deleteFilesStartingWith(storageFile)
|
||||
storage = null
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
|
||||
@@ -188,7 +188,7 @@ extra["versions.kotlinx-collections-immutable-jvm"] = immutablesVersion
|
||||
extra["versions.ktor-network"] = "1.0.1"
|
||||
|
||||
if (!project.hasProperty("versions.kotlin-native")) {
|
||||
extra["versions.kotlin-native"] = "1.4.32-release-153"
|
||||
extra["versions.kotlin-native"] = "1.4.30-dev-17200"
|
||||
}
|
||||
|
||||
val intellijUltimateEnabled by extra(project.kotlinBuildProperties.intellijUltimateEnabled)
|
||||
@@ -854,7 +854,6 @@ tasks {
|
||||
|
||||
register("kaptIdeTest") {
|
||||
dependsOn(":kotlin-annotation-processing:test")
|
||||
dependsOn(":kotlin-annotation-processing-base:test")
|
||||
}
|
||||
|
||||
register("gradleIdeTest") {
|
||||
@@ -912,7 +911,6 @@ tasks {
|
||||
":prepare:ide-plugin-dependencies:sam-with-receiver-compiler-plugin-for-ide:publish",
|
||||
":prepare:ide-plugin-dependencies:compiler-components-for-jps:publish",
|
||||
":prepare:ide-plugin-dependencies:parcelize-compiler-plugin-for-ide:publish",
|
||||
":prepare:ide-plugin-dependencies:kotlin-stdlib-for-ide:publish",
|
||||
":kotlin-script-runtime:publish",
|
||||
":kotlin-script-util:publish",
|
||||
":kotlin-scripting-common:publish",
|
||||
|
||||
@@ -254,14 +254,14 @@ fun Project.idePluginDependency(block: () -> Unit) {
|
||||
}
|
||||
}
|
||||
|
||||
fun Project.publishProjectJars(projects: List<String>, libraryDependencies: List<String> = emptyList(), configuration: String? = null) {
|
||||
fun Project.publishProjectJars(projects: List<String>, libraryDependencies: List<String> = emptyList()) {
|
||||
apply<JavaPlugin>()
|
||||
|
||||
val fatJarContents by configurations.creating
|
||||
|
||||
dependencies {
|
||||
for (projectName in projects) {
|
||||
fatJarContents(project(projectName, configuration)) { isTransitive = false }
|
||||
fatJarContents(project(projectName)) { isTransitive = false }
|
||||
}
|
||||
|
||||
for (libraryDependency in libraryDependencies) {
|
||||
|
||||
@@ -25,7 +25,6 @@ val packagesToRelocate =
|
||||
"org.fusesource",
|
||||
"net.jpountz",
|
||||
"one.util.streamex",
|
||||
"it.unimi.dsi.fastutil",
|
||||
"kotlinx.collections.immutable"
|
||||
)
|
||||
|
||||
|
||||
@@ -20,10 +20,6 @@ internal const val PLUGIN_MARKER_SUFFIX = ".gradle.plugin"
|
||||
|
||||
@OptIn(ExperimentalStdlibApi::class)
|
||||
fun Project.publishPluginMarkers(withEmptyJars: Boolean = true) {
|
||||
|
||||
fun Project.isSonatypePublish(): Boolean =
|
||||
hasProperty("isSonatypePublish") && property("isSonatypePublish") as Boolean
|
||||
|
||||
val pluginDevelopment = extensions.getByType<PluginBundleExtension>()
|
||||
val publishingExtension = extensions.getByType<PublishingExtension>()
|
||||
val mainPublication = publishingExtension.publications[KotlinBuildPublishingPlugin.PUBLICATION_NAME] as MavenPublication
|
||||
@@ -36,12 +32,7 @@ fun Project.publishPluginMarkers(withEmptyJars: Boolean = true) {
|
||||
|
||||
tasks.named<PublishToMavenRepository>(
|
||||
"publish${markerPublication.name.capitalize(Locale.ROOT)}PublicationTo${KotlinBuildPublishingPlugin.REPOSITORY_NAME}Repository"
|
||||
).apply {
|
||||
configureRepository()
|
||||
configure {
|
||||
onlyIf { !isSonatypePublish() }
|
||||
}
|
||||
}
|
||||
).configureRepository()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.codegen
|
||||
|
||||
import org.jetbrains.org.objectweb.asm.Opcodes
|
||||
|
||||
// This object should help compiling against different ASM versions in different bunch versions
|
||||
object VersionIndependentOpcodes {
|
||||
const val ACC_RECORD = Opcodes.ACC_RECORD
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.codegen
|
||||
|
||||
import org.jetbrains.org.objectweb.asm.Opcodes
|
||||
|
||||
// This object should help compiling against different ASM versions from different bunch versions
|
||||
object VersionIndependentOpcodes {
|
||||
const val ACC_RECORD = 0
|
||||
}
|
||||
@@ -26,13 +26,13 @@ import org.jetbrains.kotlin.codegen.serialization.JvmSerializationBindings;
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin;
|
||||
import org.jetbrains.org.objectweb.asm.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.kotlin.codegen.inline.InlineCodegenUtilsKt.GENERATE_SMAP;
|
||||
|
||||
public abstract class AbstractClassBuilder implements ClassBuilder {
|
||||
protected static final MethodVisitor EMPTY_METHOD_VISITOR = new MethodVisitor(Opcodes.API_VERSION) {};
|
||||
public static final RecordComponentVisitor EMPTY_RECORD_VISITOR = new RecordComponentVisitor(Opcodes.API_VERSION) {};
|
||||
protected static final FieldVisitor EMPTY_FIELD_VISITOR = new FieldVisitor(Opcodes.API_VERSION) {};
|
||||
|
||||
private String thisName;
|
||||
@@ -91,16 +91,6 @@ public abstract class AbstractClassBuilder implements ClassBuilder {
|
||||
return visitor;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public RecordComponentVisitor newRecordComponent(@NotNull String name, @NotNull String desc, @Nullable String signature) {
|
||||
RecordComponentVisitor visitor = getVisitor().visitRecordComponent(name, desc, signature);
|
||||
if (visitor == null) {
|
||||
return EMPTY_RECORD_VISITOR;
|
||||
}
|
||||
return visitor;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public JvmSerializationBindings getSerializationBindings() {
|
||||
|
||||
@@ -1,158 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.codegen;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.codegen.inline.FileMapping;
|
||||
import org.jetbrains.kotlin.codegen.inline.SMAPBuilder;
|
||||
import org.jetbrains.kotlin.codegen.inline.SourceMapper;
|
||||
import org.jetbrains.kotlin.codegen.serialization.JvmSerializationBindings;
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin;
|
||||
import org.jetbrains.org.objectweb.asm.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.kotlin.codegen.inline.InlineCodegenUtilsKt.GENERATE_SMAP;
|
||||
|
||||
public abstract class AbstractClassBuilder implements ClassBuilder {
|
||||
protected static final MethodVisitor EMPTY_METHOD_VISITOR = new MethodVisitor(Opcodes.API_VERSION) {};
|
||||
protected static final FieldVisitor EMPTY_FIELD_VISITOR = new FieldVisitor(Opcodes.API_VERSION) {};
|
||||
|
||||
private String thisName;
|
||||
|
||||
private final JvmSerializationBindings serializationBindings = new JvmSerializationBindings();
|
||||
|
||||
private String sourceName;
|
||||
|
||||
private String debugInfo;
|
||||
|
||||
public static class Concrete extends AbstractClassBuilder {
|
||||
private final ClassVisitor v;
|
||||
|
||||
public Concrete(@NotNull ClassVisitor v) {
|
||||
this.v = v;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ClassVisitor getVisitor() {
|
||||
return v;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public FieldVisitor newField(
|
||||
@NotNull JvmDeclarationOrigin origin,
|
||||
int access,
|
||||
@NotNull String name,
|
||||
@NotNull String desc,
|
||||
@Nullable String signature,
|
||||
@Nullable Object value
|
||||
) {
|
||||
FieldVisitor visitor = getVisitor().visitField(access, name, desc, signature, value);
|
||||
if (visitor == null) {
|
||||
return EMPTY_FIELD_VISITOR;
|
||||
}
|
||||
return visitor;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public MethodVisitor newMethod(
|
||||
@NotNull JvmDeclarationOrigin origin,
|
||||
int access,
|
||||
@NotNull String name,
|
||||
@NotNull String desc,
|
||||
@Nullable String signature,
|
||||
@Nullable String[] exceptions
|
||||
) {
|
||||
MethodVisitor visitor = getVisitor().visitMethod(access, name, desc, signature, exceptions);
|
||||
if (visitor == null) {
|
||||
return EMPTY_METHOD_VISITOR;
|
||||
}
|
||||
return visitor;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public JvmSerializationBindings getSerializationBindings() {
|
||||
return serializationBindings;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public AnnotationVisitor newAnnotation(@NotNull String desc, boolean visible) {
|
||||
return getVisitor().visitAnnotation(desc, visible);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void done() {
|
||||
getVisitor().visitSource(sourceName, debugInfo);
|
||||
getVisitor().visitEnd();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void defineClass(
|
||||
@Nullable PsiElement origin,
|
||||
int version,
|
||||
int access,
|
||||
@NotNull String name,
|
||||
@Nullable String signature,
|
||||
@NotNull String superName,
|
||||
@NotNull String[] interfaces
|
||||
) {
|
||||
thisName = name;
|
||||
getVisitor().visit(version, access, name, signature, superName, interfaces);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitSource(@NotNull String name, @Nullable String debug) {
|
||||
assert sourceName == null || sourceName.equals(name) : "inconsistent file name: " + sourceName + " vs " + name;
|
||||
sourceName = name;
|
||||
debugInfo = debug;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitSMAP(@NotNull SourceMapper smap, boolean backwardsCompatibleSyntax) {
|
||||
if (!GENERATE_SMAP) return;
|
||||
|
||||
List<FileMapping> fileMappings = smap.getResultMappings();
|
||||
if (fileMappings.isEmpty()) return;
|
||||
|
||||
visitSource(fileMappings.get(0).getName(), SMAPBuilder.INSTANCE.build(fileMappings, backwardsCompatibleSyntax));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitOuterClass(@NotNull String owner, @Nullable String name, @Nullable String desc) {
|
||||
getVisitor().visitOuterClass(owner, name, desc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitInnerClass(@NotNull String name, @Nullable String outerName, @Nullable String innerName, int access) {
|
||||
getVisitor().visitInnerClass(name, outerName, innerName, access);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getThisName() {
|
||||
assert thisName != null : "This name isn't set";
|
||||
return thisName;
|
||||
}
|
||||
}
|
||||
@@ -19,10 +19,14 @@ package org.jetbrains.kotlin.codegen;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.codegen.inline.FileMapping;
|
||||
import org.jetbrains.kotlin.codegen.inline.SourceMapper;
|
||||
import org.jetbrains.kotlin.codegen.serialization.JvmSerializationBindings;
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin;
|
||||
import org.jetbrains.org.objectweb.asm.*;
|
||||
import org.jetbrains.org.objectweb.asm.AnnotationVisitor;
|
||||
import org.jetbrains.org.objectweb.asm.ClassVisitor;
|
||||
import org.jetbrains.org.objectweb.asm.FieldVisitor;
|
||||
import org.jetbrains.org.objectweb.asm.MethodVisitor;
|
||||
|
||||
public interface ClassBuilder {
|
||||
@NotNull
|
||||
@@ -45,12 +49,6 @@ public interface ClassBuilder {
|
||||
@Nullable String[] exceptions
|
||||
);
|
||||
|
||||
@NotNull RecordComponentVisitor newRecordComponent(
|
||||
@NotNull String name,
|
||||
@NotNull String desc,
|
||||
@Nullable String signature
|
||||
);
|
||||
|
||||
@NotNull
|
||||
JvmSerializationBindings getSerializationBindings();
|
||||
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.codegen;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.codegen.inline.SourceMapper;
|
||||
import org.jetbrains.kotlin.codegen.serialization.JvmSerializationBindings;
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin;
|
||||
import org.jetbrains.org.objectweb.asm.*;
|
||||
|
||||
public interface ClassBuilder {
|
||||
@NotNull
|
||||
FieldVisitor newField(
|
||||
@NotNull JvmDeclarationOrigin origin,
|
||||
int access,
|
||||
@NotNull String name,
|
||||
@NotNull String desc,
|
||||
@Nullable String signature,
|
||||
@Nullable Object value
|
||||
);
|
||||
|
||||
@NotNull
|
||||
MethodVisitor newMethod(
|
||||
@NotNull JvmDeclarationOrigin origin,
|
||||
int access,
|
||||
@NotNull String name,
|
||||
@NotNull String desc,
|
||||
@Nullable String signature,
|
||||
@Nullable String[] exceptions
|
||||
);
|
||||
|
||||
@NotNull
|
||||
JvmSerializationBindings getSerializationBindings();
|
||||
|
||||
@NotNull
|
||||
AnnotationVisitor newAnnotation(@NotNull String desc, boolean visible);
|
||||
|
||||
void done();
|
||||
|
||||
@NotNull
|
||||
ClassVisitor getVisitor();
|
||||
|
||||
void defineClass(
|
||||
@Nullable PsiElement origin,
|
||||
int version,
|
||||
int access,
|
||||
@NotNull String name,
|
||||
@Nullable String signature,
|
||||
@NotNull String superName,
|
||||
@NotNull String[] interfaces
|
||||
);
|
||||
|
||||
void visitSource(@NotNull String name, @Nullable String debug);
|
||||
|
||||
void visitSMAP(@NotNull SourceMapper smap, boolean backwardsCompatibleSyntax);
|
||||
|
||||
void visitOuterClass(@NotNull String owner, @Nullable String name, @Nullable String desc);
|
||||
|
||||
void visitInnerClass(@NotNull String name, @Nullable String outerName, @Nullable String innerName, int access);
|
||||
|
||||
@NotNull
|
||||
String getThisName();
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.codegen
|
||||
|
||||
fun ClassBuilder.addRecordComponent(name: String, desc: String, signature: String?) {
|
||||
newRecordComponent(name, desc, signature)
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.codegen
|
||||
|
||||
fun ClassBuilder.addRecordComponent(name: String, desc: String, signature: String?) {
|
||||
// newRecordComponent(name, desc, signature)
|
||||
}
|
||||
@@ -19,10 +19,14 @@ package org.jetbrains.kotlin.codegen;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.codegen.inline.FileMapping;
|
||||
import org.jetbrains.kotlin.codegen.inline.SourceMapper;
|
||||
import org.jetbrains.kotlin.codegen.serialization.JvmSerializationBindings;
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin;
|
||||
import org.jetbrains.org.objectweb.asm.*;
|
||||
import org.jetbrains.org.objectweb.asm.AnnotationVisitor;
|
||||
import org.jetbrains.org.objectweb.asm.ClassVisitor;
|
||||
import org.jetbrains.org.objectweb.asm.FieldVisitor;
|
||||
import org.jetbrains.org.objectweb.asm.MethodVisitor;
|
||||
|
||||
public abstract class DelegatingClassBuilder implements ClassBuilder {
|
||||
@NotNull
|
||||
@@ -54,14 +58,6 @@ public abstract class DelegatingClassBuilder implements ClassBuilder {
|
||||
return getDelegate().newMethod(origin, access, name, desc, signature, exceptions);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public RecordComponentVisitor newRecordComponent(
|
||||
@NotNull String name, @NotNull String desc, @Nullable String signature
|
||||
) {
|
||||
return getDelegate().newRecordComponent(name, desc, signature);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JvmSerializationBindings getSerializationBindings() {
|
||||
|
||||
@@ -1,118 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.codegen;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.codegen.inline.SourceMapper;
|
||||
import org.jetbrains.kotlin.codegen.serialization.JvmSerializationBindings;
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin;
|
||||
import org.jetbrains.org.objectweb.asm.*;
|
||||
|
||||
public abstract class DelegatingClassBuilder implements ClassBuilder {
|
||||
@NotNull
|
||||
protected abstract ClassBuilder getDelegate();
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public FieldVisitor newField(
|
||||
@NotNull JvmDeclarationOrigin origin,
|
||||
int access,
|
||||
@NotNull String name,
|
||||
@NotNull String desc,
|
||||
@Nullable String signature,
|
||||
@Nullable Object value
|
||||
) {
|
||||
return getDelegate().newField(origin, access, name, desc, signature, value);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public MethodVisitor newMethod(
|
||||
@NotNull JvmDeclarationOrigin origin,
|
||||
int access,
|
||||
@NotNull String name,
|
||||
@NotNull String desc,
|
||||
@Nullable String signature,
|
||||
@Nullable String[] exceptions
|
||||
) {
|
||||
return getDelegate().newMethod(origin, access, name, desc, signature, exceptions);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JvmSerializationBindings getSerializationBindings() {
|
||||
return getDelegate().getSerializationBindings();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public AnnotationVisitor newAnnotation(@NotNull String desc, boolean visible) {
|
||||
return getDelegate().newAnnotation(desc, visible);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void done() {
|
||||
getDelegate().done();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ClassVisitor getVisitor() {
|
||||
return getDelegate().getVisitor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void defineClass(
|
||||
@Nullable PsiElement origin,
|
||||
int version,
|
||||
int access,
|
||||
@NotNull String name,
|
||||
@Nullable String signature,
|
||||
@NotNull String superName,
|
||||
@NotNull String[] interfaces
|
||||
) {
|
||||
getDelegate().defineClass(origin, version, access, name, signature, superName, interfaces);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitSource(@NotNull String name, @Nullable String debug) {
|
||||
getDelegate().visitSource(name, debug);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitSMAP(@NotNull SourceMapper smap, boolean backwardsCompatibleSyntax) {
|
||||
getDelegate().visitSMAP(smap, backwardsCompatibleSyntax);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitOuterClass(@NotNull String owner, @Nullable String name, @Nullable String desc) {
|
||||
getDelegate().visitOuterClass(owner, name, desc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitInnerClass(@NotNull String name, @Nullable String outerName, @Nullable String innerName, int access) {
|
||||
getDelegate().visitInnerClass(name, outerName, innerName, access);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getThisName() {
|
||||
return getDelegate().getThisName();
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,6 @@ import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.psi.KtClass
|
||||
import org.jetbrains.kotlin.psi.KtClassOrObject
|
||||
import org.jetbrains.kotlin.resolve.InlineClassDescriptorResolver
|
||||
import org.jetbrains.kotlin.resolve.JVM_INLINE_ANNOTATION_FQ_NAME
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.secondaryConstructors
|
||||
import org.jetbrains.kotlin.resolve.jvm.AsmTypes
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.Synthetic
|
||||
@@ -56,13 +55,6 @@ class ErasedInlineClassBodyCodegen(
|
||||
generateUnboxMethod()
|
||||
generateFunctionsFromAny()
|
||||
generateSpecializedEqualsStub()
|
||||
generateJvmInlineAnnotation()
|
||||
}
|
||||
|
||||
private fun generateJvmInlineAnnotation() {
|
||||
if (descriptor.isInline) {
|
||||
v.newAnnotation(JVM_INLINE_ANNOTATION_FQ_NAME.topLevelClassAsmType().descriptor, true).visitEnd()
|
||||
}
|
||||
}
|
||||
|
||||
private fun generateFunctionsFromAny() {
|
||||
|
||||
@@ -1221,12 +1221,7 @@ public class FunctionCodegen {
|
||||
|
||||
// 'null' because the "could not find expected declaration" error has been already reported in isDefaultNeeded earlier
|
||||
List<ValueParameterDescriptor> valueParameters =
|
||||
functionDescriptor.isSuspend()
|
||||
? CollectionsKt.plus(
|
||||
CodegenUtil.getFunctionParametersForDefaultValueGeneration(
|
||||
CoroutineCodegenUtilKt.unwrapInitialDescriptorForSuspendFunction(functionDescriptor), null),
|
||||
CollectionsKt.last(functionDescriptor.getValueParameters()))
|
||||
: CodegenUtil.getFunctionParametersForDefaultValueGeneration(functionDescriptor, null);
|
||||
CodegenUtil.getFunctionParametersForDefaultValueGeneration(functionDescriptor, null);
|
||||
|
||||
boolean isStatic = isStaticMethod(methodContext.getContextKind(), functionDescriptor);
|
||||
FrameMap frameMap = createFrameMap(state, signature, functionDescriptor.getExtensionReceiverParameter(), valueParameters, isStatic);
|
||||
|
||||
@@ -43,7 +43,6 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.DescriptorUtilsKt;
|
||||
import org.jetbrains.kotlin.resolve.jvm.annotations.JvmAnnotationUtilKt;
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin;
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOriginKt;
|
||||
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmClassSignature;
|
||||
@@ -222,10 +221,6 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
access |= ACC_ENUM;
|
||||
}
|
||||
|
||||
if (JvmAnnotationUtilKt.isJvmRecord(descriptor)) {
|
||||
access |= VersionIndependentOpcodes.ACC_RECORD;
|
||||
}
|
||||
|
||||
v.defineClass(
|
||||
myClass.getPsiOrParent(),
|
||||
state.getClassFileVersion(),
|
||||
|
||||
@@ -29,7 +29,6 @@ import org.jetbrains.kotlin.resolve.InlineClassesUtilsKt;
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||
import org.jetbrains.kotlin.resolve.calls.util.UnderscoreUtilKt;
|
||||
import org.jetbrains.kotlin.resolve.constants.ConstantValue;
|
||||
import org.jetbrains.kotlin.resolve.jvm.annotations.JvmAnnotationUtilKt;
|
||||
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOriginKt;
|
||||
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodGenericSignature;
|
||||
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature;
|
||||
@@ -436,10 +435,9 @@ public class PropertyCodegen {
|
||||
v.getSerializationBindings().put(FIELD_FOR_PROPERTY, propertyDescriptor, new Pair<>(type, name));
|
||||
|
||||
if (isBackingFieldOwner) {
|
||||
String signature = isDelegate ? null : typeMapper.mapFieldSignature(kotlinType, propertyDescriptor);
|
||||
FieldVisitor fv = builder.newField(
|
||||
JvmDeclarationOriginKt.OtherOrigin(propertyDescriptor), modifiers, name, type.getDescriptor(),
|
||||
signature, defaultValue
|
||||
isDelegate ? null : typeMapper.mapFieldSignature(kotlinType, propertyDescriptor), defaultValue
|
||||
);
|
||||
|
||||
if (annotatedField != null) {
|
||||
@@ -452,10 +450,6 @@ public class PropertyCodegen {
|
||||
AnnotationCodegen.forField(fv, memberCodegen, state, skipNullabilityAnnotations)
|
||||
.genAnnotations(annotatedField, type, propertyDescriptor.getType(), null, additionalVisibleAnnotations);
|
||||
}
|
||||
|
||||
if (propertyDescriptor.getContainingDeclaration() instanceof ClassDescriptor && JvmAnnotationUtilKt.isJvmRecord((ClassDescriptor) propertyDescriptor.getContainingDeclaration())) {
|
||||
ClassBuilderRecordKt.addRecordComponent(builder, name, type.getDescriptor(), signature);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ import org.jetbrains.kotlin.codegen.intrinsics.IntrinsicArrayConstructors
|
||||
import org.jetbrains.kotlin.codegen.state.GenerationState
|
||||
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper
|
||||
import org.jetbrains.kotlin.config.CommonConfigurationKeys
|
||||
import org.jetbrains.kotlin.config.JVMConfigurationKeys
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.incremental.components.Position
|
||||
import org.jetbrains.kotlin.incremental.components.ScopeKind
|
||||
@@ -514,6 +513,7 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
|
||||
|
||||
|
||||
companion object {
|
||||
|
||||
internal fun createInlineMethodNode(
|
||||
functionDescriptor: FunctionDescriptor,
|
||||
methodOwner: Type,
|
||||
@@ -529,15 +529,10 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
|
||||
return SMAPAndMethodNode(intrinsic, createDefaultFakeSMAP())
|
||||
}
|
||||
|
||||
var asmMethod = mapMethod(state, functionDescriptor, sourceCompilerForInline, jvmSignature, callDefault)
|
||||
if (asmMethod.name.contains("-") &&
|
||||
!state.configuration.getBoolean(JVMConfigurationKeys.USE_OLD_INLINE_CLASSES_MANGLING_SCHEME) &&
|
||||
classFileContainsMethod(functionDescriptor, state, asmMethod) == false
|
||||
) {
|
||||
state.typeMapper.useOldManglingRulesForFunctionAcceptingInlineClass = true
|
||||
asmMethod = mapMethod(state, functionDescriptor, sourceCompilerForInline, jvmSignature, callDefault)
|
||||
state.typeMapper.useOldManglingRulesForFunctionAcceptingInlineClass = false
|
||||
}
|
||||
val asmMethod = if (callDefault)
|
||||
state.typeMapper.mapDefaultMethod(functionDescriptor, sourceCompilerForInline.contextKind)
|
||||
else
|
||||
mangleSuspendInlineFunctionAsmMethodIfNeeded(functionDescriptor, jvmSignature.asmMethod)
|
||||
|
||||
val directMember = getDirectMemberAndCallableFromObject(functionDescriptor)
|
||||
if (!isBuiltInArrayIntrinsic(functionDescriptor) && directMember !is DescriptorWithContainerSource) {
|
||||
@@ -549,16 +544,6 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
|
||||
return getCompiledMethodNodeInner(functionDescriptor, directMember, asmMethod, methodOwner, state, jvmSignature)
|
||||
}
|
||||
|
||||
private fun mapMethod(
|
||||
state: GenerationState,
|
||||
functionDescriptor: FunctionDescriptor,
|
||||
sourceCompiler: SourceCompilerForInline,
|
||||
jvmSignature: JvmMethodSignature,
|
||||
callDefault: Boolean
|
||||
): Method =
|
||||
if (callDefault) state.typeMapper.mapDefaultMethod(functionDescriptor, sourceCompiler.contextKind)
|
||||
else mangleSuspendInlineFunctionAsmMethodIfNeeded(functionDescriptor, jvmSignature.asmMethod)
|
||||
|
||||
internal fun createSpecialInlineMethodNodeFromBinaries(functionDescriptor: FunctionDescriptor, state: GenerationState): MethodNode {
|
||||
val directMember = getDirectMemberAndCallableFromObject(functionDescriptor)
|
||||
assert(directMember is DescriptorWithContainerSource) {
|
||||
@@ -592,8 +577,7 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
|
||||
doCreateMethodNodeFromCompiled(directMember, state, jvmSignature.asmMethod)
|
||||
else
|
||||
null
|
||||
result ?:
|
||||
throw IllegalStateException("Couldn't obtain compiled function body for $functionDescriptor")
|
||||
result ?: throw IllegalStateException("Couldn't obtain compiled function body for $functionDescriptor")
|
||||
}
|
||||
|
||||
return SMAPAndMethodNode(cloneMethodNode(resultInCache.node), resultInCache.classSMAP)
|
||||
|
||||
@@ -130,9 +130,7 @@ fun <T, R : DefaultLambda> expandMaskConditionsAndUpdateVariableNodes(
|
||||
node.instructions.insert(position, newInsn)
|
||||
}
|
||||
|
||||
node.localVariables.removeIf {
|
||||
(it.start in toDelete && it.end in toDelete) || defaultLambdas.contains(it.index)
|
||||
}
|
||||
node.localVariables.removeIf { it.start in toDelete && it.end in toDelete }
|
||||
|
||||
node.remove(toDelete)
|
||||
|
||||
|
||||
@@ -6,7 +6,10 @@
|
||||
package org.jetbrains.kotlin.codegen
|
||||
|
||||
import org.jetbrains.kotlin.codegen.state.GenerationState
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.impl.AnonymousFunctionDescriptor
|
||||
import org.jetbrains.kotlin.load.kotlin.JvmPackagePartSource
|
||||
import org.jetbrains.kotlin.load.kotlin.VirtualFileFinder
|
||||
@@ -41,10 +44,6 @@ fun CallableDescriptor.isGenericParameter(): Boolean {
|
||||
fun classFileContainsMethod(descriptor: FunctionDescriptor, state: GenerationState, method: Method): Boolean? {
|
||||
if (descriptor !is DeserializedSimpleFunctionDescriptor) return null
|
||||
|
||||
if (descriptor.kind == CallableMemberDescriptor.Kind.FAKE_OVERRIDE) {
|
||||
return descriptor.overriddenDescriptors.any { classFileContainsMethod(it, state, method) == true }
|
||||
}
|
||||
|
||||
val classId: ClassId = when {
|
||||
descriptor.containingDeclaration is DeserializedClassDescriptor -> {
|
||||
(descriptor.containingDeclaration as DeserializedClassDescriptor).classId ?: return null
|
||||
|
||||
@@ -8,4 +8,4 @@ package org.jetbrains.kotlin.codegen.optimization.common
|
||||
import org.jetbrains.org.objectweb.asm.tree.analysis.BasicValue
|
||||
import org.jetbrains.org.objectweb.asm.tree.analysis.Frame
|
||||
|
||||
typealias TypeAnnotatedFrames = Array<Frame<BasicValue>>
|
||||
typealias TypeAnnotatedFrames = Array<Frame<BasicValue>?>
|
||||
@@ -8,4 +8,4 @@ package org.jetbrains.kotlin.codegen.optimization.common
|
||||
import org.jetbrains.org.objectweb.asm.tree.analysis.BasicValue
|
||||
import org.jetbrains.org.objectweb.asm.tree.analysis.Frame
|
||||
|
||||
typealias TypeAnnotatedFrames = Array<Frame<BasicValue>?>
|
||||
typealias TypeAnnotatedFrames = Array<Frame<BasicValue>>
|
||||
@@ -201,7 +201,7 @@ class GenerationState private constructor(
|
||||
|
||||
val target = configuration.get(JVMConfigurationKeys.JVM_TARGET) ?: JvmTarget.DEFAULT
|
||||
val runtimeStringConcat =
|
||||
if (target.majorVersion >= JvmTarget.JVM_9.majorVersion)
|
||||
if (target.bytecodeVersion >= JvmTarget.JVM_9.bytecodeVersion)
|
||||
configuration.get(JVMConfigurationKeys.STRING_CONCAT) ?: JvmStringConcat.INLINE
|
||||
else JvmStringConcat.INLINE
|
||||
|
||||
@@ -272,10 +272,7 @@ class GenerationState private constructor(
|
||||
|
||||
val rootContext: CodegenContext<*> = RootContext(this)
|
||||
|
||||
val classFileVersion: Int = run {
|
||||
val minorVersion = if (configuration.getBoolean(JVMConfigurationKeys.ENABLE_JVM_PREVIEW)) 0xffff else 0
|
||||
(minorVersion shl 16) + target.majorVersion
|
||||
}
|
||||
val classFileVersion: Int = target.bytecodeVersion
|
||||
|
||||
val generateParametersMetadata: Boolean = configuration.getBoolean(JVMConfigurationKeys.PARAMETERS_METADATA)
|
||||
|
||||
@@ -298,7 +295,7 @@ class GenerationState private constructor(
|
||||
?: if (languageVersionSettings.languageVersion >= LanguageVersion.LATEST_STABLE) JvmMetadataVersion.INSTANCE
|
||||
else JvmMetadataVersion(1, 1, 18)
|
||||
|
||||
val abiStability = configuration.get(JVMConfigurationKeys.ABI_STABILITY)
|
||||
val isIrWithStableAbi = configuration.getBoolean(JVMConfigurationKeys.IS_IR_WITH_STABLE_ABI)
|
||||
|
||||
val globalSerializationBindings = JvmSerializationBindings()
|
||||
var mapInlineClass: (ClassDescriptor) -> Type = { descriptor -> typeMapper.mapType(descriptor.defaultType) }
|
||||
|
||||
@@ -5,4 +5,4 @@
|
||||
|
||||
package org.jetbrains.kotlin.codegen.state
|
||||
|
||||
typealias JvmMethodExceptionTypes = Array<out String?>?
|
||||
typealias JvmMethodExceptionTypes = Array<out String>?
|
||||
@@ -5,4 +5,4 @@
|
||||
|
||||
package org.jetbrains.kotlin.codegen.state
|
||||
|
||||
typealias JvmMethodExceptionTypes = Array<out String>?
|
||||
typealias JvmMethodExceptionTypes = Array<out String?>?
|
||||
@@ -50,7 +50,6 @@ import org.jetbrains.kotlin.resolve.*
|
||||
import org.jetbrains.kotlin.resolve.BindingContextUtils.getDelegationConstructorCall
|
||||
import org.jetbrains.kotlin.resolve.BindingContextUtils.isBoxedLocalCapturedInClosure
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils.*
|
||||
import org.jetbrains.kotlin.resolve.annotations.hasJvmStaticAnnotation
|
||||
import org.jetbrains.kotlin.resolve.bindingContextUtil.isUsedAsExpression
|
||||
import org.jetbrains.kotlin.resolve.calls.model.DefaultValueArgument
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
@@ -61,7 +60,6 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.isPublishedApi
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.module
|
||||
import org.jetbrains.kotlin.resolve.jvm.AsmTypes.DEFAULT_CONSTRUCTOR_MARKER
|
||||
import org.jetbrains.kotlin.resolve.jvm.AsmTypes.OBJECT_TYPE
|
||||
import org.jetbrains.kotlin.resolve.jvm.JAVA_LANG_RECORD_FQ_NAME
|
||||
import org.jetbrains.kotlin.resolve.jvm.JvmClassName
|
||||
import org.jetbrains.kotlin.resolve.jvm.annotations.isCompiledToJvmDefault
|
||||
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodGenericSignature
|
||||
@@ -374,27 +372,13 @@ class KotlinTypeMapper @JvmOverloads constructor(
|
||||
kind: OwnerKind? = null,
|
||||
resolvedCall: ResolvedCall<*>? = null
|
||||
): CallableMethod {
|
||||
fun mapDefaultCallback(descriptor: FunctionDescriptor, kind: OwnerKind): () -> Method {
|
||||
if (useOldManglingRulesForFunctionAcceptingInlineClass && !useOldInlineClassesManglingScheme) {
|
||||
return {
|
||||
val prevManglingState = useOldManglingRulesForFunctionAcceptingInlineClass
|
||||
useOldManglingRulesForFunctionAcceptingInlineClass = true
|
||||
mapDefaultMethod(descriptor, kind).also {
|
||||
useOldManglingRulesForFunctionAcceptingInlineClass = prevManglingState
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return { mapDefaultMethod(descriptor, kind) }
|
||||
}
|
||||
}
|
||||
|
||||
// we generate constructors of inline classes as usual functions
|
||||
if (descriptor is ConstructorDescriptor && kind != OwnerKind.ERASED_INLINE_CLASS) {
|
||||
val method = mapSignatureSkipGeneric(descriptor.original)
|
||||
val owner = mapOwner(descriptor)
|
||||
val originalDescriptor = descriptor.original
|
||||
return CallableMethod(
|
||||
owner, owner, mapDefaultCallback(originalDescriptor, OwnerKind.IMPLEMENTATION), method, INVOKESPECIAL,
|
||||
owner, owner, { mapDefaultMethod(originalDescriptor, OwnerKind.IMPLEMENTATION) }, method, INVOKESPECIAL,
|
||||
null, null, null, null, null, originalDescriptor.returnType, isInterfaceMethod = false, isDefaultMethodInInterface = false
|
||||
)
|
||||
}
|
||||
@@ -559,7 +543,7 @@ class KotlinTypeMapper @JvmOverloads constructor(
|
||||
|
||||
return CallableMethod(
|
||||
owner, ownerForDefaultImpl,
|
||||
mapDefaultCallback(baseMethodDescriptor, getKindForDefaultImplCall(baseMethodDescriptor)),
|
||||
{ mapDefaultMethod(baseMethodDescriptor, getKindForDefaultImplCall(baseMethodDescriptor)) },
|
||||
signature, invokeOpcode, thisClass, dispatchReceiverKotlinType, receiverParameterType, extensionReceiverKotlinType,
|
||||
calleeType, returnKotlinType,
|
||||
if (jvmTarget >= JvmTarget.JVM_1_8) isInterfaceMember else invokeOpcode == INVOKEINTERFACE,
|
||||
@@ -579,16 +563,10 @@ class KotlinTypeMapper @JvmOverloads constructor(
|
||||
return when {
|
||||
descriptor is PropertyAccessorDescriptor -> {
|
||||
val property = descriptor.correspondingProperty
|
||||
val containingDeclaration = property.containingDeclaration
|
||||
|
||||
if (isAnnotationClass(containingDeclaration) &&
|
||||
(!property.hasJvmStaticAnnotation() && !descriptor.hasJvmStaticAnnotation())
|
||||
) {
|
||||
if (isAnnotationClass(property.containingDeclaration)) {
|
||||
return property.name.asString()
|
||||
}
|
||||
|
||||
if ((containingDeclaration as? ClassDescriptor)?.hasJavaLangRecordSupertype() == true) return property.name.asString()
|
||||
|
||||
val isAccessor = property is AccessorForPropertyDescriptor
|
||||
val propertyName = if (isAccessor)
|
||||
(property as AccessorForPropertyDescriptor).accessorSuffix
|
||||
@@ -623,9 +601,6 @@ class KotlinTypeMapper @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private fun ClassDescriptor.hasJavaLangRecordSupertype() =
|
||||
typeConstructor.supertypes.any { KotlinBuiltIns.isConstructedFromGivenClass(it, JAVA_LANG_RECORD_FQ_NAME) }
|
||||
|
||||
private val shouldMangleByReturnType =
|
||||
languageVersionSettings.supportsFeature(LanguageFeature.MangleClassMembersReturningInlineClasses)
|
||||
|
||||
|
||||
@@ -49,7 +49,6 @@ if "%_KOTLIN_RUNNER%"=="1" (
|
||||
"%_JAVACMD%" %JAVA_OPTS% "-Dkotlin.home=%_KOTLIN_HOME%" -cp "%_KOTLIN_HOME%\lib\kotlin-runner.jar" ^
|
||||
org.jetbrains.kotlin.runner.Main %KOTLIN_OPTS%
|
||||
) else (
|
||||
setlocal EnableDelayedExpansion
|
||||
SET _ADDITIONAL_CLASSPATH=
|
||||
|
||||
if not "%_KOTLIN_TOOL%"=="" (
|
||||
@@ -57,7 +56,7 @@ if "%_KOTLIN_RUNNER%"=="1" (
|
||||
)
|
||||
|
||||
"%_JAVACMD%" %JAVA_OPTS% -noverify -cp "%_KOTLIN_HOME%\lib\kotlin-preloader.jar" ^
|
||||
org.jetbrains.kotlin.preloading.Preloader -cp "%_KOTLIN_HOME%\lib\kotlin-compiler.jar!_ADDITIONAL_CLASSPATH!" ^
|
||||
org.jetbrains.kotlin.preloading.Preloader -cp "%_KOTLIN_HOME%\lib\kotlin-compiler.jar%_ADDITIONAL_CLASSPATH%" ^
|
||||
%_KOTLIN_COMPILER% %KOTLIN_OPTS%
|
||||
)
|
||||
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
<idea-plugin>
|
||||
<id>org.jetbrains.kotlin</id>
|
||||
<version>1.2</version>
|
||||
|
||||
<!-- Don't add more extension points here! Logic in KotlinCoreEnvironment assumes that there is only one EP. -->
|
||||
<!-- And this file should be removed once 202 is no longer supported -->
|
||||
<extensionPoints>
|
||||
<extensionPoint qualifiedName="com.intellij.psi.classFileDecompiler"
|
||||
interface="com.intellij.psi.compiled.ClassFileDecompilers$Decompiler"
|
||||
dynamic="true"/>
|
||||
</extensionPoints>
|
||||
</idea-plugin>
|
||||
@@ -85,9 +85,8 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
|
||||
@Argument(value = "-Xuse-ir", description = "Use the IR backend")
|
||||
var useIR: Boolean by FreezableVar(false)
|
||||
|
||||
@GradleOption(DefaultValues.BooleanFalseDefault::class)
|
||||
@Argument(value = "-Xuse-old-backend", description = "Use the old JVM backend")
|
||||
var useOldBackend: Boolean by FreezableVar(false)
|
||||
@Argument(value = "-Xno-use-ir", description = "Do not use the IR backend. Useful for a custom-built compiler where IR backend is enabled by default")
|
||||
var noUseIR: Boolean by FreezableVar(false)
|
||||
|
||||
@Argument(
|
||||
value = "-Xir-check-local-names",
|
||||
@@ -96,20 +95,18 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
|
||||
var irCheckLocalNames: Boolean by FreezableVar(false)
|
||||
|
||||
@Argument(
|
||||
value = "-Xallow-unstable-dependencies",
|
||||
description = "Do not report errors on classes in dependencies, which were compiled by an unstable version of the Kotlin compiler"
|
||||
value = "-Xallow-jvm-ir-dependencies",
|
||||
description = "When not using the IR backend, do not report errors on those classes in dependencies, " +
|
||||
"which were compiled by the IR backend"
|
||||
)
|
||||
var allowUnstableDependencies: Boolean by FreezableVar(false)
|
||||
var allowJvmIrDependencies: Boolean by FreezableVar(false)
|
||||
|
||||
@Argument(
|
||||
value = "-Xabi-stability",
|
||||
valueDescription = "{stable|unstable}",
|
||||
description = "When using unstable compiler features such as FIR, use 'stable' to mark generated class files as stable\n" +
|
||||
"to prevent diagnostics from stable compilers at the call site.\n" +
|
||||
"When using the JVM IR backend, conversely, use 'unstable' to mark generated class files as unstable\n" +
|
||||
"to force diagnostics to be reported."
|
||||
value = "-Xir-binary-with-stable-abi",
|
||||
description = "When using the IR backend, produce binaries which can be read by non-IR backend.\n" +
|
||||
"The author is responsible for verifying that the resulting binaries do indeed have the correct ABI"
|
||||
)
|
||||
var abiStability: String? by FreezableVar(null)
|
||||
var isIrWithStableAbi: Boolean by FreezableVar(false)
|
||||
|
||||
@Argument(
|
||||
value = "-Xir-do-not-clear-binding-context",
|
||||
@@ -315,13 +312,6 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
|
||||
)
|
||||
var jvmDefault: String by FreezableVar(JvmDefaultMode.DEFAULT.description)
|
||||
|
||||
@Argument(
|
||||
value = "-Xdefault-script-extension",
|
||||
valueDescription = "<script filename extension>",
|
||||
description = "Compile expressions and unrecognized scripts passed with the -script argument as scripts with given filename extension"
|
||||
)
|
||||
var defaultScriptExtension: String? by FreezableVar(null)
|
||||
|
||||
@Argument(value = "-Xdisable-standard-script", description = "Disable standard kotlin script support")
|
||||
var disableStandardScript: Boolean by FreezableVar(false)
|
||||
|
||||
@@ -428,13 +418,6 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
|
||||
)
|
||||
var useOldInlineClassesManglingScheme: Boolean by FreezableVar(false)
|
||||
|
||||
@Argument(
|
||||
value = "-Xjvm-enable-preview",
|
||||
description = "Allow using features from Java language that are in preview phase.\n" +
|
||||
"Works as `--enable-preview` in Java. All class files are marked as preview-generated thus it won't be possible to use them in release environment"
|
||||
)
|
||||
var enableJvmPreview: Boolean by FreezableVar(false)
|
||||
|
||||
override fun configureAnalysisFlags(collector: MessageCollector): MutableMap<AnalysisFlag<*>, Any> {
|
||||
val result = super.configureAnalysisFlags(collector)
|
||||
result[JvmAnalysisFlags.strictMetadataVersionSemantics] = strictMetadataVersionSemantics
|
||||
@@ -455,8 +438,7 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
|
||||
result[JvmAnalysisFlags.sanitizeParentheses] = sanitizeParentheses
|
||||
result[JvmAnalysisFlags.suppressMissingBuiltinsError] = suppressMissingBuiltinsError
|
||||
result[JvmAnalysisFlags.irCheckLocalNames] = irCheckLocalNames
|
||||
result[JvmAnalysisFlags.enableJvmPreview] = enableJvmPreview
|
||||
result[AnalysisFlags.allowUnstableDependencies] = allowUnstableDependencies || useFir
|
||||
result[AnalysisFlags.reportErrorsOnIrDependencies] = !useIR && !useFir && !allowJvmIrDependencies
|
||||
result[JvmAnalysisFlags.disableUltraLightClasses] = disableUltraLightClasses
|
||||
return result
|
||||
}
|
||||
@@ -470,7 +452,7 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
|
||||
}
|
||||
|
||||
override fun checkIrSupport(languageVersionSettings: LanguageVersionSettings, collector: MessageCollector) {
|
||||
if (!useIR || useOldBackend) return
|
||||
if (!useIR) return
|
||||
|
||||
if (languageVersionSettings.languageVersion < LanguageVersion.KOTLIN_1_3
|
||||
|| languageVersionSettings.apiVersion < ApiVersion.KOTLIN_1_3
|
||||
|
||||
@@ -34,36 +34,22 @@ object Main {
|
||||
KOTLIN_HOME = File(home)
|
||||
}
|
||||
|
||||
enum class HowToRun(val argName: String) {
|
||||
GUESS("guess"),
|
||||
CLASSFILE("classfile"),
|
||||
JAR("jar"),
|
||||
SCRIPT("script");
|
||||
// TODO: consider implementing REPL as well
|
||||
|
||||
companion object {
|
||||
val validValues = "${GUESS.argName} (default), ${CLASSFILE.argName}, ${JAR.argName}, ${SCRIPT.argName} (or .<script filename extension>)"
|
||||
|
||||
fun fromArg(name: String): HowToRun? =
|
||||
HowToRun.values().find { it.argName == name }
|
||||
}
|
||||
}
|
||||
|
||||
private fun run(args: Array<String>) {
|
||||
val classpath = arrayListOf<URL>()
|
||||
val compilerClasspath = arrayListOf<URL>()
|
||||
var runner: Runner? = null
|
||||
var collectingArguments = false
|
||||
var collectingExpressions = false
|
||||
var needsCompiler = false
|
||||
val arguments = arrayListOf<String>()
|
||||
val compilerArguments = arrayListOf<String>()
|
||||
var noStdLib = false
|
||||
var expression: String? = null
|
||||
var noReflect = false
|
||||
var howtorun = HowToRun.GUESS
|
||||
|
||||
fun setRunner(newRunner: Runner) {
|
||||
if (runner == null) {
|
||||
runner = newRunner
|
||||
fun setExpression(expr: String) {
|
||||
if (expression == null) {
|
||||
expression = expr
|
||||
} else {
|
||||
throw AssertionError("conflicting runner settings")
|
||||
throw RunnerException("Only single -e/-expression argument supported")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,8 +64,20 @@ object Main {
|
||||
return args[i]
|
||||
}
|
||||
|
||||
fun restAsArguments() {
|
||||
arguments.addAll(args.copyOfRange(i+1, args.size))
|
||||
if (collectingExpressions) {
|
||||
if ("-expression" == arg || "-e" == arg) {
|
||||
setExpression(next())
|
||||
i++
|
||||
continue
|
||||
} else {
|
||||
collectingArguments = true
|
||||
}
|
||||
}
|
||||
|
||||
if (collectingArguments) {
|
||||
arguments.add(arg)
|
||||
i++
|
||||
continue
|
||||
}
|
||||
|
||||
if ("-help" == arg || "-h" == arg) {
|
||||
@@ -98,55 +96,29 @@ object Main {
|
||||
compilerClasspath.addPath(path)
|
||||
}
|
||||
}
|
||||
else if ("-howtorun" == arg) {
|
||||
if (howtorun != HowToRun.GUESS) {
|
||||
throw RunnerException("-howtorun is already set to ${howtorun.argName}")
|
||||
}
|
||||
val howToRunArg = next()
|
||||
if (howToRunArg.startsWith(".")) {
|
||||
howtorun = HowToRun.SCRIPT
|
||||
compilerArguments.add("-Xdefault-script-extension=$howToRunArg")
|
||||
} else {
|
||||
howtorun = HowToRun.fromArg(howToRunArg)
|
||||
?: throw RunnerException("invalid argument to the option -howtorun $howToRunArg, valid arguments are: ${HowToRun.validValues}")
|
||||
}
|
||||
}
|
||||
else if ("-expression" == arg || "-e" == arg) {
|
||||
if (howtorun != HowToRun.GUESS && howtorun != HowToRun.SCRIPT) {
|
||||
throw RunnerException("expression evaluation is not compatible with -howtorun argument ${howtorun.argName}")
|
||||
}
|
||||
setRunner(ExpressionRunner(next()))
|
||||
restAsArguments()
|
||||
break
|
||||
}
|
||||
else if ("-no-stdlib" == arg) {
|
||||
noStdLib = true
|
||||
compilerArguments.add(arg)
|
||||
setExpression(next())
|
||||
collectingExpressions = true
|
||||
needsCompiler = true
|
||||
}
|
||||
else if ("-no-reflect" == arg) {
|
||||
noReflect = true
|
||||
compilerArguments.add(arg)
|
||||
}
|
||||
else if (arg.startsWith("-X")) {
|
||||
compilerArguments.add(arg)
|
||||
}
|
||||
else if (arg.startsWith("-")) {
|
||||
throw RunnerException("unknown option: $arg")
|
||||
throw RunnerException("unsupported argument: $arg")
|
||||
}
|
||||
else if (howtorun == HowToRun.JAR || (howtorun == HowToRun.GUESS && arg.endsWith(".jar"))) {
|
||||
setRunner(JarRunner(arg))
|
||||
restAsArguments()
|
||||
break
|
||||
else if (arg.endsWith(".jar")) {
|
||||
runner = JarRunner(arg)
|
||||
collectingArguments = true
|
||||
}
|
||||
else if (howtorun == HowToRun.SCRIPT || (howtorun == HowToRun.GUESS && arg.endsWith(".kts"))) {
|
||||
setRunner(ScriptRunner(arg))
|
||||
restAsArguments()
|
||||
break
|
||||
else if (arg.endsWith(".kts")) {
|
||||
runner = ScriptRunner(arg)
|
||||
collectingArguments = true
|
||||
needsCompiler = true
|
||||
}
|
||||
else {
|
||||
setRunner(MainClassRunner(arg))
|
||||
restAsArguments()
|
||||
break
|
||||
runner = MainClassRunner(arg)
|
||||
collectingArguments = true
|
||||
}
|
||||
i++
|
||||
}
|
||||
@@ -155,25 +127,26 @@ object Main {
|
||||
classpath.addPath(".")
|
||||
}
|
||||
|
||||
if (!noStdLib) {
|
||||
classpath.addPath("$KOTLIN_HOME/lib/kotlin-stdlib.jar")
|
||||
}
|
||||
classpath.addPath("$KOTLIN_HOME/lib/kotlin-stdlib.jar")
|
||||
|
||||
if (!noReflect) {
|
||||
classpath.addPath("$KOTLIN_HOME/lib/kotlin-reflect.jar")
|
||||
}
|
||||
|
||||
if (runner == null) {
|
||||
setRunner(ReplRunner())
|
||||
if (expression != null) {
|
||||
runner = ExpressionRunner(expression!!)
|
||||
} else if (runner == null) {
|
||||
runner = ReplRunner()
|
||||
needsCompiler = true
|
||||
}
|
||||
|
||||
if (runner is RunnerWithCompiler && compilerClasspath.isEmpty()) {
|
||||
if (needsCompiler && compilerClasspath.isEmpty()) {
|
||||
findCompilerJar(this::class.java, KOTLIN_HOME.resolve("lib")).forEach {
|
||||
compilerClasspath.add(it.absoluteFile.toURI().toURL())
|
||||
}
|
||||
}
|
||||
|
||||
runner!!.run(classpath, compilerArguments, arguments, compilerClasspath)
|
||||
runner.run(classpath, arguments, compilerClasspath)
|
||||
}
|
||||
|
||||
private fun MutableList<URL>.addPath(path: String) {
|
||||
@@ -194,31 +167,21 @@ object Main {
|
||||
private fun printUsageAndExit() {
|
||||
println("""kotlin: run Kotlin programs, scripts or REPL.
|
||||
|
||||
Usage: kotlin <options> <command> [<arguments>]
|
||||
where possible options include:
|
||||
-howtorun <value> How to run the supplied command with arguments,
|
||||
valid values: ${HowToRun.validValues}
|
||||
Usage: kotlin <options> <command> <arguments>
|
||||
where command may be one of:
|
||||
foo.Bar Runs the 'main' function from the class with the given qualified name
|
||||
app.jar Runs the given JAR file as 'java -jar' would do
|
||||
(-classpath argument is ignored and no Kotlin runtime is added to the classpath)
|
||||
""" +
|
||||
// script.kts Compiles and runs the given script
|
||||
// -expression (-e) '2+2' Evaluates the expression and prints the result
|
||||
"""and possible options include:
|
||||
-classpath (-cp) <path> Paths where to find user class files
|
||||
-Dname=value Set a system JVM property
|
||||
-J<option> Pass an option directly to JVM
|
||||
-no-stdlib Don't include Kotlin standard library into classpath
|
||||
-no-reflect Don't include Kotlin reflection implementation into classpath
|
||||
-compiler-path Kotlin compiler classpath for compiling script or expression or running REPL
|
||||
If not specified, try to find the compiler in the environment
|
||||
-X<flag>[=value] Pass -X argument to the compiler
|
||||
-version Display Kotlin version
|
||||
-help (-h) Print a synopsis of options
|
||||
and command is interpreted according to the -howtorun option argument
|
||||
or, in case of guess, according to the following rules:
|
||||
foo.Bar Runs the 'main' function from the class with the given qualified name
|
||||
(compiler arguments are ignored)
|
||||
app.jar Runs the given JAR file as 'java -jar' would do
|
||||
(compiler arguments are ignored and no Kotlin stdlib is added to the classpath)
|
||||
script.kts Compiles and runs the given script, passing <arguments> to it
|
||||
-expression (-e) '2+2' Evaluates the expression and prints the result, passing <arguments> to it
|
||||
<no command> Runs Kotlin REPL
|
||||
arguments are passed to the main function when running class or jar file, and for standard script definitions
|
||||
as the 'args' parameter when running script or expression
|
||||
""")
|
||||
exitProcess(0)
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.net.URL
|
||||
interface Runner {
|
||||
fun run(
|
||||
classpath: List<URL>,
|
||||
compilerArguments: List<String>,
|
||||
arguments: List<String>,
|
||||
compilerClasspath: List<URL>
|
||||
)
|
||||
|
||||
@@ -32,7 +32,7 @@ abstract class AbstractRunner : Runner {
|
||||
|
||||
protected abstract fun createClassLoader(classpath: List<URL>): ClassLoader
|
||||
|
||||
override fun run(classpath: List<URL>, compilerArguments: List<String>, arguments: List<String>, compilerClasspath: List<URL>) {
|
||||
override fun run(classpath: List<URL>, arguments: List<String>, compilerClasspath: List<URL>) {
|
||||
val classLoader = createClassLoader(classpath)
|
||||
|
||||
val mainClass = try {
|
||||
@@ -127,45 +127,39 @@ private fun MutableList<String>.addClasspathArgIfNeeded(classpath: List<URL>) {
|
||||
}
|
||||
}
|
||||
|
||||
private fun ArrayList<String>.addScriptArguments(arguments: List<String>) {
|
||||
if (arguments.isNotEmpty() && arguments.first() != "--") {
|
||||
add("--")
|
||||
}
|
||||
addAll(arguments)
|
||||
}
|
||||
|
||||
class ReplRunner : RunnerWithCompiler() {
|
||||
override fun run(classpath: List<URL>, compilerArguments: List<String>, arguments: List<String>, compilerClasspath: List<URL>) {
|
||||
val compilerArgs = ArrayList<String>().apply {
|
||||
addClasspathArgIfNeeded(classpath)
|
||||
addAll(compilerArguments)
|
||||
addScriptArguments(arguments)
|
||||
}
|
||||
override fun run(classpath: List<URL>, arguments: List<String>, compilerClasspath: List<URL>) {
|
||||
val compilerArgs = ArrayList<String>()
|
||||
compilerArgs.addClasspathArgIfNeeded(classpath)
|
||||
runCompiler(compilerClasspath, compilerArgs)
|
||||
}
|
||||
}
|
||||
|
||||
class ScriptRunner(private val path: String) : RunnerWithCompiler() {
|
||||
override fun run(classpath: List<URL>, compilerArguments: List<String>, arguments: List<String>, compilerClasspath: List<URL>) {
|
||||
override fun run(classpath: List<URL>, arguments: List<String>, compilerClasspath: List<URL>) {
|
||||
val compilerArgs = ArrayList<String>().apply {
|
||||
addClasspathArgIfNeeded(classpath)
|
||||
addAll(compilerArguments)
|
||||
add("-script")
|
||||
add(path)
|
||||
addScriptArguments(arguments)
|
||||
if (arguments.isNotEmpty() && arguments.first() != "--") {
|
||||
add("--")
|
||||
}
|
||||
addAll(arguments)
|
||||
}
|
||||
runCompiler(compilerClasspath, compilerArgs)
|
||||
}
|
||||
}
|
||||
|
||||
class ExpressionRunner(private val code: String) : RunnerWithCompiler() {
|
||||
override fun run(classpath: List<URL>, compilerArguments: List<String>, arguments: List<String>, compilerClasspath: List<URL>) {
|
||||
override fun run(classpath: List<URL>, arguments: List<String>, compilerClasspath: List<URL>) {
|
||||
val compilerArgs = ArrayList<String>().apply {
|
||||
addClasspathArgIfNeeded(classpath)
|
||||
addAll(compilerArguments)
|
||||
add("-expression")
|
||||
add(code)
|
||||
addScriptArguments(arguments)
|
||||
if (arguments.isNotEmpty() && arguments.first() != "--") {
|
||||
add("--")
|
||||
}
|
||||
addAll(arguments)
|
||||
}
|
||||
runCompiler(compilerClasspath, compilerArgs)
|
||||
}
|
||||
|
||||
@@ -182,19 +182,11 @@ class AnalyzerWithCompilerReport(
|
||||
)
|
||||
}
|
||||
|
||||
if (diagnostics.any { it.factory == Errors.IR_WITH_UNSTABLE_ABI_COMPILED_CLASS }) {
|
||||
if (diagnostics.any { it.factory == Errors.IR_COMPILED_CLASS }) {
|
||||
messageCollector.report(
|
||||
ERROR,
|
||||
"Classes compiled by an unstable version of the Kotlin compiler were found in dependencies. " +
|
||||
"Remove them from the classpath or use '-Xallow-unstable-dependencies' to suppress errors"
|
||||
)
|
||||
}
|
||||
|
||||
if (diagnostics.any { it.factory == Errors.FIR_COMPILED_CLASS }) {
|
||||
messageCollector.report(
|
||||
ERROR,
|
||||
"Classes compiled by the new Kotlin compiler frontend were found in dependencies. " +
|
||||
"Remove them from the classpath or use '-Xallow-unstable-dependencies' to suppress errors"
|
||||
"Classes compiled by a new Kotlin compiler backend were found in dependencies. " +
|
||||
"Remove them from the classpath or use '-Xallow-jvm-ir-dependencies' to suppress errors"
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.cli.common.messages
|
||||
|
||||
import com.intellij.psi.PsiFile
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticUtils
|
||||
|
||||
/**
|
||||
* This class behaviour is the same as [MessageCollector.report] in [AnalyzerWithCompilerReport.reportDiagnostic].
|
||||
*/
|
||||
class DefaultDiagnosticReporter(override val messageCollector: MessageCollector) : MessageCollectorBasedReporter
|
||||
|
||||
interface MessageCollectorBasedReporter : DiagnosticMessageReporter {
|
||||
val messageCollector: MessageCollector
|
||||
|
||||
override fun report(diagnostic: Diagnostic, file: PsiFile, render: String) = messageCollector.report(
|
||||
AnalyzerWithCompilerReport.convertSeverity(diagnostic.severity),
|
||||
render,
|
||||
MessageUtil.psiFileToMessageLocation(file, file.name, DiagnosticUtils.getLineAndColumn(diagnostic))
|
||||
)
|
||||
}
|
||||
@@ -17,6 +17,8 @@
|
||||
package org.jetbrains.kotlin.cli.common.messages;
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.impl.jar.CoreJarVirtualFile;
|
||||
import com.intellij.openapi.vfs.local.CoreLocalVirtualFile;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -51,6 +53,10 @@ public class MessageUtil {
|
||||
|
||||
@NotNull
|
||||
public static String virtualFileToPath(@NotNull VirtualFile virtualFile) {
|
||||
return toSystemDependentName(virtualFile.getPath());
|
||||
// Convert path to platform-dependent format when virtualFile is local file.
|
||||
if (virtualFile instanceof CoreLocalVirtualFile || virtualFile instanceof CoreJarVirtualFile) {
|
||||
return toSystemDependentName(virtualFile.getPath());
|
||||
}
|
||||
return virtualFile.getPath();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.cli.common.messages;
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticUtils;
|
||||
import org.jetbrains.kotlin.diagnostics.PsiDiagnosticUtils;
|
||||
|
||||
import static com.intellij.openapi.util.io.FileUtil.toSystemDependentName;
|
||||
|
||||
public class MessageUtil {
|
||||
private MessageUtil() {}
|
||||
|
||||
@Nullable
|
||||
public static CompilerMessageLocation psiElementToMessageLocation(@Nullable PsiElement element) {
|
||||
if (element == null) return null;
|
||||
PsiFile file = element.getContainingFile();
|
||||
return psiFileToMessageLocation(file, "<no path>", DiagnosticUtils.getLineAndColumnInPsiFile(file, element.getTextRange()));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static CompilerMessageLocation psiFileToMessageLocation(
|
||||
@NotNull PsiFile file,
|
||||
@Nullable String defaultValue,
|
||||
@NotNull PsiDiagnosticUtils.LineAndColumn lineAndColumn
|
||||
) {
|
||||
VirtualFile virtualFile = file.getVirtualFile();
|
||||
String path = virtualFile != null ? virtualFileToPath(virtualFile) : defaultValue;
|
||||
return CompilerMessageLocation.create(path, lineAndColumn.getLine(), lineAndColumn.getColumn(), lineAndColumn.getLineContent());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String virtualFileToPath(@NotNull VirtualFile virtualFile) {
|
||||
return toSystemDependentName(virtualFile.getPath());
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.cli.jvm.compiler
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension
|
||||
import com.intellij.pom.java.LanguageLevel
|
||||
|
||||
fun Project.setupHighestLanguageLevel() {
|
||||
LanguageLevelProjectExtension.getInstance(this).languageLevel = LanguageLevel.JDK_15_PREVIEW
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.cli.jvm.compiler
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension
|
||||
import com.intellij.pom.java.LanguageLevel
|
||||
|
||||
fun Project.setupHighestLanguageLevel() {
|
||||
// LanguageLevelProjectExtension.getInstance(this).languageLevel = LanguageLevel.JDK_15_PREVIEW
|
||||
}
|
||||
@@ -40,6 +40,7 @@ public class KotlinCoreApplicationEnvironment extends JavaCoreApplicationEnviron
|
||||
registerApplicationExtensionPoint(JavaMainMethodProvider.EP_NAME, JavaMainMethodProvider.class);
|
||||
|
||||
registerApplicationExtensionPoint(ContainerProvider.EP_NAME, ContainerProvider.class);
|
||||
registerApplicationExtensionPoint(ClassFileDecompilers.EP_NAME, ClassFileDecompilers.Decompiler.class);
|
||||
|
||||
registerApplicationExtensionPoint(MetaLanguage.EP_NAME, MetaLanguage.class);
|
||||
|
||||
@@ -51,4 +52,4 @@ public class KotlinCoreApplicationEnvironment extends JavaCoreApplicationEnviron
|
||||
protected VirtualFileSystem createJrtFileSystem() {
|
||||
return new CoreJrtFileSystem();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
package org.jetbrains.kotlin.cli.jvm.compiler;
|
||||
|
||||
import com.intellij.DynamicBundle;
|
||||
import com.intellij.codeInsight.ContainerProvider;
|
||||
import com.intellij.codeInsight.runner.JavaMainMethodProvider;
|
||||
import com.intellij.core.JavaCoreApplicationEnvironment;
|
||||
import com.intellij.lang.MetaLanguage;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.vfs.VirtualFileSystem;
|
||||
import com.intellij.psi.FileContextProvider;
|
||||
import com.intellij.psi.augment.PsiAugmentProvider;
|
||||
import com.intellij.psi.compiled.ClassFileDecompilers;
|
||||
import com.intellij.psi.meta.MetaDataContributor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.cli.jvm.modules.CoreJrtFileSystem;
|
||||
|
||||
public class KotlinCoreApplicationEnvironment extends JavaCoreApplicationEnvironment {
|
||||
public static KotlinCoreApplicationEnvironment create(@NotNull Disposable parentDisposable, boolean unitTestMode) {
|
||||
KotlinCoreApplicationEnvironment environment = new KotlinCoreApplicationEnvironment(parentDisposable, unitTestMode);
|
||||
registerExtensionPoints();
|
||||
return environment;
|
||||
}
|
||||
|
||||
private KotlinCoreApplicationEnvironment(@NotNull Disposable parentDisposable, boolean unitTestMode) {
|
||||
super(parentDisposable, unitTestMode);
|
||||
}
|
||||
|
||||
private static void registerExtensionPoints() {
|
||||
registerApplicationExtensionPoint(DynamicBundle.LanguageBundleEP.EP_NAME, DynamicBundle.LanguageBundleEP.class);
|
||||
registerApplicationExtensionPoint(FileContextProvider.EP_NAME, FileContextProvider.class);
|
||||
|
||||
registerApplicationExtensionPoint(MetaDataContributor.EP_NAME, MetaDataContributor.class);
|
||||
registerApplicationExtensionPoint(PsiAugmentProvider.EP_NAME, PsiAugmentProvider.class);
|
||||
registerApplicationExtensionPoint(JavaMainMethodProvider.EP_NAME, JavaMainMethodProvider.class);
|
||||
|
||||
registerApplicationExtensionPoint(ContainerProvider.EP_NAME, ContainerProvider.class);
|
||||
registerApplicationExtensionPoint(ClassFileDecompilers.getInstance().EP_NAME, ClassFileDecompilers.Decompiler.class);
|
||||
|
||||
registerApplicationExtensionPoint(MetaLanguage.EP_NAME, MetaLanguage.class);
|
||||
|
||||
IdeaExtensionPoints.INSTANCE.registerVersionSpecificAppExtensionPoints(Extensions.getRootArea());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected VirtualFileSystem createJrtFileSystem() {
|
||||
return new CoreJrtFileSystem();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
package org.jetbrains.kotlin.cli.jvm.compiler;
|
||||
|
||||
import com.intellij.DynamicBundle;
|
||||
import com.intellij.codeInsight.ContainerProvider;
|
||||
import com.intellij.codeInsight.runner.JavaMainMethodProvider;
|
||||
import com.intellij.core.JavaCoreApplicationEnvironment;
|
||||
import com.intellij.lang.MetaLanguage;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.vfs.VirtualFileSystem;
|
||||
import com.intellij.psi.FileContextProvider;
|
||||
import com.intellij.psi.augment.PsiAugmentProvider;
|
||||
import com.intellij.psi.meta.MetaDataContributor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.cli.jvm.modules.CoreJrtFileSystem;
|
||||
|
||||
public class KotlinCoreApplicationEnvironment extends JavaCoreApplicationEnvironment {
|
||||
public static KotlinCoreApplicationEnvironment create(@NotNull Disposable parentDisposable, boolean unitTestMode) {
|
||||
KotlinCoreApplicationEnvironment environment = new KotlinCoreApplicationEnvironment(parentDisposable, unitTestMode);
|
||||
registerExtensionPoints();
|
||||
return environment;
|
||||
}
|
||||
|
||||
private KotlinCoreApplicationEnvironment(@NotNull Disposable parentDisposable, boolean unitTestMode) {
|
||||
super(parentDisposable, unitTestMode);
|
||||
}
|
||||
|
||||
private static void registerExtensionPoints() {
|
||||
registerApplicationExtensionPoint(DynamicBundle.LanguageBundleEP.EP_NAME, DynamicBundle.LanguageBundleEP.class);
|
||||
registerApplicationExtensionPoint(FileContextProvider.EP_NAME, FileContextProvider.class);
|
||||
|
||||
registerApplicationExtensionPoint(MetaDataContributor.EP_NAME, MetaDataContributor.class);
|
||||
registerApplicationExtensionPoint(PsiAugmentProvider.EP_NAME, PsiAugmentProvider.class);
|
||||
registerApplicationExtensionPoint(JavaMainMethodProvider.EP_NAME, JavaMainMethodProvider.class);
|
||||
|
||||
registerApplicationExtensionPoint(ContainerProvider.EP_NAME, ContainerProvider.class);
|
||||
|
||||
registerApplicationExtensionPoint(MetaLanguage.EP_NAME, MetaLanguage.class);
|
||||
|
||||
IdeaExtensionPoints.INSTANCE.registerVersionSpecificAppExtensionPoints(Extensions.getRootArea());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected VirtualFileSystem createJrtFileSystem() {
|
||||
return new CoreJrtFileSystem();
|
||||
}
|
||||
}
|
||||
@@ -33,16 +33,13 @@ import com.intellij.openapi.extensions.Extensions
|
||||
import com.intellij.openapi.extensions.ExtensionsArea
|
||||
import com.intellij.openapi.fileTypes.PlainTextFileType
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.openapi.util.io.FileUtilRt
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import com.intellij.openapi.vfs.*
|
||||
import com.intellij.openapi.vfs.impl.ZipHandler
|
||||
import com.intellij.pom.java.LanguageLevel
|
||||
import com.intellij.psi.PsiElementFinder
|
||||
import com.intellij.psi.PsiManager
|
||||
import com.intellij.psi.compiled.ClassFileDecompilers
|
||||
import com.intellij.psi.impl.JavaClassSupersImpl
|
||||
import com.intellij.psi.impl.PsiElementFinderImpl
|
||||
import com.intellij.psi.impl.PsiTreeChangePreprocessor
|
||||
@@ -252,8 +249,6 @@ class KotlinCoreEnvironment private constructor(
|
||||
project.putUserData(APPEND_JAVA_SOURCE_ROOTS_HANDLER_KEY, fun(roots: List<File>) {
|
||||
updateClasspath(roots.map { JavaSourceRoot(it, null) })
|
||||
})
|
||||
|
||||
project.setupHighestLanguageLevel()
|
||||
}
|
||||
|
||||
private fun collectAdditionalSources(project: MockProject) {
|
||||
@@ -480,10 +475,13 @@ class KotlinCoreEnvironment private constructor(
|
||||
if (System.getProperty(KOTLIN_COMPILER_ENVIRONMENT_KEEPALIVE_PROPERTY).toBooleanLenient() != true) {
|
||||
// JPS may run many instances of the compiler in parallel (there's an option for compiling independent modules in parallel in IntelliJ)
|
||||
// All projects share the same ApplicationEnvironment, and when the last project is disposed, the ApplicationEnvironment is disposed as well
|
||||
Disposer.register(parentDisposable, Disposable {
|
||||
synchronized(APPLICATION_LOCK) {
|
||||
if (--ourProjectCount <= 0) {
|
||||
disposeApplicationEnvironment()
|
||||
@Suppress("ObjectLiteralToLambda") // Disposer tree depends on identity of disposables.
|
||||
Disposer.register(parentDisposable, object : Disposable {
|
||||
override fun dispose() {
|
||||
synchronized(APPLICATION_LOCK) {
|
||||
if (--ourProjectCount <= 0) {
|
||||
disposeApplicationEnvironment()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -511,11 +509,6 @@ class KotlinCoreEnvironment private constructor(
|
||||
val applicationEnvironment = KotlinCoreApplicationEnvironment.create(parentDisposable, unitTestMode)
|
||||
|
||||
registerApplicationExtensionPointsAndExtensionsFrom(configuration, "extensions/compiler.xml")
|
||||
// FIX ME WHEN BUNCH 202 REMOVED: this code is required to support compiler bundled to both 202 and 203.
|
||||
// Please, remove "com.intellij.psi.classFileDecompiler" EP registration once 202 is no longer supported by the compiler
|
||||
if (!Extensions.getRootArea().hasExtensionPoint("com.intellij.psi.classFileDecompiler")) {
|
||||
registerApplicationExtensionPointsAndExtensionsFrom(configuration, "extensions/core.xml")
|
||||
}
|
||||
|
||||
registerApplicationServicesForCLI(applicationEnvironment)
|
||||
registerApplicationServices(applicationEnvironment)
|
||||
@@ -699,4 +692,4 @@ class KotlinCoreEnvironment private constructor(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -649,10 +649,8 @@ class KotlinCoreEnvironment private constructor(
|
||||
registerService(CliLightClassGenerationSupport::class.java, cliLightClassGenerationSupport)
|
||||
registerService(KotlinAsJavaSupport::class.java, kotlinAsJavaSupport)
|
||||
registerService(CodeAnalyzerInitializer::class.java, traceHolder)
|
||||
if (getService(DumbUtil::class.java) == null) {
|
||||
@Suppress("UnstableApiUsage")
|
||||
registerService(DumbUtil::class.java, KotlinCoreDumbUtil())
|
||||
}
|
||||
@Suppress("UnstableApiUsage")
|
||||
registerService(DumbUtil::class.java, KotlinCoreDumbUtil())
|
||||
|
||||
val area = Extensions.getArea(this)
|
||||
|
||||
@@ -688,4 +686,4 @@ class KotlinCoreEnvironment private constructor(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -52,10 +52,10 @@ import org.jetbrains.kotlin.codegen.state.GenerationStateEventCallback
|
||||
import org.jetbrains.kotlin.config.*
|
||||
import org.jetbrains.kotlin.container.get
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.Severity
|
||||
import org.jetbrains.kotlin.diagnostics.*
|
||||
import org.jetbrains.kotlin.fir.analysis.FirAnalyzerFacade
|
||||
import org.jetbrains.kotlin.fir.backend.jvm.FirJvmBackendClassResolver
|
||||
import org.jetbrains.kotlin.fir.backend.jvm.FirJvmBackendExtension
|
||||
import org.jetbrains.kotlin.fir.backend.jvm.FirMetadataSerializer
|
||||
import org.jetbrains.kotlin.fir.checkers.registerExtendedCommonCheckers
|
||||
import org.jetbrains.kotlin.fir.java.FirProjectSessionProvider
|
||||
import org.jetbrains.kotlin.fir.session.FirJvmModuleInfo
|
||||
@@ -389,8 +389,10 @@ object KotlinToJVMBytecodeCompiler {
|
||||
performanceManager?.notifyIRGenerationStarted()
|
||||
generationState.beforeCompile()
|
||||
codegenFactory.generateModuleInFrontendIRMode(
|
||||
generationState, moduleFragment, symbolTable, sourceManager, extensions, FirJvmBackendExtension(session, components)
|
||||
)
|
||||
generationState, moduleFragment, symbolTable, sourceManager, extensions
|
||||
) { context, irClass, _, serializationBindings, parent ->
|
||||
FirMetadataSerializer(session, context, irClass, serializationBindings, parent)
|
||||
}
|
||||
CodegenFactory.doCheckCancelled(generationState)
|
||||
generationState.factory.done()
|
||||
|
||||
@@ -461,10 +463,6 @@ object KotlinToJVMBytecodeCompiler {
|
||||
environment.updateClasspath(result.additionalJavaRoots.map { JavaSourceRoot(it, null) })
|
||||
}
|
||||
|
||||
if (result.additionalClassPathRoots.isNotEmpty()) {
|
||||
environment.updateClasspath(result.additionalClassPathRoots.map { JvmClasspathRoot(it, false) })
|
||||
}
|
||||
|
||||
if (result.additionalKotlinRoots.isNotEmpty()) {
|
||||
environment.addKotlinSourceRoots(result.additionalKotlinRoots)
|
||||
}
|
||||
@@ -474,8 +472,8 @@ object KotlinToJVMBytecodeCompiler {
|
||||
// Clear all diagnostic messages
|
||||
configuration[CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY]?.clear()
|
||||
|
||||
// Repeat analysis with additional source roots generated by compiler plugins.
|
||||
return repeatAnalysisIfNeeded(analyze(environment), environment)
|
||||
// Repeat analysis with additional Java roots (kapt generated sources)
|
||||
return analyze(environment)
|
||||
}
|
||||
|
||||
return result
|
||||
@@ -570,6 +568,8 @@ object KotlinToJVMBytecodeCompiler {
|
||||
sourceFiles: List<KtFile>,
|
||||
module: Module?
|
||||
): GenerationState {
|
||||
val isIR = (configuration.getBoolean(JVMConfigurationKeys.IR) ||
|
||||
configuration.getBoolean(CommonConfigurationKeys.USE_FIR))
|
||||
val generationState = GenerationState.Builder(
|
||||
environment.project,
|
||||
ClassBuilderFactories.BINARIES,
|
||||
@@ -579,12 +579,13 @@ object KotlinToJVMBytecodeCompiler {
|
||||
configuration
|
||||
)
|
||||
.codegenFactory(
|
||||
if (configuration.getBoolean(JVMConfigurationKeys.IR)) JvmIrCodegenFactory(
|
||||
if (isIR) JvmIrCodegenFactory(
|
||||
configuration.get(CLIConfigurationKeys.PHASE_CONFIG) ?: PhaseConfig(jvmPhases)
|
||||
) else DefaultCodegenFactory
|
||||
)
|
||||
.withModule(module)
|
||||
.onIndependentPartCompilationEnd(createOutputFilesFlushingCallbackIfPossible(configuration))
|
||||
.isIrBackend(isIR)
|
||||
.build()
|
||||
|
||||
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()
|
||||
|
||||
@@ -12,6 +12,4 @@ fun setupIdeaStandaloneExecution() {
|
||||
System.getProperties().setProperty("psi.incremental.reparse.depth.limit", "1000")
|
||||
System.getProperties().setProperty("ide.hide.excluded.files", "false")
|
||||
System.getProperties().setProperty("ast.loading.filter", "false")
|
||||
System.getProperties().setProperty("idea.ignore.disabled.plugins", "true")
|
||||
System.getProperties().setProperty("idea.home.path", System.getProperty("java.io.tmpdir"))
|
||||
}
|
||||
@@ -12,4 +12,6 @@ fun setupIdeaStandaloneExecution() {
|
||||
System.getProperties().setProperty("psi.incremental.reparse.depth.limit", "1000")
|
||||
System.getProperties().setProperty("ide.hide.excluded.files", "false")
|
||||
System.getProperties().setProperty("ast.loading.filter", "false")
|
||||
System.getProperties().setProperty("idea.ignore.disabled.plugins", "true")
|
||||
System.getProperties().setProperty("idea.home.path", System.getProperty("java.io.tmpdir"))
|
||||
}
|
||||
@@ -9,7 +9,6 @@ import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
|
||||
import org.jetbrains.kotlin.cli.common.getLibraryFromHome
|
||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.*
|
||||
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
||||
import org.jetbrains.kotlin.cli.jvm.config.JvmClasspathRoot
|
||||
import org.jetbrains.kotlin.cli.jvm.config.JvmModulePathRoot
|
||||
@@ -20,6 +19,9 @@ import org.jetbrains.kotlin.utils.PathUtil
|
||||
import java.io.File
|
||||
|
||||
fun CompilerConfiguration.setupJvmSpecificArguments(arguments: K2JVMCompilerArguments) {
|
||||
|
||||
val messageCollector = getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY)
|
||||
|
||||
put(JVMConfigurationKeys.INCLUDE_RUNTIME, arguments.includeRuntime)
|
||||
|
||||
putIfNotNull(JVMConfigurationKeys.FRIEND_PATHS, arguments.friendPaths?.asList())
|
||||
@@ -37,7 +39,7 @@ fun CompilerConfiguration.setupJvmSpecificArguments(arguments: K2JVMCompilerArgu
|
||||
}
|
||||
|
||||
val jvmTarget = get(JVMConfigurationKeys.JVM_TARGET) ?: JvmTarget.DEFAULT
|
||||
if (jvmTarget.majorVersion < JvmTarget.JVM_1_8.majorVersion) {
|
||||
if (jvmTarget.bytecodeVersion < JvmTarget.JVM_1_8.bytecodeVersion) {
|
||||
val jvmDefaultMode = languageVersionSettings.getFlag(JvmAnalysisFlags.jvmDefaultMode)
|
||||
if (jvmDefaultMode.forAllMethodsWithBody) {
|
||||
messageCollector.report(
|
||||
@@ -51,7 +53,7 @@ fun CompilerConfiguration.setupJvmSpecificArguments(arguments: K2JVMCompilerArgu
|
||||
val runtimeStringConcat = JvmStringConcat.fromString(arguments.stringConcat!!)
|
||||
if (runtimeStringConcat != null) {
|
||||
put(JVMConfigurationKeys.STRING_CONCAT, runtimeStringConcat)
|
||||
if (jvmTarget.majorVersion < JvmTarget.JVM_9.majorVersion && runtimeStringConcat != JvmStringConcat.INLINE) {
|
||||
if (jvmTarget.bytecodeVersion < JvmTarget.JVM_9.bytecodeVersion && runtimeStringConcat != JvmStringConcat.INLINE) {
|
||||
messageCollector.report(
|
||||
WARNING,
|
||||
"`-Xstring-concat=${arguments.stringConcat}` does nothing with JVM target `${jvmTarget.description}`."
|
||||
@@ -69,6 +71,9 @@ fun CompilerConfiguration.setupJvmSpecificArguments(arguments: K2JVMCompilerArgu
|
||||
}
|
||||
|
||||
fun CompilerConfiguration.configureJdkHome(arguments: K2JVMCompilerArguments): Boolean {
|
||||
|
||||
val messageCollector = getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY)
|
||||
|
||||
if (arguments.noJdk) {
|
||||
put(JVMConfigurationKeys.NO_JDK, true)
|
||||
|
||||
@@ -79,7 +84,7 @@ fun CompilerConfiguration.configureJdkHome(arguments: K2JVMCompilerArguments): B
|
||||
}
|
||||
|
||||
if (arguments.jdkHome != null) {
|
||||
val jdkHome = File(arguments.jdkHome!!)
|
||||
val jdkHome = File(arguments.jdkHome)
|
||||
if (!jdkHome.exists()) {
|
||||
messageCollector.report(ERROR, "JDK home directory does not exist: $jdkHome")
|
||||
return false
|
||||
@@ -109,6 +114,7 @@ fun CompilerConfiguration.configureExplicitContentRoots(arguments: K2JVMCompiler
|
||||
}
|
||||
|
||||
fun CompilerConfiguration.configureStandardLibs(paths: KotlinPaths?, arguments: K2JVMCompilerArguments) {
|
||||
val messageCollector = getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY)
|
||||
val isModularJava = isModularJava()
|
||||
|
||||
fun addRoot(moduleName: String, libraryName: String, getLibrary: (KotlinPaths) -> File, noLibraryArgument: String) {
|
||||
@@ -165,38 +171,8 @@ fun CompilerConfiguration.configureAdvancedJvmOptions(arguments: K2JVMCompilerAr
|
||||
|
||||
put(JVMConfigurationKeys.PARAMETERS_METADATA, arguments.javaParameters)
|
||||
|
||||
val useIR = arguments.useFir ||
|
||||
if (languageVersionSettings.supportsFeature(LanguageFeature.JvmIrEnabledByDefault)) {
|
||||
!arguments.useOldBackend
|
||||
} else {
|
||||
arguments.useIR && !arguments.useOldBackend
|
||||
}
|
||||
|
||||
if (arguments.useIR && arguments.useOldBackend) {
|
||||
messageCollector.report(
|
||||
STRONG_WARNING,
|
||||
"Both -Xuse-ir and -Xuse-old-backend are passed. This is an inconsistent configuration. " +
|
||||
"The compiler will use the ${if (useIR) "JVM IR" else "old JVM"} backend"
|
||||
)
|
||||
}
|
||||
messageCollector.report(LOGGING, "Using ${if (useIR) "JVM IR" else "old JVM"} backend")
|
||||
|
||||
put(JVMConfigurationKeys.IR, useIR)
|
||||
|
||||
val abiStability = JvmAbiStability.fromStringOrNull(arguments.abiStability)
|
||||
if (arguments.abiStability != null) {
|
||||
if (abiStability == null) {
|
||||
messageCollector.report(
|
||||
ERROR,
|
||||
"Unknown ABI stability mode: ${arguments.abiStability}, supported modes: ${JvmAbiStability.values().map { it.description }}"
|
||||
)
|
||||
} else if (!useIR && abiStability == JvmAbiStability.UNSTABLE) {
|
||||
messageCollector.report(ERROR, "-Xabi-stability=unstable is not supported in the old JVM backend")
|
||||
} else {
|
||||
put(JVMConfigurationKeys.ABI_STABILITY, abiStability)
|
||||
}
|
||||
}
|
||||
|
||||
put(JVMConfigurationKeys.IR, arguments.useIR && !arguments.noUseIR)
|
||||
put(JVMConfigurationKeys.IS_IR_WITH_STABLE_ABI, arguments.isIrWithStableAbi)
|
||||
put(JVMConfigurationKeys.DO_NOT_CLEAR_BINDING_CONTEXT, arguments.doNotClearBindingContext)
|
||||
put(JVMConfigurationKeys.DISABLE_CALL_ASSERTIONS, arguments.noCallAssertions)
|
||||
put(JVMConfigurationKeys.DISABLE_RECEIVER_ASSERTIONS, arguments.noReceiverAssertions)
|
||||
@@ -213,54 +189,57 @@ fun CompilerConfiguration.configureAdvancedJvmOptions(arguments: K2JVMCompilerAr
|
||||
put(JVMConfigurationKeys.NO_UNIFIED_NULL_CHECKS, arguments.noUnifiedNullChecks)
|
||||
|
||||
if (!JVMConstructorCallNormalizationMode.isSupportedValue(arguments.constructorCallNormalizationMode)) {
|
||||
messageCollector.report(
|
||||
getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY).report(
|
||||
ERROR,
|
||||
"Unknown constructor call normalization mode: ${arguments.constructorCallNormalizationMode}, " +
|
||||
"supported modes: ${JVMConstructorCallNormalizationMode.values().map { it.description }}"
|
||||
)
|
||||
}
|
||||
|
||||
val constructorCallNormalizationMode = JVMConstructorCallNormalizationMode.fromStringOrNull(arguments.constructorCallNormalizationMode)
|
||||
val constructorCallNormalizationMode =
|
||||
JVMConstructorCallNormalizationMode.fromStringOrNull(arguments.constructorCallNormalizationMode)
|
||||
if (constructorCallNormalizationMode != null) {
|
||||
put(JVMConfigurationKeys.CONSTRUCTOR_CALL_NORMALIZATION_MODE, constructorCallNormalizationMode)
|
||||
put(
|
||||
JVMConfigurationKeys.CONSTRUCTOR_CALL_NORMALIZATION_MODE,
|
||||
constructorCallNormalizationMode
|
||||
)
|
||||
}
|
||||
|
||||
val assertionsMode =
|
||||
JVMAssertionsMode.fromStringOrNull(arguments.assertionsMode)
|
||||
if (assertionsMode == null) {
|
||||
messageCollector.report(
|
||||
getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY).report(
|
||||
ERROR,
|
||||
"Unknown assertions mode: ${arguments.assertionsMode}, supported modes: ${JVMAssertionsMode.values().map { it.description }}"
|
||||
"Unknown assertions mode: ${arguments.assertionsMode}, " +
|
||||
"supported modes: ${JVMAssertionsMode.values().map { it.description }}"
|
||||
)
|
||||
}
|
||||
put(JVMConfigurationKeys.ASSERTIONS_MODE, assertionsMode ?: JVMAssertionsMode.DEFAULT)
|
||||
put(
|
||||
JVMConfigurationKeys.ASSERTIONS_MODE,
|
||||
assertionsMode ?: JVMAssertionsMode.DEFAULT
|
||||
)
|
||||
|
||||
put(JVMConfigurationKeys.USE_TYPE_TABLE, arguments.useTypeTable)
|
||||
put(JVMConfigurationKeys.SKIP_RUNTIME_VERSION_CHECK, arguments.skipRuntimeVersionCheck)
|
||||
put(JVMConfigurationKeys.USE_PSI_CLASS_FILES_READING, arguments.useOldClassFilesReading)
|
||||
|
||||
if (arguments.useOldClassFilesReading) {
|
||||
messageCollector.report(INFO, "Using the old java class files reading implementation")
|
||||
getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY)
|
||||
.report(INFO, "Using the old java class files reading implementation")
|
||||
}
|
||||
|
||||
put(CLIConfigurationKeys.ALLOW_KOTLIN_PACKAGE, arguments.allowKotlinPackage)
|
||||
put(JVMConfigurationKeys.USE_SINGLE_MODULE, arguments.singleModule)
|
||||
put(JVMConfigurationKeys.USE_OLD_SPILLED_VAR_TYPE_ANALYSIS, arguments.useOldSpilledVarTypeAnalysis)
|
||||
put(JVMConfigurationKeys.USE_OLD_INLINE_CLASSES_MANGLING_SCHEME, arguments.useOldInlineClassesManglingScheme)
|
||||
put(JVMConfigurationKeys.ENABLE_JVM_PREVIEW, arguments.enableJvmPreview)
|
||||
|
||||
if (arguments.enableJvmPreview) {
|
||||
messageCollector.report(INFO, "Using preview Java language features")
|
||||
}
|
||||
|
||||
arguments.declarationsOutputPath?.let { put(JVMConfigurationKeys.DECLARATIONS_JSON_PATH, it) }
|
||||
}
|
||||
|
||||
fun CompilerConfiguration.configureKlibPaths(arguments: K2JVMCompilerArguments) {
|
||||
val libraries = arguments.klibLibraries ?: return
|
||||
assert(arguments.useIR && !arguments.useOldBackend) { "Klib libraries can only be used with IR backend" }
|
||||
put(JVMConfigurationKeys.KLIB_PATHS, libraries.split(File.pathSeparator.toRegex()).filterNot(String::isEmpty))
|
||||
}
|
||||
|
||||
private val CompilerConfiguration.messageCollector: MessageCollector
|
||||
get() = getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY)
|
||||
assert(arguments.useIR || arguments.klibLibraries == null) { "Klib libraries can only be used with IR backend" }
|
||||
arguments.klibLibraries?.split(File.pathSeparator.toRegex())
|
||||
?.toTypedArray()
|
||||
?.filterNot { it.isEmpty() }
|
||||
?.let { put(JVMConfigurationKeys.KLIB_PATHS, it) }
|
||||
}
|
||||
@@ -117,8 +117,8 @@ public class JVMConfigurationKeys {
|
||||
public static final CompilerConfigurationKey<List<String>> KLIB_PATHS =
|
||||
CompilerConfigurationKey.create("Paths to .klib libraries");
|
||||
|
||||
public static final CompilerConfigurationKey<JvmAbiStability> ABI_STABILITY =
|
||||
CompilerConfigurationKey.create("ABI stability of class files produced by JVM IR and/or FIR");
|
||||
public static final CompilerConfigurationKey<Boolean> IS_IR_WITH_STABLE_ABI =
|
||||
CompilerConfigurationKey.create("Is IR with stable ABI");
|
||||
|
||||
public static final CompilerConfigurationKey<Boolean> DO_NOT_CLEAR_BINDING_CONTEXT =
|
||||
CompilerConfigurationKey.create("When using the IR backend, do not clear BindingContext between psi2ir and lowerings");
|
||||
@@ -140,7 +140,4 @@ public class JVMConfigurationKeys {
|
||||
|
||||
public static final CompilerConfigurationKey<Boolean> USE_OLD_INLINE_CLASSES_MANGLING_SCHEME =
|
||||
CompilerConfigurationKey.create("Use old, 1.4 version of inline classes mangling scheme");
|
||||
|
||||
public static final CompilerConfigurationKey<Boolean> ENABLE_JVM_PREVIEW =
|
||||
CompilerConfigurationKey.create("Enable Java language preview features");
|
||||
}
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.config
|
||||
|
||||
enum class JvmAbiStability(val description: String) {
|
||||
STABLE("stable"),
|
||||
UNSTABLE("unstable"),
|
||||
;
|
||||
|
||||
companion object {
|
||||
fun fromStringOrNull(string: String?): JvmAbiStability? =
|
||||
values().find { it.description == string }
|
||||
}
|
||||
}
|
||||
@@ -33,9 +33,6 @@ object JvmAnalysisFlags {
|
||||
@JvmStatic
|
||||
val disableUltraLightClasses by AnalysisFlag.Delegates.Boolean
|
||||
|
||||
@JvmStatic
|
||||
val enableJvmPreview by AnalysisFlag.Delegates.Boolean
|
||||
|
||||
private object Delegates {
|
||||
object JavaTypeEnhancementStateWarnByDefault {
|
||||
operator fun provideDelegate(instance: Any?, property: KProperty<*>): AnalysisFlag.Delegate<JavaTypeEnhancementState> =
|
||||
|
||||
@@ -19,21 +19,32 @@ package org.jetbrains.kotlin.config
|
||||
import org.jetbrains.kotlin.platform.TargetPlatformVersion
|
||||
import org.jetbrains.org.objectweb.asm.Opcodes
|
||||
|
||||
enum class JvmTarget(
|
||||
override val description: String,
|
||||
val majorVersion: Int,
|
||||
) : TargetPlatformVersion {
|
||||
JVM_1_6("1.6", Opcodes.V1_6),
|
||||
JVM_1_8("1.8", Opcodes.V1_8),
|
||||
JVM_9("9", Opcodes.V9),
|
||||
JVM_10("10", Opcodes.V10),
|
||||
JVM_11("11", Opcodes.V11),
|
||||
JVM_12("12", Opcodes.V12),
|
||||
JVM_13("13", Opcodes.V12 + 1),
|
||||
JVM_14("14", Opcodes.V12 + 2),
|
||||
JVM_15("15", Opcodes.V12 + 3),
|
||||
enum class JvmTarget(override val description: String) : TargetPlatformVersion {
|
||||
JVM_1_6("1.6"),
|
||||
JVM_1_8("1.8"),
|
||||
JVM_9("9"),
|
||||
JVM_10("10"),
|
||||
JVM_11("11"),
|
||||
JVM_12("12"),
|
||||
JVM_13("13"),
|
||||
JVM_14("14"),
|
||||
JVM_15("15"),
|
||||
;
|
||||
|
||||
val bytecodeVersion: Int by lazy {
|
||||
when (this) {
|
||||
JVM_1_6 -> Opcodes.V1_6
|
||||
JVM_1_8 -> Opcodes.V1_8
|
||||
JVM_9 -> Opcodes.V9
|
||||
JVM_10 -> Opcodes.V10
|
||||
JVM_11 -> Opcodes.V11
|
||||
JVM_12 -> Opcodes.V12
|
||||
JVM_13 -> Opcodes.V12 + 1
|
||||
JVM_14 -> Opcodes.V12 + 2
|
||||
JVM_15 -> Opcodes.V12 + 3
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
val DEFAULT = JVM_1_6
|
||||
@@ -41,14 +52,14 @@ enum class JvmTarget(
|
||||
@JvmStatic
|
||||
fun fromString(string: String) = values().find { it.description == string }
|
||||
|
||||
fun getDescription(majorVersion: Int): String {
|
||||
val platformDescription = values().find { it.majorVersion == majorVersion }?.description ?: when (majorVersion) {
|
||||
fun getDescription(bytecodeVersion: Int): String {
|
||||
val platformDescription = values().find { it.bytecodeVersion == bytecodeVersion }?.description ?: when (bytecodeVersion) {
|
||||
Opcodes.V1_7 -> "1.7"
|
||||
else -> null
|
||||
}
|
||||
|
||||
return if (platformDescription != null) "JVM target $platformDescription"
|
||||
else "JVM bytecode version $majorVersion"
|
||||
else "JVM bytecode version $bytecodeVersion"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ object AnalysisFlags {
|
||||
val ideMode by AnalysisFlag.Delegates.Boolean
|
||||
|
||||
@JvmStatic
|
||||
val allowUnstableDependencies by AnalysisFlag.Delegates.Boolean
|
||||
val reportErrorsOnIrDependencies by AnalysisFlag.Delegates.Boolean
|
||||
|
||||
@JvmStatic
|
||||
val libraryToSourceAnalysis by AnalysisFlag.Delegates.Boolean
|
||||
|
||||
@@ -28,7 +28,7 @@ public final class Test : R|kotlin/Any| {
|
||||
|
||||
}
|
||||
|
||||
@R|kotlin/jvm/JvmInline|() public final inline class Z : R|kotlin/Any| {
|
||||
public final inline class Z : R|kotlin/Any| {
|
||||
public open operator fun equals(other: R|kotlin/Any?|): R|kotlin/Boolean|
|
||||
|
||||
public open fun hashCode(): R|kotlin/Int|
|
||||
@@ -41,4 +41,3 @@ public final class Test : R|kotlin/Any| {
|
||||
public constructor(x: R|kotlin/Int|): R|test/Z|
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@R|kotlin/jvm/JvmInline|() public final inline class Z : R|kotlin/Any| {
|
||||
public final inline class Z : R|kotlin/Any| {
|
||||
public open operator fun equals(other: R|kotlin/Any?|): R|kotlin/Boolean|
|
||||
|
||||
public open fun hashCode(): R|kotlin/Int|
|
||||
@@ -11,4 +11,3 @@
|
||||
@R|kotlin/PublishedApi|() internal constructor(value: R|kotlin/Int|): R|test/Z|
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,6 @@ public final const val s: R|kotlin/Short| = Short(20000)
|
||||
public final const val s1: R|kotlin/Short| = Short(1)
|
||||
public get(): R|kotlin/Short|
|
||||
|
||||
public final const val str: R|kotlin/String| = String(:))
|
||||
public final const val str: R|kotlin/String|
|
||||
public get(): R|kotlin/String|
|
||||
|
||||
|
||||
@@ -7,5 +7,5 @@ FILE: definetelyNotNullForTypeParameter.kt
|
||||
public final fun <F : R|kotlin/Any|> foo(computable: R|Out<F?>|): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun <T : R|kotlin/Any|> bar(computable: R|Out<T?>|): R|kotlin/Unit| {
|
||||
R|/foo|<R|T|>(R|/id|<R|T?|>(R|<local>/computable|))
|
||||
R|/foo|<R|T?!!|>(R|/id|<R|T?|>(R|<local>/computable|))
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@@ -1224,11 +1224,6 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
|
||||
public void testParenthesizedAnnotations() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/annotations/functionalTypes/parenthesizedAnnotations.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("propagteAnyAnnotations.kt")
|
||||
public void testPropagteAnyAnnotations() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/annotations/functionalTypes/propagteAnyAnnotations.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/annotations/options")
|
||||
@@ -7897,24 +7892,6 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/exceptions")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Exceptions extends AbstractFirOldFrontendDiagnosticsTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInExceptions() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/exceptions"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("kt24158.kt")
|
||||
public void testKt24158() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/exceptions/kt24158.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/exposed")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
@@ -10550,11 +10527,6 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
|
||||
runTest("compiler/testData/diagnostics/tests/inference/reportAboutUnresolvedReferenceAsUnresolved.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("reportNotEnoughTypeInformationErrorsOnBlockExpressions.kt")
|
||||
public void testReportNotEnoughTypeInformationErrorsOnBlockExpressions() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/reportNotEnoughTypeInformationErrorsOnBlockExpressions.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("resolveWithUnknownLambdaParameterType.kt")
|
||||
public void testResolveWithUnknownLambdaParameterType() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/resolveWithUnknownLambdaParameterType.kt");
|
||||
@@ -10565,9 +10537,14 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
|
||||
runTest("compiler/testData/diagnostics/tests/inference/returningLambdaInSuspendContext.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("specialCallsWithCallableReferences.kt")
|
||||
public void testSpecialCallsWithCallableReferences() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/specialCallsWithCallableReferences.kt");
|
||||
@TestMetadata("simpleLambdaInCallWithAnotherLambdaWithBuilderInference.kt")
|
||||
public void testSimpleLambdaInCallWithAnotherLambdaWithBuilderInference() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/simpleLambdaInCallWithAnotherLambdaWithBuilderInference.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("skipedUnresolvedInBuilderInferenceWithStubReceiverType.kt")
|
||||
public void testSkipedUnresolvedInBuilderInferenceWithStubReceiverType() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/skipedUnresolvedInBuilderInferenceWithStubReceiverType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("starApproximation.kt")
|
||||
@@ -10625,59 +10602,6 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
|
||||
runTest("compiler/testData/diagnostics/tests/inference/useFunctionLiteralsToInferType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/inference/builderInference")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class BuilderInference extends AbstractFirOldFrontendDiagnosticsTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInBuilderInference() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/inference/builderInference"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("simpleLambdaInCallWithAnotherLambdaWithBuilderInference.kt")
|
||||
public void testSimpleLambdaInCallWithAnotherLambdaWithBuilderInference() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/simpleLambdaInCallWithAnotherLambdaWithBuilderInference.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("skipedUnresolvedInBuilderInferenceWithStubReceiverType.kt")
|
||||
public void testSkipedUnresolvedInBuilderInferenceWithStubReceiverType() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/skipedUnresolvedInBuilderInferenceWithStubReceiverType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("specialCallsWithCallableReferences.kt")
|
||||
public void testSpecialCallsWithCallableReferences() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferences.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("specialCallsWithCallableReferencesDontCareTypeInBlockExression.kt")
|
||||
public void testSpecialCallsWithCallableReferencesDontCareTypeInBlockExression() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesDontCareTypeInBlockExression.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("specialCallsWithCallableReferencesDontRewriteAtSlice.kt")
|
||||
public void testSpecialCallsWithCallableReferencesDontRewriteAtSlice() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesDontRewriteAtSlice.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("specialCallsWithCallableReferencesErrorType.kt")
|
||||
public void testSpecialCallsWithCallableReferencesErrorType() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesErrorType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("specialCallsWithCallableReferencesNonStrictOnlyInputTypes.kt")
|
||||
public void testSpecialCallsWithCallableReferencesNonStrictOnlyInputTypes() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithCallableReferencesNonStrictOnlyInputTypes.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("specialCallsWithLambdas.kt")
|
||||
public void testSpecialCallsWithLambdas() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/builderInference/specialCallsWithLambdas.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/inference/capturedTypes")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
@@ -10735,16 +10659,6 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
|
||||
runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/captureTypeOnlyOnTopLevel.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("capturedFlexibleIntersectionTypesWithDifferentBounds.kt")
|
||||
public void testCapturedFlexibleIntersectionTypesWithDifferentBounds() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/capturedFlexibleIntersectionTypesWithDifferentBounds.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("capturedFlexibleIntersectionTypesWithDifferentConstructors.kt")
|
||||
public void testCapturedFlexibleIntersectionTypesWithDifferentConstructors() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/capturedFlexibleIntersectionTypesWithDifferentConstructors.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("capturedType.kt")
|
||||
public void testCapturedType() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/capturedType.kt");
|
||||
@@ -10770,11 +10684,6 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
|
||||
runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/capturedTypeWithTypeVariableSubtyping.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("capturedTypesSubstitutionIntoAbbreviation.kt")
|
||||
public void testCapturedTypesSubstitutionIntoAbbreviation() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/capturedTypesSubstitutionIntoAbbreviation.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("capturingFromArgumentOfFlexibleType.kt")
|
||||
public void testCapturingFromArgumentOfFlexibleType() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/capturedTypes/capturingFromArgumentOfFlexibleType.kt");
|
||||
@@ -12126,11 +12035,6 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
|
||||
runTest("compiler/testData/diagnostics/tests/inference/regressions/kt4420.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt44440.kt")
|
||||
public void testKt44440() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/regressions/kt44440.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt702.kt")
|
||||
public void testKt702() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/regressions/kt702.kt");
|
||||
@@ -12296,11 +12200,6 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
|
||||
public void testSubstitutionIntoInnerClass() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/substitutions/substitutionIntoInnerClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("substitutionOfTypeEnhancement.kt")
|
||||
public void testSubstitutionOfTypeEnhancement() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/substitutions/substitutionOfTypeEnhancement.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/inference/upperBounds")
|
||||
@@ -13008,11 +12907,6 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
|
||||
runTest("compiler/testData/diagnostics/tests/inlineClasses/inlineClassesInsideAnnotations.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("innerClassInsideInlineClass.kt")
|
||||
public void testInnerClassInsideInlineClass() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inlineClasses/innerClassInsideInlineClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lateinitInlineClasses.kt")
|
||||
public void testLateinitInlineClasses() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inlineClasses/lateinitInlineClasses.kt");
|
||||
@@ -13048,11 +12942,6 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
|
||||
runTest("compiler/testData/diagnostics/tests/inlineClasses/unsignedLiteralsWithoutArtifactOnClasspath.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("varPropertyWithInlineClassReceiver.kt")
|
||||
public void testVarPropertyWithInlineClassReceiver() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inlineClasses/varPropertyWithInlineClassReceiver.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("varargsOnParametersOfInlineClassType.kt")
|
||||
public void testVarargsOnParametersOfInlineClassType() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inlineClasses/varargsOnParametersOfInlineClassType.kt");
|
||||
@@ -17241,11 +17130,6 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
|
||||
runTest("compiler/testData/diagnostics/tests/platformTypes/override.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("propagateFlexibilityFromOtherConstraints.kt")
|
||||
public void testPropagateFlexibilityFromOtherConstraints() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/platformTypes/propagateFlexibilityFromOtherConstraints.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("rawOverrides.kt")
|
||||
public void testRawOverrides() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/platformTypes/rawOverrides.kt");
|
||||
@@ -17844,11 +17728,6 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/platformTypes/typeEnhancement"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("buildFlexibleEnhancement.kt")
|
||||
public void testBuildFlexibleEnhancement() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/buildFlexibleEnhancement.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("overriddenExtensions.kt")
|
||||
public void testOverriddenExtensions() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/overriddenExtensions.kt");
|
||||
@@ -19172,11 +19051,6 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
|
||||
runTest("compiler/testData/diagnostics/tests/regressions/propertyWithExtensionTypeInvoke.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("resolveCollectionLiteralInsideLambda.kt")
|
||||
public void testResolveCollectionLiteralInsideLambda() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/regressions/resolveCollectionLiteralInsideLambda.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("resolveSubclassOfList.kt")
|
||||
public void testResolveSubclassOfList() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/regressions/resolveSubclassOfList.kt");
|
||||
@@ -19668,11 +19542,6 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/invoke/kt9805.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("reportFunctionExpectedOnSimpleUnresolved.kt")
|
||||
public void testReportFunctionExpectedOnSimpleUnresolved() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/invoke/reportFunctionExpectedOnSimpleUnresolved.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("reportFunctionExpectedWhenOneInvokeExist.kt")
|
||||
public void testReportFunctionExpectedWhenOneInvokeExist() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/invoke/reportFunctionExpectedWhenOneInvokeExist.kt");
|
||||
@@ -20874,16 +20743,6 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
|
||||
runTest("compiler/testData/diagnostics/tests/sealed/ExhaustiveWhenWithElse.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ExhaustiveWithFreedom.kt")
|
||||
public void testExhaustiveWithFreedom() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/sealed/ExhaustiveWithFreedom.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inheritorInDifferentModule.kt")
|
||||
public void testInheritorInDifferentModule() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/sealed/inheritorInDifferentModule.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("Local.kt")
|
||||
public void testLocal() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/sealed/Local.kt");
|
||||
@@ -20894,21 +20753,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
|
||||
runTest("compiler/testData/diagnostics/tests/sealed/LocalSealed.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("MultipleFiles_enabled.kt")
|
||||
public void testMultipleFiles_enabled() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/sealed/MultipleFiles_enabled.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("NestedSealed.kt")
|
||||
public void testNestedSealed() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/sealed/NestedSealed.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("NestedSealedWithoutRestrictions.kt")
|
||||
public void testNestedSealedWithoutRestrictions() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/sealed/NestedSealedWithoutRestrictions.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("NeverConstructed.kt")
|
||||
public void testNeverConstructed() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/sealed/NeverConstructed.kt");
|
||||
@@ -21008,34 +20857,6 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
|
||||
public void testWithInterface() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/sealed/WithInterface.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/sealed/interfaces")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Interfaces extends AbstractFirOldFrontendDiagnosticsTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInInterfaces() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/sealed/interfaces"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("inheritorInDifferentModule.kt")
|
||||
public void testInheritorInDifferentModule() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/sealed/interfaces/inheritorInDifferentModule.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("sealedInterfacesDisabled.kt")
|
||||
public void testSealedInterfacesDisabled() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/sealed/interfaces/sealedInterfacesDisabled.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("simpleSealedInterface.kt")
|
||||
public void testSimpleSealedInterface() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/sealed/interfaces/simpleSealedInterface.kt");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/secondaryConstructors")
|
||||
@@ -24582,11 +24403,6 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
|
||||
runTest("compiler/testData/diagnostics/tests/typealias/boundsViolationInTypeAliasRHS.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("boundsViolationRecursive.kt")
|
||||
public void testBoundsViolationRecursive() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/typealias/boundsViolationRecursive.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("capturingTypeParametersFromOuterClass.kt")
|
||||
public void testCapturingTypeParametersFromOuterClass() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/typealias/capturingTypeParametersFromOuterClass.kt");
|
||||
@@ -24732,11 +24548,6 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
|
||||
runTest("compiler/testData/diagnostics/tests/typealias/kt14518.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt14612.kt")
|
||||
public void testKt14612() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/typealias/kt14612.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt14641.kt")
|
||||
public void testKt14641() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/typealias/kt14641.kt");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@@ -201,11 +201,6 @@ public class FirOldFrontendDiagnosticsTestWithStdlibGenerated extends AbstractFi
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/explicitMetadata.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("jvmRecordWithoutJdk15.kt")
|
||||
public void testJvmRecordWithoutJdk15() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/jvmRecordWithoutJdk15.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("JvmSyntheticOnDelegate.kt")
|
||||
public void testJvmSyntheticOnDelegate() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/JvmSyntheticOnDelegate.kt");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
|
||||
@@ -20,21 +20,24 @@ import org.jetbrains.kotlin.serialization.deserialization.builtins.BuiltInSerial
|
||||
|
||||
class FirConstDeserializer(
|
||||
val session: FirSession,
|
||||
private val binaryClass: KotlinJvmBinaryClass? = null
|
||||
private val partSource: KotlinJvmBinaryClass? = null,
|
||||
private val facadeSource: KotlinJvmBinaryClass? = null
|
||||
) {
|
||||
private val constantCache = mutableMapOf<CallableId, FirExpression>()
|
||||
companion object {
|
||||
private val constantCache = mutableMapOf<CallableId, FirExpression>()
|
||||
}
|
||||
|
||||
fun loadConstant(propertyProto: ProtoBuf.Property, callableId: CallableId, nameResolver: NameResolver): FirExpression? {
|
||||
if (!Flags.HAS_CONSTANT.get(propertyProto.flags)) return null
|
||||
|
||||
constantCache[callableId]?.let { return it }
|
||||
|
||||
if (binaryClass == null) {
|
||||
if (facadeSource == null && partSource == null) {
|
||||
val value = propertyProto.getExtensionOrNull(BuiltInSerializerProtocol.compileTimeValue) ?: return null
|
||||
return buildFirConstant(value, null, value.type.name, nameResolver)?.apply { constantCache[callableId] = this }
|
||||
}
|
||||
|
||||
binaryClass.visitMembers(object : KotlinJvmBinaryClass.MemberVisitor {
|
||||
(facadeSource ?: partSource)!!.visitMembers(object : KotlinJvmBinaryClass.MemberVisitor {
|
||||
override fun visitMethod(name: Name, desc: String): KotlinJvmBinaryClass.MethodAnnotationVisitor? = null
|
||||
|
||||
override fun visitField(name: Name, desc: String, initializer: Any?): KotlinJvmBinaryClass.AnnotationVisitor? {
|
||||
@@ -57,11 +60,11 @@ class FirConstDeserializer(
|
||||
"CHAR", "C" -> buildConstExpression(null, FirConstKind.Char, ((protoValue?.intValue ?: sourceValue) as Number).toChar())
|
||||
"SHORT", "S" -> buildConstExpression(null, FirConstKind.Short, ((protoValue?.intValue ?: sourceValue) as Number).toShort())
|
||||
"INT", "I" -> buildConstExpression(null, FirConstKind.Int, protoValue?.intValue?.toInt() ?: sourceValue as Int)
|
||||
"LONG", "J" -> buildConstExpression(null, FirConstKind.Long, protoValue?.intValue ?: sourceValue as Long)
|
||||
"FLOAT", "F" -> buildConstExpression(null, FirConstKind.Float, protoValue?.floatValue ?: sourceValue as Float)
|
||||
"DOUBLE", "D" -> buildConstExpression(null, FirConstKind.Double, protoValue?.doubleValue ?: sourceValue as Double)
|
||||
"LONG", "J" -> buildConstExpression(null, FirConstKind.Long, (protoValue?.intValue ?: sourceValue) as Long)
|
||||
"FLOAT", "F" -> buildConstExpression(null, FirConstKind.Float, (protoValue?.floatValue ?: sourceValue) as Float)
|
||||
"DOUBLE", "D" -> buildConstExpression(null, FirConstKind.Double, (protoValue?.doubleValue ?: sourceValue) as Double)
|
||||
"BOOLEAN", "Z" -> buildConstExpression(null, FirConstKind.Boolean, (protoValue?.intValue?.toInt() ?: sourceValue) != 0)
|
||||
"STRING", "Ljava/lang/String;" -> buildConstExpression(
|
||||
"STRING", "Ljava/lang/String" -> buildConstExpression(
|
||||
null, FirConstKind.String, protoValue?.stringValue?.let { nameResolver.getString(it) } ?: sourceValue as String
|
||||
)
|
||||
else -> null
|
||||
|
||||
@@ -205,6 +205,9 @@ class FirElementSerializer private constructor(
|
||||
var hasGetter = false
|
||||
var hasSetter = false
|
||||
|
||||
//val compileTimeConstant = property.compileTimeInitializer
|
||||
val hasConstant = false // TODO: compileTimeConstant != null && compileTimeConstant !is NullValue
|
||||
|
||||
val hasAnnotations = property.nonSourceAnnotations(session).isNotEmpty()
|
||||
// TODO: hasAnnotations(descriptor) || hasAnnotations(descriptor.backingField) || hasAnnotations(descriptor.delegateField)
|
||||
|
||||
@@ -244,7 +247,6 @@ class FirElementSerializer private constructor(
|
||||
}
|
||||
}
|
||||
|
||||
val hasConstant = property.isConst // TODO: this is only correct with LanguageFeature.NoConstantValueAttributeForNonConstVals
|
||||
val flags = Flags.getPropertyFlags(
|
||||
hasAnnotations,
|
||||
ProtoEnumFlags.visibility(normalizeVisibility(property)),
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.fir.backend.jvm
|
||||
|
||||
import org.jetbrains.kotlin.backend.jvm.JvmBackendContext
|
||||
import org.jetbrains.kotlin.backend.jvm.JvmBackendExtension
|
||||
import org.jetbrains.kotlin.backend.jvm.codegen.MetadataSerializer
|
||||
import org.jetbrains.kotlin.codegen.serialization.JvmSerializationBindings
|
||||
import org.jetbrains.kotlin.config.JvmAbiStability
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.backend.Fir2IrComponents
|
||||
import org.jetbrains.kotlin.ir.declarations.IrClass
|
||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
|
||||
class FirJvmBackendExtension(private val session: FirSession, private val components: Fir2IrComponents) : JvmBackendExtension {
|
||||
override fun createSerializer(
|
||||
context: JvmBackendContext,
|
||||
klass: IrClass,
|
||||
type: Type,
|
||||
bindings: JvmSerializationBindings,
|
||||
parentSerializer: MetadataSerializer?
|
||||
): MetadataSerializer {
|
||||
return FirMetadataSerializer(session, context, klass, bindings, parentSerializer)
|
||||
}
|
||||
|
||||
override fun generateMetadataExtraFlags(abiStability: JvmAbiStability?): Int =
|
||||
JvmAnnotationNames.METADATA_JVM_IR_FLAG or
|
||||
JvmAnnotationNames.METADATA_FIR_FLAG or
|
||||
(if (abiStability == JvmAbiStability.STABLE) JvmAnnotationNames.METADATA_JVM_IR_STABLE_ABI_FLAG else 0)
|
||||
}
|
||||
@@ -338,8 +338,7 @@ internal fun IrDeclarationParent.declareThisReceiverParameter(
|
||||
symbolTable.irFactory.createValueParameter(
|
||||
startOffset, endOffset, thisOrigin, symbol,
|
||||
Name.special("<this>"), UNDEFINED_PARAMETER_INDEX, thisType,
|
||||
varargElementType = null, isCrossinline = false, isNoinline = false,
|
||||
isHidden = false, isAssignable = false
|
||||
varargElementType = null, isCrossinline = false, isNoinline = false, isAssignable = false
|
||||
).apply {
|
||||
this.parent = this@declareThisReceiverParameter
|
||||
receiverDescriptor.bind(this)
|
||||
|
||||
@@ -269,8 +269,7 @@ class Fir2IrDeclarationStorage(
|
||||
startOffset, endOffset, IrDeclarationOrigin.DEFINED, symbol,
|
||||
Name.special("<set-?>"), 0, type,
|
||||
varargElementType = null,
|
||||
isCrossinline = false, isNoinline = false,
|
||||
isHidden = false, isAssignable = false
|
||||
isCrossinline = false, isNoinline = false, isAssignable = false
|
||||
).apply {
|
||||
this.parent = parent
|
||||
descriptor.bind(this)
|
||||
@@ -900,8 +899,7 @@ class Fir2IrDeclarationStorage(
|
||||
valueParameter.name, index, type,
|
||||
if (!valueParameter.isVararg) null
|
||||
else valueParameter.returnTypeRef.coneType.arrayElementType()?.toIrType(typeContext),
|
||||
isCrossinline = valueParameter.isCrossinline, isNoinline = valueParameter.isNoinline,
|
||||
isHidden = false, isAssignable = false
|
||||
valueParameter.isCrossinline, valueParameter.isNoinline
|
||||
).apply {
|
||||
descriptor.bind(this)
|
||||
if (valueParameter.defaultValue.let {
|
||||
|
||||
@@ -266,7 +266,6 @@ internal class AdapterGenerator(
|
||||
varargElementType = null,
|
||||
isCrossinline = false,
|
||||
isNoinline = false,
|
||||
isHidden = false,
|
||||
isAssignable = false
|
||||
).also { irAdapterValueParameter ->
|
||||
descriptor.bind(irAdapterValueParameter)
|
||||
|
||||
@@ -7,14 +7,14 @@ package org.jetbrains.kotlin.fir.backend.generators
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget
|
||||
import org.jetbrains.kotlin.fir.FirAnnotationContainer
|
||||
import org.jetbrains.kotlin.fir.FirFakeSourceElementKind
|
||||
import org.jetbrains.kotlin.fir.backend.Fir2IrComponents
|
||||
import org.jetbrains.kotlin.fir.declarations.FirProperty
|
||||
import org.jetbrains.kotlin.fir.declarations.FirValueParameter
|
||||
import org.jetbrains.kotlin.fir.declarations.useSiteTargetsFromMetaAnnotation
|
||||
import org.jetbrains.kotlin.fir.declarations.hasMetaAnnotationUseSiteTargets
|
||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||
import org.jetbrains.kotlin.ir.util.isPropertyField
|
||||
import org.jetbrains.kotlin.ir.util.isSetter
|
||||
|
||||
/**
|
||||
@@ -36,73 +36,80 @@ class AnnotationGenerator(private val components: Fir2IrComponents) : Fir2IrComp
|
||||
irContainer.annotations = firContainer.annotations.toIrAnnotations()
|
||||
}
|
||||
|
||||
private fun FirAnnotationCall.target(applicable: List<AnnotationUseSiteTarget>): AnnotationUseSiteTarget? =
|
||||
useSiteTarget ?: applicable.firstOrNull(useSiteTargetsFromMetaAnnotation(session)::contains)
|
||||
|
||||
companion object {
|
||||
// Priority order: constructor parameter (if applicable) -> property -> field. So, for example, if `A`
|
||||
// can be attached to all three, then in a declaration like
|
||||
// class C(@A val x: Int) { @A val y = 1 }
|
||||
// the parameter `x` and the property `y` will have the annotation, while the property `x` and both backing fields will not.
|
||||
private val propertyTargets = listOf(AnnotationUseSiteTarget.PROPERTY, AnnotationUseSiteTarget.FIELD)
|
||||
private val constructorPropertyTargets = listOf(AnnotationUseSiteTarget.CONSTRUCTOR_PARAMETER) + propertyTargets
|
||||
private val delegatedPropertyTargets = propertyTargets + listOf(AnnotationUseSiteTarget.PROPERTY_DELEGATE_FIELD)
|
||||
}
|
||||
|
||||
// TODO: third argument should be whether this parameter is a property declaration (though this probably makes no difference)
|
||||
fun generate(irValueParameter: IrValueParameter, firValueParameter: FirValueParameter, isInConstructor: Boolean) {
|
||||
if (isInConstructor) {
|
||||
irValueParameter.annotations += firValueParameter.annotations
|
||||
.filter { it.target(constructorPropertyTargets) == AnnotationUseSiteTarget.CONSTRUCTOR_PARAMETER }
|
||||
irValueParameter.annotations +=
|
||||
firValueParameter.annotations
|
||||
.filter {
|
||||
// TODO: for `null` use-site, refer to targets on the meta annotation
|
||||
it.useSiteTarget == null || !isInConstructor || it.useSiteTarget == AnnotationUseSiteTarget.CONSTRUCTOR_PARAMETER
|
||||
}
|
||||
.toIrAnnotations()
|
||||
} else {
|
||||
irValueParameter.annotations += firValueParameter.annotations.toIrAnnotations()
|
||||
}
|
||||
}
|
||||
|
||||
private fun FirAnnotationCall.targetsField(): Boolean =
|
||||
// Check if the annotation has a field-targeting meta annotation, e.g., @Target(FIELD)
|
||||
hasMetaAnnotationUseSiteTargets(session, AnnotationUseSiteTarget.FIELD, AnnotationUseSiteTarget.PROPERTY_DELEGATE_FIELD)
|
||||
|
||||
fun generate(irProperty: IrProperty, property: FirProperty) {
|
||||
val applicableTargets = when {
|
||||
property.source?.kind == FirFakeSourceElementKind.PropertyFromParameter -> constructorPropertyTargets
|
||||
irProperty.isDelegated -> delegatedPropertyTargets
|
||||
else -> propertyTargets
|
||||
}
|
||||
irProperty.annotations += property.annotations
|
||||
.filter { it.target(applicableTargets) == AnnotationUseSiteTarget.PROPERTY }
|
||||
.toIrAnnotations()
|
||||
irProperty.annotations +=
|
||||
property.annotations
|
||||
.filter {
|
||||
it.useSiteTarget == AnnotationUseSiteTarget.PROPERTY ||
|
||||
// NB: annotation with null use-site should be landed on the property (ahead of field),
|
||||
// unless it has FIELD target on the meta annotation, like @Target(FIELD)
|
||||
(it.useSiteTarget == null && !it.targetsField())
|
||||
}
|
||||
.toIrAnnotations()
|
||||
}
|
||||
|
||||
fun generate(irField: IrField, property: FirProperty) {
|
||||
val irProperty = irField.correspondingPropertySymbol?.owner ?: throw AssertionError("$irField is not a property field")
|
||||
val applicableTargets = when {
|
||||
property.source?.kind == FirFakeSourceElementKind.PropertyFromParameter -> constructorPropertyTargets
|
||||
irProperty.isDelegated -> delegatedPropertyTargets
|
||||
else -> propertyTargets
|
||||
assert(irField.isPropertyField) {
|
||||
"$irField is not a property field."
|
||||
}
|
||||
irField.annotations += property.annotations.filter {
|
||||
val target = it.target(applicableTargets)
|
||||
target == AnnotationUseSiteTarget.FIELD || target == AnnotationUseSiteTarget.PROPERTY_DELEGATE_FIELD
|
||||
}.toIrAnnotations()
|
||||
irField.annotations +=
|
||||
property.annotations
|
||||
.filter {
|
||||
it.useSiteTarget == AnnotationUseSiteTarget.FIELD ||
|
||||
it.useSiteTarget == AnnotationUseSiteTarget.PROPERTY_DELEGATE_FIELD ||
|
||||
(it.useSiteTarget == null && it.targetsField())
|
||||
}
|
||||
.toIrAnnotations()
|
||||
}
|
||||
|
||||
fun generate(propertyAccessor: IrFunction, property: FirProperty) {
|
||||
assert(propertyAccessor.isPropertyAccessor) { "$propertyAccessor is not a property accessor." }
|
||||
assert(propertyAccessor.isPropertyAccessor) {
|
||||
"$propertyAccessor is not a property accessor."
|
||||
}
|
||||
if (propertyAccessor.isSetter) {
|
||||
propertyAccessor.annotations += property.annotations
|
||||
.filter { it.useSiteTarget == AnnotationUseSiteTarget.PROPERTY_SETTER }
|
||||
.toIrAnnotations()
|
||||
val parameter = propertyAccessor.valueParameters.single()
|
||||
parameter.annotations += property.annotations
|
||||
.filter { it.useSiteTarget == AnnotationUseSiteTarget.SETTER_PARAMETER }
|
||||
.toIrAnnotations()
|
||||
propertyAccessor.annotations +=
|
||||
property.annotations
|
||||
.filter {
|
||||
it.useSiteTarget == AnnotationUseSiteTarget.PROPERTY_SETTER
|
||||
}
|
||||
.toIrAnnotations()
|
||||
propertyAccessor.valueParameters.singleOrNull()?.annotations =
|
||||
propertyAccessor.valueParameters.singleOrNull()?.annotations?.plus(
|
||||
property.annotations
|
||||
.filter {
|
||||
it.useSiteTarget == AnnotationUseSiteTarget.SETTER_PARAMETER
|
||||
}
|
||||
.toIrAnnotations()
|
||||
)!!
|
||||
} else {
|
||||
propertyAccessor.annotations += property.annotations
|
||||
.filter { it.useSiteTarget == AnnotationUseSiteTarget.PROPERTY_GETTER }
|
||||
.toIrAnnotations()
|
||||
}
|
||||
propertyAccessor.extensionReceiverParameter?.let { receiver ->
|
||||
receiver.annotations += property.annotations
|
||||
.filter { it.useSiteTarget == AnnotationUseSiteTarget.RECEIVER }
|
||||
.toIrAnnotations()
|
||||
propertyAccessor.annotations +=
|
||||
property.annotations
|
||||
.filter {
|
||||
it.useSiteTarget == AnnotationUseSiteTarget.PROPERTY_GETTER
|
||||
}
|
||||
.toIrAnnotations()
|
||||
}
|
||||
propertyAccessor.extensionReceiverParameter?.annotations =
|
||||
propertyAccessor.extensionReceiverParameter?.annotations?.plus(
|
||||
property.annotations
|
||||
.filter {
|
||||
it.useSiteTarget == AnnotationUseSiteTarget.RECEIVER
|
||||
}
|
||||
.toIrAnnotations()
|
||||
)!!
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ import org.jetbrains.kotlin.fir.references.FirDelegateFieldReference
|
||||
import org.jetbrains.kotlin.fir.references.FirReference
|
||||
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
||||
import org.jetbrains.kotlin.fir.references.FirSuperReference
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirReferencePlaceholderForResolvedAnnotations
|
||||
import org.jetbrains.kotlin.fir.render
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.getExpectedTypeForSAMConversion
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.isFunctional
|
||||
@@ -446,14 +445,8 @@ class CallAndReferenceGenerator(
|
||||
is FirDelegatedConstructorCall -> call.calleeReference
|
||||
is FirAnnotationCall -> call.calleeReference
|
||||
else -> null
|
||||
}
|
||||
val function = if (calleeReference == FirReferencePlaceholderForResolvedAnnotations) {
|
||||
val coneClassLikeType = (call as FirAnnotationCall).annotationTypeRef.coneTypeSafe<ConeClassLikeType>()
|
||||
val firClass = (coneClassLikeType?.lookupTag?.toSymbol(session) as? FirRegularClassSymbol)?.fir
|
||||
firClass?.declarations?.filterIsInstance<FirConstructor>()?.firstOrNull()
|
||||
} else {
|
||||
((calleeReference as? FirResolvedNamedReference)?.resolvedSymbol as? FirFunctionSymbol<*>)?.fir
|
||||
}
|
||||
} as? FirResolvedNamedReference
|
||||
val function = (calleeReference?.resolvedSymbol as? FirFunctionSymbol<*>)?.fir
|
||||
val valueParameters = function?.valueParameters
|
||||
val argumentMapping = call.argumentMapping
|
||||
if (argumentMapping != null && (annotationMode || argumentMapping.isNotEmpty())) {
|
||||
@@ -566,13 +559,11 @@ class CallAndReferenceGenerator(
|
||||
}
|
||||
}
|
||||
with(adapterGenerator) {
|
||||
if (parameter?.returnTypeRef is FirResolvedTypeRef) {
|
||||
// Java type case (from annotations)
|
||||
irArgument = irArgument.applySuspendConversionIfNeeded(argument, parameter)
|
||||
irArgument = irArgument.applySamConversionIfNeeded(argument, parameter)
|
||||
}
|
||||
irArgument = irArgument.applySuspendConversionIfNeeded(argument, parameter)
|
||||
}
|
||||
return irArgument.applyAssigningArrayElementsToVarargInNamedForm(argument, parameter)
|
||||
return irArgument
|
||||
.applySamConversionIfNeeded(argument, parameter)
|
||||
.applyAssigningArrayElementsToVarargInNamedForm(argument, parameter)
|
||||
}
|
||||
|
||||
private fun IrExpression.applySamConversionIfNeeded(
|
||||
|
||||
@@ -17,6 +17,8 @@ import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl
|
||||
import org.jetbrains.kotlin.fir.scopes.unsubstitutedScope
|
||||
import org.jetbrains.kotlin.fir.symbols.CallableId
|
||||
import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagImpl
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol
|
||||
import org.jetbrains.kotlin.fir.types.ConeStarProjection
|
||||
@@ -35,6 +37,7 @@ import org.jetbrains.kotlin.ir.expressions.IrMemberAccessExpression
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.ir.util.*
|
||||
import org.jetbrains.kotlin.ir.util.DataClassMembersGenerator
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
/**
|
||||
@@ -81,11 +84,11 @@ class DataClassMembersGenerator(val components: Fir2IrComponents) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
override fun getProperty(parameter: ValueParameterDescriptor?, irValueParameter: IrValueParameter?): IrProperty? =
|
||||
override fun getBackingField(parameter: ValueParameterDescriptor?, irValueParameter: IrValueParameter?): IrField? =
|
||||
irValueParameter?.let {
|
||||
irClass.properties.single { irProperty ->
|
||||
irProperty.name == irValueParameter.name && irProperty.backingField?.type == irValueParameter.type
|
||||
}
|
||||
}.backingField
|
||||
}
|
||||
|
||||
override fun transform(typeParameterDescriptor: TypeParameterDescriptor): IrType {
|
||||
@@ -213,8 +216,8 @@ class DataClassMembersGenerator(val components: Fir2IrComponents) {
|
||||
fun generateComponentBody(irFunction: IrFunction) {
|
||||
val index = getComponentIndex(irFunction)!!
|
||||
val valueParameter = irClass.primaryConstructor!!.valueParameters[index - 1]
|
||||
val irProperty = irDataClassMembersGenerator.getProperty(null, valueParameter)!!
|
||||
irDataClassMembersGenerator.generateComponentFunction(irFunction, irProperty)
|
||||
val backingField = irDataClassMembersGenerator.getBackingField(null, valueParameter)!!
|
||||
irDataClassMembersGenerator.generateComponentFunction(irFunction, backingField)
|
||||
}
|
||||
|
||||
fun generateCopyBody(irFunction: IrFunction) =
|
||||
@@ -292,7 +295,7 @@ class DataClassMembersGenerator(val components: Fir2IrComponents) {
|
||||
) { symbol ->
|
||||
components.irFactory.createValueParameter(
|
||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET, origin, symbol, name, index, type, null,
|
||||
isCrossinline = false, isNoinline = false, isHidden = false, isAssignable = false
|
||||
isCrossinline = false, isNoinline = false, isAssignable = false
|
||||
)
|
||||
}.apply {
|
||||
parent = irFunction
|
||||
|
||||
@@ -232,14 +232,13 @@ class FakeOverrideGenerator(
|
||||
|
||||
private fun IrProperty.discardAccessorsAccordingToBaseVisibility(baseSymbols: List<FirPropertySymbol>) {
|
||||
for (baseSymbol in baseSymbols) {
|
||||
val unwrappedSymbol = baseSymbol.unwrapFakeOverrides()
|
||||
val unwrappedProperty = unwrappedSymbol.fir
|
||||
val unwrapped = baseSymbol.unwrapFakeOverrides()
|
||||
// Do not create fake overrides for accessors if not allowed to do so, e.g., private lateinit var.
|
||||
if (!(unwrappedProperty.getter?.allowsToHaveFakeOverride ?: unwrappedProperty.allowsToHaveFakeOverride)) {
|
||||
if (unwrapped.fir.getter?.allowsToHaveFakeOverride != true) {
|
||||
getter = null
|
||||
}
|
||||
// or private setter
|
||||
if (!(unwrappedProperty.setter?.allowsToHaveFakeOverride ?: unwrappedProperty.allowsToHaveFakeOverride)) {
|
||||
if (unwrapped.fir.setter?.allowsToHaveFakeOverride != true) {
|
||||
setter = null
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user