mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-02 00:21:28 +00:00
Compare commits
6 Commits
abannykh/s
...
rr/lunakol
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c49950a6da | ||
|
|
24472e5082 | ||
|
|
095918f4e9 | ||
|
|
b5287ffb80 | ||
|
|
b78c0d94bb | ||
|
|
08f6a800b8 |
5
.bunch
5
.bunch
@@ -2,6 +2,7 @@
|
||||
202
|
||||
203_202
|
||||
193
|
||||
192_193
|
||||
as36_192_193
|
||||
as40_193
|
||||
as41
|
||||
as42_as41
|
||||
as41
|
||||
358
ChangeLog.md
358
ChangeLog.md
@@ -1,363 +1,5 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 1.4.10
|
||||
|
||||
### Compiler
|
||||
|
||||
#### Performance Improvements
|
||||
|
||||
- [`KT-41149`](https://youtrack.jetbrains.com/issue/KT-41149) NI: Upgraded project from 1.3.72 to 1.4.0 hangs during build
|
||||
- [`KT-41335`](https://youtrack.jetbrains.com/issue/KT-41335) Kotlin Out of Memory When evaluating expression
|
||||
- [`KT-41400`](https://youtrack.jetbrains.com/issue/KT-41400) NI: Huge performance regression for kotlin compiler from 1.3.72 to 1.4.0 due to using list of dozen lambdas in a call
|
||||
|
||||
#### Fixes
|
||||
|
||||
- [`KT-41005`](https://youtrack.jetbrains.com/issue/KT-41005) Coercion to Unit doesn't take into account nullability of a return type for lambda
|
||||
- [`KT-41043`](https://youtrack.jetbrains.com/issue/KT-41043) NI: StackOverflowError through `PostponedArgumentInputTypesResolver.getAllDeeplyRelatedTypeVariables`
|
||||
- [`KT-41135`](https://youtrack.jetbrains.com/issue/KT-41135) Type Inference Regression For Property Delegate With Receiver Type
|
||||
- [`KT-41140`](https://youtrack.jetbrains.com/issue/KT-41140) Unresolved reference to parameter of a catch block from lambda expression on 1.4.0
|
||||
- [`KT-41150`](https://youtrack.jetbrains.com/issue/KT-41150) IllegalStateException: Couldn't obtain compiled function body for public final inline fun
|
||||
- [`KT-41164`](https://youtrack.jetbrains.com/issue/KT-41164) NI: "IllegalStateException: Error type encountered" with callbackFlow builder inside condition
|
||||
- [`KT-41202`](https://youtrack.jetbrains.com/issue/KT-41202) Type inference fails in 1.4.0
|
||||
- [`KT-41218`](https://youtrack.jetbrains.com/issue/KT-41218) HMPP: arrayList declarations are visible both from stdlib-common and stdlib-jvm and lead to false-positive resolution ambiguity in IDE
|
||||
- [`KT-41308`](https://youtrack.jetbrains.com/issue/KT-41308) 1.4.0 Type inference regression in suspend blocks with elvis operator expressions
|
||||
- [`KT-41357`](https://youtrack.jetbrains.com/issue/KT-41357) ClassCastException for unstable smart cast on a property call receiver
|
||||
- [`KT-41386`](https://youtrack.jetbrains.com/issue/KT-41386) NI: Type mismatch with generic type parameters
|
||||
- [`KT-41426`](https://youtrack.jetbrains.com/issue/KT-41426) Operator compareTo is not called with nullable type
|
||||
- [`KT-41430`](https://youtrack.jetbrains.com/issue/KT-41430) Broken choosing overload by lambda return type inside builder inference
|
||||
- [`KT-41470`](https://youtrack.jetbrains.com/issue/KT-41470) Wrong nullability assertion is generated when using the BuilderInference annotation
|
||||
- [`KT-41482`](https://youtrack.jetbrains.com/issue/KT-41482) Add a fallback compiler flag to disable the unified null checks behavior
|
||||
|
||||
### IDE
|
||||
|
||||
- [`KT-41325`](https://youtrack.jetbrains.com/issue/KT-41325) SOE in IDEKotlinAsJavaSupport
|
||||
- [`KT-41390`](https://youtrack.jetbrains.com/issue/KT-41390) Typo: equals & hashCode are written with the first uppercase letter
|
||||
|
||||
### IDE. Code Style, Formatting
|
||||
|
||||
- [`KT-41314`](https://youtrack.jetbrains.com/issue/KT-41314) Formatter: Frequent freezes when reformatting code (TrailingCommaPostFormatProcessor)
|
||||
|
||||
### IDE. Debugger
|
||||
|
||||
- [`KT-40417`](https://youtrack.jetbrains.com/issue/KT-40417) Coroutines Debugger: “No coroutine information found” in case of main() entry-point without explicit debug-artifact
|
||||
|
||||
### IDE. Gradle. Script
|
||||
|
||||
- [`KT-39542`](https://youtrack.jetbrains.com/issue/KT-39542) EA-218043: java.util.NoSuchElementException: No element of given type found (GradleBuildRootsManager)
|
||||
- [`KT-41283`](https://youtrack.jetbrains.com/issue/KT-41283) Gradle scripts unable to support 1.4 language level features yet
|
||||
|
||||
### IDE. Inspections and Intentions
|
||||
|
||||
- [`KT-41264`](https://youtrack.jetbrains.com/issue/KT-41264) Disable “Redundant inner modifier” in 1.4.10
|
||||
- [`KT-41395`](https://youtrack.jetbrains.com/issue/KT-41395) Inspection description misses a space (needs to be lowercase)
|
||||
|
||||
### IDE. REPL
|
||||
|
||||
- [`KT-40898`](https://youtrack.jetbrains.com/issue/KT-40898) REPL: "IllegalAccessError: tried to access field" caused by log4j
|
||||
|
||||
### IDE. Wizards
|
||||
|
||||
- [`KT-38921`](https://youtrack.jetbrains.com/issue/KT-38921) New project wizard: Backend/Console applications template with Groovy DSL generates build.gradle with KotlinCompile instead of compileKotlin
|
||||
|
||||
### JavaScript
|
||||
|
||||
- [`KT-38059`](https://youtrack.jetbrains.com/issue/KT-38059) Support arrays passed as named arguments to varargs
|
||||
- [`KT-40964`](https://youtrack.jetbrains.com/issue/KT-40964) KJS / IR: don't generate "import" (short names) for external interfaces
|
||||
- [`KT-41081`](https://youtrack.jetbrains.com/issue/KT-41081) KJS IR: nativeGetter, nativeSetter, nativeInvoke are not supported
|
||||
|
||||
### Libraries
|
||||
|
||||
- [`KT-41320`](https://youtrack.jetbrains.com/issue/KT-41320) Actual kotlin.test annotation typealiases are inaccessible in modular environment
|
||||
|
||||
### Middle-end. IR
|
||||
|
||||
- [`KT-41324`](https://youtrack.jetbrains.com/issue/KT-41324) IR: "Compilation failed: null" caused by StackOverflowError in compiler in multi-module project
|
||||
|
||||
### Native. C and ObjC Import
|
||||
|
||||
- [`KT-39762`](https://youtrack.jetbrains.com/issue/KT-39762) cinterop on 1.4-M2 doesn't include @Deprecated Kotlin declaration for C declaration it fails to import
|
||||
|
||||
### Native. ObjC Export
|
||||
|
||||
- [`KT-39206`](https://youtrack.jetbrains.com/issue/KT-39206) New line characters in @Deprecated annotation cause syntax error in Kotlin/native exported header
|
||||
- [`KT-40976`](https://youtrack.jetbrains.com/issue/KT-40976) "Unrecognized selector sent to instance" exception invoking suspending lambda from Swift in Native iOS project
|
||||
|
||||
### Reflection
|
||||
|
||||
- [`KT-40842`](https://youtrack.jetbrains.com/issue/KT-40842) "AssertionError: Built-in class kotlin.Any is not found" on java modular run
|
||||
|
||||
### Tools. Compiler Plugins
|
||||
|
||||
- [`KT-41321`](https://youtrack.jetbrains.com/issue/KT-41321) Upgrading to 1.4.0 fails compiling native with <x> is not bound error
|
||||
|
||||
### Tools. Gradle. Multiplatform
|
||||
|
||||
- [`KT-41083`](https://youtrack.jetbrains.com/issue/KT-41083) Transitive dependency on an MPP with host-specific source sets fails to resolve: "Couldn't resolve metadata artifact..."
|
||||
|
||||
### Tools. Gradle. Native
|
||||
|
||||
- [`KT-40834`](https://youtrack.jetbrains.com/issue/KT-40834) Cannot build Kotlin Multiplatform project on Windows 10 64-bit when the Cocoapods plugin is applied
|
||||
|
||||
### Tools. Scripts
|
||||
|
||||
- [`KT-35925`](https://youtrack.jetbrains.com/issue/KT-35925) REPL: Springboot autoconfiguration problem (META-INF/spring.factories not found ?)
|
||||
|
||||
### Tools. kapt
|
||||
|
||||
- [`KT-41313`](https://youtrack.jetbrains.com/issue/KT-41313) kapt 1.4.0 throws "ZipException: zip END header not found", when Graal SVM jar in classpath
|
||||
|
||||
|
||||
## 1.4.0
|
||||
|
||||
### Compiler
|
||||
|
||||
#### New Features
|
||||
|
||||
- [`KT-23729`](https://youtrack.jetbrains.com/issue/KT-23729) Provide a way to generate JVM default method bodies in interfaces delegating to DefaultImpls
|
||||
- [`KT-30330`](https://youtrack.jetbrains.com/issue/KT-30330) Introduce KotlinNothingValueException and throw it instead of NPE on expressions of type Nothing
|
||||
- [`KT-38435`](https://youtrack.jetbrains.com/issue/KT-38435) Support suspend conversion on callable references in JVM backend
|
||||
|
||||
#### Fixes
|
||||
|
||||
- [`KT-35483`](https://youtrack.jetbrains.com/issue/KT-35483) NI: compatibility mode
|
||||
- [`KT-39728`](https://youtrack.jetbrains.com/issue/KT-39728) Declarations from `kotlin.reflect` resolved to expect-classes even in JVM modules in IDE
|
||||
- [`KT-40153`](https://youtrack.jetbrains.com/issue/KT-40153) REPL IDE services completion fails on imports completion
|
||||
- [`KT-40404`](https://youtrack.jetbrains.com/issue/KT-40404) Mixed named/positional arguments: argument can be passed twice
|
||||
- [`KT-40544`](https://youtrack.jetbrains.com/issue/KT-40544) NI: "TYPE_MISMATCH: Required: MutableList<out T!> Found: List<T>" caused by Java interface function
|
||||
- [`KT-40555`](https://youtrack.jetbrains.com/issue/KT-40555) NI: Spread operator allows inferred nullable types
|
||||
- [`KT-40646`](https://youtrack.jetbrains.com/issue/KT-40646) NI: TYPE_MISMATCH: "inferred type is Unit but Observer<T> was expected" caused by LieData.observe inference
|
||||
- [`KT-40691`](https://youtrack.jetbrains.com/issue/KT-40691) False positive CAPTURED_VAL_INITIALIZATION with EXACTLY_ONCE contract
|
||||
- [`KT-40693`](https://youtrack.jetbrains.com/issue/KT-40693) UnsupportedOperationException: no descriptor for type constructor of (CapturedType(out TResult)..CapturedType(out TResult)?)
|
||||
- [`KT-40824`](https://youtrack.jetbrains.com/issue/KT-40824) Usages of a typealias lose nullability and annotations in deserialization
|
||||
- [`KT-40843`](https://youtrack.jetbrains.com/issue/KT-40843) Unhandled exception for suspending methods that return Result type
|
||||
- [`KT-40869`](https://youtrack.jetbrains.com/issue/KT-40869) Recursion computation inside compiler resolve on a correct code
|
||||
- [`KT-40893`](https://youtrack.jetbrains.com/issue/KT-40893) Error "Captured values initialization is forbidden due to possible reassignment" when attempting to use the plusAssign operator with a java list inside an inline function
|
||||
- [`KT-40919`](https://youtrack.jetbrains.com/issue/KT-40919) kotlin.collections.ArrayDeque requires an explicit import when compiling with kotlinc 1.4-RC and -language-version 1.3
|
||||
- [`KT-40920`](https://youtrack.jetbrains.com/issue/KT-40920) Regression in JvmDefault: incorrect access to missing DefaultImpls on default methods in Java interface overriding Kotlin interface
|
||||
- [`KT-40978`](https://youtrack.jetbrains.com/issue/KT-40978) Prohibit using suspend functions as SAM in fun interfaces
|
||||
|
||||
### Docs & Examples
|
||||
|
||||
- [`KT-35218`](https://youtrack.jetbrains.com/issue/KT-35218) Fix misleading in JavaDoc for `createTempDir`/`createTempFile`
|
||||
- [`KT-36981`](https://youtrack.jetbrains.com/issue/KT-36981) Provide a visual illustration of source sets structure generated by `ios()`, `watchos()`, `tvos()` presets
|
||||
- [`KT-38050`](https://youtrack.jetbrains.com/issue/KT-38050) Language Guide: MPP reference: add sample of language settings for all roots instead of common root only
|
||||
|
||||
### IDE
|
||||
|
||||
- [`KT-30265`](https://youtrack.jetbrains.com/issue/KT-30265) IDE, MPP: False negative TYPE_PARAMETER_AS_REIFIED in common code
|
||||
- [`KT-40494`](https://youtrack.jetbrains.com/issue/KT-40494) UAST: "NoSuchElementException: No element of given type found" with use-site target annotation
|
||||
- [`KT-40639`](https://youtrack.jetbrains.com/issue/KT-40639) Shift IDE plugins updater numbers for Kotlin plugin
|
||||
|
||||
### IDE. Code Style, Formatting
|
||||
|
||||
- [`KT-40636`](https://youtrack.jetbrains.com/issue/KT-40636) Hard freeze on formatter: infinite recursion
|
||||
|
||||
### IDE. Gradle Integration
|
||||
|
||||
- [`KT-30116`](https://youtrack.jetbrains.com/issue/KT-30116) IDE: Unresolved reference in MPP module (androidMain source set) for annotation from common module (defined in commonMain and with JVM target)
|
||||
|
||||
### IDE. Gradle. Script
|
||||
|
||||
- [`KT-34552`](https://youtrack.jetbrains.com/issue/KT-34552) Deadlock in ScriptDefinitionsManager
|
||||
- [`KT-40675`](https://youtrack.jetbrains.com/issue/KT-40675) Gradle build file is not highlighted until navigating to symbol
|
||||
|
||||
### IDE. JS
|
||||
|
||||
- [`KT-40461`](https://youtrack.jetbrains.com/issue/KT-40461) Create new projects with kotlin.js.generate.executable.default=false
|
||||
|
||||
### IDE. Script
|
||||
|
||||
- [`KT-39547`](https://youtrack.jetbrains.com/issue/KT-39547) Kotlin script support freezes IDEA
|
||||
- [`KT-40242`](https://youtrack.jetbrains.com/issue/KT-40242) gradle.kts: Deadlock in ScriptClassRootsUpdater
|
||||
|
||||
### IDE. Wizards
|
||||
|
||||
- [`KT-36153`](https://youtrack.jetbrains.com/issue/KT-36153) New Project Wizard: provide more referential info on project structure editor screen
|
||||
- [`KT-39904`](https://youtrack.jetbrains.com/issue/KT-39904) New Project wizard 1.4: update Frontend Application to make it run with JS IR
|
||||
- [`KT-40149`](https://youtrack.jetbrains.com/issue/KT-40149) Gradle project wizard: templates for Kotlin/JS are not properly formatted
|
||||
|
||||
### JavaScript
|
||||
|
||||
- [`KT-25859`](https://youtrack.jetbrains.com/issue/KT-25859) JS: support function references to functions with vararg if expected type ends with repeated vararg element type
|
||||
- [`KT-40083`](https://youtrack.jetbrains.com/issue/KT-40083) K/JS-IR: java.lang.IllegalStateException: has not acquired a symbol yet
|
||||
- [`KT-40892`](https://youtrack.jetbrains.com/issue/KT-40892) KJS, IR: Unresolved references on importing classes from kotlinx-nodejs
|
||||
|
||||
### Libraries
|
||||
|
||||
- [`KT-39051`](https://youtrack.jetbrains.com/issue/KT-39051) Libraries native artifacts are published without sources
|
||||
|
||||
### Tools. Gradle
|
||||
|
||||
- [`KT-27816`](https://youtrack.jetbrains.com/issue/KT-27816) Provide a possibility to specify intermediate source sets between platform-agnostic and platform-specific test source sets
|
||||
- [`KT-37720`](https://youtrack.jetbrains.com/issue/KT-37720) Replace ArtifactTransform with TransformAction
|
||||
- [`KT-40559`](https://youtrack.jetbrains.com/issue/KT-40559) Adding the stdlib by default triggers warning in the Android Gradle Plugin
|
||||
|
||||
### Tools. Gradle. JS
|
||||
|
||||
- [`KT-40093`](https://youtrack.jetbrains.com/issue/KT-40093) Incorrect updating version of Kotlin/JS dependencies in package.json
|
||||
|
||||
### Tools. Gradle. Multiplatform
|
||||
|
||||
- [`KT-27320`](https://youtrack.jetbrains.com/issue/KT-27320) Provide a way to reuse same sources for similar Native target
|
||||
- [`KT-40058`](https://youtrack.jetbrains.com/issue/KT-40058) NPE from mpp gradle plugin on kotlinx.benchmarks
|
||||
|
||||
### Tools. Gradle. Native
|
||||
|
||||
- [`KT-40801`](https://youtrack.jetbrains.com/issue/KT-40801) Gradle CocoaPods integration: Cannot change a framework name
|
||||
|
||||
|
||||
## 1.4-RC
|
||||
|
||||
### Backend. Native
|
||||
|
||||
- [`KT-40209`](https://youtrack.jetbrains.com/issue/KT-40209) java.lang.UnsupportedOperationException: org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl@76484173
|
||||
- [`KT-40367`](https://youtrack.jetbrains.com/issue/KT-40367) Kotlin/Native-Swift interop (iOS): Array member initialization failing in release builds
|
||||
|
||||
### Compiler
|
||||
|
||||
#### Fixes
|
||||
|
||||
- [`KT-31025`](https://youtrack.jetbrains.com/issue/KT-31025) Type mismatch when callable reference is resolved with a functional expected type and SAM conversion
|
||||
- [`KT-37388`](https://youtrack.jetbrains.com/issue/KT-37388) Consider relaxing rules about inferring Nothing inside special constructions (if, try, when)
|
||||
- [`KT-37717`](https://youtrack.jetbrains.com/issue/KT-37717) NI: "IllegalStateException: Error type encountered" with @BuilderInference
|
||||
- [`KT-38427`](https://youtrack.jetbrains.com/issue/KT-38427) New inference in branched conditions (if, when) results in odd behavior with inconsistent compiler warnings and runtime errors
|
||||
- [`KT-38899`](https://youtrack.jetbrains.com/issue/KT-38899) NI: False positive IMPLICIT_NOTHING_TYPE_ARGUMENT_IN_RETURN_POSITION leads to NPE
|
||||
- [`KT-39468`](https://youtrack.jetbrains.com/issue/KT-39468) NI: overload resolution ambiguity between functions passing `T` and `Foo<T>` with a contravariant receiver
|
||||
- [`KT-39618`](https://youtrack.jetbrains.com/issue/KT-39618) NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER: unable to infer generic type on @BuilderInference annotated lambda parameter with receiver type
|
||||
- [`KT-39633`](https://youtrack.jetbrains.com/issue/KT-39633) NI: Incorrect type parameter instantiation based on contravariant type argument
|
||||
- [`KT-39691`](https://youtrack.jetbrains.com/issue/KT-39691) NI: Missing SAM conversion for nullable lambda
|
||||
- [`KT-39860`](https://youtrack.jetbrains.com/issue/KT-39860) Make Kotlin binaries publicly available (set KotlinCompilerVersion.IS_PRE_RELEASE = false)
|
||||
- [`KT-39900`](https://youtrack.jetbrains.com/issue/KT-39900) NI: Incorrect type inference in a lambda returning Unit
|
||||
- [`KT-39925`](https://youtrack.jetbrains.com/issue/KT-39925) New JVM default compilation mode doesn't check that JVM target is 1.8
|
||||
- [`KT-39943`](https://youtrack.jetbrains.com/issue/KT-39943) Write information about all-compatibility mode in metadata
|
||||
- [`KT-39953`](https://youtrack.jetbrains.com/issue/KT-39953) NI: ClassCastException "cannot be cast to java.lang.Void" with if-else in return statement in ANdroid project
|
||||
- [`KT-40045`](https://youtrack.jetbrains.com/issue/KT-40045) NI: lambda’s receiver type isn't inferred properly
|
||||
- [`KT-40057`](https://youtrack.jetbrains.com/issue/KT-40057) NI: provideDelegate org.jetbrains.kotlin.codegen.CompilationException: Back-end (JVM) Internal error: wrong bytecode generated for static initializer
|
||||
- [`KT-40060`](https://youtrack.jetbrains.com/issue/KT-40060) NI: postponed variable from the builder inference flows to back-end and leads to throw an exception
|
||||
- [`KT-40112`](https://youtrack.jetbrains.com/issue/KT-40112) Kotlin Gradle DSL: COMPATIBILITY_WARNING on `kotlin.sourceSets` block
|
||||
- [`KT-40113`](https://youtrack.jetbrains.com/issue/KT-40113) Kotlin Gradle DSL: "Expression 'main' cannot be invoked as a function" for `distributions.main` DSL block
|
||||
- [`KT-40128`](https://youtrack.jetbrains.com/issue/KT-40128) Introduce compiler key to disable compatibility resolution mechanism for new inference features
|
||||
- [`KT-40151`](https://youtrack.jetbrains.com/issue/KT-40151) NI: postponed variable isn't substituted for top-level CR inside builder inference
|
||||
- [`KT-40214`](https://youtrack.jetbrains.com/issue/KT-40214) AbstractMethodError in gradle subplugin which is used in Android app
|
||||
- [`KT-40234`](https://youtrack.jetbrains.com/issue/KT-40234) Deprecation level "hidden" has no effect on callable reference argument
|
||||
- [`KT-40247`](https://youtrack.jetbrains.com/issue/KT-40247) NI: false positive "function should be called from coroutine or another suspend function" for suspend invoke operator in try-catch
|
||||
- [`KT-40254`](https://youtrack.jetbrains.com/issue/KT-40254) Rewrite at slice with two callable reference arguments
|
||||
- [`KT-40269`](https://youtrack.jetbrains.com/issue/KT-40269) NI: "disabled Unit conversions" error has appeared on green code
|
||||
- [`KT-40337`](https://youtrack.jetbrains.com/issue/KT-40337) NI: false positive "function should be called from coroutine or another suspend function" for suspend invoke operator in `when` block
|
||||
- [`KT-40406`](https://youtrack.jetbrains.com/issue/KT-40406) Prohibit reflection on adapted callable references
|
||||
|
||||
### IDE
|
||||
|
||||
- [`KT-39968`](https://youtrack.jetbrains.com/issue/KT-39968) Paths in KotlinJavaRuntime library aren't updated after you run IDE from a different directory
|
||||
- [`KT-39989`](https://youtrack.jetbrains.com/issue/KT-39989) NullPointerException when opening Kotlin facets in Project Structure dialog in IDEA 192
|
||||
- [`KT-40311`](https://youtrack.jetbrains.com/issue/KT-40311) Create change_notes for 1.4 in IDE plugin description
|
||||
|
||||
### IDE. Debugger
|
||||
|
||||
- [`KT-39808`](https://youtrack.jetbrains.com/issue/KT-39808) (CoroutineDebugger) Doesn't start with kotlinx-coroutines-core >= 1.3.6
|
||||
- [`KT-40073`](https://youtrack.jetbrains.com/issue/KT-40073) (CoroutineDebugger) Change minimum supported kotlinx.coroutines version to 1.3.8*
|
||||
- [`KT-40172`](https://youtrack.jetbrains.com/issue/KT-40172) Restored frame variables isn't shown for suspended coroutines
|
||||
- [`KT-40635`](https://youtrack.jetbrains.com/issue/KT-40635) Coroutines Debugger: make IDE plugin accept coroutines 1.3.8-rc* versions as well
|
||||
|
||||
### IDE. Gradle Integration
|
||||
|
||||
- [`KT-38744`](https://youtrack.jetbrains.com/issue/KT-38744) No dependency between Android `test` and commonTest source sets with kotlin.mpp.enableGranularSourceSetsMetadata=true
|
||||
- [`KT-39037`](https://youtrack.jetbrains.com/issue/KT-39037) 'None of the consumable configurations have attributes' in MPP IDE import with transitive project dependency on self
|
||||
|
||||
### IDE. Gradle. Script
|
||||
|
||||
- [`KT-31137`](https://youtrack.jetbrains.com/issue/KT-31137) IntelliJ would get very slow when editing gradle buildSrc(using the kotlin dsl)
|
||||
- [`KT-36078`](https://youtrack.jetbrains.com/issue/KT-36078) Gradle Kotlin script context is not reloaded when gradle/wrapper/gradle-wrapper.properties file is changed
|
||||
- [`KT-39317`](https://youtrack.jetbrains.com/issue/KT-39317) ISE “Calling invokeAndWait from read-action leads to possible deadlock.” on importing simple Gradle-based project in nightly IJ
|
||||
|
||||
### IDE. Inspections and Intentions
|
||||
|
||||
- [`KT-28662`](https://youtrack.jetbrains.com/issue/KT-28662) Inspection to flag usage of the wrong Transient annotation on Kotlin Serializable class
|
||||
- [`KT-34209`](https://youtrack.jetbrains.com/issue/KT-34209) Switch default behaviour in 1.4 for insertion (to build script) via quick fix of the compiler option enabling inline classes
|
||||
- [`KT-36131`](https://youtrack.jetbrains.com/issue/KT-36131) Suggest to add a missing module dependency on an unresolved reference in Kotlin code
|
||||
- [`KT-37462`](https://youtrack.jetbrains.com/issue/KT-37462) Add "Add dependency to module" quickfix in multimodule Maven project
|
||||
- [`KT-39869`](https://youtrack.jetbrains.com/issue/KT-39869) Add whole project migration usages of kotlin.browser.* & kotlin.dom.* to kotlinx.browser.* & kotlinx.dom.* respectively
|
||||
|
||||
### IDE. Wizards
|
||||
|
||||
- [`KT-40004`](https://youtrack.jetbrains.com/issue/KT-40004) New Project wizard 1.4+: no `https://dl.bintray.com/kotlin/kotlinx` repository is added for kotlinx-html
|
||||
- [`KT-40037`](https://youtrack.jetbrains.com/issue/KT-40037) New Project wizard: update Ktor version
|
||||
- [`KT-40092`](https://youtrack.jetbrains.com/issue/KT-40092) Wizard: the templates panel on mac OS is too wide
|
||||
- [`KT-40232`](https://youtrack.jetbrains.com/issue/KT-40232) New Wizard: Android Sdk path doesn't have backslash escaping on Windows
|
||||
- [`KT-40371`](https://youtrack.jetbrains.com/issue/KT-40371) New Project Wizard: Frontend Application / Library results in broken run configuration
|
||||
- [`KT-40377`](https://youtrack.jetbrains.com/issue/KT-40377) New Project Wizard: Frontend Application defines NPM dependencies that are unnecessary with Kotlin 1.4-RC+
|
||||
- [`KT-40378`](https://youtrack.jetbrains.com/issue/KT-40378) New Project Wizard: Frontend Application, Disabling JavaScript test framework has no effect
|
||||
- [`KT-40407`](https://youtrack.jetbrains.com/issue/KT-40407) Wizard: do not add stdlib by default for Gradle projects in wizard
|
||||
|
||||
### JS. Tools
|
||||
|
||||
- [`KT-39984`](https://youtrack.jetbrains.com/issue/KT-39984) Update dukat version in toolchain near to release of 1.4-RC
|
||||
|
||||
### JavaScript
|
||||
|
||||
- [`KT-32186`](https://youtrack.jetbrains.com/issue/KT-32186) Make sure K/JS Reflection API documentation is correct and fix it.
|
||||
- [`KT-37563`](https://youtrack.jetbrains.com/issue/KT-37563) K/JS: stacktrace is not captured for exceptions without primary constructor inherited from Exception/Error
|
||||
- [`KT-37752`](https://youtrack.jetbrains.com/issue/KT-37752) Generated typescript incorrect for constructors of derived classes
|
||||
- [`KT-37883`](https://youtrack.jetbrains.com/issue/KT-37883) KJS: Generated TypeScript uses 'declare' rather than 'export'
|
||||
- [`KT-38771`](https://youtrack.jetbrains.com/issue/KT-38771) JS: support non-reified type parameters in typeOf
|
||||
- [`KT-39873`](https://youtrack.jetbrains.com/issue/KT-39873) Update Kotlin JavaScript wrappers due to NON_EXPORTABLE_TYPE diagnostic introduction
|
||||
- [`KT-40126`](https://youtrack.jetbrains.com/issue/KT-40126) [JS / IR] NPE while compiling interfaces with invoke which is passed as a delegate
|
||||
- [`KT-40216`](https://youtrack.jetbrains.com/issue/KT-40216) KJS / IR: AssertionError caused by an anonymous object in the dependency project
|
||||
|
||||
### Libraries
|
||||
|
||||
- [`KT-33069`](https://youtrack.jetbrains.com/issue/KT-33069) StringBuilder common functions
|
||||
- [`KT-35972`](https://youtrack.jetbrains.com/issue/KT-35972) Add contract to builder functions
|
||||
- [`KT-37101`](https://youtrack.jetbrains.com/issue/KT-37101) Mark following api with DeprecatedSinceKotlin("1.4")
|
||||
- [`KT-38360`](https://youtrack.jetbrains.com/issue/KT-38360) Make sure that JB libraries correctly define their npm deps and republish them (after KT-30619)
|
||||
- [`KT-38817`](https://youtrack.jetbrains.com/issue/KT-38817) 'capitalize' should convert digraphs to title case
|
||||
- [`KT-40168`](https://youtrack.jetbrains.com/issue/KT-40168) Remove StringBuilder.capacity from common and JS parts
|
||||
|
||||
### Middle-end. IR
|
||||
|
||||
- [`KT-40520`](https://youtrack.jetbrains.com/issue/KT-40520) Assert during fake-override generation
|
||||
|
||||
### Tools. Commonizer
|
||||
|
||||
- [`KT-40199`](https://youtrack.jetbrains.com/issue/KT-40199) Commonizer loses nullability of abbreviated types
|
||||
|
||||
### Tools. Compiler Plugins
|
||||
|
||||
- [`KT-40036`](https://youtrack.jetbrains.com/issue/KT-40036) Add diagnostic that shows is serialization plugin compatible with serialization-runtime
|
||||
|
||||
### Tools. Gradle
|
||||
|
||||
- [`KT-39755`](https://youtrack.jetbrains.com/issue/KT-39755) [KJS / Gradle / Legacy mode] Directory with whitespace is not processed
|
||||
- [`KT-39809`](https://youtrack.jetbrains.com/issue/KT-39809) Kotlin Gradle plugin: ServiceConfigurationError: org.jetbrains.kotlin.gradle.plugin.KotlinGradleSubplugin: Provider org.jetbrains.kotlin.gradle.internal.AndroidSubplugin not a subtype
|
||||
- [`KT-39977`](https://youtrack.jetbrains.com/issue/KT-39977) Collect statistics of used -Xjvm-default options
|
||||
- [`KT-40300`](https://youtrack.jetbrains.com/issue/KT-40300) Fail the build if in MPP plugin no targets configured
|
||||
|
||||
### Tools. Gradle. JS
|
||||
|
||||
- [`KT-38170`](https://youtrack.jetbrains.com/issue/KT-38170) Investigate how to improve migration experience from pre 1.4.0 DSL to the new one
|
||||
- [`KT-39654`](https://youtrack.jetbrains.com/issue/KT-39654) Default CSS settings in webpack has priority over user's settings
|
||||
- [`KT-39842`](https://youtrack.jetbrains.com/issue/KT-39842) Kotlin/JS Gradle DSL: peerNpm dependency fails
|
||||
- [`KT-40048`](https://youtrack.jetbrains.com/issue/KT-40048) [Gradle, JS] Deprecate kotlin-frontend plugin
|
||||
- [`KT-40067`](https://youtrack.jetbrains.com/issue/KT-40067) [Gradle, JS] Public package.json for mixed JS/TS project
|
||||
- [`KT-40210`](https://youtrack.jetbrains.com/issue/KT-40210) Fail the build when Kotlin/JS target is not (properly) configured
|
||||
- [`KT-40320`](https://youtrack.jetbrains.com/issue/KT-40320) Gradle JS: make migration to the new Gradle DSL smoother
|
||||
|
||||
### Tools. Gradle. Multiplatform
|
||||
|
||||
- [`KT-32239`](https://youtrack.jetbrains.com/issue/KT-32239) Custom configurations inside Kotlin JVM Gradle projects can't properly resolve multiplatform dependencies
|
||||
- [`KT-39897`](https://youtrack.jetbrains.com/issue/KT-39897) [Commonizer] Fast-pass for library fragments absent for some targets
|
||||
|
||||
### Tools. J2K
|
||||
|
||||
- [`KT-39739`](https://youtrack.jetbrains.com/issue/KT-39739) J2K: Access is allowed from event dispatch thread with IW lock only
|
||||
|
||||
### Tools. kapt
|
||||
|
||||
- [`KT-34604`](https://youtrack.jetbrains.com/issue/KT-34604) KAPT: Flaky NPE through `org.jetbrains.kotlin.kapt3.base.ProcessorLoader.doLoadProcessors`
|
||||
- [`KT-36302`](https://youtrack.jetbrains.com/issue/KT-36302) TypeTreeVisitor.visitMemberSelect IllegalStateException: node.sym must not be null on JDK 11
|
||||
- [`KT-39876`](https://youtrack.jetbrains.com/issue/KT-39876) KAPT: Serialization of classpath structure is incorrect if there are dependencies between types in jar/dir
|
||||
|
||||
|
||||
## 1.4-M3
|
||||
|
||||
### Compiler
|
||||
|
||||
@@ -8,8 +8,10 @@ buildscript {
|
||||
val cacheRedirectorEnabled = findProperty("cacheRedirectorEnabled")?.toString()?.toBoolean() == true
|
||||
if (cacheRedirectorEnabled) {
|
||||
maven("https://cache-redirector.jetbrains.com/dl.bintray.com/kotlin/kotlinx")
|
||||
maven("https://cache-redirector.jetbrains.com/dl.bintray.com/kotlin/kotlin-dev")
|
||||
} else {
|
||||
maven("https://dl.bintray.com/kotlin/kotlinx")
|
||||
maven("https://dl.bintray.com/kotlin/kotlin-dev")
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
@@ -28,8 +30,10 @@ repositories {
|
||||
val cacheRedirectorEnabled = findProperty("cacheRedirectorEnabled")?.toString()?.toBoolean() == true
|
||||
if (cacheRedirectorEnabled) {
|
||||
maven("https://cache-redirector.jetbrains.com/dl.bintray.com/kotlin/kotlinx")
|
||||
} else {
|
||||
maven("https://cache-redirector.jetbrains.com/dl.bintray.com/kotlin/kotlin-dev")
|
||||
} else {
|
||||
maven("https://dl.bintray.com/kotlin/kotlinx")
|
||||
maven("https://dl.bintray.com/kotlin/kotlin-dev")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ open class IncrementalJsCache(
|
||||
override fun markDirty(removedAndCompiledSources: Collection<File>) {
|
||||
removedAndCompiledSources.forEach { sourceFile ->
|
||||
// The common prefix of all FQN parents has to be the file package
|
||||
sourceToClassesMap[sourceFile].map { it.parentOrNull()?.asString() ?: "" }.minByOrNull { it.length }?.let {
|
||||
sourceToClassesMap[sourceFile].map { it.parentOrNull()?.asString() ?: "" }.minBy { it.length }?.let {
|
||||
packageMetadata.remove(it)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,8 +168,6 @@ open class IncrementalJvmCache(
|
||||
constantsMap.process(kotlinClass, changesCollector)
|
||||
inlineFunctionsMap.process(kotlinClass, changesCollector)
|
||||
}
|
||||
KotlinClassHeader.Kind.UNKNOWN, KotlinClassHeader.Kind.SYNTHETIC_CLASS -> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package org.jetbrains.kotlin.incremental
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.load.java.JavaDescriptorVisibilities
|
||||
import org.jetbrains.kotlin.load.java.JavaVisibilities
|
||||
import org.jetbrains.kotlin.metadata.ProtoBuf
|
||||
import org.jetbrains.kotlin.metadata.deserialization.BinaryVersion
|
||||
import org.jetbrains.kotlin.metadata.java.JavaClassProtoBuf
|
||||
@@ -41,7 +41,7 @@ class JavaClassesSerializerExtension : KotlinSerializerExtensionBase(BuiltInSeri
|
||||
childSerializer: DescriptorSerializer
|
||||
) {
|
||||
super.serializeClass(descriptor, proto, versionRequirementTable, childSerializer)
|
||||
if (descriptor.visibility == JavaDescriptorVisibilities.PACKAGE_VISIBILITY) {
|
||||
if (descriptor.visibility == JavaVisibilities.PACKAGE_VISIBILITY) {
|
||||
proto.setExtension(JavaClassProtoBuf.isPackagePrivateClass, true)
|
||||
}
|
||||
}
|
||||
@@ -50,7 +50,7 @@ class JavaClassesSerializerExtension : KotlinSerializerExtensionBase(BuiltInSeri
|
||||
proto: ProtoBuf.Constructor.Builder,
|
||||
childSerializer: DescriptorSerializer) {
|
||||
super.serializeConstructor(descriptor, proto, childSerializer)
|
||||
if (descriptor.visibility == JavaDescriptorVisibilities.PACKAGE_VISIBILITY) {
|
||||
if (descriptor.visibility == JavaVisibilities.PACKAGE_VISIBILITY) {
|
||||
proto.setExtension(JavaClassProtoBuf.isPackagePrivateConstructor, true)
|
||||
}
|
||||
}
|
||||
@@ -62,7 +62,7 @@ class JavaClassesSerializerExtension : KotlinSerializerExtensionBase(BuiltInSeri
|
||||
childSerializer: DescriptorSerializer
|
||||
) {
|
||||
super.serializeFunction(descriptor, proto, versionRequirementTable, childSerializer)
|
||||
if (descriptor.visibility == JavaDescriptorVisibilities.PACKAGE_VISIBILITY) {
|
||||
if (descriptor.visibility == JavaVisibilities.PACKAGE_VISIBILITY) {
|
||||
proto.setExtension(JavaClassProtoBuf.isPackagePrivateMethod, true)
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ class JavaClassesSerializerExtension : KotlinSerializerExtensionBase(BuiltInSeri
|
||||
childSerializer: DescriptorSerializer
|
||||
) {
|
||||
super.serializeProperty(descriptor, proto, versionRequirementTable, childSerializer)
|
||||
if (descriptor.visibility == JavaDescriptorVisibilities.PACKAGE_VISIBILITY) {
|
||||
if (descriptor.visibility == JavaVisibilities.PACKAGE_VISIBILITY) {
|
||||
proto.setExtension(JavaClassProtoBuf.isPackagePrivateField, true)
|
||||
}
|
||||
|
||||
|
||||
@@ -23,12 +23,12 @@ import org.jetbrains.kotlin.resolve.jvm.JvmClassName
|
||||
import java.io.File
|
||||
|
||||
class LocalFileKotlinClass private constructor(
|
||||
private val file: File,
|
||||
private val fileContents: ByteArray,
|
||||
className: ClassId,
|
||||
classVersion: Int,
|
||||
classHeader: KotlinClassHeader,
|
||||
innerClasses: InnerClassesInfo
|
||||
private val file: File,
|
||||
private val fileContents: ByteArray,
|
||||
className: ClassId,
|
||||
classVersion: Int,
|
||||
classHeader: KotlinClassHeader,
|
||||
innerClasses: InnerClassesInfo
|
||||
) : FileBasedKotlinClass(className, classVersion, classHeader, innerClasses) {
|
||||
|
||||
companion object {
|
||||
|
||||
@@ -80,7 +80,7 @@ open class LookupStorage(
|
||||
|
||||
for (lookupSymbol in lookups.keySet().sorted()) {
|
||||
val key = LookupSymbolKey(lookupSymbol.name, lookupSymbol.scope)
|
||||
val paths = lookups[lookupSymbol]
|
||||
val paths = lookups[lookupSymbol]!!
|
||||
val fileIds = paths.mapTo(TreeSet()) { pathToId[it]!! }
|
||||
fileIds.addAll(lookupMap[key] ?: emptySet())
|
||||
lookupMap[key] = fileIds
|
||||
|
||||
@@ -14,8 +14,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@file:Suppress("UNUSED_PARAMETER")
|
||||
|
||||
package org.jetbrains.kotlin.incremental
|
||||
|
||||
import org.jetbrains.kotlin.library.metadata.KlibMetadataProtoBuf
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.incremental
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.DescriptorVisibilities
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.incremental.ProtoCompareGenerated.ProtoBufClassKind
|
||||
import org.jetbrains.kotlin.incremental.ProtoCompareGenerated.ProtoBufPackageKind
|
||||
import org.jetbrains.kotlin.incremental.storage.ProtoMapValue
|
||||
@@ -49,7 +49,7 @@ fun ProtoMapValue.toProtoData(packageFqName: FqName): ProtoData =
|
||||
}
|
||||
|
||||
internal val MessageLite.isPrivate: Boolean
|
||||
get() = DescriptorVisibilities.isPrivate(
|
||||
get() = Visibilities.isPrivate(
|
||||
ProtoEnumFlags.visibility(
|
||||
when (this) {
|
||||
is ProtoBuf.Constructor -> Flags.VISIBILITY.get(flags)
|
||||
@@ -346,4 +346,4 @@ val ProtoBuf.Class.typeTableOrNull: ProtoBuf.TypeTable?
|
||||
get() = if (hasTypeTable()) typeTable else null
|
||||
|
||||
val ProtoBuf.Package.typeTableOrNull: ProtoBuf.TypeTable?
|
||||
get() = if (hasTypeTable()) typeTable else null
|
||||
get() = if (hasTypeTable()) typeTable else null
|
||||
@@ -187,7 +187,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.20-dev-16314"
|
||||
extra["versions.kotlin-native"] = "1.4-M3-dev-15627"
|
||||
}
|
||||
|
||||
val intellijUltimateEnabled by extra(project.kotlinBuildProperties.intellijUltimateEnabled)
|
||||
@@ -221,8 +221,6 @@ extra["compilerModules"] = arrayOf(
|
||||
":compiler:config",
|
||||
":compiler:config.jvm",
|
||||
":compiler:container",
|
||||
":compiler:resolution.common",
|
||||
":compiler:resolution.common.jvm",
|
||||
":compiler:resolution",
|
||||
":compiler:serialization",
|
||||
":compiler:psi",
|
||||
@@ -267,19 +265,17 @@ extra["compilerModules"] = arrayOf(
|
||||
":kotlin-build-common",
|
||||
":core:metadata",
|
||||
":core:metadata.jvm",
|
||||
":core:compiler.common",
|
||||
":core:compiler.common.jvm",
|
||||
":core:descriptors",
|
||||
":core:descriptors.jvm",
|
||||
":core:descriptors.runtime",
|
||||
":core:deserialization",
|
||||
":core:util.runtime",
|
||||
":core:type-system",
|
||||
":compiler:fir:cones",
|
||||
":compiler:fir:resolve",
|
||||
":compiler:fir:fir-serialization",
|
||||
":compiler:fir:fir-deserialization",
|
||||
":compiler:fir:tree",
|
||||
":compiler:fir:raw-fir:raw-fir.common",
|
||||
":compiler:fir:raw-fir:fir-common",
|
||||
":compiler:fir:raw-fir:psi2fir",
|
||||
":compiler:fir:raw-fir:light-tree2fir",
|
||||
":compiler:fir:fir2ir",
|
||||
@@ -291,6 +287,7 @@ extra["compilerModules"] = arrayOf(
|
||||
)
|
||||
|
||||
extra["compilerModulesForJps"] = listOf(
|
||||
":core:type-system",
|
||||
":kotlin-build-common",
|
||||
":kotlin-util-io",
|
||||
":kotlin-util-klib",
|
||||
@@ -299,8 +296,6 @@ extra["compilerModulesForJps"] = listOf(
|
||||
":kotlin-compiler-runner",
|
||||
":daemon-common",
|
||||
":daemon-common-new",
|
||||
":core:compiler.common",
|
||||
":core:compiler.common.jvm",
|
||||
":core:descriptors",
|
||||
":core:descriptors.jvm",
|
||||
":idea:idea-jps-common",
|
||||
@@ -360,7 +355,7 @@ fun Task.listConfigurationContents(configName: String) {
|
||||
}
|
||||
|
||||
val defaultJvmTarget = "1.8"
|
||||
val defaultJavaHome = jdkPath(if (Platform[203].orHigher()) "11" else defaultJvmTarget)
|
||||
val defaultJavaHome = jdkPath(defaultJvmTarget)
|
||||
val ignoreTestFailures by extra(project.kotlinBuildProperties.ignoreTestFailures)
|
||||
|
||||
allprojects {
|
||||
@@ -462,16 +457,6 @@ allprojects {
|
||||
outputs.doNotCacheIf("https://youtrack.jetbrains.com/issue/KT-37089") { true }
|
||||
}
|
||||
|
||||
tasks.withType<SourceTask>().configureEach {
|
||||
doFirst {
|
||||
source.visit {
|
||||
if (file.isDirectory && file.listFiles()?.isEmpty() == true) {
|
||||
logger.warn("Empty source directories may cause build cache misses: " + file.absolutePath)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
normalization {
|
||||
runtimeClasspath {
|
||||
ignore("META-INF/MANIFEST.MF")
|
||||
|
||||
@@ -53,8 +53,7 @@ enum class Ide(val platform: Platform) : CompatibilityPredicate {
|
||||
AS35(Platform.P183),
|
||||
AS36(Platform.P192),
|
||||
AS40(Platform.P193),
|
||||
AS41(Platform.P201),
|
||||
AS42(Platform.P201);
|
||||
AS41(Platform.P201);
|
||||
|
||||
val kind = Kind.values().first { it.shortName == name.take(2) }
|
||||
val version = name.dropWhile { !it.isDigit() }.toInt()
|
||||
|
||||
@@ -80,8 +80,6 @@ fun Project.androidDxJar() = "org.jetbrains.kotlin:android-dx:${rootProject.extr
|
||||
|
||||
fun Project.jpsBuildTest() = "com.jetbrains.intellij.idea:jps-build-test:${rootProject.extra["versions.intellijSdk"]}"
|
||||
|
||||
fun Project.kotlinxCollectionsImmutable() = "org.jetbrains.kotlinx:kotlinx-collections-immutable-jvm:${rootProject.extra["versions.kotlinx-collections-immutable"]}"
|
||||
|
||||
/**
|
||||
* Runtime version of annotations that are already in Kotlin stdlib (historically Kotlin has older version of this one).
|
||||
*
|
||||
|
||||
@@ -52,7 +52,6 @@ open class PublishedKotlinModule : Plugin<Project> {
|
||||
configure<SigningExtension> {
|
||||
isRequired = signingRequired
|
||||
sign(configurations["archives"])
|
||||
useGpgCmd()
|
||||
}
|
||||
|
||||
tasks.named<Sign>("signArchives").configure {
|
||||
|
||||
@@ -54,7 +54,6 @@ fun Task.dependsOnKotlinPluginInstall() {
|
||||
":kotlin-test:kotlin-test-annotations-common:install",
|
||||
":kotlin-test:kotlin-test-jvm:install",
|
||||
":kotlin-test:kotlin-test-js:install",
|
||||
":kotlin-test:kotlin-test-junit:install",
|
||||
":kotlin-gradle-subplugin-example:install",
|
||||
":kotlin-stdlib-common:install",
|
||||
":kotlin-stdlib:install",
|
||||
@@ -66,8 +65,7 @@ fun Task.dependsOnKotlinPluginInstall() {
|
||||
":kotlin-scripting-jvm:install",
|
||||
":kotlin-scripting-compiler-embeddable:install",
|
||||
":kotlin-scripting-compiler-impl-embeddable:install",
|
||||
":kotlin-test-js-runner:install",
|
||||
":native:kotlin-klib-commonizer-embeddable:install"
|
||||
":kotlin-test-js-runner:install"
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.junit.runners.AllTests;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
//@RunWith(AllTests.class)
|
||||
@RunWith(AllTests.class)
|
||||
public class AndroidRunner {
|
||||
|
||||
private static PathManager pathManager;
|
||||
|
||||
@@ -65,7 +65,7 @@ object CodegenUtil {
|
||||
if (copy)
|
||||
copyFunctions(
|
||||
declaration, traitMember, declaration.containingDeclaration, traitMember.modality,
|
||||
DescriptorVisibilities.PUBLIC, CallableMemberDescriptor.Kind.DECLARATION, true
|
||||
Visibilities.PUBLIC, CallableMemberDescriptor.Kind.DECLARATION, true
|
||||
)
|
||||
else mapMembers(declaration, traitMember)
|
||||
)
|
||||
@@ -74,13 +74,13 @@ object CodegenUtil {
|
||||
}
|
||||
|
||||
fun copyFunctions(
|
||||
inheritedMember: CallableMemberDescriptor,
|
||||
traitMember: CallableMemberDescriptor,
|
||||
newOwner: DeclarationDescriptor,
|
||||
modality: Modality,
|
||||
visibility: DescriptorVisibility,
|
||||
kind: CallableMemberDescriptor.Kind,
|
||||
copyOverrides: Boolean
|
||||
inheritedMember: CallableMemberDescriptor,
|
||||
traitMember: CallableMemberDescriptor,
|
||||
newOwner: DeclarationDescriptor,
|
||||
modality: Modality,
|
||||
visibility: Visibility,
|
||||
kind: CallableMemberDescriptor.Kind,
|
||||
copyOverrides: Boolean
|
||||
): Map<FunctionDescriptor, FunctionDescriptor> =
|
||||
mapMembers(inheritedMember.copy(newOwner, modality, visibility, kind, copyOverrides), traitMember)
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ class AccessorForCompanionObjectInstanceFieldDescriptor(
|
||||
null, null, emptyList(), emptyList(),
|
||||
companionObjectDescriptor.defaultType,
|
||||
Modality.FINAL,
|
||||
DescriptorVisibilities.LOCAL
|
||||
Visibilities.LOCAL
|
||||
)
|
||||
}
|
||||
|
||||
@@ -41,4 +41,4 @@ class AccessorForCompanionObjectInstanceFieldDescriptor(
|
||||
): FunctionDescriptorImpl {
|
||||
throw UnsupportedOperationException("Accessor for companion object $companionObjectDescriptor should not be substituted")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -42,11 +42,11 @@ class AccessorForConstructorDescriptor(
|
||||
override fun substitute(substitutor: TypeSubstitutor) = super.substitute(substitutor) as ClassConstructorDescriptor
|
||||
|
||||
override fun copy(
|
||||
newOwner: DeclarationDescriptor,
|
||||
modality: Modality,
|
||||
visibility: DescriptorVisibility,
|
||||
kind: CallableMemberDescriptor.Kind,
|
||||
copyOverrides: Boolean
|
||||
newOwner: DeclarationDescriptor,
|
||||
modality: Modality,
|
||||
visibility: Visibility,
|
||||
kind: CallableMemberDescriptor.Kind,
|
||||
copyOverrides: Boolean
|
||||
): AccessorForConstructorDescriptor {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
@@ -61,7 +61,7 @@ class AccessorForConstructorDescriptor(
|
||||
copyValueParameters(calleeDescriptor),
|
||||
calleeDescriptor.returnType,
|
||||
Modality.FINAL,
|
||||
DescriptorVisibilities.LOCAL
|
||||
Visibilities.LOCAL
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ class AccessorForFunctionDescriptor(
|
||||
copyValueParameters(calleeDescriptor),
|
||||
calleeDescriptor.returnType,
|
||||
Modality.FINAL,
|
||||
DescriptorVisibilities.LOCAL
|
||||
Visibilities.LOCAL
|
||||
)
|
||||
|
||||
isSuspend = calleeDescriptor.isSuspend
|
||||
|
||||
@@ -43,7 +43,7 @@ open class AccessorForPropertyDescriptor private constructor(
|
||||
null,
|
||||
Annotations.EMPTY,
|
||||
Modality.FINAL,
|
||||
DescriptorVisibilities.LOCAL,
|
||||
Visibilities.LOCAL,
|
||||
calleeDescriptor.isVar,
|
||||
Name.identifier("access$$accessorSuffix"),
|
||||
CallableMemberDescriptor.Kind.DECLARATION,
|
||||
@@ -111,7 +111,7 @@ open class AccessorForPropertyDescriptor private constructor(
|
||||
property,
|
||||
Annotations.EMPTY,
|
||||
Modality.FINAL,
|
||||
DescriptorVisibilities.LOCAL,
|
||||
Visibilities.LOCAL,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
@@ -136,7 +136,7 @@ open class AccessorForPropertyDescriptor private constructor(
|
||||
property,
|
||||
Annotations.EMPTY,
|
||||
Modality.FINAL,
|
||||
DescriptorVisibilities.LOCAL,
|
||||
Visibilities.LOCAL,
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
|
||||
@@ -142,7 +142,7 @@ public abstract class AnnotationCodegen {
|
||||
&& !applicableTargets.contains(KotlinTarget.CLASS)
|
||||
&& !applicableTargets.contains(KotlinTarget.ANNOTATION_CLASS)) {
|
||||
ClassDescriptor classDescriptor = (ClassDescriptor) annotated;
|
||||
if (classDescriptor.getVisibility() == DescriptorVisibilities.LOCAL) {
|
||||
if (classDescriptor.getVisibility() == Visibilities.LOCAL) {
|
||||
assert applicableTargets.contains(KotlinTarget.EXPRESSION) :
|
||||
"Inconsistent target list for object literal annotation: " + applicableTargets + " on " + annotated;
|
||||
continue;
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.config.*;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation;
|
||||
import org.jetbrains.kotlin.lexer.KtTokens;
|
||||
import org.jetbrains.kotlin.load.java.JavaDescriptorVisibilities;
|
||||
import org.jetbrains.kotlin.load.java.JavaVisibilities;
|
||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames;
|
||||
import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmProtoBufUtil;
|
||||
import org.jetbrains.kotlin.metadata.jvm.serialization.JvmStringTable;
|
||||
@@ -82,16 +82,16 @@ public class AsmUtil {
|
||||
public static final int NO_FLAG_PACKAGE_PRIVATE = 0;
|
||||
|
||||
@NotNull
|
||||
private static final Map<DescriptorVisibility, Integer> visibilityToAccessFlag = ImmutableMap.<DescriptorVisibility, Integer>builder()
|
||||
.put(DescriptorVisibilities.PRIVATE, ACC_PRIVATE)
|
||||
.put(DescriptorVisibilities.PRIVATE_TO_THIS, ACC_PRIVATE)
|
||||
.put(DescriptorVisibilities.PROTECTED, ACC_PROTECTED)
|
||||
.put(JavaDescriptorVisibilities.PROTECTED_STATIC_VISIBILITY, ACC_PROTECTED)
|
||||
.put(JavaDescriptorVisibilities.PROTECTED_AND_PACKAGE, ACC_PROTECTED)
|
||||
.put(DescriptorVisibilities.PUBLIC, ACC_PUBLIC)
|
||||
.put(DescriptorVisibilities.INTERNAL, ACC_PUBLIC)
|
||||
.put(DescriptorVisibilities.LOCAL, NO_FLAG_LOCAL)
|
||||
.put(JavaDescriptorVisibilities.PACKAGE_VISIBILITY, NO_FLAG_PACKAGE_PRIVATE)
|
||||
private static final Map<Visibility, Integer> visibilityToAccessFlag = ImmutableMap.<Visibility, Integer>builder()
|
||||
.put(Visibilities.PRIVATE, ACC_PRIVATE)
|
||||
.put(Visibilities.PRIVATE_TO_THIS, ACC_PRIVATE)
|
||||
.put(Visibilities.PROTECTED, ACC_PROTECTED)
|
||||
.put(JavaVisibilities.PROTECTED_STATIC_VISIBILITY, ACC_PROTECTED)
|
||||
.put(JavaVisibilities.PROTECTED_AND_PACKAGE, ACC_PROTECTED)
|
||||
.put(Visibilities.PUBLIC, ACC_PUBLIC)
|
||||
.put(Visibilities.INTERNAL, ACC_PUBLIC)
|
||||
.put(Visibilities.LOCAL, NO_FLAG_LOCAL)
|
||||
.put(JavaVisibilities.PACKAGE_VISIBILITY, NO_FLAG_PACKAGE_PRIVATE)
|
||||
.build();
|
||||
|
||||
public static final String CAPTURED_PREFIX = "$";
|
||||
@@ -395,7 +395,7 @@ public class AsmUtil {
|
||||
flags |= getDeprecatedAccessFlag(functionDescriptor);
|
||||
if (deprecationResolver.isDeprecatedHidden(functionDescriptor) ||
|
||||
isInlineWithReified(functionDescriptor) ||
|
||||
functionDescriptor.isSuspend() && functionDescriptor.getVisibility().equals(DescriptorVisibilities.PRIVATE)) {
|
||||
functionDescriptor.isSuspend() && functionDescriptor.getVisibility().equals(Visibilities.PRIVATE)) {
|
||||
flags |= ACC_SYNTHETIC;
|
||||
}
|
||||
return flags;
|
||||
@@ -410,7 +410,7 @@ public class AsmUtil {
|
||||
if (specialCase != null) {
|
||||
return specialCase;
|
||||
}
|
||||
DescriptorVisibility visibility = descriptor.getVisibility();
|
||||
Visibility visibility = descriptor.getVisibility();
|
||||
Integer defaultMapping = getVisibilityAccessFlag(visibility);
|
||||
if (defaultMapping == null) {
|
||||
throw new IllegalStateException(visibility + " is not a valid visibility in backend for " + DescriptorRenderer.DEBUG_TEXT.render(descriptor));
|
||||
@@ -419,7 +419,7 @@ public class AsmUtil {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Integer getVisibilityAccessFlag(DescriptorVisibility visibility) {
|
||||
public static Integer getVisibilityAccessFlag(Visibility visibility) {
|
||||
return visibilityToAccessFlag.get(visibility);
|
||||
}
|
||||
|
||||
@@ -435,11 +435,11 @@ public class AsmUtil {
|
||||
if (descriptor.getKind() == ClassKind.ENUM_ENTRY) {
|
||||
return NO_FLAG_PACKAGE_PRIVATE;
|
||||
}
|
||||
if (descriptor.getVisibility() == DescriptorVisibilities.PUBLIC ||
|
||||
descriptor.getVisibility() == DescriptorVisibilities.PROTECTED ||
|
||||
if (descriptor.getVisibility() == Visibilities.PUBLIC ||
|
||||
descriptor.getVisibility() == Visibilities.PROTECTED ||
|
||||
// TODO: should be package private, but for now Kotlin's reflection can't access members of such classes
|
||||
descriptor.getVisibility() == DescriptorVisibilities.LOCAL ||
|
||||
descriptor.getVisibility() == DescriptorVisibilities.INTERNAL) {
|
||||
descriptor.getVisibility() == Visibilities.LOCAL ||
|
||||
descriptor.getVisibility() == Visibilities.INTERNAL) {
|
||||
return ACC_PUBLIC;
|
||||
}
|
||||
return NO_FLAG_PACKAGE_PRIVATE;
|
||||
@@ -458,7 +458,7 @@ public class AsmUtil {
|
||||
int visibility =
|
||||
innerClass instanceof SyntheticClassDescriptorForLambda
|
||||
? getVisibilityAccessFlagForAnonymous(innerClass)
|
||||
: innerClass.getVisibility() == DescriptorVisibilities.LOCAL
|
||||
: innerClass.getVisibility() == Visibilities.LOCAL
|
||||
? ACC_PUBLIC
|
||||
: getVisibilityAccessFlag(innerClass);
|
||||
return visibility |
|
||||
@@ -511,7 +511,7 @@ public class AsmUtil {
|
||||
@Nullable
|
||||
private static Integer specialCaseVisibility(@NotNull MemberDescriptor memberDescriptor, @Nullable OwnerKind kind) {
|
||||
DeclarationDescriptor containingDeclaration = memberDescriptor.getContainingDeclaration();
|
||||
DescriptorVisibility memberVisibility = memberDescriptor.getVisibility();
|
||||
Visibility memberVisibility = memberDescriptor.getVisibility();
|
||||
|
||||
if (JvmCodegenUtil.isNonIntrinsicPrivateCompanionObjectInInterface(memberDescriptor)) {
|
||||
return ACC_PUBLIC;
|
||||
@@ -534,7 +534,7 @@ public class AsmUtil {
|
||||
return ACC_PRIVATE;
|
||||
}
|
||||
|
||||
if (memberVisibility == DescriptorVisibilities.LOCAL && memberDescriptor instanceof CallableMemberDescriptor) {
|
||||
if (memberVisibility == Visibilities.LOCAL && memberDescriptor instanceof CallableMemberDescriptor) {
|
||||
return ACC_PUBLIC;
|
||||
}
|
||||
|
||||
@@ -564,7 +564,7 @@ public class AsmUtil {
|
||||
}
|
||||
}
|
||||
|
||||
if (memberDescriptor instanceof CallableDescriptor && memberVisibility == DescriptorVisibilities.PROTECTED) {
|
||||
if (memberDescriptor instanceof CallableDescriptor && memberVisibility == Visibilities.PROTECTED) {
|
||||
for (CallableDescriptor overridden : DescriptorUtils.getAllOverriddenDescriptors((CallableDescriptor) memberDescriptor)) {
|
||||
if (isJvmInterface(overridden.getContainingDeclaration())) {
|
||||
return ACC_PUBLIC;
|
||||
@@ -572,7 +572,7 @@ public class AsmUtil {
|
||||
}
|
||||
}
|
||||
|
||||
if (!DescriptorVisibilities.isPrivate(memberVisibility)) {
|
||||
if (!Visibilities.isPrivate(memberVisibility)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,6 @@ import static org.jetbrains.kotlin.codegen.binding.CodegenBinding.enumEntryNeedS
|
||||
import static org.jetbrains.kotlin.resolve.DescriptorToSourceUtils.descriptorToDeclaration;
|
||||
import static org.jetbrains.kotlin.resolve.jvm.AsmTypes.OBJECT_TYPE;
|
||||
import static org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOriginKind.CLASS_MEMBER_DELEGATION_TO_DEFAULT_IMPL;
|
||||
import static org.jetbrains.kotlin.util.DeclarationUtilKt.findImplementationFromInterface;
|
||||
import static org.jetbrains.kotlin.util.DeclarationUtilKt.findInterfaceImplementation;
|
||||
|
||||
public abstract class ClassBodyCodegen extends MemberCodegen<KtPureClassOrObject> {
|
||||
@@ -237,12 +236,9 @@ public abstract class ClassBodyCodegen extends MemberCodegen<KtPureClassOrObject
|
||||
@NotNull GenerationState state,
|
||||
boolean isErasedInlineClass
|
||||
) {
|
||||
CallableMemberDescriptor actualImplementation =
|
||||
interfaceFun.getKind().isReal() ? interfaceFun : findImplementationFromInterface(interfaceFun);
|
||||
assert actualImplementation != null : "Can't find actual implementation for " + interfaceFun;
|
||||
// Skip Java 8 default methods
|
||||
if (CodegenUtilKt.isDefinitelyNotDefaultImplsMethod(actualImplementation) ||
|
||||
JvmAnnotationUtilKt.isCallableMemberCompiledToJvmDefault(actualImplementation, state.getJvmDefaultMode())) {
|
||||
if (CodegenUtilKt.isDefinitelyNotDefaultImplsMethod(interfaceFun) ||
|
||||
JvmAnnotationUtilKt.checkIsImplementationCompiledToJvmDefault(interfaceFun, state.getJvmDefaultMode())) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package org.jetbrains.kotlin.codegen
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMapper
|
||||
import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMap
|
||||
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind.DECLARATION
|
||||
@@ -321,7 +321,7 @@ class CollectionStubMethodGenerator(
|
||||
)
|
||||
|
||||
child.modality = Modality.FINAL
|
||||
child.visibility = DescriptorVisibilities.PUBLIC
|
||||
child.visibility = Visibilities.PUBLIC
|
||||
val typeParameters = descriptor.typeConstructor.parameters
|
||||
val newTypeParameters = ArrayList<TypeParameterDescriptor>(typeParameters.size)
|
||||
DescriptorSubstitutor.substituteTypeParameters(typeParameters, TypeSubstitution.EMPTY, child, newTypeParameters)
|
||||
@@ -360,7 +360,7 @@ private val READ_ONLY_ARE_EQUAL_TO_MUTABLE_TYPE_CHECKER = KotlinTypeCheckerImpl.
|
||||
val firstClass = x.declarationDescriptor as? ClassDescriptor ?: return@withAxioms x == y
|
||||
val secondClass = y.declarationDescriptor as? ClassDescriptor ?: return@withAxioms x == y
|
||||
|
||||
val j2k = JavaToKotlinClassMapper
|
||||
val j2k = JavaToKotlinClassMap
|
||||
val firstReadOnly = if (j2k.isMutable(firstClass)) j2k.convertMutableToReadOnly(firstClass) else firstClass
|
||||
val secondReadOnly = if (j2k.isMutable(secondClass)) j2k.convertMutableToReadOnly(secondClass) else secondClass
|
||||
firstReadOnly.typeConstructor == secondReadOnly.typeConstructor
|
||||
|
||||
@@ -268,7 +268,7 @@ class DefaultParameterValueSubstitutor(val state: GenerationState) {
|
||||
|
||||
if (CodegenBinding.canHaveOuter(state.bindingContext, classDescriptor)) return false
|
||||
|
||||
if (DescriptorVisibilities.isPrivate(constructorDescriptor.visibility)) return false
|
||||
if (Visibilities.isPrivate(constructorDescriptor.visibility)) return false
|
||||
|
||||
if (constructorDescriptor.valueParameters.isEmpty()) return false
|
||||
if (classOrObject is KtClass && hasSecondaryConstructorsWithNoParameters(classOrObject)) return false
|
||||
|
||||
@@ -51,7 +51,7 @@ import org.jetbrains.kotlin.descriptors.impl.SyntheticFieldDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.impl.TypeAliasConstructorDescriptor;
|
||||
import org.jetbrains.kotlin.diagnostics.Errors;
|
||||
import org.jetbrains.kotlin.lexer.KtTokens;
|
||||
import org.jetbrains.kotlin.load.java.DescriptorsJvmAbiUtil;
|
||||
import org.jetbrains.kotlin.load.java.JvmAbi;
|
||||
import org.jetbrains.kotlin.load.kotlin.MethodSignatureMappingKt;
|
||||
import org.jetbrains.kotlin.load.kotlin.TypeSignatureMappingKt;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
@@ -173,7 +173,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
return null;
|
||||
}
|
||||
|
||||
public static class BlockStackElement {
|
||||
static class BlockStackElement {
|
||||
}
|
||||
|
||||
static class LoopBlockStackElement extends BlockStackElement {
|
||||
@@ -2174,14 +2174,14 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
|
||||
DeclarationDescriptor containingDeclaration = propertyDescriptor.getContainingDeclaration();
|
||||
|
||||
boolean isBackingFieldMovedFromCompanion = DescriptorsJvmAbiUtil.isPropertyWithBackingFieldInOuterClass(propertyDescriptor);
|
||||
boolean isBackingFieldMovedFromCompanion = JvmAbi.isPropertyWithBackingFieldInOuterClass(propertyDescriptor);
|
||||
AccessorKind fieldAccessorKind;
|
||||
if (skipLateinitAssertion) {
|
||||
fieldAccessorKind = AccessorKind.LATEINIT_INTRINSIC;
|
||||
}
|
||||
else if (isBackingFieldMovedFromCompanion &&
|
||||
(forceField ||
|
||||
(DescriptorVisibilities.isPrivate(propertyDescriptor.getVisibility()) &&
|
||||
(Visibilities.isPrivate(propertyDescriptor.getVisibility()) &&
|
||||
isDefaultAccessor(propertyDescriptor.getGetter()) && isDefaultAccessor(propertyDescriptor.getSetter())))) {
|
||||
fieldAccessorKind = JvmCodegenUtil.isDebuggerContext(context) ? AccessorKind.NORMAL : AccessorKind.IN_CLASS_COMPANION;
|
||||
}
|
||||
@@ -2224,9 +2224,8 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
|
||||
if (!skipPropertyAccessors) {
|
||||
if (isBackingFieldMovedFromCompanion && context.getContextDescriptor() instanceof AccessorForPropertyBackingField) {
|
||||
CodegenContext<?> parentContext = backingFieldContext.getParentContext();
|
||||
propertyDescriptor =
|
||||
parentContext.getAccessor(propertyDescriptor, AccessorKind.IN_CLASS_COMPANION, delegateType, superCallTarget);
|
||||
propertyDescriptor = (PropertyDescriptor) backingFieldContext.getParentContext()
|
||||
.getAccessor(propertyDescriptor, AccessorKind.IN_CLASS_COMPANION, delegateType, superCallTarget);
|
||||
}
|
||||
else {
|
||||
propertyDescriptor =
|
||||
@@ -2254,7 +2253,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
skipPropertyAccessors = forceField;
|
||||
|
||||
if (JvmCodegenUtil.isDebuggerContext(context)
|
||||
&& DescriptorVisibilities.isPrivate(propertyDescriptor.getVisibility())
|
||||
&& Visibilities.isPrivate(propertyDescriptor.getVisibility())
|
||||
&& bindingContext.get(BACKING_FIELD_REQUIRED, propertyDescriptor) == Boolean.TRUE
|
||||
) {
|
||||
skipPropertyAccessors = true;
|
||||
@@ -2836,7 +2835,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
TypeApproximator approximator = new TypeApproximator(state.getModule().getBuiltIns());
|
||||
|
||||
KotlinType approximatedType =
|
||||
TypeUtils.contains(type, (containedType) -> CapturedTypeConstructorKt.isCaptured(containedType)) ?
|
||||
CapturedTypeConstructorKt.isCaptured(type) ?
|
||||
(KotlinType) approximator.approximateToSuperType(
|
||||
type, TypeApproximatorConfiguration.InternalTypesApproximation.INSTANCE
|
||||
) : null;
|
||||
@@ -4104,14 +4103,15 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
TypeAndNullability right754Type = calcTypeForIeee754ArithmeticIfNeeded(right, getRightOperandType(primitiveNumericComparisonInfo));
|
||||
boolean isSame754ArithmeticTypes = left754Type != null && right754Type != null && left754Type.type.equals(right754Type.type);
|
||||
boolean properIeee754Comparisons = shouldUseProperIeee754Comparisons();
|
||||
boolean isStandardCompareTo = primitiveNumericComparisonInfo != null;
|
||||
|
||||
if (properIeee754Comparisons && isStandardCompareTo && left754Type != null && right754Type != null) {
|
||||
if (properIeee754Comparisons && left754Type != null && right754Type != null) {
|
||||
type = comparisonOperandType(left754Type.type, right754Type.type);
|
||||
//type = comparisonOperandType(leftType, rightType);
|
||||
leftValue = gen(left);
|
||||
rightValue = gen(right);
|
||||
}
|
||||
else if (!properIeee754Comparisons && isStandardCompareTo &&
|
||||
else if (!properIeee754Comparisons &&
|
||||
state.getIntrinsics().getIntrinsic((FunctionDescriptor) resolvedCall.getResultingDescriptor()) instanceof CompareTo &&
|
||||
((isPrimitive(leftType) && isPrimitive(rightType)) || isSame754ArithmeticTypes)) {
|
||||
type = isSame754ArithmeticTypes ? left754Type.type : comparisonOperandType(leftType, rightType);
|
||||
leftValue = gen(left);
|
||||
@@ -5051,9 +5051,7 @@ The "returned" value of try expression with no finally is either the last expres
|
||||
return Unit.INSTANCE;
|
||||
}
|
||||
|
||||
CodegenUtilKt.generateAsCast(
|
||||
v, rightKotlinType, boxedRightType, safeAs, state.getLanguageVersionSettings(), state.getUnifiedNullChecks()
|
||||
);
|
||||
CodegenUtilKt.generateAsCast(v, rightKotlinType, boxedRightType, safeAs, state.getLanguageVersionSettings());
|
||||
|
||||
return Unit.INSTANCE;
|
||||
});
|
||||
|
||||
@@ -8,7 +8,6 @@ package org.jetbrains.kotlin.codegen;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.builtins.CompanionObjectMapping;
|
||||
import org.jetbrains.kotlin.builtins.CompanionObjectMappingUtilsKt;
|
||||
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper;
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.kotlin.load.java.JvmAbi;
|
||||
@@ -25,7 +24,7 @@ public class FieldInfo {
|
||||
throw new UnsupportedOperationException("Can't create singleton field for class: " + classDescriptor);
|
||||
}
|
||||
|
||||
if (isNonCompanionObject(classDescriptor) || CompanionObjectMappingUtilsKt.isMappedIntrinsicCompanionObject(CompanionObjectMapping.INSTANCE, classDescriptor)) {
|
||||
if (isNonCompanionObject(classDescriptor) || CompanionObjectMapping.INSTANCE.isMappedIntrinsicCompanionObject(classDescriptor)) {
|
||||
return createSingletonViaInstance(classDescriptor, typeMapper, JvmAbi.INSTANCE_FIELD);
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ import static org.jetbrains.kotlin.codegen.serialization.JvmSerializationBinding
|
||||
import static org.jetbrains.kotlin.codegen.state.KotlinTypeMapper.isAccessor;
|
||||
import static org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind.DECLARATION;
|
||||
import static org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind.DELEGATION;
|
||||
import static org.jetbrains.kotlin.descriptors.ModalityUtilsKt.isOverridable;
|
||||
import static org.jetbrains.kotlin.descriptors.ModalityKt.isOverridable;
|
||||
import static org.jetbrains.kotlin.resolve.DescriptorToSourceUtils.getSourceFromDescriptor;
|
||||
import static org.jetbrains.kotlin.resolve.DescriptorUtils.*;
|
||||
import static org.jetbrains.kotlin.resolve.inline.InlineOnlyKt.isInlineOnlyPrivateInBytecode;
|
||||
@@ -1152,7 +1152,7 @@ public class FunctionCodegen {
|
||||
// $default methods are never private to be accessible from other class files (e.g. inner) without the need of synthetic accessors
|
||||
// $default methods are never protected to be accessible from subclass nested classes
|
||||
int visibilityFlag =
|
||||
DescriptorVisibilities.isPrivate(functionDescriptor.getVisibility()) || isInlineOnlyPrivateInBytecode(functionDescriptor)
|
||||
Visibilities.isPrivate(functionDescriptor.getVisibility()) || isInlineOnlyPrivateInBytecode(functionDescriptor)
|
||||
? AsmUtil.NO_FLAG_PACKAGE_PRIVATE : Opcodes.ACC_PUBLIC;
|
||||
int flags = visibilityFlag | getDeprecatedAccessFlag(functionDescriptor) | ACC_SYNTHETIC;
|
||||
if (!(functionDescriptor instanceof ConstructorDescriptor &&
|
||||
@@ -1685,7 +1685,7 @@ public class FunctionCodegen {
|
||||
} else {
|
||||
switch (kind) {
|
||||
case DEFAULT_IMPLS: return true;
|
||||
case IMPLEMENTATION: return !DescriptorVisibilities.isPrivate(memberDescriptor.getVisibility()) && !isDefault && !isSynthetic;
|
||||
case IMPLEMENTATION: return !Visibilities.isPrivate(memberDescriptor.getVisibility()) && !isDefault && !isSynthetic;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,15 +62,12 @@ import org.jetbrains.org.objectweb.asm.commons.Method;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static org.jetbrains.kotlin.builtins.StandardNames.ENUM_VALUES;
|
||||
import static org.jetbrains.kotlin.builtins.StandardNames.ENUM_VALUE_OF;
|
||||
import static org.jetbrains.kotlin.codegen.AsmUtil.*;
|
||||
import static org.jetbrains.kotlin.codegen.CodegenUtilKt.isGenericToArray;
|
||||
import static org.jetbrains.kotlin.codegen.CodegenUtilKt.isNonGenericToArray;
|
||||
import static org.jetbrains.kotlin.codegen.JvmCodegenUtil.*;
|
||||
import static org.jetbrains.kotlin.codegen.binding.CodegenBinding.enumEntryNeedSubclass;
|
||||
import static org.jetbrains.kotlin.codegen.binding.CodegenBinding.getDelegatedLocalVariableMetadata;
|
||||
import static org.jetbrains.kotlin.load.java.DescriptorsJvmAbiUtil.*;
|
||||
import static org.jetbrains.kotlin.load.java.JvmAbi.*;
|
||||
import static org.jetbrains.kotlin.resolve.BindingContext.INDEXED_LVALUE_GET;
|
||||
import static org.jetbrains.kotlin.resolve.BindingContext.INDEXED_LVALUE_SET;
|
||||
@@ -817,7 +814,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
}
|
||||
if (properVisibilityForCompanionObjectInstanceField &&
|
||||
JvmCodegenUtil.isCompanionObjectInInterfaceNotIntrinsic(companionObjectDescriptor) &&
|
||||
DescriptorVisibilities.isPrivate(companionObjectDescriptor.getVisibility())) {
|
||||
Visibilities.isPrivate(companionObjectDescriptor.getVisibility())) {
|
||||
fieldAccessFlags |= ACC_SYNTHETIC;
|
||||
}
|
||||
StackValue.Field field = StackValue.singleton(companionObjectDescriptor, typeMapper);
|
||||
|
||||
@@ -65,7 +65,7 @@ class InterfaceImplBodyCodegen(
|
||||
if (memberDescriptor !is CallableMemberDescriptor) continue
|
||||
|
||||
if (memberDescriptor.kind.isReal) continue
|
||||
if (memberDescriptor.visibility == DescriptorVisibilities.INVISIBLE_FAKE) continue
|
||||
if (memberDescriptor.visibility == Visibilities.INVISIBLE_FAKE) continue
|
||||
if (memberDescriptor.modality == Modality.ABSTRACT) continue
|
||||
|
||||
val implementation = findImplementationFromInterface(memberDescriptor) ?: continue
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.codegen
|
||||
|
||||
import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMapper
|
||||
import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMap
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.findClassAcrossModuleDependencies
|
||||
@@ -42,7 +42,7 @@ class JvmBackendClassResolverForModuleWithDependencies(
|
||||
|
||||
val platformClass = moduleDescriptor.findClassAcrossModuleDependencies(type.classId) ?: return emptyList()
|
||||
|
||||
return JavaToKotlinClassMapper.mapPlatformClass(platformClass) + platformClass
|
||||
return JavaToKotlinClassMap.mapPlatformClass(platformClass) + platformClass
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,4 +54,4 @@ val Type.classId: ClassId
|
||||
val classRelativeNameWithDollars = if (lastDotIndex >= 0) className.substring(lastDotIndex + 1) else className
|
||||
val classFQN = FqName(classRelativeNameWithDollars.replace('$', '.'))
|
||||
return ClassId(packageFQN, classFQN, false)
|
||||
}
|
||||
}
|
||||
@@ -12,8 +12,6 @@ import kotlin.text.StringsKt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.backend.common.CodegenUtil;
|
||||
import org.jetbrains.kotlin.builtins.StandardNames;
|
||||
import org.jetbrains.kotlin.builtins.functions.BuiltInFunctionArity;
|
||||
import org.jetbrains.kotlin.builtins.functions.FunctionInvokeDescriptor;
|
||||
import org.jetbrains.kotlin.codegen.binding.CalculatedClosure;
|
||||
import org.jetbrains.kotlin.codegen.context.CodegenContext;
|
||||
@@ -29,7 +27,7 @@ import org.jetbrains.kotlin.config.LanguageVersionSettings;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.descriptors.impl.AnonymousFunctionDescriptor;
|
||||
import org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor;
|
||||
import org.jetbrains.kotlin.load.java.DescriptorsJvmAbiUtil;
|
||||
import org.jetbrains.kotlin.load.java.JvmAbi;
|
||||
import org.jetbrains.kotlin.load.java.descriptors.JavaCallableMemberDescriptor;
|
||||
import org.jetbrains.kotlin.load.java.descriptors.JavaPropertyDescriptor;
|
||||
import org.jetbrains.kotlin.load.kotlin.ModuleVisibilityUtilsKt;
|
||||
@@ -108,7 +106,7 @@ public class JvmCodegenUtil {
|
||||
boolean isDelegate = descriptor.getKind() == CallableMemberDescriptor.Kind.DELEGATION;
|
||||
|
||||
DeclarationDescriptor containingDeclaration = descriptor.getContainingDeclaration().getOriginal();
|
||||
if (DescriptorsJvmAbiUtil.isPropertyWithBackingFieldInOuterClass(descriptor)) {
|
||||
if (JvmAbi.isPropertyWithBackingFieldInOuterClass(descriptor)) {
|
||||
// For property with backed field, check if the access is done in the same class containing the backed field and
|
||||
// not the class that declared the field.
|
||||
containingDeclaration = containingDeclaration.getContainingDeclaration();
|
||||
@@ -221,7 +219,7 @@ public class JvmCodegenUtil {
|
||||
if (DescriptorPsiUtilsKt.hasBody(accessor)) return false;
|
||||
|
||||
// If the accessor is private or final, it can't be overridden in the subclass and thus we can use direct access
|
||||
return DescriptorVisibilities.isPrivate(accessor.getVisibility()) || accessor.getModality() == FINAL;
|
||||
return Visibilities.isPrivate(accessor.getVisibility()) || accessor.getModality() == FINAL;
|
||||
}
|
||||
|
||||
public static boolean isDebuggerContext(@NotNull CodegenContext context) {
|
||||
@@ -340,12 +338,12 @@ public class JvmCodegenUtil {
|
||||
public static boolean isCompanionObjectInInterfaceNotIntrinsic(@NotNull DeclarationDescriptor companionObject) {
|
||||
return isCompanionObject(companionObject) &&
|
||||
isJvmInterface(companionObject.getContainingDeclaration()) &&
|
||||
!DescriptorsJvmAbiUtil.isMappedIntrinsicCompanionObject((ClassDescriptor) companionObject);
|
||||
!JvmAbi.isMappedIntrinsicCompanionObject((ClassDescriptor) companionObject);
|
||||
}
|
||||
|
||||
public static boolean isNonIntrinsicPrivateCompanionObjectInInterface(@NotNull DeclarationDescriptorWithVisibility companionObject) {
|
||||
return isCompanionObjectInInterfaceNotIntrinsic(companionObject) &&
|
||||
DescriptorVisibilities.isPrivate(companionObject.getVisibility());
|
||||
Visibilities.isPrivate(companionObject.getVisibility());
|
||||
}
|
||||
|
||||
public static boolean isDeclarationOfBigArityFunctionInvoke(@Nullable DeclarationDescriptor descriptor) {
|
||||
@@ -354,7 +352,7 @@ public class JvmCodegenUtil {
|
||||
|
||||
public static boolean isDeclarationOfBigArityCreateCoroutineMethod(@Nullable DeclarationDescriptor descriptor) {
|
||||
return descriptor instanceof SimpleFunctionDescriptor && descriptor.getName().asString().equals(SUSPEND_FUNCTION_CREATE_METHOD_NAME) &&
|
||||
((SimpleFunctionDescriptor) descriptor).getValueParameters().size() >= BuiltInFunctionArity.BIG_ARITY - 1 &&
|
||||
((SimpleFunctionDescriptor) descriptor).getValueParameters().size() >= FunctionInvokeDescriptor.BIG_ARITY - 1 &&
|
||||
descriptor.getContainingDeclaration() instanceof AnonymousFunctionDescriptor && ((AnonymousFunctionDescriptor) descriptor.getContainingDeclaration()).isSuspend();
|
||||
}
|
||||
|
||||
@@ -406,7 +404,7 @@ public class JvmCodegenUtil {
|
||||
// The Result class is the only inline class in the standard library without special rules for equality.
|
||||
// We only call Result.equals-impl0 if we are compiling for Kotlin 1.4 or later. Otherwise, the code
|
||||
// might well be running against an older version of the standard library.
|
||||
if (DescriptorUtils.getFqNameSafe(classDescriptor).equals(StandardNames.RESULT_FQ_NAME)) {
|
||||
if (DescriptorUtils.getFqNameSafe(classDescriptor).equals(DescriptorUtils.RESULT_FQ_NAME)) {
|
||||
return state.getLanguageVersionSettings().getApiVersion().compareTo(ApiVersion.KOTLIN_1_4) >= 0;
|
||||
} else {
|
||||
return ((DeserializedClassDescriptor) descriptor).getMetadataVersion().isAtLeast(1, 1, 16);
|
||||
|
||||
@@ -86,7 +86,7 @@ class JvmRuntimeTypes(
|
||||
packageFragment, classKind, false, false, Name.identifier(name), SourceElement.NO_SOURCE, LockBasedStorageManager.NO_LOCKS
|
||||
).apply {
|
||||
modality = Modality.FINAL
|
||||
visibility = DescriptorVisibilities.PUBLIC
|
||||
visibility = Visibilities.PUBLIC
|
||||
setTypeParameterDescriptors(emptyList())
|
||||
createTypeConstructor()
|
||||
}
|
||||
|
||||
@@ -25,8 +25,7 @@ import org.jetbrains.kotlin.descriptors.annotations.AnnotatedImpl;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl;
|
||||
import org.jetbrains.kotlin.fileClasses.JvmFileClassUtil;
|
||||
import org.jetbrains.kotlin.load.java.DescriptorsJvmAbiUtil;
|
||||
import org.jetbrains.kotlin.load.java.JavaDescriptorVisibilities;
|
||||
import org.jetbrains.kotlin.load.java.JavaVisibilities;
|
||||
import org.jetbrains.kotlin.load.java.JvmAbi;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.name.SpecialNames;
|
||||
@@ -469,7 +468,7 @@ public abstract class MemberCodegen<T extends KtPureElement/* TODO: & KtDeclarat
|
||||
Name.special("<clinit>"), SYNTHESIZED, KotlinSourceElementKt.toSourceElement(element));
|
||||
clInit.initialize(null, null, Collections.emptyList(), Collections.emptyList(),
|
||||
DescriptorUtilsKt.getModule(descriptor).getBuiltIns().getUnitType(),
|
||||
Modality.FINAL, DescriptorVisibilities.PRIVATE);
|
||||
Modality.FINAL, Visibilities.PRIVATE);
|
||||
return clInit;
|
||||
}
|
||||
|
||||
@@ -878,11 +877,11 @@ public abstract class MemberCodegen<T extends KtPureElement/* TODO: & KtDeclarat
|
||||
AccessorKind fieldAccessorKind = accessor instanceof AccessorForPropertyBackingField
|
||||
? accessor.getAccessorKind() : null;
|
||||
boolean syntheticBackingField = fieldAccessorKind == AccessorKind.FIELD_FROM_LOCAL;
|
||||
boolean forceFieldForCompanionProperty = DescriptorsJvmAbiUtil.isPropertyWithBackingFieldInOuterClass(original) &&
|
||||
boolean forceFieldForCompanionProperty = JvmAbi.isPropertyWithBackingFieldInOuterClass(original) &&
|
||||
!isCompanionObject(accessor.getContainingDeclaration());
|
||||
boolean forceField = forceFieldForCompanionProperty ||
|
||||
syntheticBackingField ||
|
||||
original.getVisibility() == JavaDescriptorVisibilities.PROTECTED_STATIC_VISIBILITY;
|
||||
original.getVisibility() == JavaVisibilities.PROTECTED_STATIC_VISIBILITY;
|
||||
StackValue property = codegen.intermediateValueForProperty(
|
||||
original, forceField, syntheticBackingField, accessor.getSuperCallTarget(),
|
||||
forceFieldForCompanionProperty, StackValue.none(), null,
|
||||
|
||||
@@ -224,7 +224,7 @@ class MultifileClassCodegenImpl(
|
||||
}
|
||||
|
||||
private fun shouldGenerateInFacade(descriptor: MemberDescriptor): Boolean {
|
||||
if (DescriptorVisibilities.isPrivate(descriptor.visibility)) return false
|
||||
if (Visibilities.isPrivate(descriptor.visibility)) return false
|
||||
if (AsmUtil.getVisibilityAccessFlag(descriptor) == Opcodes.ACC_PRIVATE) return false
|
||||
|
||||
if (!state.classBuilderMode.generateBodies) return true
|
||||
|
||||
@@ -19,7 +19,6 @@ import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper;
|
||||
import org.jetbrains.kotlin.config.LanguageFeature;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||
import org.jetbrains.kotlin.load.java.DescriptorsJvmAbiUtil;
|
||||
import org.jetbrains.kotlin.load.java.JvmAbi;
|
||||
import org.jetbrains.kotlin.psi.*;
|
||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
@@ -160,7 +159,7 @@ public class PropertyCodegen {
|
||||
|
||||
private void genBackingFieldAndAnnotations(@NotNull PropertyDescriptor descriptor) {
|
||||
// Fields and '$annotations' methods for non-private const properties are generated in the multi-file facade
|
||||
boolean isBackingFieldOwner = descriptor.isConst() && !DescriptorVisibilities.isPrivate(descriptor.getVisibility())
|
||||
boolean isBackingFieldOwner = descriptor.isConst() && !Visibilities.isPrivate(descriptor.getVisibility())
|
||||
? !(context instanceof MultifileClassPartContext)
|
||||
: CodegenContextUtil.isImplementationOwner(context, descriptor);
|
||||
|
||||
@@ -218,7 +217,7 @@ public class PropertyCodegen {
|
||||
// and setter, in this case, the property can always be accessed through the accessor 'access<property name>$cp' and avoid some
|
||||
// useless indirection by using others accessors.
|
||||
if (isCompanionObject(descriptor.getContainingDeclaration())) {
|
||||
if (DescriptorVisibilities.isPrivate(descriptor.getVisibility()) && isDefaultGetterAndSetter) {
|
||||
if (Visibilities.isPrivate(descriptor.getVisibility()) && isDefaultGetterAndSetter) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -228,14 +227,14 @@ public class PropertyCodegen {
|
||||
if (isTopLevelInJvmMultifileClass(descriptor)) return true;
|
||||
|
||||
// Private class properties have accessors only in cases when those accessors are non-trivial
|
||||
if (DescriptorVisibilities.isPrivate(descriptor.getVisibility())) {
|
||||
if (Visibilities.isPrivate(descriptor.getVisibility())) {
|
||||
return !isDefaultAccessor;
|
||||
}
|
||||
|
||||
// Non-private properties with private setter should not be generated for trivial properties
|
||||
// as the class will use direct field access instead
|
||||
//noinspection ConstantConditions
|
||||
if (accessor != null && accessor.isSetter() && DescriptorVisibilities.isPrivate(descriptor.getSetter().getVisibility())) {
|
||||
if (accessor != null && accessor.isSetter() && Visibilities.isPrivate(descriptor.getSetter().getVisibility())) {
|
||||
return !isDefaultAccessor;
|
||||
}
|
||||
|
||||
@@ -254,12 +253,12 @@ public class PropertyCodegen {
|
||||
if (hasJvmFieldAnnotation(descriptor)) return false;
|
||||
if (kind == OwnerKind.ERASED_INLINE_CLASS) return false;
|
||||
|
||||
DescriptorVisibility visibility = descriptor.getVisibility();
|
||||
Visibility visibility = descriptor.getVisibility();
|
||||
if (InlineClassesUtilsKt.isInlineClass(descriptor.getContainingDeclaration())) {
|
||||
return visibility.isPublicAPI();
|
||||
}
|
||||
else {
|
||||
return !DescriptorVisibilities.isPrivate(visibility);
|
||||
return !Visibilities.isPrivate(visibility);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -411,7 +410,7 @@ public class PropertyCodegen {
|
||||
if (AsmUtil.isInstancePropertyWithStaticBackingField(propertyDescriptor) ) {
|
||||
modifiers |= ACC_STATIC;
|
||||
|
||||
if (DescriptorsJvmAbiUtil.isPropertyWithBackingFieldInOuterClass(propertyDescriptor)) {
|
||||
if (JvmAbi.isPropertyWithBackingFieldInOuterClass(propertyDescriptor)) {
|
||||
ImplementationBodyCodegen codegen = (ImplementationBodyCodegen) memberCodegen.getParentCodegen();
|
||||
builder = codegen.v;
|
||||
backingFieldContext = codegen.context;
|
||||
@@ -512,7 +511,7 @@ public class PropertyCodegen {
|
||||
|
||||
private void generateAccessor(@Nullable KtPropertyAccessor accessor, @NotNull PropertyAccessorDescriptor descriptor) {
|
||||
if (context instanceof MultifileClassFacadeContext &&
|
||||
(DescriptorVisibilities.isPrivate(descriptor.getVisibility()) ||
|
||||
(Visibilities.isPrivate(descriptor.getVisibility()) ||
|
||||
AsmUtil.getVisibilityAccessFlag(descriptor) == Opcodes.ACC_PRIVATE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ public class SamWrapperCodegen {
|
||||
SimpleFunctionDescriptor erasedInterfaceFunction = samType.getOriginalAbstractMethod().copy(
|
||||
classDescriptor,
|
||||
Modality.FINAL,
|
||||
DescriptorVisibilities.PUBLIC,
|
||||
Visibilities.PUBLIC,
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED,
|
||||
/*copyOverrides=*/ false
|
||||
);
|
||||
@@ -268,12 +268,12 @@ public class SamWrapperCodegen {
|
||||
if (!(descriptor instanceof CallableMemberDescriptor)) continue;
|
||||
CallableMemberDescriptor member = (CallableMemberDescriptor) descriptor;
|
||||
if (member.getModality() == Modality.ABSTRACT ||
|
||||
DescriptorVisibilities.isPrivate(member.getVisibility()) ||
|
||||
member.getVisibility() == DescriptorVisibilities.INVISIBLE_FAKE ||
|
||||
Visibilities.isPrivate(member.getVisibility()) ||
|
||||
member.getVisibility() == Visibilities.INVISIBLE_FAKE ||
|
||||
DescriptorUtils.isMethodOfAny(member)) continue;
|
||||
|
||||
for (Map.Entry<FunctionDescriptor, FunctionDescriptor> entry : CodegenUtil.INSTANCE.copyFunctions(
|
||||
member, member, classDescriptor, Modality.OPEN, DescriptorVisibilities.PUBLIC, CallableMemberDescriptor.Kind.DECLARATION, false
|
||||
member, member, classDescriptor, Modality.OPEN, Visibilities.PUBLIC, CallableMemberDescriptor.Kind.DECLARATION, false
|
||||
).entrySet()) {
|
||||
ClassBodyCodegen.generateDelegationToDefaultImpl(entry.getKey(), entry.getValue(), receiverType, functionCodegen, state, false);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper;
|
||||
import org.jetbrains.kotlin.config.LanguageFeature;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.descriptors.impl.SyntheticFieldDescriptor;
|
||||
import org.jetbrains.kotlin.load.java.DescriptorsJvmAbiUtil;
|
||||
import org.jetbrains.kotlin.load.java.JvmAbi;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.psi.KtExpression;
|
||||
@@ -1544,7 +1543,7 @@ public abstract class StackValue {
|
||||
|
||||
//TODO: try to don't generate defaults at all in CollectionElementReceiver
|
||||
|
||||
List<ResolvedValueArgument> getterArguments = new ArrayList<>(collectionElementReceiver.valueArguments);
|
||||
List<ResolvedValueArgument> getterArguments = new ArrayList(collectionElementReceiver.valueArguments);
|
||||
List<ResolvedValueArgument> getterDefaults = CollectionsKt.takeLastWhile(getterArguments,
|
||||
argument -> argument instanceof DefaultValueArgument);
|
||||
|
||||
@@ -1762,7 +1761,7 @@ public abstract class StackValue {
|
||||
// is from a different context), the assertion will be generated on each access, see KT-28331.
|
||||
if (descriptor instanceof AccessorForPropertyBackingField) {
|
||||
PropertyDescriptor property = ((AccessorForPropertyBackingField) descriptor).getCalleeDescriptor();
|
||||
if (!skipLateinitAssertion && property.isLateInit() && DescriptorsJvmAbiUtil.isPropertyWithBackingFieldInOuterClass(property) &&
|
||||
if (!skipLateinitAssertion && property.isLateInit() && JvmAbi.isPropertyWithBackingFieldInOuterClass(property) &&
|
||||
!JvmCodegenUtil.couldUseDirectAccessToProperty(property, true, false, codegen.context, false)) {
|
||||
genNonNullAssertForLateinit(v, property.getName().asString());
|
||||
}
|
||||
|
||||
@@ -616,7 +616,7 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid {
|
||||
String nameForClassOrPackageMember = getNameForClassOrPackageMember(functionDescriptor);
|
||||
|
||||
if (functionDescriptor instanceof SimpleFunctionDescriptor && functionDescriptor.isSuspend() &&
|
||||
!functionDescriptor.getVisibility().equals(DescriptorVisibilities.LOCAL)) {
|
||||
!functionDescriptor.getVisibility().equals(Visibilities.LOCAL)) {
|
||||
|
||||
if (nameForClassOrPackageMember != null) {
|
||||
nameStack.push(nameForClassOrPackageMember);
|
||||
@@ -821,17 +821,20 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid {
|
||||
|
||||
Map<ValueParameterDescriptor, ResolvedValueArgument> arguments = newResolvedCall.getValueArguments();
|
||||
for (ValueParameterDescriptor valueParameter : arguments.keySet()) {
|
||||
SamType samType = SamType.createByValueParameter(valueParameter);
|
||||
if (samType == null) continue;
|
||||
|
||||
ResolvedValueArgument argument = arguments.get(valueParameter);
|
||||
if (argument instanceof ExpressionValueArgument) {
|
||||
ValueArgument valueArgument = ((ExpressionValueArgument) argument).getValueArgument();
|
||||
if (valueArgument != null && newResolvedCall.getExpectedTypeForSamConvertedArgument(valueArgument) != null) {
|
||||
recordSamTypeOnArgumentExpression(valueParameter, valueArgument);
|
||||
recordSamTypeOnArgumentExpression(samType, valueArgument);
|
||||
}
|
||||
} else if (argument instanceof VarargValueArgument) {
|
||||
VarargValueArgument varargValueArgument = (VarargValueArgument) argument;
|
||||
for (ValueArgument valueArgument : varargValueArgument.getArguments()) {
|
||||
if (valueArgument != null && newResolvedCall.getExpectedTypeForSamConvertedArgument(valueArgument) != null) {
|
||||
recordSamTypeOnArgumentExpression(valueParameter, valueArgument);
|
||||
recordSamTypeOnArgumentExpression(samType, valueArgument);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -869,13 +872,6 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid {
|
||||
}
|
||||
}
|
||||
|
||||
private void recordSamTypeOnArgumentExpression(ValueParameterDescriptor valueParameter, ValueArgument valueArgument) {
|
||||
SamType samType = SamType.createByValueParameter(valueParameter);
|
||||
if (samType == null) return;
|
||||
|
||||
recordSamTypeOnArgumentExpression(samType, valueArgument);
|
||||
}
|
||||
|
||||
private void recordSamTypeOnArgumentExpression(SamType samType, ValueArgument valueArgument) {
|
||||
KtExpression argumentExpression = valueArgument.getArgumentExpression();
|
||||
assert argumentExpression != null : valueArgument.asElement().getText();
|
||||
|
||||
@@ -19,13 +19,14 @@ import org.jetbrains.kotlin.codegen.inline.ReificationArgument
|
||||
import org.jetbrains.kotlin.codegen.intrinsics.TypeIntrinsics
|
||||
import org.jetbrains.kotlin.codegen.state.GenerationState
|
||||
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper
|
||||
import org.jetbrains.kotlin.config.ApiVersion
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.config.isReleaseCoroutines
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.deserialization.PLATFORM_DEPENDENT_ANNOTATION_FQ_NAME
|
||||
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl
|
||||
import org.jetbrains.kotlin.load.java.BuiltinMethodsWithSpecialGenericSignature.SpecialSignatureInfo
|
||||
import org.jetbrains.kotlin.load.java.DescriptorsJvmAbiUtil
|
||||
import org.jetbrains.kotlin.load.java.JvmAbi
|
||||
import org.jetbrains.kotlin.load.java.descriptors.JavaCallableMemberDescriptor
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
@@ -97,12 +98,11 @@ fun generateAsCast(
|
||||
kotlinType: KotlinType,
|
||||
asmType: Type,
|
||||
isSafe: Boolean,
|
||||
languageVersionSettings: LanguageVersionSettings,
|
||||
unifiedNullChecks: Boolean,
|
||||
languageVersionSettings: LanguageVersionSettings
|
||||
) {
|
||||
if (!isSafe) {
|
||||
if (!TypeUtils.isNullableType(kotlinType)) {
|
||||
generateNullCheckForNonSafeAs(v, kotlinType, unifiedNullChecks)
|
||||
generateNullCheckForNonSafeAs(v, kotlinType, languageVersionSettings)
|
||||
}
|
||||
} else {
|
||||
with(v) {
|
||||
@@ -122,13 +122,15 @@ fun generateAsCast(
|
||||
private fun generateNullCheckForNonSafeAs(
|
||||
v: InstructionAdapter,
|
||||
type: KotlinType,
|
||||
unifiedNullChecks: Boolean,
|
||||
languageVersionSettings: LanguageVersionSettings
|
||||
) {
|
||||
with(v) {
|
||||
dup()
|
||||
val nonnull = Label()
|
||||
ifnonnull(nonnull)
|
||||
val exceptionClass = if (unifiedNullChecks) "java/lang/NullPointerException" else "kotlin/TypeCastException"
|
||||
val exceptionClass =
|
||||
if (languageVersionSettings.apiVersion >= ApiVersion.KOTLIN_1_4) "java/lang/NullPointerException"
|
||||
else "kotlin/TypeCastException"
|
||||
AsmUtil.genThrow(
|
||||
v,
|
||||
exceptionClass,
|
||||
@@ -152,7 +154,7 @@ fun populateCompanionBackingFieldNamesToOuterContextIfNeeded(
|
||||
return
|
||||
}
|
||||
|
||||
if (!DescriptorsJvmAbiUtil.isClassCompanionObjectWithBackingFieldsInOuter(descriptor)) {
|
||||
if (!JvmAbi.isClassCompanionObjectWithBackingFieldsInOuter(descriptor)) {
|
||||
return
|
||||
}
|
||||
val properties = companion.declarations.filterIsInstance<KtProperty>()
|
||||
@@ -683,4 +685,4 @@ internal fun LabelNode.linkWithLabel(): LabelNode {
|
||||
return this
|
||||
}
|
||||
|
||||
fun linkedLabel(): Label = LabelNode().linkWithLabel().label
|
||||
fun linkedLabel(): Label = LabelNode().linkWithLabel().label
|
||||
@@ -14,7 +14,7 @@ import org.jetbrains.kotlin.codegen.state.GenerationState;
|
||||
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper;
|
||||
import org.jetbrains.kotlin.config.JvmDefaultMode;
|
||||
import org.jetbrains.kotlin.descriptors.*;
|
||||
import org.jetbrains.kotlin.load.java.JavaDescriptorVisibilities;
|
||||
import org.jetbrains.kotlin.load.java.JavaVisibilities;
|
||||
import org.jetbrains.kotlin.resolve.sam.SamConstructorDescriptor;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.psi.KtFile;
|
||||
@@ -625,7 +625,7 @@ public abstract class CodegenContext<T extends DeclarationDescriptor> {
|
||||
}
|
||||
|
||||
if (descriptorContext == null &&
|
||||
JavaDescriptorVisibilities.PROTECTED_STATIC_VISIBILITY == descriptor.getVisibility() &&
|
||||
JavaVisibilities.PROTECTED_STATIC_VISIBILITY == descriptor.getVisibility() &&
|
||||
(!(descriptor.getOriginal() instanceof SamConstructorDescriptor))) {
|
||||
//seems we need static receiver in resolved call
|
||||
descriptorContext = ExpressionCodegen.getParentContextSubclassOf((ClassDescriptor) enclosed, this);
|
||||
@@ -672,7 +672,7 @@ public abstract class CodegenContext<T extends DeclarationDescriptor> {
|
||||
PropertySetterDescriptor setter = propertyDescriptor.getSetter();
|
||||
|
||||
int setterAccessFlag = propertyAccessFlag;
|
||||
if (setter != null && setter.getVisibility().normalize() != DescriptorVisibilities.INVISIBLE_FAKE) {
|
||||
if (setter != null && setter.getVisibility().normalize() != Visibilities.INVISIBLE_FAKE) {
|
||||
setterAccessFlag = propertyAccessFlag | getVisibilityAccessFlag(setter);
|
||||
}
|
||||
boolean setterAccessorRequired = isAccessorRequired(setterAccessFlag, unwrappedDescriptor, descriptorContext,
|
||||
|
||||
@@ -43,6 +43,7 @@ import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature
|
||||
import org.jetbrains.kotlin.serialization.DescriptorSerializer
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.typeUtil.makeNullable
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
import org.jetbrains.kotlin.utils.sure
|
||||
import org.jetbrains.org.objectweb.asm.Label
|
||||
import org.jetbrains.org.objectweb.asm.MethodVisitor
|
||||
@@ -94,7 +95,7 @@ abstract class AbstractCoroutineCodegen(
|
||||
},
|
||||
builtIns.nullableAnyType,
|
||||
Modality.FINAL,
|
||||
DescriptorVisibilities.PUBLIC,
|
||||
Visibilities.PUBLIC,
|
||||
userDataForDoResume
|
||||
)
|
||||
}
|
||||
@@ -103,9 +104,9 @@ abstract class AbstractCoroutineCodegen(
|
||||
ValueParameterDescriptorImpl(
|
||||
this, null, index, Annotations.EMPTY, name,
|
||||
type,
|
||||
declaresDefaultValue = false, isCrossinline = false,
|
||||
isNoinline = false,
|
||||
varargElementType = null, source = SourceElement.NO_SOURCE
|
||||
false, false,
|
||||
false,
|
||||
null, SourceElement.NO_SOURCE
|
||||
)
|
||||
|
||||
override fun generateConstructor(): Method {
|
||||
@@ -156,7 +157,7 @@ abstract class AbstractCoroutineCodegen(
|
||||
return constructor
|
||||
}
|
||||
|
||||
protected abstract val passArityToSuperClass: Boolean
|
||||
abstract protected val passArityToSuperClass: Boolean
|
||||
}
|
||||
|
||||
class CoroutineCodegenForLambda private constructor(
|
||||
@@ -186,23 +187,6 @@ class CoroutineCodegenForLambda private constructor(
|
||||
|
||||
private val endLabel = Label()
|
||||
|
||||
private val varsCountByType = hashMapOf<Type, Int>()
|
||||
|
||||
private val fieldsForParameters: Map<ParameterDescriptor, FieldInfo> = createFieldsForParameters()
|
||||
|
||||
private fun createFieldsForParameters(): Map<ParameterDescriptor, FieldInfo> {
|
||||
val result = hashMapOf<ParameterDescriptor, FieldInfo>()
|
||||
for (parameter in allFunctionParameters()) {
|
||||
if (parameter.isUnused()) continue
|
||||
val type = state.typeMapper.mapType(parameter.type)
|
||||
val normalizedType = type.normalize()
|
||||
val index = varsCountByType[normalizedType]?.plus(1) ?: 0
|
||||
varsCountByType[normalizedType] = index
|
||||
result[parameter] = createHiddenFieldInfo(parameter.type, "${normalizedType.descriptor[0]}$$index")
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
private fun getCreateFunction(): SimpleFunctionDescriptor = SimpleFunctionDescriptorImpl.create(
|
||||
funDescriptor.containingDeclaration,
|
||||
Annotations.EMPTY,
|
||||
@@ -220,7 +204,7 @@ class CoroutineCodegenForLambda private constructor(
|
||||
state.languageVersionSettings.supportsFeature(LanguageFeature.ReleaseCoroutines)
|
||||
),
|
||||
funDescriptor.modality,
|
||||
DescriptorVisibilities.PUBLIC
|
||||
Visibilities.PUBLIC
|
||||
)
|
||||
}
|
||||
|
||||
@@ -248,7 +232,8 @@ class CoroutineCodegenForLambda private constructor(
|
||||
|
||||
override fun generateClosureBody() {
|
||||
for (parameter in allFunctionParameters()) {
|
||||
val fieldInfo = fieldsForParameters[parameter] ?: continue
|
||||
if (parameter.isUnused()) continue
|
||||
val fieldInfo = parameter.getFieldInfoForCoroutineLambdaParameter()
|
||||
v.newField(
|
||||
OtherOrigin(parameter),
|
||||
Opcodes.ACC_PRIVATE + Opcodes.ACC_SYNTHETIC,
|
||||
@@ -272,7 +257,7 @@ class CoroutineCodegenForLambda private constructor(
|
||||
super.generateBody()
|
||||
|
||||
if (doNotGenerateInvokeBridge) {
|
||||
v.serializationBindings.put(
|
||||
v.serializationBindings.put<FunctionDescriptor, Method>(
|
||||
METHOD_FOR_FUNCTION,
|
||||
originalSuspendFunctionDescriptor,
|
||||
typeMapper.mapAsmMethod(erasedInvokeFunction)
|
||||
@@ -335,7 +320,7 @@ class CoroutineCodegenForLambda private constructor(
|
||||
newarray(AsmTypes.OBJECT_TYPE)
|
||||
// 0 - this
|
||||
// 1..22 - parameters
|
||||
// 23 - first empty slot
|
||||
// 23 - first empy slot
|
||||
val arraySlot = 23
|
||||
store(arraySlot, AsmTypes.OBJECT_TYPE)
|
||||
for ((varIndex, type) in parameterTypes.withVariableIndices()) {
|
||||
@@ -420,8 +405,8 @@ class CoroutineCodegenForLambda private constructor(
|
||||
// Pass lambda parameters to 'invoke' call on newly constructed object
|
||||
var index = 1
|
||||
for (parameter in allFunctionParameters()) {
|
||||
val fieldInfoForCoroutineLambdaParameter = fieldsForParameters[parameter]
|
||||
if (fieldInfoForCoroutineLambdaParameter != null) {
|
||||
val fieldInfoForCoroutineLambdaParameter = parameter.getFieldInfoForCoroutineLambdaParameter()
|
||||
if (!parameter.isUnused()) {
|
||||
if (isBigArity) {
|
||||
load(cloneIndex, fieldInfoForCoroutineLambdaParameter.ownerType)
|
||||
load(1, AsmTypes.OBJECT_TYPE)
|
||||
@@ -457,7 +442,7 @@ class CoroutineCodegenForLambda private constructor(
|
||||
)
|
||||
}
|
||||
}
|
||||
index += if (isBigArity || generateErasedCreate) 1 else state.typeMapper.mapType(parameter.type).size
|
||||
index += if (isBigArity || generateErasedCreate) 1 else fieldInfoForCoroutineLambdaParameter.fieldType.size
|
||||
}
|
||||
|
||||
load(cloneIndex, AsmTypes.OBJECT_TYPE)
|
||||
@@ -467,22 +452,17 @@ class CoroutineCodegenForLambda private constructor(
|
||||
|
||||
private fun ExpressionCodegen.initializeCoroutineParameters() {
|
||||
for (parameter in allFunctionParameters()) {
|
||||
val fieldForParameter = fieldsForParameters[parameter] ?: continue
|
||||
val fieldStackValue = StackValue.field(fieldForParameter, generateThisOrOuter(context.thisDescriptor, false))
|
||||
if (parameter.isUnused()) continue
|
||||
val fieldStackValue =
|
||||
StackValue.field(
|
||||
parameter.getFieldInfoForCoroutineLambdaParameter(), generateThisOrOuter(context.thisDescriptor, false)
|
||||
)
|
||||
|
||||
val originalType = typeMapper.mapType(parameter.type)
|
||||
// If a parameter has reference type, it has prefix L$,
|
||||
// however, when the type is primitive, its prefix is ${type.descriptor}$.
|
||||
// In other words, it the type is Boolean, the prefix is Z$.
|
||||
// This is different from spilled variables, where all int-like primitives have prefix I$.
|
||||
// This is not a problem, since we do not clean spilled primitives up
|
||||
// and we do not coerce Int to Boolean, which takes quite a bit of bytecode (see coerceInt).
|
||||
val normalizedType = originalType.normalize()
|
||||
fieldStackValue.put(normalizedType, v)
|
||||
val mappedType = typeMapper.mapType(parameter.type)
|
||||
fieldStackValue.put(mappedType, v)
|
||||
|
||||
val newIndex = myFrameMap.enter(parameter, originalType)
|
||||
StackValue.coerce(normalizedType, originalType, v)
|
||||
v.store(newIndex, originalType)
|
||||
val newIndex = myFrameMap.enter(parameter, mappedType)
|
||||
v.store(newIndex, mappedType)
|
||||
|
||||
val name =
|
||||
if (parameter is ReceiverParameterDescriptor)
|
||||
@@ -491,7 +471,7 @@ class CoroutineCodegenForLambda private constructor(
|
||||
(getNameForDestructuredParameterOrNull(parameter as ValueParameterDescriptor) ?: parameter.name.asString())
|
||||
val label = Label()
|
||||
v.mark(label)
|
||||
v.visitLocalVariable(name, originalType.descriptor, null, label, endLabel, newIndex)
|
||||
v.visitLocalVariable(name, mappedType.descriptor, null, label, endLabel, newIndex)
|
||||
}
|
||||
|
||||
initializeVariablesForDestructuredLambdaParameters(
|
||||
@@ -505,10 +485,13 @@ class CoroutineCodegenForLambda private constructor(
|
||||
originalSuspendFunctionDescriptor.extensionReceiverParameter.let(::listOfNotNull) +
|
||||
originalSuspendFunctionDescriptor.valueParameters
|
||||
|
||||
private fun ParameterDescriptor.getFieldInfoForCoroutineLambdaParameter() =
|
||||
createHiddenFieldInfo(type, COROUTINE_LAMBDA_PARAMETER_PREFIX + (this.safeAs<ValueParameterDescriptor>()?.index ?: ""))
|
||||
|
||||
private fun createHiddenFieldInfo(type: KotlinType, name: String) =
|
||||
FieldInfo.createForHiddenField(
|
||||
typeMapper.mapClass(closureContext.thisDescriptor),
|
||||
typeMapper.mapType(type).normalize(),
|
||||
typeMapper.mapType(type),
|
||||
type,
|
||||
name
|
||||
)
|
||||
@@ -531,8 +514,7 @@ class CoroutineCodegenForLambda private constructor(
|
||||
isForNamedFunction = false,
|
||||
languageVersionSettings = languageVersionSettings,
|
||||
disableTailCallOptimizationForFunctionReturningUnit = false,
|
||||
useOldSpilledVarTypeAnalysis = state.configuration.getBoolean(JVMConfigurationKeys.USE_OLD_SPILLED_VAR_TYPE_ANALYSIS),
|
||||
initialVarsCountByType = varsCountByType
|
||||
useOldSpilledVarTypeAnalysis = state.configuration.getBoolean(JVMConfigurationKeys.USE_OLD_SPILLED_VAR_TYPE_ANALYSIS)
|
||||
)
|
||||
val maybeWithForInline = if (forInline)
|
||||
SuspendForInlineCopyingMethodVisitor(stateMachineBuilder, access, name, desc, functionCodegen::newMethod)
|
||||
@@ -776,11 +758,16 @@ class CoroutineCodegenForNamedFunction private constructor(
|
||||
declaration: KtFunction
|
||||
): CoroutineCodegenForNamedFunction {
|
||||
val bindingContext = expressionCodegen.state.bindingContext
|
||||
val closure = bindingContext[CLOSURE, bindingContext[CodegenBinding.CLASS_FOR_CALLABLE, originalSuspendDescriptor]]
|
||||
.sure { "There must be a closure defined for $originalSuspendDescriptor" }
|
||||
val closure =
|
||||
bindingContext[
|
||||
CodegenBinding.CLOSURE,
|
||||
bindingContext[CodegenBinding.CLASS_FOR_CALLABLE, originalSuspendDescriptor]
|
||||
].sure { "There must be a closure defined for $originalSuspendDescriptor" }
|
||||
|
||||
val suspendFunctionView = bindingContext[CodegenBinding.SUSPEND_FUNCTION_TO_JVM_VIEW, originalSuspendDescriptor]
|
||||
.sure { "There must be a jvm view defined for $originalSuspendDescriptor" }
|
||||
val suspendFunctionView =
|
||||
bindingContext[
|
||||
CodegenBinding.SUSPEND_FUNCTION_TO_JVM_VIEW, originalSuspendDescriptor
|
||||
].sure { "There must be a jvm view defined for $originalSuspendDescriptor" }
|
||||
|
||||
if (suspendFunctionView.dispatchReceiverParameter != null) {
|
||||
closure.setNeedsCaptureOuterClass()
|
||||
@@ -798,8 +785,10 @@ class CoroutineCodegenForNamedFunction private constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private const val COROUTINE_LAMBDA_PARAMETER_PREFIX = "p$"
|
||||
|
||||
private object FailingFunctionGenerationStrategy : FunctionGenerationStrategy() {
|
||||
override fun skipNotNullAssertionsForParameters(): Boolean {
|
||||
override fun skipNotNullAssertionsForParameters(): kotlin.Boolean {
|
||||
error("This functions must not be called")
|
||||
}
|
||||
|
||||
@@ -816,4 +805,4 @@ private object FailingFunctionGenerationStrategy : FunctionGenerationStrategy()
|
||||
|
||||
fun reportSuspensionPointInsideMonitor(element: KtElement, state: GenerationState, stackTraceElement: String) {
|
||||
state.diagnostics.report(ErrorsJvm.SUSPENSION_POINT_INSIDE_MONITOR.on(element, stackTraceElement))
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,6 @@ import org.jetbrains.org.objectweb.asm.Opcodes
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
|
||||
import org.jetbrains.org.objectweb.asm.tree.*
|
||||
import org.jetbrains.org.objectweb.asm.tree.analysis.BasicValue
|
||||
import kotlin.math.max
|
||||
|
||||
private const val COROUTINES_DEBUG_METADATA_VERSION = 1
|
||||
@@ -64,9 +63,7 @@ class CoroutineTransformerMethodVisitor(
|
||||
// JVM_IR backend generates $completion, while old backend does not
|
||||
private val putContinuationParameterToLvt: Boolean = true,
|
||||
// New SourceInterpreter-less analyser can be somewhat unstable, disable it
|
||||
private val useOldSpilledVarTypeAnalysis: Boolean = false,
|
||||
// Parameters of suspend lambda are put to the same fields as spilled variables
|
||||
private val initialVarsCountByType: Map<Type, Int> = emptyMap()
|
||||
private val useOldSpilledVarTypeAnalysis: Boolean = false
|
||||
) : TransformationMethodVisitor(delegate, access, name, desc, signature, exceptions) {
|
||||
|
||||
private val classBuilderForCoroutineState: ClassBuilder by lazy(obtainClassBuilderForCoroutineState)
|
||||
@@ -143,11 +140,9 @@ class CoroutineTransformerMethodVisitor(
|
||||
|
||||
val suspensionPointLineNumbers = suspensionPoints.map { findSuspensionPointLineNumber(it) }
|
||||
|
||||
// Create states in state-machine, to which state-machine can jump
|
||||
val stateLabels = suspensionPoints.withIndex().map {
|
||||
transformCallAndReturnStateLabel(
|
||||
it.index + 1, it.value, methodNode, suspendMarkerVarIndex, suspensionPointLineNumbers[it.index]
|
||||
)
|
||||
val continuationLabels = suspensionPoints.withIndex().map {
|
||||
transformCallAndReturnContinuationLabel(
|
||||
it.index + 1, it.value, methodNode, suspendMarkerVarIndex, suspensionPointLineNumbers[it.index])
|
||||
}
|
||||
|
||||
methodNode.instructions.apply {
|
||||
@@ -170,7 +165,7 @@ class CoroutineTransformerMethodVisitor(
|
||||
0,
|
||||
suspensionPoints.size,
|
||||
defaultLabel,
|
||||
firstStateLabel, *stateLabels.toTypedArray()
|
||||
firstStateLabel, *continuationLabels.toTypedArray()
|
||||
),
|
||||
firstStateLabel
|
||||
)
|
||||
@@ -187,8 +182,6 @@ class CoroutineTransformerMethodVisitor(
|
||||
})
|
||||
}
|
||||
|
||||
initializeFakeInlinerVariables(methodNode, stateLabels)
|
||||
|
||||
dropSuspensionMarkers(methodNode)
|
||||
methodNode.removeEmptyCatchBlocks()
|
||||
|
||||
@@ -197,28 +190,9 @@ class CoroutineTransformerMethodVisitor(
|
||||
}
|
||||
}
|
||||
|
||||
// When suspension point is inlined, it is in range of fake inliner variables.
|
||||
// Path from TABLESWITCH into unspilling goes to latter part of the range.
|
||||
// In this case the variables are uninitialized, initialize them
|
||||
private fun initializeFakeInlinerVariables(methodNode: MethodNode, stateLabels: List<LabelNode>) {
|
||||
for (stateLabel in stateLabels) {
|
||||
for (record in methodNode.localVariables) {
|
||||
if (isFakeLocalVariableForInline(record.name) &&
|
||||
methodNode.instructions.indexOf(record.start) < methodNode.instructions.indexOf(stateLabel) &&
|
||||
methodNode.instructions.indexOf(stateLabel) < methodNode.instructions.indexOf(record.end)
|
||||
) {
|
||||
methodNode.instructions.insert(stateLabel, withInstructionAdapter {
|
||||
iconst(0)
|
||||
store(record.index, Type.INT_TYPE)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun addCompletionParameterToLVT(methodNode: MethodNode) {
|
||||
val index =
|
||||
/* all args */ Type.getMethodType(methodNode.desc).argumentTypes.fold(0) { a, b -> a + b.size } +
|
||||
/* all args */ Type.getMethodType(methodNode.desc).argumentTypes.fold(0) { a, b -> a + b.size } +
|
||||
/* this */ (if (isStatic(methodNode.access)) 0 else 1) -
|
||||
/* only last */ 1
|
||||
val startLabel = with(methodNode.instructions) {
|
||||
@@ -597,23 +571,11 @@ class CoroutineTransformerMethodVisitor(
|
||||
|
||||
fun AbstractInsnNode.index() = instructions.indexOf(this)
|
||||
|
||||
// We postpone these actions because they change instruction indices that we use when obtaining frames
|
||||
val postponedActions = mutableListOf<() -> Unit>()
|
||||
val maxVarsCountByType = mutableMapOf<Type, Int>()
|
||||
var initialSpilledVariablesCount = 0
|
||||
for ((type, count) in initialVarsCountByType) {
|
||||
if (type == AsmTypes.OBJECT_TYPE) {
|
||||
initialSpilledVariablesCount = count
|
||||
}
|
||||
maxVarsCountByType[type] = count
|
||||
}
|
||||
|
||||
val livenessFrames = analyzeLiveness(methodNode)
|
||||
|
||||
// References shall be cleaned up after uspill (during spill in next suspension point) to prevent memory leaks,
|
||||
val referencesToSpillBySuspensionPointIndex = arrayListOf<List<ReferenceToSpill>>()
|
||||
// while primitives shall not
|
||||
val primitivesToSpillBySuspensionPointIndex = arrayListOf<List<PrimitiveToSpill>>()
|
||||
|
||||
// Collect information about spillable variables, that we use to determine which variables we need to cleanup
|
||||
val spilledToVariableMapping = arrayListOf<List<SpilledVariableAndField>>()
|
||||
|
||||
for (suspension in suspensionPoints) {
|
||||
val suspensionCallBegin = suspension.suspensionCallBegin
|
||||
@@ -640,8 +602,7 @@ class CoroutineTransformerMethodVisitor(
|
||||
// NB: it's also rather useful for sake of optimization
|
||||
val livenessFrame = livenessFrames[suspensionCallBegin.index()]
|
||||
|
||||
val referencesToSpill = arrayListOf<ReferenceToSpill>()
|
||||
val primitivesToSpill = arrayListOf<PrimitiveToSpill>()
|
||||
val spilledToVariable = arrayListOf<SpilledVariableAndField>()
|
||||
|
||||
// 0 - this
|
||||
// 1 - parameter
|
||||
@@ -649,181 +610,77 @@ class CoroutineTransformerMethodVisitor(
|
||||
// k - continuation
|
||||
// k + 1 - data
|
||||
// k + 2 - exception
|
||||
for (slot in 0 until localsCount) {
|
||||
if (slot == continuationIndex || slot == dataIndex || slot == exceptionIndex) continue
|
||||
val value = frame.getLocal(slot)
|
||||
if (value.type == null || !livenessFrame.isAlive(slot)) continue
|
||||
val variablesToSpill =
|
||||
(0 until localsCount)
|
||||
.filterNot { it in setOf(continuationIndex, dataIndex, exceptionIndex) }
|
||||
.map { Pair(it, frame.getLocal(it)) }
|
||||
.filter { (index, value) ->
|
||||
(index == 0 && needDispatchReceiver && isForNamedFunction) ||
|
||||
(value.type != null && livenessFrame.isAlive(index))
|
||||
}
|
||||
|
||||
if (value == StrictBasicValue.NULL_VALUE) {
|
||||
referencesToSpill += slot to null
|
||||
for ((index, basicValue) in variablesToSpill) {
|
||||
if (basicValue == StrictBasicValue.NULL_VALUE) {
|
||||
postponedActions.add {
|
||||
with(instructions) {
|
||||
insert(suspension.tryCatchBlockEndLabelAfterSuspensionCall, withInstructionAdapter {
|
||||
aconst(null)
|
||||
store(index, AsmTypes.OBJECT_TYPE)
|
||||
})
|
||||
}
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
val type = value.type!!
|
||||
val type = basicValue.type!!
|
||||
val normalizedType = type.normalize()
|
||||
|
||||
val indexBySort = varsCountByType[normalizedType]?.plus(1) ?: 0
|
||||
varsCountByType[normalizedType] = indexBySort
|
||||
|
||||
val fieldName = normalizedType.fieldNameForVar(indexBySort)
|
||||
if (normalizedType == AsmTypes.OBJECT_TYPE) {
|
||||
referencesToSpill += slot to SpillableVariable(value, type, normalizedType, fieldName)
|
||||
} else {
|
||||
primitivesToSpill += slot to SpillableVariable(value, type, normalizedType, fieldName)
|
||||
localVariableName(methodNode, index, suspension.suspensionCallEnd.next.index())
|
||||
?.let { spilledToVariable.add(SpilledVariableAndField(fieldName, it)) }
|
||||
|
||||
postponedActions.add {
|
||||
with(instructions) {
|
||||
// store variable before suspension call
|
||||
insertBefore(suspension.suspensionCallBegin, withInstructionAdapter {
|
||||
load(continuationIndex, AsmTypes.OBJECT_TYPE)
|
||||
load(index, type)
|
||||
StackValue.coerce(type, normalizedType, this)
|
||||
putfield(classBuilderForCoroutineState.thisName, fieldName, normalizedType.descriptor)
|
||||
})
|
||||
|
||||
// restore variable after suspension call
|
||||
insert(suspension.tryCatchBlockEndLabelAfterSuspensionCall, withInstructionAdapter {
|
||||
load(continuationIndex, AsmTypes.OBJECT_TYPE)
|
||||
getfield(classBuilderForCoroutineState.thisName, fieldName, normalizedType.descriptor)
|
||||
StackValue.coerce(normalizedType, type, this)
|
||||
store(index, type)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
referencesToSpillBySuspensionPointIndex += referencesToSpill
|
||||
primitivesToSpillBySuspensionPointIndex += primitivesToSpill
|
||||
spilledToVariableMapping.add(spilledToVariable)
|
||||
|
||||
for ((type, index) in varsCountByType) {
|
||||
maxVarsCountByType[type] = max(maxVarsCountByType[type] ?: 0, index)
|
||||
varsCountByType.forEach {
|
||||
maxVarsCountByType[it.key] = max(maxVarsCountByType[it.key] ?: 0, it.value)
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate variables to cleanup
|
||||
postponedActions.forEach(Function0<Unit>::invoke)
|
||||
|
||||
// Use CFG to calculate amount of spilled variables in previous suspension point (P) and current one (C).
|
||||
// All fields from L$C to L$P should be cleaned. I.e. we should spill ACONST_NULL to them.
|
||||
val cfg = ControlFlowGraph.build(methodNode)
|
||||
|
||||
// Collect all immediately preceding suspension points. I.e. suspension points, from which there is a path
|
||||
// into current one, that does not cross other suspension points.
|
||||
val suspensionPointEnds = suspensionPoints.associateBy { it.suspensionCallEnd }
|
||||
fun findSuspensionPointPredecessors(suspension: SuspensionPoint): List<SuspensionPoint> {
|
||||
val visited = mutableSetOf<AbstractInsnNode>()
|
||||
fun dfs(current: AbstractInsnNode): List<SuspensionPoint> {
|
||||
if (!visited.add(current)) return emptyList()
|
||||
suspensionPointEnds[current]?.let { return listOf(it) }
|
||||
return cfg.getPredecessorsIndices(current).flatMap { dfs(instructions[it]) }
|
||||
}
|
||||
return dfs(suspension.suspensionCallBegin)
|
||||
}
|
||||
|
||||
val predSuspensionPoints = suspensionPoints.associateWith { findSuspensionPointPredecessors(it) }
|
||||
|
||||
// Calculate all pairs SuspensionPoint -> C and P, where P is minimum of all preds' Cs
|
||||
fun countVariablesToSpill(index: Int): Int =
|
||||
referencesToSpillBySuspensionPointIndex[index].count { (_, variable) -> variable != null }
|
||||
|
||||
val referencesToCleanBySuspensionPointIndex = arrayListOf<Pair<Int, Int>>() // current to pred
|
||||
for (suspensionPointIndex in suspensionPoints.indices) {
|
||||
val suspensionPoint = suspensionPoints[suspensionPointIndex]
|
||||
val currentSpilledReferencesCount = countVariablesToSpill(suspensionPointIndex)
|
||||
val preds = predSuspensionPoints[suspensionPoint]
|
||||
val predSpilledReferencesCount =
|
||||
if (preds.isNullOrEmpty()) initialSpilledVariablesCount
|
||||
else preds.maxOf { countVariablesToSpill(suspensionPoints.indexOf(it)) }
|
||||
referencesToCleanBySuspensionPointIndex += currentSpilledReferencesCount to predSpilledReferencesCount
|
||||
}
|
||||
|
||||
// Mutate method node
|
||||
|
||||
fun generateSpillAndUnspill(suspension: SuspensionPoint, slot: Int, spillableVariable: SpillableVariable?) {
|
||||
if (spillableVariable == null) {
|
||||
with(instructions) {
|
||||
insert(suspension.tryCatchBlockEndLabelAfterSuspensionCall, withInstructionAdapter {
|
||||
aconst(null)
|
||||
store(slot, AsmTypes.OBJECT_TYPE)
|
||||
})
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
with(instructions) {
|
||||
// store variable before suspension call
|
||||
insertBefore(suspension.suspensionCallBegin, withInstructionAdapter {
|
||||
load(continuationIndex, AsmTypes.OBJECT_TYPE)
|
||||
load(slot, spillableVariable.type)
|
||||
StackValue.coerce(spillableVariable.type, spillableVariable.normalizedType, this)
|
||||
putfield(
|
||||
classBuilderForCoroutineState.thisName,
|
||||
spillableVariable.fieldName,
|
||||
spillableVariable.normalizedType.descriptor
|
||||
)
|
||||
})
|
||||
|
||||
// restore variable after suspension call
|
||||
insert(suspension.tryCatchBlockEndLabelAfterSuspensionCall, withInstructionAdapter {
|
||||
load(continuationIndex, AsmTypes.OBJECT_TYPE)
|
||||
getfield(
|
||||
classBuilderForCoroutineState.thisName,
|
||||
spillableVariable.fieldName,
|
||||
spillableVariable.normalizedType.descriptor
|
||||
)
|
||||
StackValue.coerce(spillableVariable.normalizedType, spillableVariable.type, this)
|
||||
store(slot, spillableVariable.type)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fun cleanUpField(suspension: SuspensionPoint, fieldIndex: Int) {
|
||||
with(instructions) {
|
||||
insertBefore(suspension.suspensionCallBegin, withInstructionAdapter {
|
||||
load(continuationIndex, AsmTypes.OBJECT_TYPE)
|
||||
aconst(null)
|
||||
putfield(
|
||||
classBuilderForCoroutineState.thisName,
|
||||
"L\$$fieldIndex",
|
||||
AsmTypes.OBJECT_TYPE.descriptor
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
for (suspensionPointIndex in suspensionPoints.indices) {
|
||||
val suspension = suspensionPoints[suspensionPointIndex]
|
||||
for ((slot, referenceToSpill) in referencesToSpillBySuspensionPointIndex[suspensionPointIndex]) {
|
||||
generateSpillAndUnspill(suspension, slot, referenceToSpill)
|
||||
}
|
||||
val (currentSpilledCount, predSpilledCount) = referencesToCleanBySuspensionPointIndex[suspensionPointIndex]
|
||||
if (predSpilledCount > currentSpilledCount) {
|
||||
for (fieldIndex in currentSpilledCount until predSpilledCount) {
|
||||
cleanUpField(suspension, fieldIndex)
|
||||
}
|
||||
}
|
||||
for ((slot, primitiveToSpill) in primitivesToSpillBySuspensionPointIndex[suspensionPointIndex]) {
|
||||
generateSpillAndUnspill(suspension, slot, primitiveToSpill)
|
||||
}
|
||||
}
|
||||
|
||||
for (entry in maxVarsCountByType) {
|
||||
maxVarsCountByType.forEach { entry ->
|
||||
val (type, maxIndex) = entry
|
||||
for (index in (initialVarsCountByType[type]?.plus(1) ?: 0)..maxIndex) {
|
||||
for (index in 0..maxIndex) {
|
||||
classBuilderForCoroutineState.newField(
|
||||
JvmDeclarationOrigin.NO_ORIGIN, AsmUtil.NO_FLAG_PACKAGE_PRIVATE,
|
||||
type.fieldNameForVar(index), type.descriptor, null, null
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// Calculate debug metadata mapping
|
||||
|
||||
fun calculateSpilledVariableAndField(
|
||||
suspension: SuspensionPoint,
|
||||
slot: Int,
|
||||
spillableVariable: SpillableVariable?
|
||||
): SpilledVariableAndField? {
|
||||
if (spillableVariable == null) return null
|
||||
val name = localVariableName(methodNode, slot, suspension.suspensionCallEnd.next.index()) ?: return null
|
||||
return SpilledVariableAndField(spillableVariable.fieldName, name)
|
||||
}
|
||||
|
||||
val spilledToVariableMapping = arrayListOf<List<SpilledVariableAndField>>()
|
||||
for (suspensionPointIndex in suspensionPoints.indices) {
|
||||
val suspension = suspensionPoints[suspensionPointIndex]
|
||||
|
||||
val spilledToVariable = arrayListOf<SpilledVariableAndField>()
|
||||
|
||||
referencesToSpillBySuspensionPointIndex[suspensionPointIndex].mapNotNullTo(spilledToVariable) { (slot, spillableVariable) ->
|
||||
calculateSpilledVariableAndField(suspension, slot, spillableVariable)
|
||||
}
|
||||
primitivesToSpillBySuspensionPointIndex[suspensionPointIndex].mapNotNullTo(spilledToVariable) { (slot, spillableVariable) ->
|
||||
calculateSpilledVariableAndField(suspension, slot, spillableVariable)
|
||||
}
|
||||
|
||||
spilledToVariableMapping += spilledToVariable
|
||||
}
|
||||
return spilledToVariableMapping
|
||||
}
|
||||
|
||||
@@ -845,21 +702,21 @@ class CoroutineTransformerMethodVisitor(
|
||||
private val SuspensionPoint.tryCatchBlockEndLabelAfterSuspensionCall: LabelNode
|
||||
get() {
|
||||
assert(suspensionCallEnd.next is LabelNode) {
|
||||
"Next instruction after $this should be a label, but " +
|
||||
"Next instruction after ${this} should be a label, but " +
|
||||
"${suspensionCallEnd.next::class.java}/${suspensionCallEnd.next.opcode} was found"
|
||||
}
|
||||
|
||||
return suspensionCallEnd.next as LabelNode
|
||||
}
|
||||
|
||||
private fun transformCallAndReturnStateLabel(
|
||||
private fun transformCallAndReturnContinuationLabel(
|
||||
id: Int,
|
||||
suspension: SuspensionPoint,
|
||||
methodNode: MethodNode,
|
||||
suspendMarkerVarIndex: Int,
|
||||
suspendPointLineNumber: LineNumberNode?
|
||||
): LabelNode {
|
||||
val stateLabel = LabelNode().linkWithLabel()
|
||||
val continuationLabel = LabelNode().linkWithLabel()
|
||||
val continuationLabelAfterLoadedResult = LabelNode()
|
||||
val suspendElementLineNumber = lineNumber
|
||||
var nextLineNumberNode = nextDefinitelyHitLineNumber(suspension)
|
||||
@@ -887,7 +744,7 @@ class CoroutineTransformerMethodVisitor(
|
||||
load(suspendMarkerVarIndex, AsmTypes.OBJECT_TYPE)
|
||||
areturn(AsmTypes.OBJECT_TYPE)
|
||||
// Mark place for continuation
|
||||
visitLabel(stateLabel.label)
|
||||
visitLabel(continuationLabel.label)
|
||||
})
|
||||
|
||||
// After suspension point there is always three nodes: L1, NOP, L2
|
||||
@@ -938,7 +795,7 @@ class CoroutineTransformerMethodVisitor(
|
||||
}
|
||||
}
|
||||
|
||||
return stateLabel
|
||||
return continuationLabel
|
||||
}
|
||||
|
||||
// Find the next line number instruction that is defintely hit. That is, a line number
|
||||
@@ -946,11 +803,9 @@ class CoroutineTransformerMethodVisitor(
|
||||
private fun nextDefinitelyHitLineNumber(suspension: SuspensionPoint): LineNumberNode? {
|
||||
var next = suspension.suspensionCallEnd.next
|
||||
while (next != null) {
|
||||
when {
|
||||
next.isBranchOrCall -> return null
|
||||
next is LineNumberNode -> return next
|
||||
else -> next = next.next
|
||||
}
|
||||
if (next.isBranchOrCall) return null
|
||||
else if (next is LineNumberNode) return next
|
||||
else next = next.next
|
||||
}
|
||||
return next
|
||||
}
|
||||
@@ -1009,16 +864,6 @@ class CoroutineTransformerMethodVisitor(
|
||||
private data class SpilledVariableAndField(val fieldName: String, val variableName: String)
|
||||
}
|
||||
|
||||
private class SpillableVariable(
|
||||
val value: BasicValue,
|
||||
val type: Type,
|
||||
val normalizedType: Type,
|
||||
val fieldName: String
|
||||
)
|
||||
|
||||
private typealias ReferenceToSpill = Pair<Int, SpillableVariable?>
|
||||
private typealias PrimitiveToSpill = Pair<Int, SpillableVariable>
|
||||
|
||||
internal fun InstructionAdapter.generateContinuationConstructorCall(
|
||||
objectTypeForState: Type?,
|
||||
methodNode: MethodNode,
|
||||
@@ -1084,7 +929,7 @@ inline fun withInstructionAdapter(block: InstructionAdapter.() -> Unit): InsnLis
|
||||
return tmpMethodNode.instructions
|
||||
}
|
||||
|
||||
internal fun Type.normalize() =
|
||||
private fun Type.normalize() =
|
||||
when (sort) {
|
||||
Type.ARRAY, Type.OBJECT -> AsmTypes.OBJECT_TYPE
|
||||
else -> this
|
||||
@@ -1210,9 +1055,10 @@ private fun updateLvtAccordingToLiveness(method: MethodNode, isForNamedFunction:
|
||||
}
|
||||
|
||||
for (variable in oldLvt) {
|
||||
// $continuation and $result are dead, but they are used by debugger, as well as fake inliner variables
|
||||
// $completion, $continuation and $result are dead, but they are used by debugger, as well as fake inliner variables
|
||||
// For example, $continuation is used to create async stack trace
|
||||
if (variable.name == CONTINUATION_VARIABLE_NAME ||
|
||||
if (variable.name == SUSPEND_FUNCTION_COMPLETION_PARAMETER_NAME ||
|
||||
variable.name == CONTINUATION_VARIABLE_NAME ||
|
||||
variable.name == SUSPEND_CALL_RESULT_NAME ||
|
||||
isFakeLocalVariableForInline(variable.name)
|
||||
) {
|
||||
|
||||
@@ -26,6 +26,7 @@ import org.jetbrains.org.objectweb.asm.tree.analysis.BasicInterpreter
|
||||
import org.jetbrains.org.objectweb.asm.tree.analysis.BasicValue
|
||||
import org.jetbrains.org.objectweb.asm.tree.analysis.Frame
|
||||
|
||||
// TODO Use this in variable liveness analysis
|
||||
internal class MethodNodeExaminer(
|
||||
val languageVersionSettings: LanguageVersionSettings,
|
||||
containingClassInternalName: String,
|
||||
|
||||
@@ -8,8 +8,8 @@ package org.jetbrains.kotlin.codegen.coroutines
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.backend.common.COROUTINE_SUSPENDED_NAME
|
||||
import org.jetbrains.kotlin.backend.common.isBuiltInSuspendCoroutineUninterceptedOrReturn
|
||||
import org.jetbrains.kotlin.builtins.StandardNames
|
||||
import org.jetbrains.kotlin.builtins.isBuiltinFunctionalClassDescriptor
|
||||
import org.jetbrains.kotlin.builtins.isBuiltinFunctionalType
|
||||
import org.jetbrains.kotlin.codegen.*
|
||||
import org.jetbrains.kotlin.codegen.binding.CodegenBinding
|
||||
import org.jetbrains.kotlin.codegen.inline.addFakeContinuationMarker
|
||||
@@ -312,7 +312,7 @@ private fun FunctionDescriptor.getContinuationParameterTypeOfSuspendFunction(isR
|
||||
|
||||
fun ModuleDescriptor.getResult(kotlinType: KotlinType) =
|
||||
module.resolveTopLevelClass(
|
||||
StandardNames.RESULT_FQ_NAME,
|
||||
DescriptorUtils.RESULT_FQ_NAME,
|
||||
NoLookupLocation.FROM_BACKEND
|
||||
)?.defaultType?.let {
|
||||
KotlinTypeFactory.simpleType(
|
||||
@@ -494,14 +494,14 @@ fun Method.getImplForOpenMethod(ownerInternalName: String) =
|
||||
|
||||
fun FunctionDescriptor.isSuspendLambdaOrLocalFunction() = this.isSuspend && when (this) {
|
||||
is AnonymousFunctionDescriptor -> this.isSuspendLambda
|
||||
is SimpleFunctionDescriptor -> this.visibility == DescriptorVisibilities.LOCAL
|
||||
is SimpleFunctionDescriptor -> this.visibility == Visibilities.LOCAL
|
||||
else -> false
|
||||
}
|
||||
|
||||
fun FunctionDescriptor.isLocalSuspendFunctionNotSuspendLambda() = isSuspendLambdaOrLocalFunction() && this !is AnonymousFunctionDescriptor
|
||||
|
||||
@JvmField
|
||||
val EXPERIMENTAL_CONTINUATION_ASM_TYPE = StandardNames.CONTINUATION_INTERFACE_FQ_NAME_EXPERIMENTAL.topLevelClassAsmType()
|
||||
val EXPERIMENTAL_CONTINUATION_ASM_TYPE = DescriptorUtils.CONTINUATION_INTERFACE_FQ_NAME_EXPERIMENTAL.topLevelClassAsmType()
|
||||
|
||||
@JvmField
|
||||
val RELEASE_CONTINUATION_ASM_TYPE = StandardNames.CONTINUATION_INTERFACE_FQ_NAME_RELEASE.topLevelClassAsmType()
|
||||
val RELEASE_CONTINUATION_ASM_TYPE = DescriptorUtils.CONTINUATION_INTERFACE_FQ_NAME_RELEASE.topLevelClassAsmType()
|
||||
|
||||
@@ -31,7 +31,7 @@ internal class FictitiousArrayConstructor(arrayClass: ClassDescriptor) : SimpleF
|
||||
return FictitiousArrayConstructor(arrayClass).apply {
|
||||
this.initialize(
|
||||
null, null, arrayConstructor.typeParameters, arrayConstructor.valueParameters, arrayClass.defaultType,
|
||||
Modality.FINAL, DescriptorVisibilities.PUBLIC
|
||||
Modality.FINAL, Visibilities.PUBLIC
|
||||
)
|
||||
this.isInline = true
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ package org.jetbrains.kotlin.codegen.inline
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.util.ArrayUtil
|
||||
import org.jetbrains.kotlin.builtins.StandardNames
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.codegen.*
|
||||
import org.jetbrains.kotlin.codegen.AsmUtil.isPrimitive
|
||||
import org.jetbrains.kotlin.codegen.context.ClosureContext
|
||||
@@ -658,10 +658,6 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
|
||||
if (nameWithoutManglingSuffix != null) {
|
||||
methodNode = getMethodNode(bytes, nameWithoutManglingSuffix, asmMethod.descriptor, classType)
|
||||
}
|
||||
if (methodNode == null) {
|
||||
val nameWithImplSuffix = "$nameWithoutManglingSuffix-impl"
|
||||
methodNode = getMethodNode(bytes, nameWithImplSuffix, asmMethod.descriptor, classType)
|
||||
}
|
||||
}
|
||||
return methodNode
|
||||
}
|
||||
@@ -675,7 +671,7 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
|
||||
if (callableDescriptor is FictitiousArrayConstructor) return true
|
||||
val name = callableDescriptor.name.asString()
|
||||
return (name == "arrayOf" || name == "emptyArray") && callableDescriptor.containingDeclaration.let { container ->
|
||||
container is PackageFragmentDescriptor && container.fqName == StandardNames.BUILT_INS_PACKAGE_FQ_NAME
|
||||
container is PackageFragmentDescriptor && container.fqName == KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -171,7 +171,7 @@ public class InternalFinallyBlockInliner extends CoveringTryCatchNodeProcessor {
|
||||
checkClusterInvariant(clustersFromInnermost);
|
||||
|
||||
int originalDepthIndex = 0;
|
||||
List<TryCatchBlockNodeInfo> nestedUnsplitBlocksWithoutFinally = new ArrayList<>();
|
||||
List<TryCatchBlockNodeInfo> nestedUnsplitBlocksWithoutFinally = new ArrayList();
|
||||
while (tryCatchBlockIterator.hasNext()) {
|
||||
TryBlockCluster<TryCatchBlockNodeInfo> clusterToFindFinally = tryCatchBlockIterator.next();
|
||||
List<TryCatchBlockNodeInfo> clusterBlocks = clusterToFindFinally.getBlocks();
|
||||
|
||||
@@ -91,7 +91,7 @@ class ParametersBuilder private constructor() {
|
||||
}
|
||||
|
||||
fun buildParameters(): Parameters {
|
||||
var nextDeclarationIndex = (params.maxOfOrNull { it.declarationIndex } ?: -1) + 1
|
||||
var nextDeclarationIndex = (params.maxBy { it.declarationIndex }?.declarationIndex ?: -1) + 1
|
||||
|
||||
return Parameters(params.map { param ->
|
||||
if (param is CapturedParamInfo) {
|
||||
|
||||
@@ -41,10 +41,7 @@ class PsiInlineCodegen(
|
||||
private val actualDispatchReceiver: Type = methodOwner
|
||||
) : InlineCodegen<ExpressionCodegen>(
|
||||
codegen, state, function, methodOwner, signature, typeParameterMappings, sourceCompiler,
|
||||
ReifiedTypeInliner(
|
||||
typeParameterMappings, PsiInlineIntrinsicsSupport(state), codegen.typeSystem,
|
||||
state.languageVersionSettings, state.unifiedNullChecks
|
||||
),
|
||||
ReifiedTypeInliner(typeParameterMappings, PsiInlineIntrinsicsSupport(state), codegen.typeSystem, state.languageVersionSettings),
|
||||
), CallGenerator {
|
||||
override fun generateAssertFieldIfNeeded(info: RootInliningContext) {
|
||||
if (info.generateAssertField) {
|
||||
|
||||
@@ -53,8 +53,7 @@ class ReifiedTypeInliner<KT : KotlinTypeMarker>(
|
||||
private val parametersMapping: TypeParameterMappings<KT>?,
|
||||
private val intrinsicsSupport: IntrinsicsSupport<KT>,
|
||||
private val typeSystem: TypeSystemCommonBackendContext,
|
||||
private val languageVersionSettings: LanguageVersionSettings,
|
||||
private val unifiedNullChecks: Boolean,
|
||||
private val languageVersionSettings: LanguageVersionSettings
|
||||
) {
|
||||
enum class OperationKind {
|
||||
NEW_ARRAY, AS, SAFE_AS, IS, JAVA_CLASS, ENUM_REIFIED, TYPE_OF;
|
||||
@@ -223,7 +222,7 @@ class ReifiedTypeInliner<KT : KotlinTypeMarker>(
|
||||
if (stubCheckcast !is TypeInsnNode) return false
|
||||
|
||||
val newMethodNode = MethodNode(Opcodes.API_VERSION)
|
||||
generateAsCast(InstructionAdapter(newMethodNode), kotlinType, asmType, safe, languageVersionSettings, unifiedNullChecks)
|
||||
generateAsCast(InstructionAdapter(newMethodNode), kotlinType, asmType, safe, languageVersionSettings)
|
||||
|
||||
instructions.insert(insn, newMethodNode.instructions)
|
||||
// Keep stubCheckcast to avoid VerifyErrors on 1.8+ bytecode,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* 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.
|
||||
*/
|
||||
@file:Suppress("JAVA_MODULE_DOES_NOT_EXPORT_PACKAGE")
|
||||
|
||||
package org.jetbrains.kotlin.codegen.inline.coroutines
|
||||
|
||||
import com.intellij.util.ArrayUtil
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.codegen.ASSERTIONS_DISABLED_FIELD_NAME
|
||||
import org.jetbrains.kotlin.codegen.AsmUtil
|
||||
import org.jetbrains.kotlin.codegen.BaseExpressionCodegen
|
||||
import org.jetbrains.kotlin.codegen.MemberCodegen
|
||||
import org.jetbrains.kotlin.codegen.SamWrapperCodegen.SAM_WRAPPER_SUFFIX
|
||||
import org.jetbrains.kotlin.codegen.`when`.WhenByEnumsMapping
|
||||
import org.jetbrains.kotlin.codegen.binding.CodegenBinding
|
||||
|
||||
@@ -8,7 +8,6 @@ package org.jetbrains.kotlin.codegen.inline
|
||||
import org.jetbrains.kotlin.backend.common.isBuiltInIntercepted
|
||||
import org.jetbrains.kotlin.backend.common.isBuiltInSuspendCoroutineUninterceptedOrReturn
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.StandardNames
|
||||
import org.jetbrains.kotlin.codegen.AsmUtil
|
||||
import org.jetbrains.kotlin.codegen.coroutines.createMethodNodeForCoroutineContext
|
||||
import org.jetbrains.kotlin.codegen.coroutines.createMethodNodeForIntercepted
|
||||
@@ -55,7 +54,7 @@ internal fun generateInlineIntrinsic(
|
||||
|
||||
private fun isSpecialEnumMethod(descriptor: FunctionDescriptor): Boolean {
|
||||
val containingDeclaration = descriptor.containingDeclaration as? PackageFragmentDescriptor ?: return false
|
||||
if (containingDeclaration.fqName != StandardNames.BUILT_INS_PACKAGE_FQ_NAME) {
|
||||
if (containingDeclaration.fqName != KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME) {
|
||||
return false
|
||||
}
|
||||
if (descriptor.typeParameters.size != 1) {
|
||||
|
||||
@@ -20,7 +20,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import kotlin.text.StringsKt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.builtins.StandardNames;
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
|
||||
import org.jetbrains.kotlin.builtins.PrimitiveType;
|
||||
import org.jetbrains.kotlin.codegen.AsmUtil;
|
||||
import org.jetbrains.kotlin.config.JvmTarget;
|
||||
@@ -32,7 +32,7 @@ import org.jetbrains.kotlin.resolve.jvm.JvmPrimitiveType;
|
||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions;
|
||||
import org.jetbrains.org.objectweb.asm.Type;
|
||||
|
||||
import static org.jetbrains.kotlin.builtins.StandardNames.*;
|
||||
import static org.jetbrains.kotlin.builtins.KotlinBuiltIns.*;
|
||||
import static org.jetbrains.org.objectweb.asm.Opcodes.*;
|
||||
|
||||
public class IntrinsicMethods {
|
||||
@@ -70,15 +70,15 @@ public class IntrinsicMethods {
|
||||
|
||||
public IntrinsicMethods(JvmTarget jvmTarget, boolean canReplaceStdlibRuntimeApiBehavior, boolean shouldThrowNpeOnExplicitEqualsForBoxedNull) {
|
||||
intrinsicsMap.registerIntrinsic(KOTLIN_JVM, RECEIVER_PARAMETER_FQ_NAME, "javaClass", -1, JavaClassProperty.INSTANCE);
|
||||
intrinsicsMap.registerIntrinsic(KOTLIN_JVM, StandardNames.FqNames.kClass, "java", -1, new KClassJavaProperty());
|
||||
intrinsicsMap.registerIntrinsic(KOTLIN_JVM, StandardNames.FqNames.kClass, "javaObjectType", -1, new KClassJavaObjectTypeProperty());
|
||||
intrinsicsMap.registerIntrinsic(KOTLIN_JVM, StandardNames.FqNames.kClass, "javaPrimitiveType", -1, new KClassJavaPrimitiveTypeProperty());
|
||||
intrinsicsMap.registerIntrinsic(StandardNames.FqNames.kCallable.toSafe(), null, "name", -1, new KCallableNameProperty());
|
||||
intrinsicsMap.registerIntrinsic(KOTLIN_JVM, KotlinBuiltIns.FQ_NAMES.kClass, "java", -1, new KClassJavaProperty());
|
||||
intrinsicsMap.registerIntrinsic(KOTLIN_JVM, KotlinBuiltIns.FQ_NAMES.kClass, "javaObjectType", -1, new KClassJavaObjectTypeProperty());
|
||||
intrinsicsMap.registerIntrinsic(KOTLIN_JVM, KotlinBuiltIns.FQ_NAMES.kClass, "javaPrimitiveType", -1, new KClassJavaPrimitiveTypeProperty());
|
||||
intrinsicsMap.registerIntrinsic(KotlinBuiltIns.FQ_NAMES.kCallable.toSafe(), null, "name", -1, new KCallableNameProperty());
|
||||
intrinsicsMap.registerIntrinsic(new FqName("kotlin.jvm.internal.unsafe"), null, "monitorEnter", 1, MonitorInstruction.MONITOR_ENTER);
|
||||
intrinsicsMap.registerIntrinsic(new FqName("kotlin.jvm.internal.unsafe"), null, "monitorExit", 1, MonitorInstruction.MONITOR_EXIT);
|
||||
intrinsicsMap.registerIntrinsic(KOTLIN_JVM, StandardNames.FqNames.array, "isArrayOf", 0, new IsArrayOf());
|
||||
intrinsicsMap.registerIntrinsic(KOTLIN_JVM, KotlinBuiltIns.FQ_NAMES.array, "isArrayOf", 0, new IsArrayOf());
|
||||
|
||||
intrinsicsMap.registerIntrinsic(BUILT_INS_PACKAGE_FQ_NAME, StandardNames.FqNames.kProperty0, "isInitialized", -1, LateinitIsInitialized.INSTANCE);
|
||||
intrinsicsMap.registerIntrinsic(BUILT_INS_PACKAGE_FQ_NAME, KotlinBuiltIns.FQ_NAMES.kProperty0, "isInitialized", -1, LateinitIsInitialized.INSTANCE);
|
||||
|
||||
intrinsicsMap.registerIntrinsic(BUILT_INS_PACKAGE_FQ_NAME, null, "arrayOf", 1, new ArrayOf());
|
||||
|
||||
@@ -87,7 +87,7 @@ public class IntrinsicMethods {
|
||||
ImmutableList<Name> primitiveCastMethods = OperatorConventions.NUMBER_CONVERSIONS.asList();
|
||||
for (Name method : primitiveCastMethods) {
|
||||
String methodName = method.asString();
|
||||
declareIntrinsicFunction(StandardNames.FqNames.number, methodName, 0, NUMBER_CAST);
|
||||
declareIntrinsicFunction(FQ_NAMES.number, methodName, 0, NUMBER_CAST);
|
||||
for (PrimitiveType type : PrimitiveType.NUMBER_TYPES) {
|
||||
declareIntrinsicFunction(type.getTypeFqName(), methodName, 0, NUMBER_CAST);
|
||||
}
|
||||
@@ -139,20 +139,20 @@ public class IntrinsicMethods {
|
||||
declareBinaryOp("or", IOR);
|
||||
declareBinaryOp("xor", IXOR);
|
||||
|
||||
declareIntrinsicFunction(StandardNames.FqNames._boolean, "not", 0, new Not());
|
||||
declareIntrinsicFunction(FQ_NAMES._boolean, "not", 0, new Not());
|
||||
|
||||
declareIntrinsicFunction(StandardNames.FqNames.string, "plus", 1, new Concat());
|
||||
declareIntrinsicFunction(StandardNames.FqNames.string, "get", 1, new StringGetChar());
|
||||
declareIntrinsicFunction(FQ_NAMES.string, "plus", 1, new Concat());
|
||||
declareIntrinsicFunction(FQ_NAMES.string, "get", 1, new StringGetChar());
|
||||
|
||||
if (canReplaceStdlibRuntimeApiBehavior) {
|
||||
intrinsicsMap.registerIntrinsic(TEXT_PACKAGE_FQ_NAME, StandardNames.FqNames.string, "trimMargin", 1, new TrimMargin());
|
||||
intrinsicsMap.registerIntrinsic(TEXT_PACKAGE_FQ_NAME, StandardNames.FqNames.string, "trimIndent", 0, new TrimIndent());
|
||||
intrinsicsMap.registerIntrinsic(TEXT_PACKAGE_FQ_NAME, FQ_NAMES.string, "trimMargin", 1, new TrimMargin());
|
||||
intrinsicsMap.registerIntrinsic(TEXT_PACKAGE_FQ_NAME, FQ_NAMES.string, "trimIndent", 0, new TrimIndent());
|
||||
}
|
||||
|
||||
declareIntrinsicFunction(StandardNames.FqNames.cloneable, "clone", 0, CLONE);
|
||||
declareIntrinsicFunction(FQ_NAMES.cloneable, "clone", 0, CLONE);
|
||||
|
||||
intrinsicsMap.registerIntrinsic(BUILT_INS_PACKAGE_FQ_NAME, StandardNames.FqNames.any, "toString", 0, TO_STRING);
|
||||
intrinsicsMap.registerIntrinsic(BUILT_INS_PACKAGE_FQ_NAME, StandardNames.FqNames.string, "plus", 1, STRING_PLUS);
|
||||
intrinsicsMap.registerIntrinsic(BUILT_INS_PACKAGE_FQ_NAME, KotlinBuiltIns.FQ_NAMES.any, "toString", 0, TO_STRING);
|
||||
intrinsicsMap.registerIntrinsic(BUILT_INS_PACKAGE_FQ_NAME, KotlinBuiltIns.FQ_NAMES.string, "plus", 1, STRING_PLUS);
|
||||
intrinsicsMap.registerIntrinsic(BUILT_INS_PACKAGE_FQ_NAME, null, "arrayOfNulls", 1, new NewArray());
|
||||
|
||||
for (PrimitiveType type : PrimitiveType.values()) {
|
||||
@@ -197,7 +197,7 @@ public class IntrinsicMethods {
|
||||
for (JvmPrimitiveType jvmPrimitiveType : JvmPrimitiveType.values()) {
|
||||
declareArrayMethods(jvmPrimitiveType.getPrimitiveType().getArrayTypeFqName());
|
||||
}
|
||||
declareArrayMethods(FqNames.array.toSafe());
|
||||
declareArrayMethods(FQ_NAMES.array.toSafe());
|
||||
}
|
||||
|
||||
private void declareArrayMethods(@NotNull FqName arrayTypeFqName) {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.codegen.intrinsics
|
||||
|
||||
import org.jetbrains.kotlin.builtins.StandardNames.COLLECTIONS_PACKAGE_FQ_NAME
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns.COLLECTIONS_PACKAGE_FQ_NAME
|
||||
import org.jetbrains.kotlin.codegen.AsmUtil
|
||||
import org.jetbrains.kotlin.codegen.Callable
|
||||
import org.jetbrains.kotlin.codegen.CallableMethod
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.codegen.intrinsics
|
||||
|
||||
import org.jetbrains.kotlin.builtins.StandardNames.FqNames
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns.FQ_NAMES
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.jvm.AsmTypes
|
||||
@@ -16,6 +16,7 @@ import org.jetbrains.org.objectweb.asm.Opcodes
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
|
||||
import org.jetbrains.org.objectweb.asm.tree.*
|
||||
import kotlin.text.Regex
|
||||
|
||||
object TypeIntrinsics {
|
||||
@JvmStatic
|
||||
@@ -133,20 +134,20 @@ object TypeIntrinsics {
|
||||
|
||||
|
||||
private val MUTABLE_COLLECTION_TYPE_FQ_NAMES = setOf(
|
||||
FqNames.mutableIterator,
|
||||
FqNames.mutableIterable,
|
||||
FqNames.mutableCollection,
|
||||
FqNames.mutableList,
|
||||
FqNames.mutableListIterator,
|
||||
FqNames.mutableMap,
|
||||
FqNames.mutableSet,
|
||||
FqNames.mutableMapEntry
|
||||
FQ_NAMES.mutableIterator,
|
||||
FQ_NAMES.mutableIterable,
|
||||
FQ_NAMES.mutableCollection,
|
||||
FQ_NAMES.mutableList,
|
||||
FQ_NAMES.mutableListIterator,
|
||||
FQ_NAMES.mutableMap,
|
||||
FQ_NAMES.mutableSet,
|
||||
FQ_NAMES.mutableMapEntry
|
||||
)
|
||||
|
||||
private fun getMutableCollectionMethodName(prefix: String, jetType: KotlinType): String? {
|
||||
val fqName = getClassFqName(jetType)
|
||||
if (fqName == null || fqName !in MUTABLE_COLLECTION_TYPE_FQ_NAMES) return null
|
||||
val baseName = if (fqName == FqNames.mutableMapEntry) "MutableMapEntry" else fqName.shortName().asString()
|
||||
val baseName = if (fqName == FQ_NAMES.mutableMapEntry) "MutableMapEntry" else fqName.shortName().asString()
|
||||
return prefix + baseName
|
||||
}
|
||||
|
||||
@@ -199,4 +200,4 @@ object TypeIntrinsics {
|
||||
|
||||
private val BEFORE_CHECKCAST_TO_FUNCTION_OF_ARITY_DESCRIPTOR =
|
||||
Type.getMethodDescriptor(OBJECT_TYPE, OBJECT_TYPE, Type.INT_TYPE)
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,6 @@
|
||||
package org.jetbrains.kotlin.codegen.range
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.StandardNames
|
||||
import org.jetbrains.kotlin.builtins.UnsignedTypes
|
||||
import org.jetbrains.kotlin.codegen.AsmUtil.isPrimitiveNumberClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
@@ -84,10 +83,10 @@ fun getRangeOrProgressionElementType(rangeType: KotlinType): KotlinType? {
|
||||
COMPARABLE_RANGE_FQN -> rangeType.arguments.singleOrNull()?.type
|
||||
|
||||
UINT_RANGE_FQN, UINT_PROGRESSION_FQN ->
|
||||
rangeClassDescriptor.findTypeInModuleByTopLevelClassFqName(StandardNames.FqNames.uIntFqName)
|
||||
rangeClassDescriptor.findTypeInModuleByTopLevelClassFqName(KotlinBuiltIns.FQ_NAMES.uIntFqName)
|
||||
|
||||
ULONG_RANGE_FQN, ULONG_PROGRESSION_FQN ->
|
||||
rangeClassDescriptor.findTypeInModuleByTopLevelClassFqName(StandardNames.FqNames.uLongFqName)
|
||||
rangeClassDescriptor.findTypeInModuleByTopLevelClassFqName(KotlinBuiltIns.FQ_NAMES.uLongFqName)
|
||||
|
||||
else -> null
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.jetbrains.kotlin.codegen.state.KotlinTypeMapperBase
|
||||
import org.jetbrains.kotlin.config.JvmDefaultMode
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.load.java.DescriptorsJvmAbiUtil
|
||||
import org.jetbrains.kotlin.load.java.JvmAbi
|
||||
import org.jetbrains.kotlin.load.java.lazy.types.RawTypeImpl
|
||||
import org.jetbrains.kotlin.load.kotlin.NON_EXISTENT_CLASS_NAME
|
||||
import org.jetbrains.kotlin.metadata.ProtoBuf
|
||||
@@ -63,15 +63,15 @@ class JvmSerializerExtension @JvmOverloads constructor(
|
||||
|
||||
override fun shouldUseTypeTable(): Boolean = useTypeTable
|
||||
override fun shouldSerializeFunction(descriptor: FunctionDescriptor): Boolean {
|
||||
return classBuilderMode != ClassBuilderMode.ABI || descriptor.visibility != DescriptorVisibilities.PRIVATE
|
||||
return classBuilderMode != ClassBuilderMode.ABI || descriptor.visibility != Visibilities.PRIVATE
|
||||
}
|
||||
|
||||
override fun shouldSerializeProperty(descriptor: PropertyDescriptor): Boolean {
|
||||
return classBuilderMode != ClassBuilderMode.ABI || descriptor.visibility != DescriptorVisibilities.PRIVATE
|
||||
return classBuilderMode != ClassBuilderMode.ABI || descriptor.visibility != Visibilities.PRIVATE
|
||||
}
|
||||
|
||||
override fun shouldSerializeTypeAlias(descriptor: TypeAliasDescriptor): Boolean {
|
||||
return classBuilderMode != ClassBuilderMode.ABI || descriptor.visibility != DescriptorVisibilities.PRIVATE
|
||||
return classBuilderMode != ClassBuilderMode.ABI || descriptor.visibility != Visibilities.PRIVATE
|
||||
}
|
||||
|
||||
override fun shouldSerializeNestedClass(descriptor: ClassDescriptor): Boolean {
|
||||
@@ -233,7 +233,7 @@ class JvmSerializerExtension @JvmOverloads constructor(
|
||||
|
||||
private fun FunctionDescriptor.needsInlineParameterNullCheckRequirement(): Boolean =
|
||||
isInline && !isSuspend && !isParamAssertionsDisabled &&
|
||||
!DescriptorVisibilities.isPrivate(visibility) &&
|
||||
!Visibilities.isPrivate(visibility) &&
|
||||
(valueParameters.any { it.type.isFunctionType } || extensionReceiverParameter?.type?.isFunctionType == true)
|
||||
|
||||
override fun serializeProperty(
|
||||
@@ -283,7 +283,7 @@ class JvmSerializerExtension @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
private fun PropertyDescriptor.isJvmFieldPropertyInInterfaceCompanion(): Boolean {
|
||||
if (!DescriptorsJvmAbiUtil.hasJvmFieldAnnotation(this)) return false
|
||||
if (!JvmAbi.hasJvmFieldAnnotation(this)) return false
|
||||
|
||||
val container = containingDeclaration
|
||||
if (!DescriptorUtils.isCompanionObject(container)) return false
|
||||
|
||||
@@ -51,12 +51,14 @@ class BuilderFactoryForDuplicateSignatureDiagnostics(
|
||||
moduleName: String,
|
||||
languageVersionSettings: LanguageVersionSettings,
|
||||
shouldGenerate: (JvmDeclarationOrigin) -> Boolean,
|
||||
mapAsmMethod: ((FunctionDescriptor) -> Method)?
|
||||
) : SignatureCollectingClassBuilderFactory(builderFactory, shouldGenerate) {
|
||||
|
||||
private val mapAsmMethod: (FunctionDescriptor) -> Method = KotlinTypeMapper(
|
||||
// Avoid errors when some classes are not loaded for some reason
|
||||
bindingContext, ClassBuilderMode.LIGHT_CLASSES, moduleName, languageVersionSettings, isIrBackend = false
|
||||
)::mapAsmMethod
|
||||
private val mapAsmMethod = mapAsmMethod
|
||||
?: KotlinTypeMapper(
|
||||
// Avoid errors when some classes are not loaded for some reason
|
||||
bindingContext, ClassBuilderMode.LIGHT_CLASSES, moduleName, languageVersionSettings, isIrBackend = false
|
||||
)::mapAsmMethod
|
||||
|
||||
private val reportDiagnosticsTasks = ArrayList<() -> Unit>()
|
||||
|
||||
@@ -202,7 +204,7 @@ class BuilderFactoryForDuplicateSignatureDiagnostics(
|
||||
fun processMember(member: DeclarationDescriptor?) {
|
||||
if (member !is CallableMemberDescriptor) return
|
||||
// a member of super is not visible: no override
|
||||
if (member.visibility == DescriptorVisibilities.INVISIBLE_FAKE) return
|
||||
if (member.visibility == Visibilities.INVISIBLE_FAKE) return
|
||||
// if a signature clashes with a SAM-adapter or something like that, there's no harm
|
||||
if (isOrOverridesSamAdapter(member)) return
|
||||
|
||||
@@ -231,7 +233,7 @@ class BuilderFactoryForDuplicateSignatureDiagnostics(
|
||||
descriptor.getParentJavaStaticClassScope()?.run {
|
||||
getContributedDescriptors(DescriptorKindFilter.FUNCTIONS)
|
||||
.filter {
|
||||
it is FunctionDescriptor && DescriptorVisibilities.isVisibleIgnoringReceiver(it, descriptor)
|
||||
it is FunctionDescriptor && Visibilities.isVisibleIgnoringReceiver(it, descriptor)
|
||||
}
|
||||
.forEach(::processMember)
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.jetbrains.kotlin.codegen.optimization.OptimizationClassBuilderFactory
|
||||
import org.jetbrains.kotlin.codegen.serialization.JvmSerializationBindings
|
||||
import org.jetbrains.kotlin.config.*
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ScriptDescriptor
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
@@ -47,6 +48,7 @@ import org.jetbrains.kotlin.storage.LockBasedStorageManager
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeApproximator
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
import org.jetbrains.org.objectweb.asm.commons.Method
|
||||
import java.io.File
|
||||
|
||||
class GenerationState private constructor(
|
||||
@@ -249,9 +251,7 @@ class GenerationState private constructor(
|
||||
val assertionsMode: JVMAssertionsMode = configuration.get(JVMConfigurationKeys.ASSERTIONS_MODE, JVMAssertionsMode.DEFAULT)
|
||||
val isInlineDisabled: Boolean = configuration.getBoolean(CommonConfigurationKeys.DISABLE_INLINE)
|
||||
val useTypeTableInSerializer: Boolean = configuration.getBoolean(JVMConfigurationKeys.USE_TYPE_TABLE)
|
||||
val unifiedNullChecks: Boolean =
|
||||
languageVersionSettings.apiVersion >= ApiVersion.KOTLIN_1_4 &&
|
||||
!configuration.getBoolean(JVMConfigurationKeys.NO_UNIFIED_NULL_CHECKS)
|
||||
val unifiedNullChecks: Boolean = languageVersionSettings.apiVersion >= ApiVersion.KOTLIN_1_4
|
||||
val functionsWithInlineClassReturnTypesMangled: Boolean =
|
||||
languageVersionSettings.supportsFeature(LanguageFeature.MangleClassMembersReturningInlineClasses)
|
||||
|
||||
@@ -283,6 +283,7 @@ class GenerationState private constructor(
|
||||
val isIrWithStableAbi = configuration.getBoolean(JVMConfigurationKeys.IS_IR_WITH_STABLE_ABI)
|
||||
|
||||
val globalSerializationBindings = JvmSerializationBindings()
|
||||
lateinit var irBasedMapAsmMethod: (FunctionDescriptor) -> Method
|
||||
var mapInlineClass: (ClassDescriptor) -> Type = { descriptor -> typeMapper.mapType(descriptor.defaultType) }
|
||||
|
||||
val typeApproximator: TypeApproximator? =
|
||||
@@ -309,6 +310,7 @@ class GenerationState private constructor(
|
||||
BuilderFactoryForDuplicateSignatureDiagnostics(
|
||||
it, this.bindingContext, diagnostics, this.moduleName, this.languageVersionSettings,
|
||||
shouldGenerate = { origin -> !shouldOnlyCollectSignatures(origin) },
|
||||
mapAsmMethod = if (isIrBackend) { descriptor: FunctionDescriptor -> irBasedMapAsmMethod(descriptor) } else null
|
||||
).apply { duplicateSignatureFactory = this }
|
||||
},
|
||||
{ BuilderFactoryForDuplicateClassNameDiagnostics(it, diagnostics) },
|
||||
|
||||
@@ -8,9 +8,7 @@ package org.jetbrains.kotlin.codegen.state
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import org.jetbrains.kotlin.builtins.BuiltInsPackageFragment
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.StandardNames.RESULT_FQ_NAME
|
||||
import org.jetbrains.kotlin.builtins.functions.FunctionClassDescriptor
|
||||
import org.jetbrains.kotlin.builtins.functions.FunctionClassKind
|
||||
import org.jetbrains.kotlin.builtins.jvm.JavaToKotlinClassMap
|
||||
import org.jetbrains.kotlin.codegen.*
|
||||
import org.jetbrains.kotlin.codegen.AsmUtil.isStaticMethod
|
||||
@@ -54,7 +52,10 @@ import org.jetbrains.kotlin.resolve.bindingContextUtil.isUsedAsExpression
|
||||
import org.jetbrains.kotlin.resolve.calls.model.DefaultValueArgument
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.model.VarargValueArgument
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.*
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.classId
|
||||
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.JvmClassName
|
||||
@@ -329,8 +330,8 @@ class KotlinTypeMapper @JvmOverloads constructor(
|
||||
|
||||
if (classDescriptor is FunctionClassDescriptor) {
|
||||
if (classDescriptor.hasBigArity ||
|
||||
classDescriptor.functionKind == FunctionClassKind.KFunction ||
|
||||
classDescriptor.functionKind == FunctionClassKind.KSuspendFunction
|
||||
classDescriptor.functionKind == FunctionClassDescriptor.Kind.KFunction ||
|
||||
classDescriptor.functionKind == FunctionClassDescriptor.Kind.KSuspendFunction
|
||||
) {
|
||||
// kotlin.reflect.KFunction{n}<P1, ..., Pn, R> is mapped to kotlin.reflect.KFunction<R> (for all n), and
|
||||
// kotlin.Function{n}<P1, ..., Pn, R> is mapped to kotlin.jvm.functions.FunctionN<R> (for n > 22).
|
||||
@@ -384,11 +385,6 @@ class KotlinTypeMapper @JvmOverloads constructor(
|
||||
return functionDescriptor.builtIns.nullableAnyType
|
||||
}
|
||||
|
||||
// Force boxing for Result type, otherwise, the coroutines machinery will break
|
||||
if (originalReturnType.constructor.declarationDescriptor?.fqNameSafe == RESULT_FQ_NAME) {
|
||||
return functionDescriptor.builtIns.nullableAnyType
|
||||
}
|
||||
|
||||
// Don't box other inline classes
|
||||
return originalReturnType
|
||||
}
|
||||
@@ -449,7 +445,7 @@ class KotlinTypeMapper @JvmOverloads constructor(
|
||||
else
|
||||
mapClass(ownerForDefault)
|
||||
|
||||
if (isInterface && (superCall || descriptor.visibility == DescriptorVisibilities.PRIVATE || isAccessor(descriptor))) {
|
||||
if (isInterface && (superCall || descriptor.visibility == Visibilities.PRIVATE || isAccessor(descriptor))) {
|
||||
thisClass = mapClass(functionParent)
|
||||
dispatchReceiverKotlinType = functionParent.defaultType
|
||||
if (declarationOwner is JavaClassDescriptor ||
|
||||
@@ -495,7 +491,7 @@ class KotlinTypeMapper @JvmOverloads constructor(
|
||||
isInterfaceMember = true
|
||||
}
|
||||
else -> {
|
||||
val isPrivateFunInvocation = DescriptorVisibilities.isPrivate(functionDescriptor.visibility) && !functionDescriptor.isSuspend
|
||||
val isPrivateFunInvocation = Visibilities.isPrivate(functionDescriptor.visibility) && !functionDescriptor.isSuspend
|
||||
invokeOpcode = if (superCall || isPrivateFunInvocation) INVOKESPECIAL else INVOKEVIRTUAL
|
||||
isInterfaceMember = false
|
||||
}
|
||||
@@ -677,7 +673,7 @@ class KotlinTypeMapper @JvmOverloads constructor(
|
||||
newName = sanitizeNameIfNeeded(newName, languageVersionSettings)
|
||||
|
||||
if (isTopLevelDeclaration(descriptor)) {
|
||||
if (DescriptorVisibilities.isPrivate(descriptor.visibility) && descriptor !is ConstructorDescriptor && "<clinit>" != newName) {
|
||||
if (Visibilities.isPrivate(descriptor.visibility) && descriptor !is ConstructorDescriptor && "<clinit>" != newName) {
|
||||
val partName = getPartSimpleNameForMangling(descriptor)
|
||||
if (partName != null) return "$newName$$partName"
|
||||
}
|
||||
@@ -685,7 +681,7 @@ class KotlinTypeMapper @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
return if (descriptor !is ConstructorDescriptor &&
|
||||
descriptor.visibility === DescriptorVisibilities.INTERNAL &&
|
||||
descriptor.visibility === Visibilities.INTERNAL &&
|
||||
!descriptor.isPublishedApi()
|
||||
) {
|
||||
InternalNameMapper.mangleInternalName(newName, getModuleName(descriptor))
|
||||
@@ -1297,7 +1293,7 @@ class KotlinTypeMapper @JvmOverloads constructor(
|
||||
val visibility = descriptor.visibility
|
||||
return if (!publicFacade ||
|
||||
isNonConstProperty(descriptor) ||
|
||||
DescriptorVisibilities.isPrivate(visibility) ||
|
||||
Visibilities.isPrivate(visibility) ||
|
||||
isAccessor/*Cause of KT-9603*/) {
|
||||
JvmFileClassUtil.getFileClassInternalName(file)
|
||||
} else {
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.codegen.state
|
||||
|
||||
import org.jetbrains.kotlin.builtins.StandardNames.FqNames
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
@@ -38,6 +37,7 @@ import org.jetbrains.kotlin.types.checker.convertVariance
|
||||
import org.jetbrains.kotlin.types.getEffectiveVariance
|
||||
import org.jetbrains.kotlin.types.model.KotlinTypeMarker
|
||||
import org.jetbrains.kotlin.types.model.TypeParameterMarker
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns.FQ_NAMES as BUILTIN_NAMES
|
||||
|
||||
// TODO: probably class upper bound should be used
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
@@ -81,9 +81,9 @@ val FqName?.isMethodWithDeclarationSiteWildcardsFqName: Boolean
|
||||
|
||||
private fun FqName.child(name: String): FqName = child(Name.identifier(name))
|
||||
private val METHODS_WITH_DECLARATION_SITE_WILDCARDS = setOf(
|
||||
FqNames.mutableCollection.child("addAll"),
|
||||
FqNames.mutableList.child("addAll"),
|
||||
FqNames.mutableMap.child("putAll")
|
||||
BUILTIN_NAMES.mutableCollection.child("addAll"),
|
||||
BUILTIN_NAMES.mutableList.child("addAll"),
|
||||
BUILTIN_NAMES.mutableMap.child("putAll")
|
||||
)
|
||||
|
||||
fun TypeMappingMode.updateArgumentModeFromAnnotations(
|
||||
|
||||
@@ -35,7 +35,7 @@ private class State<T>(val path: MutableList<String>) {
|
||||
path.add(step)
|
||||
}
|
||||
|
||||
fun removeStep() {
|
||||
fun removeStep(step: String) {
|
||||
path.removeAt(path.lastIndex)
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ abstract class TypeAnnotationCollector<T>(val context: TypeSystemCommonBackendCo
|
||||
fun KotlinTypeMarker.process(step: String) {
|
||||
state.addStep(step)
|
||||
this.gatherTypeAnnotations()
|
||||
state.removeStep()
|
||||
state.removeStep(step)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
package org.jetbrains.kotlin.serialization.builtins
|
||||
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import org.jetbrains.kotlin.builtins.StandardNames
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.builtins.jvm.JvmBuiltInClassDescriptorFactory
|
||||
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
|
||||
import org.jetbrains.kotlin.cli.common.config.addKotlinSourceRoots
|
||||
@@ -100,9 +100,9 @@ class BuiltInsSerializer(dependOnOldBuiltIns: Boolean) : MetadataSerializer(Buil
|
||||
// Since Kotlin 1.1, we always discard this class during deserialization (see ClassDeserializer.kt).
|
||||
private fun createCloneable(module: ModuleDescriptor): ClassDescriptor {
|
||||
val factory = JvmBuiltInClassDescriptorFactory(LockBasedStorageManager.NO_LOCKS, module) {
|
||||
EmptyPackageFragmentDescriptor(module, StandardNames.BUILT_INS_PACKAGE_FQ_NAME)
|
||||
EmptyPackageFragmentDescriptor(module, KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME)
|
||||
}
|
||||
return factory.createClass(ClassId.topLevel(StandardNames.FqNames.cloneable.toSafe()))
|
||||
return factory.createClass(ClassId.topLevel(KotlinBuiltIns.FQ_NAMES.cloneable.toSafe()))
|
||||
?: error("Could not create kotlin.Cloneable in $module")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ dependencies {
|
||||
compile(project(":compiler:fir:resolve"))
|
||||
compile(project(":compiler:fir:jvm"))
|
||||
compile(project(":compiler:fir:java"))
|
||||
implementation(project(":compiler:fir:entrypoint"))
|
||||
compile(project(":compiler:fir:fir2ir"))
|
||||
compile(project(":compiler:fir:fir2ir:jvm-backend"))
|
||||
compile(project(":compiler:fir:checkers"))
|
||||
|
||||
@@ -317,12 +317,6 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
||||
)
|
||||
var useFir: Boolean by FreezableVar(false)
|
||||
|
||||
@Argument(
|
||||
value = "-Xuse-fir-extended-checkers",
|
||||
description = "Use extended analysis mode based on Front-end IR. Warning: this feature is far from being production-ready"
|
||||
)
|
||||
var useFirExtendedCheckers: Boolean by FreezableVar(false)
|
||||
|
||||
@Argument(
|
||||
value = "-Xuse-mixed-named-arguments",
|
||||
description = "Enable Support named arguments in their own position even if the result appears as mixed"
|
||||
|
||||
@@ -175,9 +175,6 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
|
||||
@Argument(value = "-Xdisable-fake-override-validator", description = "Disable IR fake override validator")
|
||||
var disableFakeOverrideValidator: Boolean by FreezableVar(false)
|
||||
|
||||
@Argument(value = "-Xerror-tolerance-policy", description = "Set up error tolerance policy (NONE, SEMANTIC, SYNTAX, ALL)")
|
||||
var errorTolerancePolicy: String? by NullableStringFreezableVar(null)
|
||||
|
||||
override fun checkIrSupport(languageVersionSettings: LanguageVersionSettings, collector: MessageCollector) {
|
||||
if (!isIrBackendEnabled()) return
|
||||
|
||||
|
||||
@@ -352,12 +352,6 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
|
||||
)
|
||||
var noKotlinNothingValueException: Boolean by FreezableVar(false)
|
||||
|
||||
@Argument(
|
||||
value = "-Xno-unified-null-checks",
|
||||
description = "Use pre-1.4 exception types in null checks instead of java.lang.NPE. See KT-22275 for more details"
|
||||
)
|
||||
var noUnifiedNullChecks: Boolean by FreezableVar(false)
|
||||
|
||||
@Argument(
|
||||
value = "-Xprofile",
|
||||
valueDescription = "<profilerPath:command:outputDir>",
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.kotlin.cli.common.messages;
|
||||
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -24,7 +25,6 @@ import java.io.File;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.Serializable;
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
public class OutputMessageUtil {
|
||||
@@ -69,7 +69,7 @@ public class OutputMessageUtil {
|
||||
}
|
||||
|
||||
private static Collection<File> parseSourceFiles(String[] strings, int start) {
|
||||
Collection<File> sourceFiles = new ArrayList<>();
|
||||
Collection<File> sourceFiles = ContainerUtil.newArrayList();
|
||||
for (int i = start; i < strings.length; i++) {
|
||||
sourceFiles.add(new File(strings[i]));
|
||||
}
|
||||
|
||||
@@ -89,9 +89,6 @@ open class GenericReplEvaluator(
|
||||
|
||||
historyActor.addPlaceholder(compileResult.lineId, EvalClassWithInstanceAndLoader(scriptClass.kotlin, null, classLoader, invokeWrapper))
|
||||
|
||||
val savedClassLoader = Thread.currentThread().contextClassLoader
|
||||
Thread.currentThread().contextClassLoader = classLoader
|
||||
|
||||
val scriptInstance =
|
||||
try {
|
||||
if (invokeWrapper != null) invokeWrapper.invoke { scriptInstanceConstructor.newInstance(*constructorArgs) }
|
||||
@@ -107,7 +104,6 @@ open class GenericReplEvaluator(
|
||||
}
|
||||
finally {
|
||||
historyActor.removePlaceholder(compileResult.lineId)
|
||||
Thread.currentThread().contextClassLoader = savedClassLoader
|
||||
}
|
||||
|
||||
historyActor.addFinal(compileResult.lineId, EvalClassWithInstanceAndLoader(scriptClass.kotlin, scriptInstance, classLoader, invokeWrapper))
|
||||
|
||||
@@ -34,12 +34,12 @@ fun String.replUnescapeLineBreaks() = StringUtil.replace(this, XML_REPLACEMENTS,
|
||||
fun String.replEscapeLineBreaks() = StringUtil.replace(this, SOURCE_CHARS, XML_REPLACEMENTS)
|
||||
|
||||
fun String.replOutputAsXml(escapeType: ReplEscapeType): String {
|
||||
val escapedXml = StringUtil.escapeXmlEntities(replEscapeLineBreaks())
|
||||
val escapedXml = StringUtil.escapeXml(replEscapeLineBreaks())
|
||||
return "$XML_PREAMBLE<output type=\"$escapeType\">$escapedXml</output>"
|
||||
}
|
||||
|
||||
fun String.replInputAsXml(): String {
|
||||
val escapedXml = StringUtil.escapeXmlEntities(replEscapeLineBreaks())
|
||||
val escapedXml = StringUtil.escapeXml(replEscapeLineBreaks())
|
||||
return "$XML_PREAMBLE<input>$escapedXml</input>"
|
||||
}
|
||||
|
||||
@@ -86,4 +86,4 @@ internal fun URLClassLoader.listLocalUrlsAsFiles(): List<File> {
|
||||
internal fun <T : Any> List<T>.ensureNotEmpty(error: String): List<T> {
|
||||
if (this.isEmpty()) throw IllegalStateException(error)
|
||||
return this
|
||||
}
|
||||
}
|
||||
@@ -35,7 +35,10 @@ import org.jetbrains.kotlin.incremental.js.IncrementalNextRoundChecker
|
||||
import org.jetbrains.kotlin.incremental.js.IncrementalResultsConsumer
|
||||
import org.jetbrains.kotlin.ir.backend.js.*
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.PersistentIrFactory
|
||||
import org.jetbrains.kotlin.js.config.*
|
||||
import org.jetbrains.kotlin.js.config.EcmaVersion
|
||||
import org.jetbrains.kotlin.js.config.JSConfigurationKeys
|
||||
import org.jetbrains.kotlin.js.config.JsConfig
|
||||
import org.jetbrains.kotlin.js.config.SourceMapSourceEmbedding
|
||||
import org.jetbrains.kotlin.metadata.deserialization.BinaryVersion
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.serialization.js.ModuleKind
|
||||
@@ -311,13 +314,6 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
|
||||
configuration.putIfNotNull(CommonConfigurationKeys.LOOKUP_TRACKER, services[LookupTracker::class.java])
|
||||
configuration.putIfNotNull(CommonConfigurationKeys.EXPECT_ACTUAL_TRACKER, services[ExpectActualTracker::class.java])
|
||||
|
||||
val errorTolerancePolicy = arguments.errorTolerancePolicy?.let { ErrorTolerancePolicy.resolvePolicy(it) }
|
||||
configuration.putIfNotNull(JSConfigurationKeys.ERROR_TOLERANCE_POLICY, errorTolerancePolicy)
|
||||
|
||||
if (errorTolerancePolicy?.allowErrors == true) {
|
||||
configuration.put(JSConfigurationKeys.DEVELOPER_MODE, true)
|
||||
}
|
||||
|
||||
val sourceMapEmbedContentString = arguments.sourceMapEmbedSources
|
||||
var sourceMapContentEmbedding: SourceMapSourceEmbedding? = if (sourceMapEmbedContentString != null)
|
||||
sourceMapContentEmbeddingMap[sourceMapEmbedContentString]
|
||||
|
||||
@@ -127,10 +127,10 @@ object Main {
|
||||
classpath.addPath(".")
|
||||
}
|
||||
|
||||
classpath.addPath("$KOTLIN_HOME/lib/kotlin-stdlib.jar")
|
||||
classpath.addPath(KOTLIN_HOME.toString() + "/lib/kotlin-stdlib.jar")
|
||||
|
||||
if (!noReflect) {
|
||||
classpath.addPath("$KOTLIN_HOME/lib/kotlin-reflect.jar")
|
||||
classpath.addPath(KOTLIN_HOME.toString() + "/lib/kotlin-reflect.jar")
|
||||
}
|
||||
|
||||
if (expression != null) {
|
||||
|
||||
@@ -89,10 +89,8 @@ abstract class CLICompiler<A : CommonCompilerArguments> : CLITool<A>() {
|
||||
|
||||
performanceManager.notifyCompilationFinished()
|
||||
if (arguments.reportPerf) {
|
||||
collector.report(INFO, "PERF: " + performanceManager.getTargetInfo())
|
||||
for (measurement in performanceManager.getMeasurementResults()) {
|
||||
collector.report(INFO, "PERF: " + measurement.render(), null)
|
||||
}
|
||||
performanceManager.getMeasurementResults()
|
||||
.forEach { it -> configuration.get(MESSAGE_COLLECTOR_KEY)!!.report(INFO, "PERF: " + it.render(), null) }
|
||||
}
|
||||
|
||||
if (arguments.dumpPerf != null) {
|
||||
|
||||
@@ -24,13 +24,6 @@ abstract class CommonCompilerPerformanceManager(private val presentableName: Str
|
||||
private var irTranslationStart: Long = 0
|
||||
private var irGenerationStart: Long = 0
|
||||
|
||||
private var targetDescription: String? = null
|
||||
protected var files: Int? = null
|
||||
protected var lines: Int? = null
|
||||
|
||||
fun getTargetInfo(): String =
|
||||
"$targetDescription, $files files ($lines lines)"
|
||||
|
||||
fun getMeasurementResults(): List<PerformanceMeasurement> = measurements
|
||||
|
||||
fun enableCollectingPerformanceStatistics() {
|
||||
@@ -41,13 +34,9 @@ abstract class CommonCompilerPerformanceManager(private val presentableName: Str
|
||||
|
||||
private fun deltaTime(start: Long): Long = PerformanceCounter.currentTime() - start
|
||||
|
||||
open fun notifyCompilerInitialized(files: Int, lines: Int, targetDescription: String) {
|
||||
open fun notifyCompilerInitialized() {
|
||||
if (!isEnabled) return
|
||||
recordInitializationTime()
|
||||
|
||||
this.files = files
|
||||
this.lines = lines
|
||||
this.targetDescription = targetDescription
|
||||
}
|
||||
|
||||
open fun notifyCompilationFinished() {
|
||||
@@ -61,30 +50,32 @@ abstract class CommonCompilerPerformanceManager(private val presentableName: Str
|
||||
analysisStart = PerformanceCounter.currentTime()
|
||||
}
|
||||
|
||||
open fun notifyAnalysisFinished() {
|
||||
open fun notifyAnalysisFinished(files: Int, lines: Int, additionalDescription: String?) {
|
||||
val time = PerformanceCounter.currentTime() - analysisStart
|
||||
measurements += CodeAnalysisMeasurement(lines, TimeUnit.NANOSECONDS.toMillis(time))
|
||||
measurements += CodeAnalysisMeasurement(files, lines, TimeUnit.NANOSECONDS.toMillis(time), additionalDescription)
|
||||
}
|
||||
|
||||
open fun notifyGenerationStarted() {
|
||||
generationStart = PerformanceCounter.currentTime()
|
||||
}
|
||||
|
||||
open fun notifyGenerationFinished() {
|
||||
open fun notifyGenerationFinished(files: Int, lines: Int, additionalDescription: String) {
|
||||
val time = PerformanceCounter.currentTime() - generationStart
|
||||
measurements += CodeGenerationMeasurement(lines, TimeUnit.NANOSECONDS.toMillis(time))
|
||||
measurements += CodeGenerationMeasurement(files, lines, TimeUnit.NANOSECONDS.toMillis(time), additionalDescription)
|
||||
}
|
||||
|
||||
open fun notifyIRTranslationStarted() {
|
||||
irTranslationStart = PerformanceCounter.currentTime()
|
||||
}
|
||||
|
||||
open fun notifyIRTranslationFinished() {
|
||||
open fun notifyIRTranslationFinished(files: Int, lines: Int, additionalDescription: String?) {
|
||||
val time = deltaTime(irTranslationStart)
|
||||
measurements += IRMeasurement(
|
||||
files,
|
||||
lines,
|
||||
TimeUnit.NANOSECONDS.toMillis(time),
|
||||
IRMeasurement.Kind.TRANSLATION
|
||||
additionalDescription,
|
||||
IRMeasurement.Kind.Translation
|
||||
)
|
||||
}
|
||||
|
||||
@@ -92,12 +83,14 @@ abstract class CommonCompilerPerformanceManager(private val presentableName: Str
|
||||
irGenerationStart = PerformanceCounter.currentTime()
|
||||
}
|
||||
|
||||
open fun notifyIRGenerationFinished() {
|
||||
open fun notifyIRGenerationFinished(files: Int, lines: Int, additionalDescription: String) {
|
||||
val time = deltaTime(irGenerationStart)
|
||||
measurements += IRMeasurement(
|
||||
files,
|
||||
lines,
|
||||
TimeUnit.NANOSECONDS.toMillis(time),
|
||||
IRMeasurement.Kind.GENERATION
|
||||
additionalDescription,
|
||||
IRMeasurement.Kind.Generation
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.cli.common;
|
||||
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import kotlin.jvm.JvmClassMappingKt;
|
||||
import kotlin.reflect.KCallable;
|
||||
@@ -30,9 +29,6 @@ import org.jetbrains.kotlin.cli.common.arguments.ParseCommandLineArgumentsKt;
|
||||
import org.jetbrains.kotlin.cli.common.arguments.PreprocessCommandLineArgumentsKt;
|
||||
|
||||
public class Usage {
|
||||
public static final String BAT_DELIMITER_CHARACTERS_NOTE =
|
||||
"Note: on Windows, arguments that contain delimiter characters (whitespace, =, ;, ,) need to be surrounded with double quotes (\").";
|
||||
|
||||
// The magic number 29 corresponds to the similar padding width in javac and scalac command line compilers
|
||||
private static final int OPTION_NAME_PADDING_WIDTH = 29;
|
||||
|
||||
@@ -45,7 +41,7 @@ public class Usage {
|
||||
KClass<? extends CommonToolArguments> kClass = JvmClassMappingKt.getKotlinClass(arguments.getClass());
|
||||
for (KCallable<?> callable : kClass.getMembers()) {
|
||||
if (!(callable instanceof KProperty1)) continue;
|
||||
propertyUsage(sb, (KProperty1<?, ?>) callable, extraHelp);
|
||||
propertyUsage(sb, (KProperty1) callable, extraHelp);
|
||||
}
|
||||
|
||||
if (extraHelp) {
|
||||
@@ -56,20 +52,10 @@ public class Usage {
|
||||
renderArgfileUsage(sb);
|
||||
}
|
||||
|
||||
if (SystemInfo.isWindows) {
|
||||
appendln(sb, "");
|
||||
appendln(sb, BAT_DELIMITER_CHARACTERS_NOTE);
|
||||
}
|
||||
|
||||
if (!extraHelp && tool instanceof CLICompiler<?>) {
|
||||
appendln(sb, "");
|
||||
appendln(sb, "For details, see https://kotl.in/cli");
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private static void propertyUsage(@NotNull StringBuilder sb, @NotNull KProperty1<?, ?> property, boolean extraHelp) {
|
||||
private static void propertyUsage(@NotNull StringBuilder sb, @NotNull KProperty1 property, boolean extraHelp) {
|
||||
Argument argument = ContainerUtil.findInstance(property.getAnnotations(), Argument.class);
|
||||
if (argument == null) return;
|
||||
|
||||
@@ -116,6 +102,6 @@ public class Usage {
|
||||
|
||||
private static void appendln(@NotNull StringBuilder sb, @NotNull String string) {
|
||||
sb.append(string);
|
||||
sb.append('\n');
|
||||
StringsKt.appendln(sb);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ fun <A : CommonCompilerArguments> CompilerConfiguration.setupCommonArguments(
|
||||
) {
|
||||
put(CommonConfigurationKeys.DISABLE_INLINE, arguments.noInline)
|
||||
put(CommonConfigurationKeys.USE_FIR, arguments.useFir)
|
||||
put(CommonConfigurationKeys.USE_FIR_EXTENDED_CHECKERS, arguments.useFirExtendedCheckers)
|
||||
put(CommonConfigurationKeys.EXPECT_ACTUAL_LINKER, arguments.expectActualLinker)
|
||||
putIfNotNull(CLIConfigurationKeys.INTELLIJ_PLUGIN_ROOT, arguments.intellijPluginRoot)
|
||||
put(CommonConfigurationKeys.REPORT_OUTPUT_FILES, arguments.reportOutputFiles)
|
||||
|
||||
@@ -9,41 +9,54 @@ interface PerformanceMeasurement {
|
||||
fun render(): String
|
||||
}
|
||||
|
||||
|
||||
class JitCompilationMeasurement(private val milliseconds: Long) : PerformanceMeasurement {
|
||||
override fun render(): String = "JIT time is $milliseconds ms"
|
||||
}
|
||||
|
||||
|
||||
class CompilerInitializationMeasurement(private val milliseconds: Long) : PerformanceMeasurement {
|
||||
override fun render(): String = "INIT: Compiler initialized in $milliseconds ms"
|
||||
}
|
||||
|
||||
class CodeAnalysisMeasurement(private val lines: Int?, val milliseconds: Long) : PerformanceMeasurement {
|
||||
override fun render(): String = formatMeasurement("ANALYZE", milliseconds, lines)
|
||||
|
||||
class CodeAnalysisMeasurement(val files: Int, val lines: Int, val milliseconds: Long, private val description: String?) :
|
||||
PerformanceMeasurement {
|
||||
|
||||
val lps: Double = lines.toDouble() * 1000 / milliseconds
|
||||
|
||||
override fun render(): String =
|
||||
"ANALYZE: $files files ($lines lines) ${description ?: ""}in $milliseconds ms - ${"%.3f".format(lps)} loc/s"
|
||||
}
|
||||
|
||||
class CodeGenerationMeasurement(private val lines: Int?, private val milliseconds: Long) : PerformanceMeasurement {
|
||||
override fun render(): String = formatMeasurement("GENERATE", milliseconds, lines)
|
||||
|
||||
class CodeGenerationMeasurement(private val files: Int, val lines: Int, private val milliseconds: Long, private val description: String?) :
|
||||
PerformanceMeasurement {
|
||||
|
||||
private val speed: Double = lines.toDouble() * 1000 / milliseconds
|
||||
|
||||
override fun render(): String =
|
||||
"GENERATE: $files files ($lines lines) ${description}in $milliseconds ms - ${"%.3f".format(speed)} loc/s"
|
||||
}
|
||||
|
||||
|
||||
class GarbageCollectionMeasurement(val garbageCollectionKind: String, val milliseconds: Long, val count: Long) : PerformanceMeasurement {
|
||||
override fun render(): String = "GC time for $garbageCollectionKind is $milliseconds ms, $count collections"
|
||||
}
|
||||
|
||||
|
||||
class PerformanceCounterMeasurement(private val counterReport: String) : PerformanceMeasurement {
|
||||
override fun render(): String = counterReport
|
||||
}
|
||||
|
||||
class IRMeasurement(val lines: Int?, val milliseconds: Long, val kind: Kind) : PerformanceMeasurement {
|
||||
override fun render(): String = formatMeasurement("IR $kind", milliseconds, lines)
|
||||
class IRMeasurement(val files: Int, val lines: Int, val milliseconds: Long, private val description: String?, val kind: Kind) :
|
||||
PerformanceMeasurement {
|
||||
|
||||
val lps: Double = lines.toDouble() * 1000 / milliseconds
|
||||
override fun render(): String =
|
||||
"IR: $kind $files files ($lines lines) ${description ?: ""}in $milliseconds ms - ${"%.3f".format(lps)} loc/s"
|
||||
|
||||
enum class Kind {
|
||||
TRANSLATION, GENERATION
|
||||
Generation, Translation
|
||||
}
|
||||
}
|
||||
|
||||
private fun formatMeasurement(name: String, time: Long, lines: Int?): String =
|
||||
"%15s%8s ms".format(name, time) +
|
||||
(lines?.let {
|
||||
val lps = it.toDouble() * 1000 / time
|
||||
"%12.3f loc/s".format(lps)
|
||||
} ?: "")
|
||||
|
||||
@@ -147,14 +147,9 @@ class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
|
||||
ModuleChunk(listOf(module))
|
||||
}
|
||||
|
||||
val chunk = moduleChunk.modules
|
||||
KotlinToJVMBytecodeCompiler.configureSourceRoots(configuration, chunk, buildFile)
|
||||
val environment = createCoreEnvironment(
|
||||
rootDisposable, configuration, messageCollector,
|
||||
chunk.map { input -> input.getModuleName() + "-" + input.getModuleType() }.let { names ->
|
||||
names.singleOrNull() ?: names.joinToString()
|
||||
}
|
||||
) ?: return COMPILATION_ERROR
|
||||
KotlinToJVMBytecodeCompiler.configureSourceRoots(configuration, moduleChunk.modules, buildFile)
|
||||
val environment = createCoreEnvironment(rootDisposable, configuration, messageCollector)
|
||||
?: return COMPILATION_ERROR
|
||||
environment.registerJavacIfNeeded(arguments).let {
|
||||
if (!it) return COMPILATION_ERROR
|
||||
}
|
||||
@@ -166,7 +161,7 @@ class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
|
||||
return COMPILATION_ERROR
|
||||
}
|
||||
|
||||
KotlinToJVMBytecodeCompiler.compileModules(environment, buildFile, chunk)
|
||||
KotlinToJVMBytecodeCompiler.compileModules(environment, buildFile, moduleChunk.modules)
|
||||
return OK
|
||||
} catch (e: CompilationException) {
|
||||
messageCollector.report(
|
||||
@@ -218,17 +213,13 @@ class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
|
||||
private fun createCoreEnvironment(
|
||||
rootDisposable: Disposable,
|
||||
configuration: CompilerConfiguration,
|
||||
messageCollector: MessageCollector,
|
||||
targetDescription: String
|
||||
messageCollector: MessageCollector
|
||||
): KotlinCoreEnvironment? {
|
||||
if (messageCollector.hasErrors()) return null
|
||||
|
||||
val environment = KotlinCoreEnvironment.createForProduction(rootDisposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES)
|
||||
|
||||
val sourceFiles = environment.getSourceFiles()
|
||||
configuration[CLIConfigurationKeys.PERF_MANAGER]?.notifyCompilerInitialized(
|
||||
sourceFiles.size, environment.countLinesOfCode(sourceFiles), targetDescription
|
||||
)
|
||||
configuration[CLIConfigurationKeys.PERF_MANAGER]?.notifyCompilerInitialized()
|
||||
|
||||
return if (messageCollector.hasErrors()) null else environment
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ class CliKotlinAsJavaSupport(
|
||||
override fun getFacadeClassesInPackage(packageFqName: FqName, scope: GlobalSearchScope): Collection<PsiClass> {
|
||||
return findFacadeFilesInPackage(packageFqName, scope)
|
||||
.groupBy { it.javaFileFacadeFqName }
|
||||
.mapNotNull { (facadeClassFqName, _) ->
|
||||
.mapNotNull { (facadeClassFqName, files) ->
|
||||
KtLightClassForFacade.createForFacade(psiManager, facadeClassFqName, scope)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* 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.codeInsight.ContainerProvider;
|
||||
import com.intellij.codeInsight.runner.JavaMainMethodProvider;
|
||||
import com.intellij.core.CoreApplicationEnvironment;
|
||||
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.extensions.ExtensionsArea;
|
||||
import com.intellij.openapi.fileTypes.FileTypeExtensionPoint;
|
||||
import com.intellij.openapi.vfs.VirtualFileSystem;
|
||||
import com.intellij.psi.FileContextProvider;
|
||||
import com.intellij.psi.augment.PsiAugmentProvider;
|
||||
import com.intellij.psi.augment.TypeAnnotationModifier;
|
||||
import com.intellij.psi.compiled.ClassFileDecompilers;
|
||||
import com.intellij.psi.meta.MetaDataContributor;
|
||||
import com.intellij.psi.stubs.BinaryFileStubBuilders;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.cli.jvm.modules.CoreJrtFileSystem;
|
||||
|
||||
// Mostly a placeholder for the functionality added to the bunch 193
|
||||
public class KotlinCoreApplicationEnvironment extends JavaCoreApplicationEnvironment {
|
||||
|
||||
public static KotlinCoreApplicationEnvironment create(@NotNull Disposable parentDisposable, boolean unitTestMode) {
|
||||
Extensions.cleanRootArea(parentDisposable);
|
||||
registerExtensionPoints();
|
||||
return new KotlinCoreApplicationEnvironment(parentDisposable, unitTestMode);
|
||||
}
|
||||
|
||||
private KotlinCoreApplicationEnvironment(@NotNull Disposable parentDisposable, boolean unitTestMode) {
|
||||
super(parentDisposable, unitTestMode);
|
||||
}
|
||||
|
||||
private static void registerExtensionPoints() {
|
||||
ExtensionsArea area = Extensions.getRootArea();
|
||||
|
||||
CoreApplicationEnvironment.registerExtensionPoint(area, BinaryFileStubBuilders.EP_NAME, FileTypeExtensionPoint.class);
|
||||
CoreApplicationEnvironment.registerExtensionPoint(area, FileContextProvider.EP_NAME, FileContextProvider.class);
|
||||
|
||||
CoreApplicationEnvironment.registerExtensionPoint(area, MetaDataContributor.EP_NAME, MetaDataContributor.class);
|
||||
CoreApplicationEnvironment.registerExtensionPoint(area, PsiAugmentProvider.EP_NAME, PsiAugmentProvider.class);
|
||||
CoreApplicationEnvironment.registerExtensionPoint(area, JavaMainMethodProvider.EP_NAME, JavaMainMethodProvider.class);
|
||||
|
||||
CoreApplicationEnvironment.registerExtensionPoint(area, ContainerProvider.EP_NAME, ContainerProvider.class);
|
||||
CoreApplicationEnvironment.registerExtensionPoint(area, ClassFileDecompilers.EP_NAME, ClassFileDecompilers.Decompiler.class);
|
||||
|
||||
CoreApplicationEnvironment.registerExtensionPoint(area, TypeAnnotationModifier.EP_NAME, TypeAnnotationModifier.class);
|
||||
CoreApplicationEnvironment.registerExtensionPoint(area, MetaLanguage.EP_NAME, MetaLanguage.class);
|
||||
|
||||
IdeaExtensionPoints.INSTANCE.registerVersionSpecificAppExtensionPoints(area);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected VirtualFileSystem createJrtFileSystem() {
|
||||
return new CoreJrtFileSystem();
|
||||
}
|
||||
}
|
||||
@@ -608,10 +608,7 @@ class KotlinCoreEnvironment private constructor(
|
||||
// made public for Upsource
|
||||
@JvmStatic
|
||||
@Deprecated("Use registerProjectServices(project) instead.", ReplaceWith("registerProjectServices(projectEnvironment.project)"))
|
||||
fun registerProjectServices(
|
||||
projectEnvironment: JavaCoreProjectEnvironment,
|
||||
@Suppress("UNUSED_PARAMETER") messageCollector: MessageCollector?
|
||||
) {
|
||||
fun registerProjectServices(projectEnvironment: JavaCoreProjectEnvironment, messageCollector: MessageCollector?) {
|
||||
registerProjectServices(projectEnvironment.project)
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,8 @@ import org.jetbrains.kotlin.asJava.finder.JavaElementFinder
|
||||
import org.jetbrains.kotlin.backend.common.output.OutputFileCollection
|
||||
import org.jetbrains.kotlin.backend.common.output.SimpleOutputFileCollection
|
||||
import org.jetbrains.kotlin.backend.common.phaser.PhaseConfig
|
||||
import org.jetbrains.kotlin.backend.common.serialization.signature.IdSignatureDescriptor
|
||||
import org.jetbrains.kotlin.backend.jvm.JvmGeneratorExtensions
|
||||
import org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory
|
||||
import org.jetbrains.kotlin.backend.jvm.jvmPhases
|
||||
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
|
||||
@@ -50,19 +52,26 @@ import org.jetbrains.kotlin.codegen.KotlinCodegenFacade
|
||||
import org.jetbrains.kotlin.codegen.state.GenerationState
|
||||
import org.jetbrains.kotlin.codegen.state.GenerationStateEventCallback
|
||||
import org.jetbrains.kotlin.config.*
|
||||
import org.jetbrains.kotlin.diagnostics.*
|
||||
import org.jetbrains.kotlin.fileClasses.JvmFileClassUtil
|
||||
import org.jetbrains.kotlin.fir.FirPsiSourceElement
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.analysis.FirAnalyzerFacade
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.*
|
||||
import org.jetbrains.kotlin.fir.backend.Fir2IrConverter
|
||||
import org.jetbrains.kotlin.fir.backend.jvm.FirJvmBackendClassResolver
|
||||
import org.jetbrains.kotlin.fir.backend.jvm.FirJvmClassCodegen
|
||||
import org.jetbrains.kotlin.fir.checkers.registerExtendedCommonCheckers
|
||||
import org.jetbrains.kotlin.fir.backend.jvm.FirJvmKotlinMangler
|
||||
import org.jetbrains.kotlin.fir.builder.RawFirBuilder
|
||||
import org.jetbrains.kotlin.fir.extensions.BunchOfRegisteredExtensions
|
||||
import org.jetbrains.kotlin.fir.extensions.extensionService
|
||||
import org.jetbrains.kotlin.fir.extensions.registerExtensions
|
||||
import org.jetbrains.kotlin.fir.java.FirJavaModuleBasedSession
|
||||
import org.jetbrains.kotlin.fir.java.FirLibrarySession
|
||||
import org.jetbrains.kotlin.fir.java.FirProjectSessionProvider
|
||||
import org.jetbrains.kotlin.fir.session.FirSessionFactory
|
||||
import org.jetbrains.kotlin.fir.resolve.firProvider
|
||||
import org.jetbrains.kotlin.fir.resolve.providers.impl.FirProviderImpl
|
||||
import org.jetbrains.kotlin.fir.resolve.transformers.FirTotalResolveProcessor
|
||||
import org.jetbrains.kotlin.idea.MainFunctionDetector
|
||||
import org.jetbrains.kotlin.ir.backend.jvm.jvmResolveLibraries
|
||||
import org.jetbrains.kotlin.ir.backend.jvm.serialization.JvmManglerDesc
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
|
||||
import org.jetbrains.kotlin.javac.JavacWrapper
|
||||
import org.jetbrains.kotlin.load.kotlin.ModuleVisibilityManager
|
||||
import org.jetbrains.kotlin.modules.Module
|
||||
@@ -74,7 +83,6 @@ import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
|
||||
import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.resolve.PlatformDependentAnalyzerServices
|
||||
import org.jetbrains.kotlin.resolve.diagnostics.SimpleDiagnostics
|
||||
import org.jetbrains.kotlin.resolve.jvm.KotlinJavaPsiFacade
|
||||
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatformAnalyzerServices
|
||||
import org.jetbrains.kotlin.utils.newLinkedHashMapWithExpectedSize
|
||||
@@ -185,11 +193,12 @@ object KotlinToJVMBytecodeCompiler {
|
||||
|
||||
val projectConfiguration = environment.configuration
|
||||
if (projectConfiguration.getBoolean(CommonConfigurationKeys.USE_FIR)) {
|
||||
val extendedAnalysisMode = projectConfiguration.getBoolean(CommonConfigurationKeys.USE_FIR_EXTENDED_CHECKERS)
|
||||
return compileModulesUsingFrontendIR(environment, buildFile, chunk, extendedAnalysisMode)
|
||||
return compileModulesUsingFrontendIR(environment, buildFile, chunk)
|
||||
}
|
||||
|
||||
val result = repeatAnalysisIfNeeded(analyze(environment), environment)
|
||||
val targetDescription = "in targets [" + chunk.joinToString { input -> input.getModuleName() + "-" + input.getModuleType() } + "]"
|
||||
|
||||
val result = repeatAnalysisIfNeeded(analyze(environment, targetDescription), environment, targetDescription)
|
||||
if (result == null || !result.shouldGenerateCode) return false
|
||||
|
||||
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()
|
||||
@@ -294,16 +303,13 @@ object KotlinToJVMBytecodeCompiler {
|
||||
configuration.addAll(JVMConfigurationKeys.MODULES, chunk)
|
||||
}
|
||||
|
||||
private fun compileModulesUsingFrontendIR(
|
||||
environment: KotlinCoreEnvironment,
|
||||
buildFile: File?,
|
||||
chunk: List<Module>,
|
||||
extendedAnalysisMode: Boolean
|
||||
): Boolean {
|
||||
private fun compileModulesUsingFrontendIR(environment: KotlinCoreEnvironment, buildFile: File?, chunk: List<Module>): Boolean {
|
||||
val project = environment.project
|
||||
val performanceManager = environment.configuration.get(CLIConfigurationKeys.PERF_MANAGER)
|
||||
|
||||
PsiElementFinder.EP.getPoint(project).unregisterExtension(JavaElementFinder::class.java)
|
||||
Extensions.getArea(project)
|
||||
.getExtensionPoint(PsiElementFinder.EP_NAME)
|
||||
.unregisterExtension(JavaElementFinder::class.java)
|
||||
|
||||
val projectConfiguration = environment.configuration
|
||||
val localFileSystem = VirtualFileManager.getInstance().getFileSystem(StandardFileSystems.FILE_PROTOCOL)
|
||||
@@ -337,42 +343,47 @@ object KotlinToJVMBytecodeCompiler {
|
||||
}
|
||||
|
||||
val moduleInfo = FirJvmModuleInfo(module.getModuleName())
|
||||
val session: FirSession = FirSessionFactory.createJavaModuleBasedSession(moduleInfo, provider, scope) {
|
||||
if (extendedAnalysisMode) {
|
||||
registerExtendedCommonCheckers()
|
||||
}
|
||||
}.also {
|
||||
val session: FirSession = FirJavaModuleBasedSession.create(moduleInfo, provider, scope).also {
|
||||
val dependenciesInfo = FirJvmModuleInfo(Name.special("<dependencies>"))
|
||||
moduleInfo.dependencies.add(dependenciesInfo)
|
||||
val librariesScope = ProjectScope.getLibrariesScope(project)
|
||||
FirSessionFactory.createLibrarySession(
|
||||
FirLibrarySession.create(
|
||||
dependenciesInfo, provider, librariesScope,
|
||||
project, environment.createPackagePartProvider(librariesScope)
|
||||
)
|
||||
it.extensionService.registerExtensions(BunchOfRegisteredExtensions.empty())
|
||||
}
|
||||
val firProvider = (session.firProvider as FirProviderImpl)
|
||||
val builder = RawFirBuilder(session, firProvider.kotlinScopeProvider, stubMode = false)
|
||||
val resolveTransformer = FirTotalResolveProcessor(session)
|
||||
val firFiles = ktFiles.map {
|
||||
val firFile = builder.buildFirFile(it)
|
||||
firProvider.recordFile(firFile)
|
||||
firFile
|
||||
}.also {
|
||||
try {
|
||||
resolveTransformer.process(it)
|
||||
} catch (e: Exception) {
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
val firAnalyzerFacade = FirAnalyzerFacade(session, moduleConfiguration.languageVersionSettings, ktFiles)
|
||||
|
||||
firAnalyzerFacade.runResolution()
|
||||
val firDiagnostics = firAnalyzerFacade.runCheckers()
|
||||
AnalyzerWithCompilerReport.reportDiagnostics(
|
||||
SimpleDiagnostics(
|
||||
firDiagnostics.map { it.toRegularDiagnostic() }
|
||||
),
|
||||
environment.messageCollector
|
||||
)
|
||||
performanceManager?.notifyAnalysisFinished()
|
||||
|
||||
if (firDiagnostics.any { it.severity == Severity.ERROR }) {
|
||||
return false
|
||||
}
|
||||
val debugTargetDescription = "target " + module.getModuleName() + "-" + module.getModuleType() + " "
|
||||
val codeLines = environment.countLinesOfCode(ktFiles)
|
||||
performanceManager?.notifyAnalysisFinished(ktFiles.size, codeLines, debugTargetDescription)
|
||||
|
||||
performanceManager?.notifyGenerationStarted()
|
||||
val signaturer = IdSignatureDescriptor(JvmManglerDesc())
|
||||
|
||||
performanceManager?.notifyIRTranslationStarted()
|
||||
val (moduleFragment, symbolTable, sourceManager, components) = firAnalyzerFacade.convertToIr()
|
||||
val (moduleFragment, symbolTable, sourceManager, components) =
|
||||
Fir2IrConverter.createModuleFragment(
|
||||
session, resolveTransformer.scopeSession, firFiles,
|
||||
moduleConfiguration.languageVersionSettings, signaturer,
|
||||
JvmGeneratorExtensions(), FirJvmKotlinMangler(session), IrFactoryImpl
|
||||
)
|
||||
|
||||
performanceManager?.notifyIRTranslationFinished()
|
||||
performanceManager?.notifyIRTranslationFinished(ktFiles.size, codeLines, debugTargetDescription)
|
||||
|
||||
val dummyBindingContext = NoScopeRecordCliBindingTrace().bindingContext
|
||||
|
||||
@@ -404,6 +415,11 @@ object KotlinToJVMBytecodeCompiler {
|
||||
}
|
||||
CodegenFactory.doCheckCancelled(generationState)
|
||||
generationState.factory.done()
|
||||
performanceManager?.notifyGenerationFinished(
|
||||
ktFiles.size,
|
||||
codeLines,
|
||||
additionalDescription = debugTargetDescription
|
||||
)
|
||||
|
||||
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()
|
||||
|
||||
@@ -419,37 +435,13 @@ object KotlinToJVMBytecodeCompiler {
|
||||
generationState.extraJvmDiagnosticsTrace.bindingContext, environment.messageCollector
|
||||
)
|
||||
|
||||
performanceManager?.notifyIRGenerationFinished()
|
||||
performanceManager?.notifyGenerationFinished()
|
||||
performanceManager?.notifyIRGenerationFinished(ktFiles.size, codeLines, additionalDescription = debugTargetDescription)
|
||||
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()
|
||||
outputs[module] = generationState
|
||||
}
|
||||
return writeOutputs(environment, projectConfiguration, chunk, outputs)
|
||||
}
|
||||
|
||||
private fun FirDiagnostic<*>.toRegularDiagnostic(): Diagnostic {
|
||||
val psiSource = element as FirPsiSourceElement<*>
|
||||
@Suppress("TYPE_MISMATCH")
|
||||
when (this) {
|
||||
is FirSimpleDiagnostic ->
|
||||
return SimpleDiagnostic(
|
||||
psiSource.psi, factory.psiDiagnosticFactory, severity
|
||||
)
|
||||
is FirDiagnosticWithParameters1<*, *> ->
|
||||
return DiagnosticWithParameters1(
|
||||
psiSource.psi, this.a, factory.psiDiagnosticFactory, severity
|
||||
)
|
||||
is FirDiagnosticWithParameters2<*, *, *> ->
|
||||
return DiagnosticWithParameters2(
|
||||
psiSource.psi, this.a, this.b, factory.psiDiagnosticFactory, severity
|
||||
)
|
||||
is FirDiagnosticWithParameters3<*, *, *, *> ->
|
||||
return DiagnosticWithParameters3(
|
||||
psiSource.psi, this.a, this.b, this.c, factory.psiDiagnosticFactory, severity
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getBuildFilePaths(buildFile: File?, sourceFilePaths: List<String>): List<String> =
|
||||
if (buildFile == null) sourceFilePaths
|
||||
else sourceFilePaths.map { path ->
|
||||
@@ -492,7 +484,11 @@ object KotlinToJVMBytecodeCompiler {
|
||||
}
|
||||
}
|
||||
|
||||
private fun repeatAnalysisIfNeeded(result: AnalysisResult?, environment: KotlinCoreEnvironment): AnalysisResult? {
|
||||
private fun repeatAnalysisIfNeeded(
|
||||
result: AnalysisResult?,
|
||||
environment: KotlinCoreEnvironment,
|
||||
targetDescription: String?
|
||||
): AnalysisResult? {
|
||||
if (result is AnalysisResult.RetryWithAdditionalRoots) {
|
||||
val configuration = environment.configuration
|
||||
|
||||
@@ -515,7 +511,7 @@ object KotlinToJVMBytecodeCompiler {
|
||||
configuration[CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY]?.clear()
|
||||
|
||||
// Repeat analysis with additional Java roots (kapt generated sources)
|
||||
return analyze(environment)
|
||||
return analyze(environment, targetDescription)
|
||||
}
|
||||
|
||||
return result
|
||||
@@ -523,7 +519,7 @@ object KotlinToJVMBytecodeCompiler {
|
||||
|
||||
@Suppress("MemberVisibilityCanBePrivate") // Used in ExecuteKotlinScriptMojo
|
||||
fun analyzeAndGenerate(environment: KotlinCoreEnvironment): GenerationState? {
|
||||
val result = repeatAnalysisIfNeeded(analyze(environment), environment) ?: return null
|
||||
val result = repeatAnalysisIfNeeded(analyze(environment, null), environment, null) ?: return null
|
||||
|
||||
if (!result.shouldGenerateCode) return null
|
||||
|
||||
@@ -532,7 +528,7 @@ object KotlinToJVMBytecodeCompiler {
|
||||
return generate(environment, environment.configuration, result, environment.getSourceFiles(), null)
|
||||
}
|
||||
|
||||
fun analyze(environment: KotlinCoreEnvironment): AnalysisResult? {
|
||||
fun analyze(environment: KotlinCoreEnvironment, targetDescription: String?): AnalysisResult? {
|
||||
val sourceFiles = environment.getSourceFiles()
|
||||
val collector = environment.messageCollector
|
||||
|
||||
@@ -565,7 +561,7 @@ object KotlinToJVMBytecodeCompiler {
|
||||
)
|
||||
}
|
||||
|
||||
performanceManager?.notifyAnalysisFinished()
|
||||
performanceManager?.notifyAnalysisFinished(sourceFiles.size, environment.countLinesOfCode(sourceFiles), targetDescription)
|
||||
|
||||
val analysisResult = analyzerWithCompilerReport.analysisResult
|
||||
|
||||
@@ -646,7 +642,11 @@ object KotlinToJVMBytecodeCompiler {
|
||||
|
||||
KotlinCodegenFacade.compileCorrectFiles(generationState)
|
||||
|
||||
performanceManager?.notifyGenerationFinished()
|
||||
performanceManager?.notifyGenerationFinished(
|
||||
sourceFiles.size,
|
||||
environment.countLinesOfCode(sourceFiles),
|
||||
additionalDescription = if (module != null) "target " + module.getModuleName() + "-" + module.getModuleType() + " " else ""
|
||||
)
|
||||
|
||||
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()
|
||||
|
||||
|
||||
@@ -166,7 +166,6 @@ fun CompilerConfiguration.configureAdvancedJvmOptions(arguments: K2JVMCompilerAr
|
||||
put(JVMConfigurationKeys.EMIT_JVM_TYPE_ANNOTATIONS, arguments.emitJvmTypeAnnotations)
|
||||
put(JVMConfigurationKeys.NO_OPTIMIZED_CALLABLE_REFERENCES, arguments.noOptimizedCallableReferences)
|
||||
put(JVMConfigurationKeys.NO_KOTLIN_NOTHING_VALUE_EXCEPTION, arguments.noKotlinNothingValueException)
|
||||
put(JVMConfigurationKeys.NO_UNIFIED_NULL_CHECKS, arguments.noUnifiedNullChecks)
|
||||
|
||||
if (!JVMConstructorCallNormalizationMode.isSupportedValue(arguments.constructorCallNormalizationMode)) {
|
||||
getNotNull(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY).report(
|
||||
|
||||
@@ -49,7 +49,7 @@ object KotlinCompilerRunnerUtils {
|
||||
additionalJvmParams: Array<String> = arrayOf()
|
||||
): CompileServiceSession? {
|
||||
val daemonJVMOptions = configureDaemonJVMOptions(
|
||||
additionalParams = additionalJvmParams,
|
||||
additionalParams = *additionalJvmParams,
|
||||
inheritMemoryLimits = true,
|
||||
inheritOtherJvmOptions = false,
|
||||
inheritAdditionalProperties = true
|
||||
|
||||
@@ -123,9 +123,6 @@ public class JVMConfigurationKeys {
|
||||
public static final CompilerConfigurationKey<Boolean> NO_KOTLIN_NOTHING_VALUE_EXCEPTION =
|
||||
CompilerConfigurationKey.create("Do not use KotlinNothingValueException available since 1.4");
|
||||
|
||||
public static final CompilerConfigurationKey<Boolean> NO_UNIFIED_NULL_CHECKS =
|
||||
CompilerConfigurationKey.create("Use pre-1.4 exception types in null checks instead of java.lang.NPE");
|
||||
|
||||
public static final CompilerConfigurationKey<Boolean> USE_OLD_SPILLED_VAR_TYPE_ANALYSIS =
|
||||
CompilerConfigurationKey.create("Use old, SourceInterpreter-based analysis for fields, used for spilled variables in coroutines");
|
||||
}
|
||||
|
||||
@@ -4,8 +4,7 @@ plugins {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api(project(":core:metadata"))
|
||||
api(project(":core:compiler.common"))
|
||||
api(project(":core:deserialization"))
|
||||
api(project(":compiler:util"))
|
||||
compileOnly(intellijCoreDep()) { includeJars("intellij-core") }
|
||||
}
|
||||
|
||||
@@ -50,9 +50,6 @@ object CommonConfigurationKeys {
|
||||
|
||||
@JvmField
|
||||
val DESERIALIZE_FAKE_OVERRIDES = CompilerConfigurationKey.create<Boolean>("Deserialize fake overrides")
|
||||
|
||||
@JvmField
|
||||
val USE_FIR_EXTENDED_CHECKERS = CompilerConfigurationKey.create<Boolean>("fir extended checkers")
|
||||
}
|
||||
|
||||
var CompilerConfiguration.languageVersionSettings: LanguageVersionSettings
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
|
||||
package org.jetbrains.kotlin.config
|
||||
|
||||
import org.jetbrains.kotlin.builtins.StandardNames
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
|
||||
fun LanguageVersionSettings.coroutinesPackageFqName(): FqName {
|
||||
return coroutinesPackageFqName(isReleaseCoroutines())
|
||||
@@ -17,9 +17,9 @@ fun LanguageVersionSettings.isReleaseCoroutines() = supportsFeature(LanguageFeat
|
||||
|
||||
private fun coroutinesPackageFqName(isReleaseCoroutines: Boolean): FqName {
|
||||
return if (isReleaseCoroutines)
|
||||
StandardNames.COROUTINES_PACKAGE_FQ_NAME_RELEASE
|
||||
DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_RELEASE
|
||||
else
|
||||
StandardNames.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL
|
||||
DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL
|
||||
}
|
||||
|
||||
fun LanguageVersionSettings.coroutinesIntrinsicsPackageFqName() =
|
||||
@@ -33,7 +33,7 @@ fun LanguageVersionSettings.restrictsSuspensionFqName() =
|
||||
|
||||
fun FqName.isBuiltInCoroutineContext(languageVersionSettings: LanguageVersionSettings) =
|
||||
if (languageVersionSettings.supportsFeature(LanguageFeature.ReleaseCoroutines))
|
||||
this == StandardNames.COROUTINES_PACKAGE_FQ_NAME_RELEASE.child(Name.identifier("coroutineContext"))
|
||||
this == DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_RELEASE.child(Name.identifier("coroutineContext"))
|
||||
else
|
||||
this == StandardNames.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL.child(Name.identifier("coroutineContext")) ||
|
||||
this == StandardNames.COROUTINES_INTRINSICS_PACKAGE_FQ_NAME_EXPERIMENTAL.child(Name.identifier("coroutineContext"))
|
||||
this == DescriptorUtils.COROUTINES_PACKAGE_FQ_NAME_EXPERIMENTAL.child(Name.identifier("coroutineContext")) ||
|
||||
this == DescriptorUtils.COROUTINES_INTRINSICS_PACKAGE_FQ_NAME_EXPERIMENTAL.child(Name.identifier("coroutineContext"))
|
||||
|
||||
@@ -79,7 +79,6 @@ internal class ComponentRegistry {
|
||||
By mimicking the usual descriptors we get lazy evaluation and consistency checks for free.
|
||||
*/
|
||||
for (resolver in clashResolvers) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val clashedComponents = registrationMap[resolver.applicableTo] as? Collection<ComponentDescriptor> ?: continue
|
||||
if (clashedComponents.size <= 1) continue
|
||||
|
||||
@@ -87,4 +86,4 @@ internal class ComponentRegistry {
|
||||
registrationMap[resolver.applicableTo] = substituteDescriptor
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -153,7 +153,6 @@ internal class ClashResolutionDescriptor<E : PlatformSpecificExtension<E>>(
|
||||
|
||||
override fun createInstance(context: ValueResolveContext): Any {
|
||||
state = ComponentState.Initializing
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val extensions = computeArguments(clashedComponents) as List<E>
|
||||
val resolution = resolver.resolveExtensionsClash(extensions)
|
||||
state = ComponentState.Initialized
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
|
||||
description = "Kotlin Daemon Client New"
|
||||
|
||||
plugins {
|
||||
@@ -47,12 +49,6 @@ dependencies {
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>> {
|
||||
kotlinOptions {
|
||||
apiVersion = "1.3"
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
"main" { projectDefault() }
|
||||
"test" {}
|
||||
|
||||
@@ -297,13 +297,13 @@ class KotlinCompilerClient : KotlinCompilerDaemonClient {
|
||||
log.info("Executing daemon compilation with args: " + filteredArgs.joinToString(" "))
|
||||
val servicesFacade =
|
||||
CompilerCallbackServicesFacadeServerServerSide()
|
||||
servicesFacade.runServer()
|
||||
val serverRun = servicesFacade.runServer()
|
||||
try {
|
||||
val memBefore = daemon.getUsedMemory().get() / 1024
|
||||
val startTime = System.nanoTime()
|
||||
|
||||
val compResults = createCompResults()
|
||||
compResults.runServer()
|
||||
val compResultsServerRun = compResults.runServer()
|
||||
val res = daemon.compile(
|
||||
CompileService.NO_SESSION,
|
||||
filteredArgs.toList().toTypedArray(),
|
||||
@@ -373,6 +373,7 @@ class KotlinCompilerClient : KotlinCompilerDaemonClient {
|
||||
|
||||
// --- Implementation ---------------------------------------
|
||||
|
||||
@Synchronized
|
||||
private inline fun <R> connectLoop(reportingTargets: DaemonReportingTargets, autostart: Boolean, body: (Boolean) -> R?): R? {
|
||||
try {
|
||||
var attempts = 1
|
||||
@@ -543,7 +544,6 @@ class KotlinCompilerClient : KotlinCompilerDaemonClient {
|
||||
// assuming that all important output is already done, the rest should be routed to the log by the daemon itself
|
||||
if (stdoutThread.isAlive) {
|
||||
// TODO: find better method to stop the thread, but seems it will require asynchronous consuming of the stream
|
||||
@Suppress("DEPRECATION")
|
||||
stdoutThread.stop()
|
||||
}
|
||||
reportingTargets.out?.flush()
|
||||
|
||||
@@ -38,13 +38,6 @@ dependencies {
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>> {
|
||||
kotlinOptions {
|
||||
// This module is being run from within Gradle, older versions of which only have kotlin-stdlib 1.3 in the runtime classpath.
|
||||
apiVersion = "1.3"
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
"main" { projectDefault() }
|
||||
"test" {}
|
||||
|
||||
@@ -31,6 +31,7 @@ import org.jetbrains.kotlin.utils.isProcessCanceledException
|
||||
import java.io.File
|
||||
import java.rmi.server.UnicastRemoteObject
|
||||
|
||||
|
||||
open class CompilerCallbackServicesFacadeServer(
|
||||
val incrementalCompilationComponents: IncrementalCompilationComponents? = null,
|
||||
val lookupTracker: LookupTracker? = null,
|
||||
@@ -39,7 +40,7 @@ open class CompilerCallbackServicesFacadeServer(
|
||||
val incrementalResultsConsumer: IncrementalResultsConsumer? = null,
|
||||
val incrementalDataProvider: IncrementalDataProvider? = null,
|
||||
port: Int = SOCKET_ANY_FREE_PORT
|
||||
) : @Suppress("DEPRECATION") CompilerCallbackServicesFacade,
|
||||
) : CompilerCallbackServicesFacade,
|
||||
UnicastRemoteObject(
|
||||
port,
|
||||
LoopbackNetworkInterface.clientLoopbackSocketFactory,
|
||||
|
||||
@@ -63,7 +63,7 @@ object KotlinCompilerClient {
|
||||
daemonOptions: DaemonOptions,
|
||||
reportingTargets: DaemonReportingTargets,
|
||||
autostart: Boolean = true,
|
||||
@Suppress("UNUSED_PARAMETER") checkId: Boolean = true
|
||||
checkId: Boolean = true
|
||||
): CompileService? {
|
||||
val flagFile = getOrCreateClientFlagFile(daemonOptions)
|
||||
return connectToCompileService(compilerId, flagFile, daemonJVMOptions, daemonOptions, reportingTargets, autostart)
|
||||
@@ -142,7 +142,6 @@ object KotlinCompilerClient {
|
||||
compilerService.releaseCompileSession(sessionId)
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
@Deprecated("Use other compile method", ReplaceWith("compile"))
|
||||
fun compile(compilerService: CompileService,
|
||||
sessionId: Int,
|
||||
@@ -157,7 +156,6 @@ object KotlinCompilerClient {
|
||||
}
|
||||
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
@Deprecated("Use non-deprecated compile method", ReplaceWith("compile"))
|
||||
fun incrementalCompile(compileService: CompileService,
|
||||
sessionId: Int,
|
||||
@@ -279,7 +277,6 @@ object KotlinCompilerClient {
|
||||
val memBefore = daemon.getUsedMemory().get() / 1024
|
||||
val startTime = System.nanoTime()
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
val res = daemon.remoteCompile(CompileService.NO_SESSION, CompileService.TargetPlatform.JVM, filteredArgs.toList().toTypedArray(), servicesFacade, outStrm, CompileService.OutputFormat.PLAIN, outStrm, null)
|
||||
|
||||
val endTime = System.nanoTime()
|
||||
@@ -311,9 +308,8 @@ object KotlinCompilerClient {
|
||||
|
||||
// --- Implementation ---------------------------------------
|
||||
|
||||
private inline fun <R> connectLoop(
|
||||
reportingTargets: DaemonReportingTargets, autostart: Boolean, body: (Boolean) -> R?
|
||||
): R? = synchronized(this) {
|
||||
@Synchronized
|
||||
private inline fun <R> connectLoop(reportingTargets: DaemonReportingTargets, autostart: Boolean, body: (Boolean) -> R?): R? {
|
||||
try {
|
||||
var attempts = 1
|
||||
while (true) {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user