mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-04-25 15:52:47 +00:00
Compare commits
84 Commits
rr/ScriptT
...
rr/abannyk
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e38cadff40 | ||
|
|
d78691a682 | ||
|
|
4206e9e506 | ||
|
|
cdb122c698 | ||
|
|
0c8b847ae6 | ||
|
|
c1fd891916 | ||
|
|
644c5a941b | ||
|
|
939f0d0344 | ||
|
|
abc6ecaa1c | ||
|
|
8fcd73e3cb | ||
|
|
916a5f367c | ||
|
|
adf5ee394e | ||
|
|
514ac7dc8f | ||
|
|
3acb4e54d5 | ||
|
|
3e69250f72 | ||
|
|
fbbf4e06ba | ||
|
|
6b964cb61d | ||
|
|
2f3e1dcbc6 | ||
|
|
1a32fdf6d7 | ||
|
|
c85432b2f9 | ||
|
|
c44fd235ce | ||
|
|
dcae6f1415 | ||
|
|
307871a050 | ||
|
|
0baa1c8723 | ||
|
|
e6993e1b88 | ||
|
|
ef94716af5 | ||
|
|
7f9ef5e11d | ||
|
|
551f1f85a9 | ||
|
|
19ec8646b8 | ||
|
|
fd83596c91 | ||
|
|
0691595ed2 | ||
|
|
bba597cdff | ||
|
|
d8a2b92098 | ||
|
|
501fea1202 | ||
|
|
697bb04d46 | ||
|
|
b5ee0e8222 | ||
|
|
1fea01754d | ||
|
|
508036742c | ||
|
|
39601f99ab | ||
|
|
44334fca11 | ||
|
|
9fde2ac269 | ||
|
|
346df07adc | ||
|
|
4c4af9971e | ||
|
|
202a55cb39 | ||
|
|
1c4d7c5772 | ||
|
|
81869b282b | ||
|
|
2487f9369c | ||
|
|
16aee6c8d6 | ||
|
|
3af937ea9a | ||
|
|
4d21455e72 | ||
|
|
593fd646b1 | ||
|
|
ca44242f37 | ||
|
|
d8f5b50cd8 | ||
|
|
79af726872 | ||
|
|
bc979a33f7 | ||
|
|
d3e858645f | ||
|
|
4ab5bfef22 | ||
|
|
5e383e9d71 | ||
|
|
7a283c64cb | ||
|
|
c37f339d8c | ||
|
|
550c53c2ac | ||
|
|
e3a5df1aaa | ||
|
|
340deb01dd | ||
|
|
6ef597a4ee | ||
|
|
3d91c410e7 | ||
|
|
93d7015139 | ||
|
|
8bb3c0796d | ||
|
|
3afc37438e | ||
|
|
7f472ba24e | ||
|
|
3d9353f7f5 | ||
|
|
2e2a5a0156 | ||
|
|
2bb9838a80 | ||
|
|
78a4563baf | ||
|
|
53b2fe9fd8 | ||
|
|
d2deff4864 | ||
|
|
a5bfa3ae63 | ||
|
|
86791f1fef | ||
|
|
58af8d68a1 | ||
|
|
d1cb776e29 | ||
|
|
a3a79e4295 | ||
|
|
29849b1330 | ||
|
|
943b59b5d8 | ||
|
|
38535c4fe1 | ||
|
|
ebc4910834 |
20
.idea/runConfigurations/Test__KMM.xml
generated
Normal file
20
.idea/runConfigurations/Test__KMM.xml
generated
Normal file
@@ -0,0 +1,20 @@
|
||||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Test: KMM" type="GradleRunConfiguration" factoryName="Gradle">
|
||||
<ExternalSystemSettings>
|
||||
<option name="executionName" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="externalSystemIdString" value="GRADLE" />
|
||||
<option name="scriptParameters" value="" />
|
||||
<option name="taskDescriptions">
|
||||
<list />
|
||||
</option>
|
||||
<option name="taskNames">
|
||||
<list>
|
||||
<option value="kmmTest" />
|
||||
</list>
|
||||
</option>
|
||||
<option name="vmOptions" value="" />
|
||||
</ExternalSystemSettings>
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
</component>
|
||||
526
ChangeLog.md
526
ChangeLog.md
@@ -1,5 +1,504 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 1.4-M3
|
||||
|
||||
### Compiler
|
||||
|
||||
#### New Features
|
||||
|
||||
- [`KT-23575`](https://youtrack.jetbrains.com/issue/KT-23575) Deprecate with replacement and SinceKotlin
|
||||
- [`KT-38652`](https://youtrack.jetbrains.com/issue/KT-38652) Do not generate optional annotations to class files on JVM
|
||||
- [`KT-38777`](https://youtrack.jetbrains.com/issue/KT-38777) Hide Throwable.addSuppressed member and prefer extension instead
|
||||
|
||||
#### Performance Improvements
|
||||
|
||||
- [`KT-38489`](https://youtrack.jetbrains.com/issue/KT-38489) Compilation of kotlin html DSL increasingly slow
|
||||
- [`KT-28650`](https://youtrack.jetbrains.com/issue/KT-28650) Type inference for argument type is very slow if several interfaces with a type parameter is used as an upper bound of a type parameter
|
||||
|
||||
#### Fixes
|
||||
|
||||
- [`KT-15971`](https://youtrack.jetbrains.com/issue/KT-15971) Incorrect bytecode generated when inheriting default arguments not from the first supertype
|
||||
- [`KT-25290`](https://youtrack.jetbrains.com/issue/KT-25290) NI: "AssertionError: If original type is SAM type, then candidate should have same type constructor" on out projection of Java class
|
||||
- [`KT-28672`](https://youtrack.jetbrains.com/issue/KT-28672) Contracts on calls with implicit receivers
|
||||
- [`KT-30279`](https://youtrack.jetbrains.com/issue/KT-30279) Support non-reified type parameters in typeOf
|
||||
- [`KT-31908`](https://youtrack.jetbrains.com/issue/KT-31908) NI: CCE on passing lambda to function which accepts vararg SAM interface
|
||||
- [`KT-32156`](https://youtrack.jetbrains.com/issue/KT-32156) New inference issue with generics
|
||||
- [`KT-32229`](https://youtrack.jetbrains.com/issue/KT-32229) New inference algorithm not taking into account the upper bound class
|
||||
- [`KT-33455`](https://youtrack.jetbrains.com/issue/KT-33455) Override equals/hashCode in functional interface wrappers
|
||||
- [`KT-34902`](https://youtrack.jetbrains.com/issue/KT-34902) AnalyzerException: Argument 1: expected I, but found R for unsigned types in generic data class
|
||||
- [`KT-35075`](https://youtrack.jetbrains.com/issue/KT-35075) AssertionError: "No resolved call for ..." with conditional function references
|
||||
- [`KT-35468`](https://youtrack.jetbrains.com/issue/KT-35468) Overcome ambiguity between typealias kotlin.Throws and the aliased type kotlin.jvm.Throws
|
||||
- [`KT-35494`](https://youtrack.jetbrains.com/issue/KT-35494) NI: Multiple duplicate error diagnostics (in IDE popup) with NULL_FOR_NONNULL_TYPE
|
||||
- [`KT-35681`](https://youtrack.jetbrains.com/issue/KT-35681) Wrong common supertype between raw and integer literal type leads to unsound code
|
||||
- [`KT-35937`](https://youtrack.jetbrains.com/issue/KT-35937) Error "Declaration has several compatible actuals" on incremental build
|
||||
- [`KT-36013`](https://youtrack.jetbrains.com/issue/KT-36013) Functional interface conversion not happens on a value of functional type with smart cast to a relevant functional type
|
||||
- [`KT-36045`](https://youtrack.jetbrains.com/issue/KT-36045) Do not depend on the order of lambda arguments to coerce result to `Unit`
|
||||
- [`KT-36448`](https://youtrack.jetbrains.com/issue/KT-36448) NI: fix tests after enabling NI in the compiler
|
||||
- [`KT-36706`](https://youtrack.jetbrains.com/issue/KT-36706) Prohibit functional interface constructor references
|
||||
- [`KT-36969`](https://youtrack.jetbrains.com/issue/KT-36969) Generate @NotNull on instance parameters of Interface$DefaultImpls methods
|
||||
- [`KT-37058`](https://youtrack.jetbrains.com/issue/KT-37058) Incorrect overload resolution ambiguity on callable reference in a conditional expression with new inference
|
||||
- [`KT-37120`](https://youtrack.jetbrains.com/issue/KT-37120) [FIR] False UNRESOLVED_REFERENCE for public and protected member functions and properties which are declared in object inner class
|
||||
- [`KT-37149`](https://youtrack.jetbrains.com/issue/KT-37149) Conversion when generic specified by type argument of SAM type
|
||||
- [`KT-37249`](https://youtrack.jetbrains.com/issue/KT-37249) false TYPE_MISMATCH when When-expression branches have try-catch blocks
|
||||
- [`KT-37341`](https://youtrack.jetbrains.com/issue/KT-37341) NI: Type mismatch with combination of lambda and function reference
|
||||
- [`KT-37436`](https://youtrack.jetbrains.com/issue/KT-37436) AME: "Receiver class does not define or inherit an implementation of the resolved method" in runtime on usage of non-abstract method of fun interface
|
||||
- [`KT-37510`](https://youtrack.jetbrains.com/issue/KT-37510) NI infers `java.lang.Void` from the expression in a lazy property delegate and throws ClassCastException at runtime
|
||||
- [`KT-37541`](https://youtrack.jetbrains.com/issue/KT-37541) SAM conversion with fun interface without a function fails on compiling and IDE analysis in SamAdapterFunctionsScope.getSamConstructor()
|
||||
- [`KT-37574`](https://youtrack.jetbrains.com/issue/KT-37574) NI: Type mismatch with Kotlin object extending functional type passed as @FunctionalInterface to Java
|
||||
- [`KT-37630`](https://youtrack.jetbrains.com/issue/KT-37630) NI: ILT suitability in a call is broken if there are CST calculation and calling function's type parameters
|
||||
- [`KT-37665`](https://youtrack.jetbrains.com/issue/KT-37665) NI: applicability error due to implicitly inferred Nothing for returning T with expected type
|
||||
- [`KT-37712`](https://youtrack.jetbrains.com/issue/KT-37712) No extension receiver in functional interface created with lambda
|
||||
- [`KT-37715`](https://youtrack.jetbrains.com/issue/KT-37715) NI: VerifyError: Bad type on operand stack with varargs generic value when type is inferred
|
||||
- [`KT-37721`](https://youtrack.jetbrains.com/issue/KT-37721) NI: Function reference with vararg parameter treated as array and missing default parameter is rejected
|
||||
- [`KT-37887`](https://youtrack.jetbrains.com/issue/KT-37887) NI: Smart casting for Map doesn't work if the variable is already "smart casted"
|
||||
- [`KT-37914`](https://youtrack.jetbrains.com/issue/KT-37914) NI: broken inference for a casting to subtype function within the common constraint system with this subtype
|
||||
- [`KT-37952`](https://youtrack.jetbrains.com/issue/KT-37952) NI: improve lambdas completion through separation the lambdas analysis into several steps
|
||||
- [`KT-38069`](https://youtrack.jetbrains.com/issue/KT-38069) Callable reference adaptation should have dependency on API version 1.4
|
||||
- [`KT-38143`](https://youtrack.jetbrains.com/issue/KT-38143) New type inference fails when calling extension function defined on generic type with type arguments nested too deep
|
||||
- [`KT-38156`](https://youtrack.jetbrains.com/issue/KT-38156) FIR Metadata generation
|
||||
- [`KT-38197`](https://youtrack.jetbrains.com/issue/KT-38197) java.lang.OutOfMemoryError: Java heap space: failed reallocation of scalar replaced objects
|
||||
- [`KT-38259`](https://youtrack.jetbrains.com/issue/KT-38259) NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER for provideDelegate
|
||||
- [`KT-38337`](https://youtrack.jetbrains.com/issue/KT-38337) Map delegation fails for inline classes
|
||||
- [`KT-38401`](https://youtrack.jetbrains.com/issue/KT-38401) FIR: protected effective visibility is handled unprecisely
|
||||
- [`KT-38416`](https://youtrack.jetbrains.com/issue/KT-38416) FIR: infinite loop in BB coroutine test 'overrideDefaultArgument.kt'
|
||||
- [`KT-38432`](https://youtrack.jetbrains.com/issue/KT-38432) FIR: incorrect effective visibility in anonymous object
|
||||
- [`KT-38434`](https://youtrack.jetbrains.com/issue/KT-38434) Implement resolution of suspend-conversion on FE only, but give error if suspend conversion is called
|
||||
- [`KT-38437`](https://youtrack.jetbrains.com/issue/KT-38437) [FIR] String(CharArray) is resolved to java.lang.String constructor instead of kotlin.text.String pseudo-constructor
|
||||
- [`KT-38439`](https://youtrack.jetbrains.com/issue/KT-38439) NI: anonymous functions without receiver is allowed if there is an expected type with receiver
|
||||
- [`KT-38473`](https://youtrack.jetbrains.com/issue/KT-38473) FIR: ConeIntegerLiteralType in signature
|
||||
- [`KT-38537`](https://youtrack.jetbrains.com/issue/KT-38537) IllegalArgumentException: "marginPrefix must be non-blank string" with raw strings and space as margin prefix in trimMargin() call
|
||||
- [`KT-38604`](https://youtrack.jetbrains.com/issue/KT-38604) Implicit suspend conversion on call arguments doesn't work on vararg elements
|
||||
- [`KT-38680`](https://youtrack.jetbrains.com/issue/KT-38680) NSME when calling generic interface method with default parameters overriden with inline class type argument
|
||||
- [`KT-38681`](https://youtrack.jetbrains.com/issue/KT-38681) Wrong bytecode generated when calling generic interface method with default parameters overriden with primitive type argument
|
||||
- [`KT-38691`](https://youtrack.jetbrains.com/issue/KT-38691) NI: overload resolution ambiguity if take `R` and `() -> R`, and pass literal lambda, which returns `R`
|
||||
- [`KT-38799`](https://youtrack.jetbrains.com/issue/KT-38799) False positive USELESS_CAST for lambda parameter
|
||||
- [`KT-38802`](https://youtrack.jetbrains.com/issue/KT-38802) Generated code crashes by ClassCastException when delegating with inline class
|
||||
- [`KT-38853`](https://youtrack.jetbrains.com/issue/KT-38853) Backend Internal error: Error type encountered: Unresolved type for nested class used in an annotation argument on an interface method
|
||||
- [`KT-38890`](https://youtrack.jetbrains.com/issue/KT-38890) NI: false negative Type mismatch for values with fun keyword
|
||||
- [`KT-39010`](https://youtrack.jetbrains.com/issue/KT-39010) NI: Regression with false-positive smartcast on var of generic type
|
||||
- [`KT-39013`](https://youtrack.jetbrains.com/issue/KT-39013) 202, ASM 8: "AnalyzerException: Execution can fall off the end of the code"
|
||||
- [`KT-39260`](https://youtrack.jetbrains.com/issue/KT-39260) "AssertionError: Unsigned type expected: Int" in range
|
||||
- [`KT-39305`](https://youtrack.jetbrains.com/issue/KT-39305) NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER: unable to infer deeply nested type bound when class implements generic interface
|
||||
- [`KT-39408`](https://youtrack.jetbrains.com/issue/KT-39408) Using unsigned arrays as generics fails in 1.4-M2 with class cast exception
|
||||
- [`KT-39533`](https://youtrack.jetbrains.com/issue/KT-39533) NI: Wrong overload resolution for methods with SAM converted function reference arguments
|
||||
- [`KT-39535`](https://youtrack.jetbrains.com/issue/KT-39535) NI: Inference fails for the parameters of SAM converted lambdas with type parameters
|
||||
- [`KT-39603`](https://youtrack.jetbrains.com/issue/KT-39603) Require explicit override in JVM default compatibility mode on implicit generic specialization of inherited methods in classes
|
||||
- [`KT-39671`](https://youtrack.jetbrains.com/issue/KT-39671) Couldn't inline method call 'expectBody'
|
||||
- [`KT-39816`](https://youtrack.jetbrains.com/issue/KT-39816) NI:ClassCastException and no IDE error with provideDelegate when DELEGATE_SPECIAL_FUNCTION_MISSING in OI
|
||||
- [`KT-32779`](https://youtrack.jetbrains.com/issue/KT-32779) `Rewrite at slice` in array access resolution in coroutine inference
|
||||
- [`KT-39387`](https://youtrack.jetbrains.com/issue/KT-39387) Can't build Kotlin project due to overload resolution ambiguity on flatMap calls
|
||||
- [`KT-39229`](https://youtrack.jetbrains.com/issue/KT-39229) NI: resolution to wrong candidate (SAM-type against similar functional type)
|
||||
|
||||
### Docs & Examples
|
||||
|
||||
- [`KT-36245`](https://youtrack.jetbrains.com/issue/KT-36245) Document that @kotlin.native.ThreadLocal annotation doesn't work anywhere except in Kotlin/Native
|
||||
- [`KT-37943`](https://youtrack.jetbrains.com/issue/KT-37943) Conflicting overloads in the factory functions sample code in Coding Conventions Page
|
||||
|
||||
### IDE
|
||||
|
||||
#### New Features
|
||||
|
||||
- [`KT-10974`](https://youtrack.jetbrains.com/issue/KT-10974) Add Code Style: Import Layout Configuration Table
|
||||
- [`KT-39065`](https://youtrack.jetbrains.com/issue/KT-39065) "Join lines" should remove trailing comma on call site
|
||||
|
||||
#### Fixes
|
||||
|
||||
- [`KT-9065`](https://youtrack.jetbrains.com/issue/KT-9065) Wrong result when move statement through if block with call with lambda
|
||||
- [`KT-14757`](https://youtrack.jetbrains.com/issue/KT-14757) Move statement up breaks code in function parameter list
|
||||
- [`KT-14946`](https://youtrack.jetbrains.com/issue/KT-14946) Move statement up/down (with Ctrl+Shift+Up/Down) messes with empty lines
|
||||
- [`KT-15143`](https://youtrack.jetbrains.com/issue/KT-15143) Kotlin: Colors&Fonts -> "Enum entry" should use Language Default -> Classes - Static field
|
||||
- [`KT-17887`](https://youtrack.jetbrains.com/issue/KT-17887) Moving statement (Ctrl/Cmd+Shift+Down) messes with use block
|
||||
- [`KT-34187`](https://youtrack.jetbrains.com/issue/KT-34187) UAST cannot get type of array access
|
||||
- [`KT-34524`](https://youtrack.jetbrains.com/issue/KT-34524) "PSI and index do not match" and IDE freeze with library import from `square/workflow`
|
||||
- [`KT-35574`](https://youtrack.jetbrains.com/issue/KT-35574) UAST: UBreakExpression in when expression should be UYieldExpression
|
||||
- [`KT-36801`](https://youtrack.jetbrains.com/issue/KT-36801) IDE: Unsupported language version value is represented with "latest stable" in GUI
|
||||
- [`KT-37378`](https://youtrack.jetbrains.com/issue/KT-37378) Remove IDE option "Enable new type inference algorithm..." in 1.4
|
||||
- [`KT-38003`](https://youtrack.jetbrains.com/issue/KT-38003) "Analyze Data Flow from Here" should work on parameter of abstract method
|
||||
- [`KT-38173`](https://youtrack.jetbrains.com/issue/KT-38173) Reified types do no have extends information
|
||||
- [`KT-38217`](https://youtrack.jetbrains.com/issue/KT-38217) Make Kotlin plugin settings searchable
|
||||
- [`KT-38247`](https://youtrack.jetbrains.com/issue/KT-38247) "IncorrectOperationException: Incorrect expression" through UltraLightUtils.kt: inlined string is not escaped before parsing
|
||||
- [`KT-38293`](https://youtrack.jetbrains.com/issue/KT-38293) Throwable: "'codestyle.name.kotlin' is not found in java.util.PropertyResourceBundle" at KotlinLanguageCodeStyleSettingsProvider.getConfigurableDisplayName()
|
||||
- [`KT-38407`](https://youtrack.jetbrains.com/issue/KT-38407) Drop components from plugin.xml
|
||||
- [`KT-38443`](https://youtrack.jetbrains.com/issue/KT-38443) No error on change in property initializer
|
||||
- [`KT-38521`](https://youtrack.jetbrains.com/issue/KT-38521) ISE: Loop in parent structure when converting a DOT_QUALIFIED_EXPRESSION with parent ANNOTATED_EXPRESSION
|
||||
- [`KT-38571`](https://youtrack.jetbrains.com/issue/KT-38571) Rework deprecated EPs
|
||||
- [`KT-38632`](https://youtrack.jetbrains.com/issue/KT-38632) Change the code style to official in tests
|
||||
|
||||
### IDE. Code Style, Formatting
|
||||
|
||||
#### Fixes
|
||||
|
||||
- [`KT-24750`](https://youtrack.jetbrains.com/issue/KT-24750) Formatter: Minimum blank lines after class header does nothing
|
||||
- [`KT-31169`](https://youtrack.jetbrains.com/issue/KT-31169) IDEA settings search fails to find "Tabs and Indents" tab in Kotlin code style settings
|
||||
- [`KT-35359`](https://youtrack.jetbrains.com/issue/KT-35359) Incorrect indent for multiline expression in string template
|
||||
- [`KT-37420`](https://youtrack.jetbrains.com/issue/KT-37420) Add setting to disable inserting empty line between declaration and declaration with comment
|
||||
- [`KT-37891`](https://youtrack.jetbrains.com/issue/KT-37891) Formatter inserts empty lines between annotated properties
|
||||
- [`KT-38036`](https://youtrack.jetbrains.com/issue/KT-38036) Use trailing comma setting does not apply to code example in Settings dialog
|
||||
- [`KT-38568`](https://youtrack.jetbrains.com/issue/KT-38568) False positive: weak warning "Missing line break" on -> in when expression
|
||||
- [`KT-39024`](https://youtrack.jetbrains.com/issue/KT-39024) Add option for blank lines before declaration with comment or annotation on separate line
|
||||
- [`KT-39079`](https://youtrack.jetbrains.com/issue/KT-39079) Trailing comma: add base support for call site
|
||||
- [`KT-39123`](https://youtrack.jetbrains.com/issue/KT-39123) Option `Align 'when' branches in columns` does nothing
|
||||
- [`KT-39180`](https://youtrack.jetbrains.com/issue/KT-39180) Move trailing comma settings in Other tab
|
||||
|
||||
### IDE. Completion
|
||||
|
||||
- [`KT-18538`](https://youtrack.jetbrains.com/issue/KT-18538) Completion of static members of grand-super java class inserts unnecessary qualifier
|
||||
- [`KT-38445`](https://youtrack.jetbrains.com/issue/KT-38445) Fully qualified class name is used instead after insertion of `delay` method
|
||||
|
||||
### IDE. Debugger
|
||||
|
||||
#### Fixes
|
||||
|
||||
- [`KT-14057`](https://youtrack.jetbrains.com/issue/KT-14057) Debugger couldn't step into Reader.read
|
||||
- [`KT-14828`](https://youtrack.jetbrains.com/issue/KT-14828) Bad step into/over behavior for functions with default parameters
|
||||
- [`KT-36403`](https://youtrack.jetbrains.com/issue/KT-36403) Method breakpoints don't work for libraries
|
||||
- [`KT-36404`](https://youtrack.jetbrains.com/issue/KT-36404) Evaluate: "AssertionError: Argument expression is not saved for a SAM constructor"
|
||||
- [`KT-37486`](https://youtrack.jetbrains.com/issue/KT-37486) Kotlin plugin keeps reference to stream debugger support classes after stream debugger plugin is disabled
|
||||
- [`KT-38484`](https://youtrack.jetbrains.com/issue/KT-38484) Coroutines Debugger: IAE “Requested element count -1 is less than zero.” is thrown by calling dumpCoroutines
|
||||
- [`KT-38606`](https://youtrack.jetbrains.com/issue/KT-38606) Coroutine Debugger: OCE from org.jetbrains.kotlin.idea.debugger.coroutine.proxy.mirror.BaseMirror.isCompatible
|
||||
- [`KT-39143`](https://youtrack.jetbrains.com/issue/KT-39143) NPE on setCurrentStackFrame to Kotlin inner compiled class content
|
||||
- [`KT-39412`](https://youtrack.jetbrains.com/issue/KT-39412) Failed to find Premain-Class manifest attribute when debugging main method with ktor
|
||||
- [`KT-39634`](https://youtrack.jetbrains.com/issue/KT-39634) (CoroutineDebugger) Agent doesn't start if using kotlinx-coroutines-core only dependency
|
||||
- [`KT-39648`](https://youtrack.jetbrains.com/issue/KT-39648) Coroutines debugger doesn't see stacktraces in case of the project has kotlinx-coroutines-debug dependency
|
||||
|
||||
### IDE. Gradle Integration
|
||||
|
||||
#### Performance Improvements
|
||||
|
||||
- [`KT-39059`](https://youtrack.jetbrains.com/issue/KT-39059) Poor performance of `modifyDependenciesOnMppModules`
|
||||
|
||||
#### Fixes
|
||||
|
||||
- [`KT-35921`](https://youtrack.jetbrains.com/issue/KT-35921) Gradle Import fails with "Unsupported major.minor version 52.0" on pure Java project in case "Gradle JDK" is lower 1.8 and Kotlin plugin is enabled
|
||||
- [`KT-36673`](https://youtrack.jetbrains.com/issue/KT-36673) Gradle Project importing: move ModelBuilders and ModelProviders to kotlin-gradle-tooling jar
|
||||
- [`KT-36792`](https://youtrack.jetbrains.com/issue/KT-36792) IDEA 2020.1: Some module->module dependencies in HMPP project are missed after import from Gradle
|
||||
- [`KT-37125`](https://youtrack.jetbrains.com/issue/KT-37125) Imported modules structure for MPP project is displayed messy in UI in IDEA 2020.1
|
||||
- [`KT-37428`](https://youtrack.jetbrains.com/issue/KT-37428) NPE at KotlinFacetSettings.setLanguageLevel() on the first project import
|
||||
- [`KT-38706`](https://youtrack.jetbrains.com/issue/KT-38706) IDE Gradle import creates 4 JavaScript modules for MPP source sets with BOTH compiler type
|
||||
- [`KT-38767`](https://youtrack.jetbrains.com/issue/KT-38767) Published hierarchical multiplatform library symbols are unresolved in IDE (master)
|
||||
- [`KT-38842`](https://youtrack.jetbrains.com/issue/KT-38842) False positive [INVISIBLE_MEMBER] for `internal` declaration of commonMain called from commonTest
|
||||
- [`KT-39213`](https://youtrack.jetbrains.com/issue/KT-39213) IDE: references from MPP project to JavaScript library are unresolved, when project and library are compiled with "both" mode
|
||||
- [`KT-39657`](https://youtrack.jetbrains.com/issue/KT-39657) Language settings for intermediate source-sets are lost during import
|
||||
|
||||
### IDE. Gradle. Script
|
||||
|
||||
#### New Features
|
||||
|
||||
- [`KT-34481`](https://youtrack.jetbrains.com/issue/KT-34481) `*.gradle.kts`: use Intellij IDEA Gradle project sync mechanics for updating script configuration
|
||||
|
||||
#### Performance Improvements
|
||||
|
||||
- [`KT-34138`](https://youtrack.jetbrains.com/issue/KT-34138) Deadlock in `ScriptTemplatesFromDependenciesProvider`
|
||||
- [`KT-38875`](https://youtrack.jetbrains.com/issue/KT-38875) Deadlock in ScriptClassRootsUpdater.checkInvalidSdks
|
||||
|
||||
#### Fixes
|
||||
|
||||
- [`KT-34265`](https://youtrack.jetbrains.com/issue/KT-34265) Bogus "build configuration failed, run 'gradle tasks' for more information" message and other issues related to "script dependencies"
|
||||
- [`KT-34444`](https://youtrack.jetbrains.com/issue/KT-34444) *.gradle.kts: special storage of all scripts configuration on one file
|
||||
- [`KT-35153`](https://youtrack.jetbrains.com/issue/KT-35153) build.gradle.kts: scripts in removed subproject remain imported, but shouldn't
|
||||
- [`KT-35573`](https://youtrack.jetbrains.com/issue/KT-35573) Request for gradle build script configuration only after explicit click on notification
|
||||
- [`KT-36675`](https://youtrack.jetbrains.com/issue/KT-36675) move .gradle.kts ModelBuilders and ModelProviders to kotlin-gradle-tooling jar
|
||||
- [`KT-37178`](https://youtrack.jetbrains.com/issue/KT-37178) build.gradle.kts: Rework the notification for scripts out of project
|
||||
- [`KT-37631`](https://youtrack.jetbrains.com/issue/KT-37631) Unnecessary loading dependencies after opening build.gradle.kts after project import with Gradle 6
|
||||
- [`KT-37863`](https://youtrack.jetbrains.com/issue/KT-37863) Scanning dependencies for script definitions takes too long or indefinitely during Gradle import
|
||||
- [`KT-38296`](https://youtrack.jetbrains.com/issue/KT-38296) MISSING_DEPENDENCY_SUPERCLASS in the build.gradle.kts editor while Gradle runs Ok
|
||||
- [`KT-38541`](https://youtrack.jetbrains.com/issue/KT-38541) "Invalid file" exception in ScriptChangeListener.getAnalyzableKtFileForScript()
|
||||
- [`KT-39104`](https://youtrack.jetbrains.com/issue/KT-39104) “Gradle Kotlin DSL script configuration is missing” after importing project in IJ201, Gradle 6.3
|
||||
- [`KT-39469`](https://youtrack.jetbrains.com/issue/KT-39469) Gradle version is not updated in script dependencies if the version of gradle was changed in gradle-wrapper.properties
|
||||
- [`KT-39771`](https://youtrack.jetbrains.com/issue/KT-39771) Freeze 30s from org.jetbrains.kotlin.scripting.resolve.ApiChangeDependencyResolverWrapper.resolve on loading script configuration with Gradle 5.6.4
|
||||
|
||||
### IDE. Inspections and Intentions
|
||||
|
||||
#### New Features
|
||||
|
||||
- [`KT-14884`](https://youtrack.jetbrains.com/issue/KT-14884) Intention to add missing "class" keyword for enum and annotation top-level declarations
|
||||
- [`KT-17209`](https://youtrack.jetbrains.com/issue/KT-17209) Provide intention to fix platform declaration clash (CONFLICTING_JVM_DECLARATIONS)
|
||||
- [`KT-24522`](https://youtrack.jetbrains.com/issue/KT-24522) Suggest to move typealias outside the class
|
||||
- [`KT-30263`](https://youtrack.jetbrains.com/issue/KT-30263) Detect redundant conversions of unsigned types
|
||||
- [`KT-35893`](https://youtrack.jetbrains.com/issue/KT-35893) Support Inspection for unnecessary asSequence() call
|
||||
- [`KT-38559`](https://youtrack.jetbrains.com/issue/KT-38559) "Change JVM name" (@JvmName) quickfix: improve name suggester for generic functions
|
||||
- [`KT-38597`](https://youtrack.jetbrains.com/issue/KT-38597) Expand Boolean intention
|
||||
- [`KT-38982`](https://youtrack.jetbrains.com/issue/KT-38982) Add "Logger initialized with foreign class" inspection
|
||||
- [`KT-39131`](https://youtrack.jetbrains.com/issue/KT-39131) TrailingCommaInspection: should suggest fixes for call-site without warnings
|
||||
|
||||
#### Fixes
|
||||
|
||||
- [`KT-5271`](https://youtrack.jetbrains.com/issue/KT-5271) Missing QuickFix for Multiple supertypes available
|
||||
- [`KT-11865`](https://youtrack.jetbrains.com/issue/KT-11865) "Create secondary constructor" quick fix always inserts parameter-less call to `this()`
|
||||
- [`KT-14021`](https://youtrack.jetbrains.com/issue/KT-14021) Quickfix to add parameter to function gives strange name to parameter
|
||||
- [`KT-17121`](https://youtrack.jetbrains.com/issue/KT-17121) "Implement members" quick fix is not suggested
|
||||
- [`KT-17368`](https://youtrack.jetbrains.com/issue/KT-17368) Don't highlight members annotated with @JsName as unused
|
||||
- [`KT-20795`](https://youtrack.jetbrains.com/issue/KT-20795) "replace explicit parameter with it" creates invalid code in case of overload ambiguities
|
||||
- [`KT-22014`](https://youtrack.jetbrains.com/issue/KT-22014) Intention "convert lambda to reference" should be available for implicit 'this'
|
||||
- [`KT-22015`](https://youtrack.jetbrains.com/issue/KT-22015) Intention "Convert lambda to reference" should be available in spite of the lambda in or out of parentheses
|
||||
- [`KT-22142`](https://youtrack.jetbrains.com/issue/KT-22142) Intentions: "Convert to primary constructor" changes semantics for property with custom setter
|
||||
- [`KT-22878`](https://youtrack.jetbrains.com/issue/KT-22878) Empty argument list at the call site of custom function named "suspend" shouldn't be reported as unnecessary
|
||||
- [`KT-24281`](https://youtrack.jetbrains.com/issue/KT-24281) Importing of invoke() from the same file is reported as unused even if it isn't
|
||||
- [`KT-25050`](https://youtrack.jetbrains.com/issue/KT-25050) False-positive inspection "Call replaceable with binary operator" for 'equals'
|
||||
- [`KT-26361`](https://youtrack.jetbrains.com/issue/KT-26361) @Deprecated "ReplaceWith" quickfix inserts 'this' incorrectly when using function imports
|
||||
- [`KT-27651`](https://youtrack.jetbrains.com/issue/KT-27651) 'Condition is always true' inspection should not be triggered when the condition has references to a named constant
|
||||
- [`KT-29934`](https://youtrack.jetbrains.com/issue/KT-29934) False negative `Change type` quickfix on primary constructor override val parameter when it has wrong type
|
||||
- [`KT-31682`](https://youtrack.jetbrains.com/issue/KT-31682) 'Convert lambda to reference' intention inside class with function which return object produces uncompilable code
|
||||
- [`KT-31760`](https://youtrack.jetbrains.com/issue/KT-31760) Implement Abstract Function/Property intentions position generated member improperly
|
||||
- [`KT-32511`](https://youtrack.jetbrains.com/issue/KT-32511) Create class quick fix is not suggested in super type list in case of missing primary constructor
|
||||
- [`KT-32565`](https://youtrack.jetbrains.com/issue/KT-32565) False positive "Variable is the same as 'credentials' and should be inlined" with object declared and returned from lambda
|
||||
- [`KT-32801`](https://youtrack.jetbrains.com/issue/KT-32801) False positive "Call on collection type may be reduced" with mapNotNull, generic lambda block and new inference
|
||||
- [`KT-33951`](https://youtrack.jetbrains.com/issue/KT-33951) ReplaceWith quickfix with unqualified object member call doesn't substitute argument for parameter
|
||||
- [`KT-34378`](https://youtrack.jetbrains.com/issue/KT-34378) "Convert lambda to reference" refactoring does not work for suspend functions
|
||||
- [`KT-34677`](https://youtrack.jetbrains.com/issue/KT-34677) False positive "Collection count can be converted to size" with `Iterable`
|
||||
- [`KT-34696`](https://youtrack.jetbrains.com/issue/KT-34696) Wrong 'Redundant qualifier name' for 'MyEnum.values' usage
|
||||
- [`KT-34713`](https://youtrack.jetbrains.com/issue/KT-34713) "Condition is always 'false'": quickfix "Delete expression" doesn't remove `else` keyword (may break control flow)
|
||||
- [`KT-35015`](https://youtrack.jetbrains.com/issue/KT-35015) ReplaceWith doesn't substitute parameters with argument expressions
|
||||
- [`KT-35329`](https://youtrack.jetbrains.com/issue/KT-35329) Replace 'when' with 'if' intention: do not suggest if 'when' is used as expression and it has no 'else' branch
|
||||
- [`KT-36194`](https://youtrack.jetbrains.com/issue/KT-36194) "Add braces to 'for' statement" inserts extra line break and moves the following single-line comment
|
||||
- [`KT-36406`](https://youtrack.jetbrains.com/issue/KT-36406) "To ordinary string literal" intention adds unnecessary escapes to characters in template expression
|
||||
- [`KT-36461`](https://youtrack.jetbrains.com/issue/KT-36461) "Create enum constant" quick fix adds after semicolon, if the last entry has a comma
|
||||
- [`KT-36462`](https://youtrack.jetbrains.com/issue/KT-36462) "Create enum constant" quick fix doesn't add trailing comma
|
||||
- [`KT-36508`](https://youtrack.jetbrains.com/issue/KT-36508) False positive "Replace 'to' with infix form" when 'to' lambda generic type argument is specified explicitly
|
||||
- [`KT-36930`](https://youtrack.jetbrains.com/issue/KT-36930) Intention "Specify type explicitly" adds NotNull annotation when calling java method with the annotation
|
||||
- [`KT-37148`](https://youtrack.jetbrains.com/issue/KT-37148) "Remove redundant `.let` call doesn't remove extra calls
|
||||
- [`KT-37156`](https://youtrack.jetbrains.com/issue/KT-37156) "Unused unary operator" inspection highlighting is hard to see
|
||||
- [`KT-37173`](https://youtrack.jetbrains.com/issue/KT-37173) "Replace with string templates" intention for String.format produces uncompilable string template
|
||||
- [`KT-37181`](https://youtrack.jetbrains.com/issue/KT-37181) Don't show "Remove redundant qualifier name" inspection on qualified Companion imported with star import
|
||||
- [`KT-37214`](https://youtrack.jetbrains.com/issue/KT-37214) "Convert lambda to reference" with a labeled "this" receiver fails
|
||||
- [`KT-37256`](https://youtrack.jetbrains.com/issue/KT-37256) False positive `PlatformExtensionReceiverOfInline` inspection if a platform type value is passed to a nullable receiver
|
||||
- [`KT-37744`](https://youtrack.jetbrains.com/issue/KT-37744) "Convert lambda to reference" inspection quick fix create incompilable code when type is inferred from lambda parameter
|
||||
- [`KT-37746`](https://youtrack.jetbrains.com/issue/KT-37746) "Redundant suspend modifier" should not be reported for functions with actual keyword
|
||||
- [`KT-37842`](https://youtrack.jetbrains.com/issue/KT-37842) "Convert to anonymous function" creates broken code with suspend functions
|
||||
- [`KT-37908`](https://youtrack.jetbrains.com/issue/KT-37908) "Convert to anonymous object" quickfix: false negative when interface has concrete functions
|
||||
- [`KT-37967`](https://youtrack.jetbrains.com/issue/KT-37967) Replace 'invoke' with direct call intention adds unnecessary parenthesis
|
||||
- [`KT-37977`](https://youtrack.jetbrains.com/issue/KT-37977) "Replace 'invoke' with direct call" intention: false positive when function is not operator
|
||||
- [`KT-38062`](https://youtrack.jetbrains.com/issue/KT-38062) Reactor Quickfix throws `NotImplementedError` for Kotlin
|
||||
- [`KT-38240`](https://youtrack.jetbrains.com/issue/KT-38240) False positive redundant semicolon with `as` cast and `not` unary operator on next line
|
||||
- [`KT-38261`](https://youtrack.jetbrains.com/issue/KT-38261) Redundant 'let' call removal leaves ?. operator and makes code uncompilable
|
||||
- [`KT-38310`](https://youtrack.jetbrains.com/issue/KT-38310) Remove explicit type annotation intention drops 'suspend'
|
||||
- [`KT-38492`](https://youtrack.jetbrains.com/issue/KT-38492) False positive "Add import" intention for already imported class
|
||||
- [`KT-38520`](https://youtrack.jetbrains.com/issue/KT-38520) SetterBackingFieldAssignmentInspection throws exception
|
||||
- [`KT-38649`](https://youtrack.jetbrains.com/issue/KT-38649) False positive quickfix "Assignment should be lifted out of when" in presence of smartcasts
|
||||
- [`KT-38677`](https://youtrack.jetbrains.com/issue/KT-38677) Invalid psi tree after `Lift assigment out of...`
|
||||
- [`KT-38790`](https://youtrack.jetbrains.com/issue/KT-38790) "Convert sealed subclass to object" for data classes doesn't remove 'data' keyword
|
||||
- [`KT-38829`](https://youtrack.jetbrains.com/issue/KT-38829) 'Remove redundant backticks' can be broken with @ in name
|
||||
- [`KT-38831`](https://youtrack.jetbrains.com/issue/KT-38831) 'Replace with assignment' can be broken with fast code change
|
||||
- [`KT-38832`](https://youtrack.jetbrains.com/issue/KT-38832) "Remove curly braces" intention may produce CCE
|
||||
- [`KT-38948`](https://youtrack.jetbrains.com/issue/KT-38948) False positive quickfix "Make containing function suspend" for anonymous function
|
||||
- [`KT-38961`](https://youtrack.jetbrains.com/issue/KT-38961) "Useless call on collection type" for filterNotNull on non-null array where list return type is expected
|
||||
- [`KT-39069`](https://youtrack.jetbrains.com/issue/KT-39069) Improve TrailingCommaInspection
|
||||
- [`KT-39151`](https://youtrack.jetbrains.com/issue/KT-39151) False positive inspection to replace Java forEach with Kotlin forEach when using ConcurrentHashMap
|
||||
|
||||
### IDE. JS
|
||||
|
||||
- [`KT-39275`](https://youtrack.jetbrains.com/issue/KT-39275) Kotlin JS Browser template for kotlin dsl doesn't include index.html
|
||||
|
||||
### IDE. KDoc
|
||||
|
||||
- [`KT-32163`](https://youtrack.jetbrains.com/issue/KT-32163) Open Quick Documentation when cursor inside function / constructor brackets
|
||||
|
||||
### IDE. Navigation
|
||||
|
||||
- [`KT-32245`](https://youtrack.jetbrains.com/issue/KT-32245) Method in Kotlin class is not listed among implementing methods
|
||||
- [`KT-33510`](https://youtrack.jetbrains.com/issue/KT-33510) There is no gutter icon to navigate from `actual` to `expect` if `expect` and the corresponding `actual` declarations are in the same file
|
||||
- [`KT-38260`](https://youtrack.jetbrains.com/issue/KT-38260) Navigation bar doesn't show directories of files with a single top level Kotlin class
|
||||
- [`KT-38466`](https://youtrack.jetbrains.com/issue/KT-38466) Top level functions/properties aren't shown in navigation panel
|
||||
|
||||
### IDE. Project View
|
||||
|
||||
- [`KT-36444`](https://youtrack.jetbrains.com/issue/KT-36444) Structure view: add ability to sort by visibility
|
||||
- [`KT-38276`](https://youtrack.jetbrains.com/issue/KT-38276) Structure view: support visibility filter for class properties
|
||||
|
||||
### IDE. REPL
|
||||
|
||||
- [`KT-38454`](https://youtrack.jetbrains.com/issue/KT-38454) Kotlin REPL in IntelliJ doesn't take module's JVM target setting into account
|
||||
|
||||
### IDE. Refactorings
|
||||
|
||||
- [`KT-12878`](https://youtrack.jetbrains.com/issue/KT-12878) "Change signature" forces line breaks after every parameter declaration
|
||||
- [`KT-30128`](https://youtrack.jetbrains.com/issue/KT-30128) Change Signature should move lambda outside of parentheses if the arguments are reordered so that the lambda goes last
|
||||
- [`KT-35338`](https://youtrack.jetbrains.com/issue/KT-35338) Move/rename refactorings mess up code formatting by wrapping lines
|
||||
- [`KT-38449`](https://youtrack.jetbrains.com/issue/KT-38449) Extract variable refactoring is broken by NPE
|
||||
- [`KT-38543`](https://youtrack.jetbrains.com/issue/KT-38543) Copy can't work to package with escaped package
|
||||
- [`KT-38627`](https://youtrack.jetbrains.com/issue/KT-38627) Rename package refactorings mess up code formatting by wrapping lines
|
||||
|
||||
### IDE. Run Configurations
|
||||
|
||||
- [`KT-34516`](https://youtrack.jetbrains.com/issue/KT-34516) Don't suggest incompatible targets in a drop-down list for run test gutter icon in multiplatform projects
|
||||
- [`KT-38102`](https://youtrack.jetbrains.com/issue/KT-38102) DeprecatedMethodException ConfigurationFactory.getId
|
||||
|
||||
### IDE. Scratch
|
||||
|
||||
- [`KT-38455`](https://youtrack.jetbrains.com/issue/KT-38455) Kotlin scratch files don't take module's JVM target setting into account
|
||||
|
||||
### IDE. Script
|
||||
|
||||
- [`KT-39791`](https://youtrack.jetbrains.com/issue/KT-39791) Kotlin plugin loads VFS in the output directories
|
||||
|
||||
### IDE. Structural Search
|
||||
|
||||
- [`KT-39721`](https://youtrack.jetbrains.com/issue/KT-39721) Optimize Kotlin SSR by using the index
|
||||
- [`KT-39733`](https://youtrack.jetbrains.com/issue/KT-39733) Augmented assignment matching
|
||||
- [`KT-39769`](https://youtrack.jetbrains.com/issue/KT-39769) "When expressions" predefined template doesn't match all when expressions
|
||||
|
||||
### IDE. Wizards
|
||||
|
||||
- [`KT-38673`](https://youtrack.jetbrains.com/issue/KT-38673) New Project Wizard: multiplatform templates are generated having unsupported Gradle version in a wrapper
|
||||
- [`KT-38810`](https://youtrack.jetbrains.com/issue/KT-38810) Incorrect order of build phases in Xcode project from new wizard
|
||||
- [`KT-38952`](https://youtrack.jetbrains.com/issue/KT-38952) Remove old new_project_wizards
|
||||
- [`KT-39503`](https://youtrack.jetbrains.com/issue/KT-39503) New Project wizard 1.4+: release kotlinx.html version is added to dependencies with milestone IDE plugin
|
||||
- [`KT-39700`](https://youtrack.jetbrains.com/issue/KT-39700) Wizard: group project templates on the first step by the project type
|
||||
- [`KT-39770`](https://youtrack.jetbrains.com/issue/KT-39770) CSS Support in Kotlin wizards
|
||||
- [`KT-39826`](https://youtrack.jetbrains.com/issue/KT-39826) Fix Android app in New Template Wizard
|
||||
- [`KT-39843`](https://youtrack.jetbrains.com/issue/KT-39843) Change imports in JS/browser wizard
|
||||
|
||||
### JS. Tools
|
||||
|
||||
- [`KT-32273`](https://youtrack.jetbrains.com/issue/KT-32273) Kotlin/JS console error on hot reload
|
||||
- [`KT-39498`](https://youtrack.jetbrains.com/issue/KT-39498) Update dukat version in toolchain near to release of 1.4-M3
|
||||
|
||||
### JavaScript
|
||||
|
||||
- [`KT-29916`](https://youtrack.jetbrains.com/issue/KT-29916) Implement `typeOf` on JS
|
||||
- [`KT-35857`](https://youtrack.jetbrains.com/issue/KT-35857) Kotlin/JS CLI bundled to IDEA plugin can't compile using IR back-end out of the box
|
||||
- [`KT-36798`](https://youtrack.jetbrains.com/issue/KT-36798) KJS: prohibit using @JsExport on a non-top-level declaration
|
||||
- [`KT-37771`](https://youtrack.jetbrains.com/issue/KT-37771) KJS: Generated TypeScript does not recursively export base classes (can fail with generics)
|
||||
- [`KT-38113`](https://youtrack.jetbrains.com/issue/KT-38113) Review public API of JS stdlib for IR BE
|
||||
- [`KT-38765`](https://youtrack.jetbrains.com/issue/KT-38765) [JS / IR] AssertionError: class EventEmitter: Super class should be any: with nested class extending parent class
|
||||
- [`KT-38768`](https://youtrack.jetbrains.com/issue/KT-38768) KJS IR: generate ES2015 (aka ES6) classes
|
||||
|
||||
### Libraries
|
||||
|
||||
#### New Features
|
||||
|
||||
- [`KT-11253`](https://youtrack.jetbrains.com/issue/KT-11253) Function to sum long or other numeric property of items in a collection
|
||||
- [`KT-28933`](https://youtrack.jetbrains.com/issue/KT-28933) capitalize() with Locale argument in the JDK stdlib
|
||||
- [`KT-34142`](https://youtrack.jetbrains.com/issue/KT-34142) Create SortedMap with Comparator and items
|
||||
- [`KT-34506`](https://youtrack.jetbrains.com/issue/KT-34506) Add Sequence.flatMap overload that works on Iterable
|
||||
- [`KT-36894`](https://youtrack.jetbrains.com/issue/KT-36894) Support flatMapIndexed in the Collections API
|
||||
- [`KT-38480`](https://youtrack.jetbrains.com/issue/KT-38480) Introduce experimental annotation for enabling overload resolution by lambda result
|
||||
- [`KT-38708`](https://youtrack.jetbrains.com/issue/KT-38708) minOf/maxOf functions to return min/max value provided by selector
|
||||
- [`KT-39707`](https://youtrack.jetbrains.com/issue/KT-39707) Make some interfaces in stdlib functional
|
||||
|
||||
#### Performance Improvements
|
||||
|
||||
- [`KT-23142`](https://youtrack.jetbrains.com/issue/KT-23142) toHashSet is suboptimal for inputs with a lot of duplicates
|
||||
|
||||
#### Fixes
|
||||
|
||||
- [`KT-21266`](https://youtrack.jetbrains.com/issue/KT-21266) Add module-info for standard library artifacts
|
||||
- [`KT-23322`](https://youtrack.jetbrains.com/issue/KT-23322) Document 'reduce' operation behavior on empty collections
|
||||
- [`KT-28753`](https://youtrack.jetbrains.com/issue/KT-28753) Comparing floating point values in array/list operations 'contains', 'indexOf', 'lastIndexOf': IEEE 754 or total order
|
||||
- [`KT-30083`](https://youtrack.jetbrains.com/issue/KT-30083) Annotate KTypeProjection.STAR with JvmField in a compatible way
|
||||
- [`KT-30084`](https://youtrack.jetbrains.com/issue/KT-30084) Annotate functions in KTypeProjection.Companion with JvmStatic
|
||||
- [`KT-31343`](https://youtrack.jetbrains.com/issue/KT-31343) Deprecate old String <-> CharArray, ByteArray conversion api
|
||||
- [`KT-34596`](https://youtrack.jetbrains.com/issue/KT-34596) Add some validation to KTypeProjection constructor
|
||||
- [`KT-35978`](https://youtrack.jetbrains.com/issue/KT-35978) Review and remove experimental stdlib API status for 1.4
|
||||
- [`KT-38388`](https://youtrack.jetbrains.com/issue/KT-38388) Document `fromIndex` and `toIndex` parameters
|
||||
- [`KT-38854`](https://youtrack.jetbrains.com/issue/KT-38854) Gradually change the return type of collection min/max functions to non-nullable
|
||||
- [`KT-39023`](https://youtrack.jetbrains.com/issue/KT-39023) Document split(Pattern) extension differences from Pattern.split
|
||||
- [`KT-39064`](https://youtrack.jetbrains.com/issue/KT-39064) Introduce minOrNull and maxOrNull extension functions on collections
|
||||
- [`KT-39235`](https://youtrack.jetbrains.com/issue/KT-39235) Lift experimental annotation from bit operations
|
||||
- [`KT-39237`](https://youtrack.jetbrains.com/issue/KT-39237) Lift experimental annotation from common StringBuilder
|
||||
- [`KT-39238`](https://youtrack.jetbrains.com/issue/KT-39238) Appendable.appendRange - remove nullability
|
||||
- [`KT-39239`](https://youtrack.jetbrains.com/issue/KT-39239) Lift experimental annotation from String <-> utf8 conversion api
|
||||
- [`KT-39244`](https://youtrack.jetbrains.com/issue/KT-39244) KJS: update polyfills, all or most of them must not be enumerable
|
||||
- [`KT-39330`](https://youtrack.jetbrains.com/issue/KT-39330) Migrate declarations from kotlin.dom and kotlin.browser packages to kotlinx.*
|
||||
|
||||
### Middle-end. IR
|
||||
|
||||
- [`KT-31088`](https://youtrack.jetbrains.com/issue/KT-31088) need a way to compute fake overrides for pure IR
|
||||
- [`KT-33207`](https://youtrack.jetbrains.com/issue/KT-33207) Kotlin/Native: KNPE during deserialization of an inner class
|
||||
- [`KT-33267`](https://youtrack.jetbrains.com/issue/KT-33267) Kotlin/Native: Deserialization error for an "inner" extension property imported from a class
|
||||
- [`KT-37255`](https://youtrack.jetbrains.com/issue/KT-37255) Make psi2ir aware of declarations provided by compiler plugins
|
||||
|
||||
### Reflection
|
||||
|
||||
- [`KT-22936`](https://youtrack.jetbrains.com/issue/KT-22936) Not all things can be changed to `createType` yet, and now `defaultType` methods are starting to fail
|
||||
- [`KT-32241`](https://youtrack.jetbrains.com/issue/KT-32241) Move KType.javaType into stdlib from reflect
|
||||
- [`KT-34344`](https://youtrack.jetbrains.com/issue/KT-34344) KType.javaType implementation throws when invoked with a typeOf<T>()
|
||||
- [`KT-38491`](https://youtrack.jetbrains.com/issue/KT-38491) IllegalArgumentException when using callBy on function with inline class parameters and default arguments
|
||||
- [`KT-38881`](https://youtrack.jetbrains.com/issue/KT-38881) Add KClass.isFun modifier of functional interfaces to reflection
|
||||
|
||||
### Tools. Android Extensions
|
||||
|
||||
- [`KT-25807`](https://youtrack.jetbrains.com/issue/KT-25807) Kotlin extension annotation @Parcelize in AIDL returns Object instead of original T
|
||||
|
||||
### Tools. CLI
|
||||
|
||||
- [`KT-30211`](https://youtrack.jetbrains.com/issue/KT-30211) Support a way to pass arguments to the underlying JVM in kotlinc batch scripts on Windows
|
||||
- [`KT-30778`](https://youtrack.jetbrains.com/issue/KT-30778) kotlin-compiler.jar contains shaded but not relocated kotlinx.coroutines
|
||||
- [`KT-38070`](https://youtrack.jetbrains.com/issue/KT-38070) Compiler option to bypass prerelease metadata incompatibility error
|
||||
- [`KT-38413`](https://youtrack.jetbrains.com/issue/KT-38413) Add JVM target bytecode version 14
|
||||
|
||||
### Tools. Compiler Plugins
|
||||
|
||||
- [`KT-39274`](https://youtrack.jetbrains.com/issue/KT-39274) [KJS / IR] Custom serializer for class without zero argument constructor doesn't compile
|
||||
|
||||
### Tools. Gradle
|
||||
|
||||
- [`KT-25428`](https://youtrack.jetbrains.com/issue/KT-25428) Kotlin Gradle Plugin: Use new Gradle API for Lazy tasks
|
||||
- [`KT-34487`](https://youtrack.jetbrains.com/issue/KT-34487) Gradle build fails with "Cannot run program "java": error=7, Argument list too long
|
||||
- [`KT-35957`](https://youtrack.jetbrains.com/issue/KT-35957) MPP IC fails with "X has several compatible actual declarations" error
|
||||
- [`KT-38250`](https://youtrack.jetbrains.com/issue/KT-38250) Drop support for Gradle versions older than 5.3 in the Kotlin Gradle plugin
|
||||
|
||||
### Tools. Gradle. JS
|
||||
|
||||
#### New Features
|
||||
|
||||
- [`KT-30619`](https://youtrack.jetbrains.com/issue/KT-30619) Support NPM transitive dependencies in multi-platform JS target
|
||||
- [`KT-38286`](https://youtrack.jetbrains.com/issue/KT-38286) [Gradle, JS] Error handling on Webpack problems
|
||||
|
||||
#### Fixes
|
||||
|
||||
- [`KT-31669`](https://youtrack.jetbrains.com/issue/KT-31669) Gradle/JS: rise error when plugin loaded more than once
|
||||
- [`KT-32531`](https://youtrack.jetbrains.com/issue/KT-32531) [Gradle/JS] Add scoped NPM dependencies
|
||||
- [`KT-34832`](https://youtrack.jetbrains.com/issue/KT-34832) [Kotlin/JS] Failed build after webpack run (Karma not found)
|
||||
- [`KT-35194`](https://youtrack.jetbrains.com/issue/KT-35194) Kotlin/JS: browserRun fails with "address already in use" when trying to connect to local server
|
||||
- [`KT-35611`](https://youtrack.jetbrains.com/issue/KT-35611) Kotlin Gradle plugin should report `kotlin2js` plugin ID as deprecated
|
||||
- [`KT-35641`](https://youtrack.jetbrains.com/issue/KT-35641) Kotlin Gradle plugin should report `kotlin-dce-js` plugin ID as deprecated
|
||||
- [`KT-36410`](https://youtrack.jetbrains.com/issue/KT-36410) JS: Collect stats about IR backend usage
|
||||
- [`KT-36451`](https://youtrack.jetbrains.com/issue/KT-36451) KJS Adding npm dependency breaks Webpack devserver reloading
|
||||
- [`KT-37258`](https://youtrack.jetbrains.com/issue/KT-37258) Kotlin/JS + Gradle: in continuous mode kotlinNpmInstall time to time outputs "ENOENT: no such file or directory" error
|
||||
- [`KT-38109`](https://youtrack.jetbrains.com/issue/KT-38109) [Gradle, JS] Error handling on Karma launcher problems
|
||||
- [`KT-38331`](https://youtrack.jetbrains.com/issue/KT-38331) Add an ability to control generating externals for npm deps individually
|
||||
- [`KT-38485`](https://youtrack.jetbrains.com/issue/KT-38485) [Gradle, JS] Unable to configure JS compiler with string
|
||||
- [`KT-38683`](https://youtrack.jetbrains.com/issue/KT-38683) Remove possibility to set NPM dependency without version
|
||||
- [`KT-38990`](https://youtrack.jetbrains.com/issue/KT-38990) Support multiple range versions for NPM dependencies
|
||||
- [`KT-38994`](https://youtrack.jetbrains.com/issue/KT-38994) Remove possibility to set NPM dependency with npm(org, name, version)
|
||||
- [`KT-39109`](https://youtrack.jetbrains.com/issue/KT-39109) ArithmeticException: "/ by zero" caused by kotlinNodeJsSetup task with enabled gradle caching on Windows
|
||||
- [`KT-39210`](https://youtrack.jetbrains.com/issue/KT-39210) Kotlin/JS: with both JS and MPP modules in the same project Gradle configuration fails on `nodejs {}` and `browser {}`
|
||||
- [`KT-39377`](https://youtrack.jetbrains.com/issue/KT-39377) Use standard source-map-loader instead of custom one
|
||||
|
||||
### Tools. Gradle. Multiplatform
|
||||
|
||||
- [`KT-39184`](https://youtrack.jetbrains.com/issue/KT-39184) Support publication of Kotlin-distributed libraries with Gradle Metadata
|
||||
- [`KT-39304`](https://youtrack.jetbrains.com/issue/KT-39304) Gradle import error `java.util.NoSuchElementException: Key source set foo is missing in the map` on unused source set
|
||||
|
||||
### Tools. Gradle. Native
|
||||
|
||||
- [`KT-37514`](https://youtrack.jetbrains.com/issue/KT-37514) CocoaPods Gradle plugin: Support building from terminal projects for several platforms
|
||||
- [`KT-38440`](https://youtrack.jetbrains.com/issue/KT-38440) Make error message about missing Podfile path for cocoapods integration actionable for a user
|
||||
- [`KT-38991`](https://youtrack.jetbrains.com/issue/KT-38991) Gradle MPP plugin: Enable parallel in-process execution for K/N compiler
|
||||
- [`KT-39935`](https://youtrack.jetbrains.com/issue/KT-39935) Support overriding the `KotlinNativeCompile` task sources
|
||||
- [`KT-37512`](https://youtrack.jetbrains.com/issue/KT-37512) Cocoapods Gradle plugin: Improve error logging for external tools
|
||||
|
||||
### Tools. J2K
|
||||
|
||||
- [`KT-35169`](https://youtrack.jetbrains.com/issue/KT-35169) Do not show "Inline local variable" popup during "Cleaning up code" phase of J2K
|
||||
- [`KT-38004`](https://youtrack.jetbrains.com/issue/KT-38004) J2K breaks java getter call in java code
|
||||
- [`KT-38450`](https://youtrack.jetbrains.com/issue/KT-38450) J2K should convert Java SAM interfaces to Kotlin fun interfaces
|
||||
|
||||
### Tools. JPS
|
||||
|
||||
- [`KT-27458`](https://youtrack.jetbrains.com/issue/KT-27458) The Kotlin standard library is not found in the module graph ... in a non-Kotlin project.
|
||||
- [`KT-29552`](https://youtrack.jetbrains.com/issue/KT-29552) Project is completely rebuilt after each gradle sync.
|
||||
|
||||
### Tools. Scripts
|
||||
|
||||
- [`KT-37766`](https://youtrack.jetbrains.com/issue/KT-37766) Impossible to apply compiler plugins onto scripts with the new scripting API
|
||||
|
||||
### Tools. kapt
|
||||
|
||||
- [`KT-29355`](https://youtrack.jetbrains.com/issue/KT-29355) Provide access to default values for primary constructor properties
|
||||
|
||||
|
||||
## 1.4-M2
|
||||
|
||||
### Compiler
|
||||
@@ -1010,6 +1509,33 @@
|
||||
- [`KT-35414`](https://youtrack.jetbrains.com/issue/KT-35414) Switch for `-Xexpression` to `-expression`/`-e` cli argument syntax for JVM cli compiler in 1.4
|
||||
|
||||
|
||||
## 1.3.72 - IDE plugins update
|
||||
|
||||
### Backend. JVM
|
||||
|
||||
- [`KT-39013`](https://youtrack.jetbrains.com/issue/KT-39013) 202, ASM 8: "AnalyzerException: Execution can fall off the end of the code"
|
||||
|
||||
### IDE. Decompiler, Indexing, Stubs
|
||||
|
||||
- [`KT-37896`](https://youtrack.jetbrains.com/issue/KT-37896) IAE: "Argument for @NotNull parameter 'file' of IndexTodoCacheManagerImpl.getTodoCount must not be null" through KotlinTodoSearcher.processQuery()
|
||||
|
||||
### IDE. Gradle Integration
|
||||
|
||||
- [`KT-38037`](https://youtrack.jetbrains.com/issue/KT-38037) UnsupportedOperationException on sync gradle Kotlin project with at least two multiplatform modules
|
||||
|
||||
### IDE. Highlighting
|
||||
|
||||
- [`KT-39590`](https://youtrack.jetbrains.com/issue/KT-39590) Turn new inference in IDE for 1.3.70 version off
|
||||
|
||||
### IDE. Refactorings
|
||||
|
||||
- [`KT-38527`](https://youtrack.jetbrains.com/issue/KT-38527) Move nested class to upper level fails silently: MissingResourceException
|
||||
|
||||
### Tools.JPS
|
||||
|
||||
- [`KT-27458`](https://youtrack.jetbrains.com/issue/KT-27458) The Kotlin standard library is not found in the module graph ... in a non-Kotlin project.
|
||||
|
||||
|
||||
## 1.3.72
|
||||
|
||||
### Compiler
|
||||
|
||||
@@ -827,6 +827,21 @@ tasks {
|
||||
}
|
||||
}
|
||||
|
||||
register("kmmTest", AggregateTest::class) {
|
||||
dependsOn(
|
||||
":idea:idea-gradle:test",
|
||||
":idea:test",
|
||||
":compiler:test",
|
||||
":js:js.tests:test"
|
||||
)
|
||||
if (Ide.IJ193.orHigher())
|
||||
dependsOn(":kotlin-gradle-plugin-integration-tests:test")
|
||||
if (Ide.AS40.orHigher())
|
||||
dependsOn(":kotlin-ultimate:ide:android-studio-native:test")
|
||||
|
||||
testPatternFile = file("tests/mpp/kmm-patterns.csv")
|
||||
}
|
||||
|
||||
register("test") {
|
||||
doLast {
|
||||
throw GradleException("Don't use directly, use aggregate tasks *-check instead")
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
@file:Suppress("PropertyName", "HasPlatformType", "UnstableApiUsage")
|
||||
|
||||
import org.gradle.internal.os.OperatingSystem
|
||||
import org.jetbrains.kotlin.gradle.tasks.internal.CleanableStore
|
||||
import java.io.Closeable
|
||||
import java.io.OutputStreamWriter
|
||||
import java.net.URI
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
import javax.xml.stream.XMLOutputFactory
|
||||
|
||||
import org.jetbrains.kotlin.gradle.tasks.internal.CleanableStore
|
||||
import java.time.Duration
|
||||
import java.time.Instant
|
||||
import java.util.*
|
||||
import javax.xml.stream.XMLOutputFactory
|
||||
|
||||
plugins {
|
||||
base
|
||||
@@ -180,6 +179,7 @@ val mergeSources by tasks.creating(Jar::class.java) {
|
||||
dependsOn(sources)
|
||||
isPreserveFileTimestamps = false
|
||||
isReproducibleFileOrder = true
|
||||
isZip64 = true
|
||||
if (!kotlinBuildProperties.isTeamcityBuild) {
|
||||
from(provider { sources.map(::zipTree) })
|
||||
}
|
||||
|
||||
72
buildSrc/src/main/kotlin/AggregateTest.kt
Normal file
72
buildSrc/src/main/kotlin/AggregateTest.kt
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
import org.gradle.api.GradleException
|
||||
import org.gradle.api.tasks.*
|
||||
import org.gradle.api.tasks.testing.Test
|
||||
import java.io.File
|
||||
|
||||
// You can see "How To" via link: https://jetbrains.quip.com/xQ2WAUy9bZmy/How-to-use-AggregateTest-task
|
||||
open class AggregateTest : Test() { // Inherit from Test to see test results in IDEA Test viewer
|
||||
private var patterns: MutableMap<String, MutableList<String>> = mutableMapOf()
|
||||
|
||||
@InputFile
|
||||
lateinit var testPatternFile: File
|
||||
|
||||
init {
|
||||
// Set empty FileCollection to avoid NPE when initializing a base 'Test' class
|
||||
classpath = project.objects.fileCollection()
|
||||
testClassesDirs = project.objects.fileCollection()
|
||||
|
||||
project.gradle.taskGraph.whenReady {
|
||||
if (allTasks.filterIsInstance<AggregateTest>().isNotEmpty()) {
|
||||
initPatterns()
|
||||
allTasks.filterIsInstance<Test>().forEach { testTask -> subTaskConfigure(testTask) }
|
||||
|
||||
if (!project.gradle.startParameter.taskNames.all { project.tasks.findByPath(it) is AggregateTest }) {
|
||||
logger.warn("Please, don't use AggregateTest and non-AggregateTest test tasks together. You can get incorrect results.")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun initPatterns() {
|
||||
if (!testPatternFile.exists())
|
||||
throw GradleException("File with test patterns is not found")
|
||||
testPatternFile
|
||||
.readLines()
|
||||
.asSequence()
|
||||
.filter { it.isNotEmpty() }
|
||||
.forEach { line ->
|
||||
// patternType is exclude or include value
|
||||
val (pattern, patternType) = line.split(',').map { it.trim() }
|
||||
patterns.getOrPut(patternType) { mutableListOf() }.add(pattern)
|
||||
}
|
||||
}
|
||||
|
||||
private fun subTaskConfigure(testTask: Test) {
|
||||
testTask.outputs.upToDateWhen { false }
|
||||
testTask.ignoreFailures = true
|
||||
testTask.filter {
|
||||
isFailOnNoMatchingTests = false
|
||||
patterns["include"]?.let {
|
||||
it.forEach { pattern ->
|
||||
includeTestsMatching(pattern)
|
||||
}
|
||||
}
|
||||
patterns["exclude"]?.let {
|
||||
it.forEach { pattern ->
|
||||
excludeTestsMatching(pattern)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@TaskAction
|
||||
override fun executeTests() {
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ fun CompatibilityPredicate.or(other: CompatibilityPredicate): CompatibilityPredi
|
||||
}
|
||||
|
||||
enum class Platform : CompatibilityPredicate {
|
||||
P183, P191, P192, P193, P201, P202;
|
||||
P183, P191, P192, P193, P201, P202, P203;
|
||||
|
||||
val version: Int = name.drop(1).toInt()
|
||||
|
||||
@@ -48,6 +48,7 @@ enum class Ide(val platform: Platform) : CompatibilityPredicate {
|
||||
IJ193(Platform.P193),
|
||||
IJ201(Platform.P201),
|
||||
IJ202(Platform.P202),
|
||||
IJ203(Platform.P203),
|
||||
|
||||
AS35(Platform.P183),
|
||||
AS36(Platform.P192),
|
||||
|
||||
@@ -184,7 +184,7 @@ fun Project.runIdeTask(name: String, ideaPluginDir: File, ideaSandboxDir: File,
|
||||
"-Dplugin.path=${ideaPluginDir.absolutePath}"
|
||||
)
|
||||
|
||||
if (Platform[201].orHigher()) {
|
||||
if (Platform[201].orHigher() && !isIntellijUltimateSdkAvailable()) {
|
||||
jvmArgs("-Didea.platform.prefix=Idea")
|
||||
}
|
||||
|
||||
|
||||
@@ -388,6 +388,7 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
||||
put(LanguageFeature.NewInference, LanguageFeature.State.ENABLED)
|
||||
put(LanguageFeature.SamConversionPerArgument, LanguageFeature.State.ENABLED)
|
||||
put(LanguageFeature.FunctionReferenceWithDefaultValueAsOtherType, LanguageFeature.State.ENABLED)
|
||||
put(LanguageFeature.DisableCompatibilityModeForNewInference, LanguageFeature.State.ENABLED)
|
||||
}
|
||||
|
||||
if (inlineClasses) {
|
||||
@@ -467,6 +468,8 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
||||
|
||||
if (!functionReferenceWithDefaultValueFeaturePassedExplicitly)
|
||||
put(LanguageFeature.FunctionReferenceWithDefaultValueAsOtherType, LanguageFeature.State.ENABLED)
|
||||
|
||||
put(LanguageFeature.DisableCompatibilityModeForNewInference, LanguageFeature.State.ENABLED)
|
||||
}
|
||||
|
||||
if (featuresThatForcePreReleaseBinaries.isNotEmpty()) {
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
package org.jetbrains.kotlin.cli.jvm.compiler;
|
||||
|
||||
import com.intellij.DynamicBundle;
|
||||
import com.intellij.codeInsight.ContainerProvider;
|
||||
import com.intellij.codeInsight.runner.JavaMainMethodProvider;
|
||||
import com.intellij.core.JavaCoreApplicationEnvironment;
|
||||
import com.intellij.lang.MetaLanguage;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.vfs.VirtualFileSystem;
|
||||
import com.intellij.psi.FileContextProvider;
|
||||
import com.intellij.psi.augment.PsiAugmentProvider;
|
||||
import com.intellij.psi.compiled.ClassFileDecompilers;
|
||||
import com.intellij.psi.meta.MetaDataContributor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.cli.jvm.modules.CoreJrtFileSystem;
|
||||
|
||||
public class KotlinCoreApplicationEnvironment extends JavaCoreApplicationEnvironment {
|
||||
public static KotlinCoreApplicationEnvironment create(@NotNull Disposable parentDisposable, boolean unitTestMode) {
|
||||
KotlinCoreApplicationEnvironment environment = new KotlinCoreApplicationEnvironment(parentDisposable, unitTestMode);
|
||||
registerExtensionPoints();
|
||||
return environment;
|
||||
}
|
||||
|
||||
private KotlinCoreApplicationEnvironment(@NotNull Disposable parentDisposable, boolean unitTestMode) {
|
||||
super(parentDisposable, unitTestMode);
|
||||
}
|
||||
|
||||
private static void registerExtensionPoints() {
|
||||
registerApplicationExtensionPoint(DynamicBundle.LanguageBundleEP.EP_NAME, DynamicBundle.LanguageBundleEP.class);
|
||||
registerApplicationExtensionPoint(FileContextProvider.EP_NAME, FileContextProvider.class);
|
||||
|
||||
registerApplicationExtensionPoint(MetaDataContributor.EP_NAME, MetaDataContributor.class);
|
||||
registerApplicationExtensionPoint(PsiAugmentProvider.EP_NAME, PsiAugmentProvider.class);
|
||||
registerApplicationExtensionPoint(JavaMainMethodProvider.EP_NAME, JavaMainMethodProvider.class);
|
||||
|
||||
registerApplicationExtensionPoint(ContainerProvider.EP_NAME, ContainerProvider.class);
|
||||
registerApplicationExtensionPoint(ClassFileDecompilers.getInstance().EP_NAME, ClassFileDecompilers.Decompiler.class);
|
||||
|
||||
registerApplicationExtensionPoint(MetaLanguage.EP_NAME, MetaLanguage.class);
|
||||
|
||||
IdeaExtensionPoints.INSTANCE.registerVersionSpecificAppExtensionPoints(Extensions.getRootArea());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected VirtualFileSystem createJrtFileSystem() {
|
||||
return new CoreJrtFileSystem();
|
||||
}
|
||||
}
|
||||
@@ -4,8 +4,6 @@ plugins {
|
||||
id("jps-compatible")
|
||||
}
|
||||
|
||||
jvmTarget = "1.6"
|
||||
|
||||
val ktorExcludesForDaemon: List<Pair<String, String>> by rootProject.extra
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -11,8 +11,7 @@ public/*package*/ open class A : R|kotlin/Any| {
|
||||
|
||||
}
|
||||
public final enum class Mixed : R|kotlin/Enum<ft<Mixed, Mixed?>!>| {
|
||||
public final static field NOT_ENTRY_EITHER: R|Mixed|
|
||||
|
||||
public final static enum entry NOT_ENTRY_EITHER: R|Mixed|
|
||||
public final static fun values(): R|kotlin/Array<Mixed>| {
|
||||
}
|
||||
|
||||
@@ -21,10 +20,8 @@ public final enum class Mixed : R|kotlin/Enum<ft<Mixed, Mixed?>!>| {
|
||||
|
||||
}
|
||||
public final enum class Signs : R|kotlin/Enum<ft<Signs, Signs?>!>| {
|
||||
public final static field HELLO: R|Signs|
|
||||
|
||||
public final static field WORLD: R|Signs|
|
||||
|
||||
public final static enum entry HELLO: R|Signs|
|
||||
public final static enum entry WORLD: R|Signs|
|
||||
public final static field X: R|ft<Signs, Signs?>!|
|
||||
|
||||
public final static fun values(): R|kotlin/Array<Signs>| {
|
||||
|
||||
60
compiler/fir/analysis-tests/testData/resolve/exhaustiveness_enumJava.kt
vendored
Normal file
60
compiler/fir/analysis-tests/testData/resolve/exhaustiveness_enumJava.kt
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
// FILE: JavaEnum.java
|
||||
public enum JavaEnum {
|
||||
A, B, C;
|
||||
|
||||
public int i = 0;
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
fun test_1(e: JavaEnum) {
|
||||
val a = when (e) {
|
||||
JavaEnum.A -> 1
|
||||
JavaEnum.B -> 2
|
||||
}.<!UNRESOLVED_REFERENCE!>plus<!>(0)
|
||||
|
||||
val b = when (e) {
|
||||
JavaEnum.A -> 1
|
||||
JavaEnum.B -> 2
|
||||
is String -> 3
|
||||
}.<!UNRESOLVED_REFERENCE!>plus<!>(0)
|
||||
|
||||
val c = when (e) {
|
||||
JavaEnum.A -> 1
|
||||
JavaEnum.B -> 2
|
||||
JavaEnum.C -> 3
|
||||
}.plus(0)
|
||||
|
||||
val d = when (e) {
|
||||
JavaEnum.A -> 1
|
||||
else -> 2
|
||||
}.plus(0)
|
||||
}
|
||||
|
||||
fun test_2(e: JavaEnum?) {
|
||||
val a = when (e) {
|
||||
JavaEnum.A -> 1
|
||||
JavaEnum.B -> 2
|
||||
JavaEnum.C -> 3
|
||||
}.<!UNRESOLVED_REFERENCE!>plus<!>(0)
|
||||
|
||||
val a = when (e) {
|
||||
JavaEnum.A -> 1
|
||||
JavaEnum.B -> 2
|
||||
JavaEnum.C -> 3
|
||||
null -> 4
|
||||
}.plus(0)
|
||||
|
||||
val a = when (e) {
|
||||
JavaEnum.A -> 1
|
||||
JavaEnum.B -> 2
|
||||
JavaEnum.C -> 3
|
||||
else -> 4
|
||||
}.plus(0)
|
||||
}
|
||||
|
||||
fun test_3(e: JavaEnum) {
|
||||
val a = when (e) {
|
||||
JavaEnum.A, JavaEnum.B -> 1
|
||||
JavaEnum.C -> 2
|
||||
}.plus(0)
|
||||
}
|
||||
100
compiler/fir/analysis-tests/testData/resolve/exhaustiveness_enumJava.txt
vendored
Normal file
100
compiler/fir/analysis-tests/testData/resolve/exhaustiveness_enumJava.txt
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
FILE: main.kt
|
||||
public final fun test_1(e: R|JavaEnum|): R|kotlin/Unit| {
|
||||
lval a: <ERROR TYPE REF: Unresolved name: plus> = when (R|<local>/e|) {
|
||||
==($subj$, Q|JavaEnum|.R|/JavaEnum.A|) -> {
|
||||
Int(1)
|
||||
}
|
||||
==($subj$, Q|JavaEnum|.R|/JavaEnum.B|) -> {
|
||||
Int(2)
|
||||
}
|
||||
}
|
||||
.<Unresolved name: plus>#(Int(0))
|
||||
lval b: <ERROR TYPE REF: Unresolved name: plus> = when (R|<local>/e|) {
|
||||
==($subj$, Q|JavaEnum|.R|/JavaEnum.A|) -> {
|
||||
Int(1)
|
||||
}
|
||||
==($subj$, Q|JavaEnum|.R|/JavaEnum.B|) -> {
|
||||
Int(2)
|
||||
}
|
||||
($subj$ is R|kotlin/String|) -> {
|
||||
Int(3)
|
||||
}
|
||||
}
|
||||
.<Unresolved name: plus>#(Int(0))
|
||||
lval c: R|kotlin/Int| = when (R|<local>/e|) {
|
||||
==($subj$, Q|JavaEnum|.R|/JavaEnum.A|) -> {
|
||||
Int(1)
|
||||
}
|
||||
==($subj$, Q|JavaEnum|.R|/JavaEnum.B|) -> {
|
||||
Int(2)
|
||||
}
|
||||
==($subj$, Q|JavaEnum|.R|/JavaEnum.C|) -> {
|
||||
Int(3)
|
||||
}
|
||||
}
|
||||
.R|kotlin/Int.plus|(Int(0))
|
||||
lval d: R|kotlin/Int| = when (R|<local>/e|) {
|
||||
==($subj$, Q|JavaEnum|.R|/JavaEnum.A|) -> {
|
||||
Int(1)
|
||||
}
|
||||
else -> {
|
||||
Int(2)
|
||||
}
|
||||
}
|
||||
.R|kotlin/Int.plus|(Int(0))
|
||||
}
|
||||
public final fun test_2(e: R|JavaEnum?|): R|kotlin/Unit| {
|
||||
lval a: <ERROR TYPE REF: Unresolved name: plus> = when (R|<local>/e|) {
|
||||
==($subj$, Q|JavaEnum|.R|/JavaEnum.A|) -> {
|
||||
Int(1)
|
||||
}
|
||||
==($subj$, Q|JavaEnum|.R|/JavaEnum.B|) -> {
|
||||
Int(2)
|
||||
}
|
||||
==($subj$, Q|JavaEnum|.R|/JavaEnum.C|) -> {
|
||||
Int(3)
|
||||
}
|
||||
}
|
||||
.<Unresolved name: plus>#(Int(0))
|
||||
lval a: R|kotlin/Int| = when (R|<local>/e|) {
|
||||
==($subj$, Q|JavaEnum|.R|/JavaEnum.A|) -> {
|
||||
Int(1)
|
||||
}
|
||||
==($subj$, Q|JavaEnum|.R|/JavaEnum.B|) -> {
|
||||
Int(2)
|
||||
}
|
||||
==($subj$, Q|JavaEnum|.R|/JavaEnum.C|) -> {
|
||||
Int(3)
|
||||
}
|
||||
==($subj$, Null(null)) -> {
|
||||
Int(4)
|
||||
}
|
||||
}
|
||||
.R|kotlin/Int.plus|(Int(0))
|
||||
lval a: R|kotlin/Int| = when (R|<local>/e|) {
|
||||
==($subj$, Q|JavaEnum|.R|/JavaEnum.A|) -> {
|
||||
Int(1)
|
||||
}
|
||||
==($subj$, Q|JavaEnum|.R|/JavaEnum.B|) -> {
|
||||
Int(2)
|
||||
}
|
||||
==($subj$, Q|JavaEnum|.R|/JavaEnum.C|) -> {
|
||||
Int(3)
|
||||
}
|
||||
else -> {
|
||||
Int(4)
|
||||
}
|
||||
}
|
||||
.R|kotlin/Int.plus|(Int(0))
|
||||
}
|
||||
public final fun test_3(e: R|JavaEnum|): R|kotlin/Unit| {
|
||||
lval a: R|kotlin/Int| = when (R|<local>/e|) {
|
||||
==($subj$, Q|JavaEnum|.R|/JavaEnum.A|) || ==($subj$, Q|JavaEnum|.R|/JavaEnum.B|) -> {
|
||||
Int(1)
|
||||
}
|
||||
==($subj$, Q|JavaEnum|.R|/JavaEnum.C|) -> {
|
||||
Int(2)
|
||||
}
|
||||
}
|
||||
.R|kotlin/Int.plus|(Int(0))
|
||||
}
|
||||
@@ -30,6 +30,6 @@ FILE: importedReceiver.kt
|
||||
(Q|My|, String()).R|/My.bar|<R|kotlin/String|>()
|
||||
Q|My|.R|/My.baz|()
|
||||
(Q|My|, Boolean(true)).R|/My.gau|()
|
||||
R|/Your.wat|()
|
||||
Q|My|.R|/Your.wat|()
|
||||
(Q|My|, Boolean(false)).R|FakeOverride</My.watwat: R|kotlin/Unit|>|<R|kotlin/Boolean|>()
|
||||
}
|
||||
|
||||
@@ -11,5 +11,5 @@ FILE: objectOverrideCallViaImport.kt
|
||||
|
||||
}
|
||||
public final fun test(): R|kotlin/Unit| {
|
||||
R|/Base.foo|()
|
||||
Q|Derived|.R|/Base.foo|()
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// TODO: This interface must be marked as "fun" ones that modifier is supported
|
||||
interface MyRunnable {
|
||||
fun interface MyRunnable {
|
||||
fun foo(x: Int): Boolean
|
||||
}
|
||||
|
||||
|
||||
@@ -1,21 +1,20 @@
|
||||
// TODO: These interfaces must be marked as "fun" ones that modifier is supported
|
||||
interface MyRunnable {
|
||||
fun interface MyRunnable {
|
||||
fun foo(x: Int): Boolean
|
||||
}
|
||||
|
||||
interface WithProperty {
|
||||
fun interface WithProperty {
|
||||
val x: Int
|
||||
}
|
||||
|
||||
interface TwoAbstract : MyRunnable {
|
||||
fun interface TwoAbstract : MyRunnable {
|
||||
fun bar()
|
||||
}
|
||||
|
||||
interface Super {
|
||||
fun interface Super {
|
||||
fun foo(x: Int): Any
|
||||
}
|
||||
|
||||
interface Derived : Super {
|
||||
fun interface Derived : Super {
|
||||
override fun foo(x: Int): Boolean
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
interface MySam {
|
||||
fun interface MySam {
|
||||
fun run(x: String): Int
|
||||
}
|
||||
|
||||
|
||||
160
compiler/fir/analysis-tests/testData/resolveWithStdlib/inference/plusAssignWithLambdaInRhs.dot
vendored
Normal file
160
compiler/fir/analysis-tests/testData/resolveWithStdlib/inference/plusAssignWithLambdaInRhs.dot
vendored
Normal file
@@ -0,0 +1,160 @@
|
||||
digraph plusAssignWithLambdaInRhs_kt {
|
||||
graph [nodesep=3]
|
||||
node [shape=box penwidth=2]
|
||||
edge [penwidth=2]
|
||||
|
||||
subgraph cluster_0 {
|
||||
color=red
|
||||
0 [label="Enter function test" style="filled" fillcolor=red];
|
||||
subgraph cluster_1 {
|
||||
color=blue
|
||||
1 [label="Enter block"];
|
||||
2 [label="Const: Null(null)"];
|
||||
3 [label="Check not null: Null(null)!!"];
|
||||
4 [label="Variable declaration: lval list: R|kotlin/collections/MutableList<kotlin/Function1<kotlin/String, kotlin/String>>|"];
|
||||
5 [label="Access variable R|<local>/list|"];
|
||||
6 [label="Postponed enter to lambda"];
|
||||
subgraph cluster_2 {
|
||||
color=blue
|
||||
11 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
||||
subgraph cluster_3 {
|
||||
color=blue
|
||||
12 [label="Enter block"];
|
||||
13 [label="Access variable R|<local>/it|"];
|
||||
14 [label="Exit block"];
|
||||
}
|
||||
15 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
|
||||
}
|
||||
7 [label="Postponed exit from lambda"];
|
||||
8 [label="Function call: R|<local>/list|.R|kotlin/collections/plusAssign|<R|(kotlin/String) -> kotlin/String|>(...)"];
|
||||
9 [label="Exit block"];
|
||||
}
|
||||
10 [label="Exit function test" style="filled" fillcolor=red];
|
||||
}
|
||||
0 -> {1};
|
||||
1 -> {2};
|
||||
2 -> {3};
|
||||
3 -> {4};
|
||||
4 -> {5};
|
||||
5 -> {6};
|
||||
6 -> {11};
|
||||
6 -> {7} [color=red];
|
||||
7 -> {8};
|
||||
8 -> {9};
|
||||
9 -> {10};
|
||||
11 -> {15 12};
|
||||
12 -> {13};
|
||||
13 -> {14};
|
||||
14 -> {15};
|
||||
15 -> {7} [color=green];
|
||||
15 -> {11} [color=green style=dashed];
|
||||
|
||||
subgraph cluster_4 {
|
||||
color=red
|
||||
16 [label="Enter class A" style="filled" fillcolor=red];
|
||||
subgraph cluster_5 {
|
||||
color=blue
|
||||
18 [label="Enter property" style="filled" fillcolor=red];
|
||||
19 [label="Access variable R|<local>/executor|"];
|
||||
20 [label="Exit property" style="filled" fillcolor=red];
|
||||
}
|
||||
17 [label="Exit class A" style="filled" fillcolor=red];
|
||||
}
|
||||
16 -> {18} [color=green];
|
||||
18 -> {19};
|
||||
19 -> {20};
|
||||
20 -> {17} [color=green];
|
||||
|
||||
subgraph cluster_6 {
|
||||
color=red
|
||||
21 [label="Enter function <init>" style="filled" fillcolor=red];
|
||||
22 [label="Delegated constructor call: super<R|kotlin/Any|>()"];
|
||||
23 [label="Exit function <init>" style="filled" fillcolor=red];
|
||||
}
|
||||
21 -> {22};
|
||||
22 -> {23};
|
||||
|
||||
subgraph cluster_7 {
|
||||
color=red
|
||||
24 [label="Enter function getter" style="filled" fillcolor=red];
|
||||
25 [label="Exit function getter" style="filled" fillcolor=red];
|
||||
}
|
||||
24 -> {25};
|
||||
|
||||
subgraph cluster_8 {
|
||||
color=red
|
||||
26 [label="Enter function postpone" style="filled" fillcolor=red];
|
||||
subgraph cluster_9 {
|
||||
color=blue
|
||||
27 [label="Enter block"];
|
||||
28 [label="Function call: R|kotlin/collections/mutableListOf|<R|() -> kotlin/Unit|>()"];
|
||||
29 [label="Variable declaration: lval queue: R|kotlin/collections/MutableList<kotlin/Function0<kotlin/Unit>>|"];
|
||||
30 [label="Postponed enter to lambda"];
|
||||
subgraph cluster_10 {
|
||||
color=blue
|
||||
37 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
||||
subgraph cluster_11 {
|
||||
color=blue
|
||||
38 [label="Enter block"];
|
||||
39 [label="Access variable R|<local>/queue|"];
|
||||
40 [label="Postponed enter to lambda"];
|
||||
subgraph cluster_12 {
|
||||
color=blue
|
||||
45 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
||||
subgraph cluster_13 {
|
||||
color=blue
|
||||
46 [label="Enter block"];
|
||||
47 [label="Function call: R|<local>/computation|.R|FakeOverride<kotlin/Function0.invoke: R|T|>|()"];
|
||||
48 [label="Function call: R|<local>/resolve|.R|FakeOverride<kotlin/Function1.invoke: R|kotlin/Unit|>|(...)"];
|
||||
49 [label="Exit block"];
|
||||
}
|
||||
50 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
|
||||
}
|
||||
41 [label="Postponed exit from lambda"];
|
||||
42 [label="Function call: R|<local>/queue|.R|kotlin/collections/plusAssign|<R|() -> kotlin/Unit|>(...)"];
|
||||
43 [label="Exit block"];
|
||||
}
|
||||
44 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
|
||||
}
|
||||
31 [label="Postponed exit from lambda"];
|
||||
32 [label="Function call: R|/A.A|<R|T|>(...)"];
|
||||
33 [label="Jump: ^postpone R|/A.A|<R|T|>(<L> = A@fun <anonymous>(resolve: R|(T) -> kotlin/Unit|): R|kotlin/Unit| {
|
||||
R|<local>/queue|.R|kotlin/collections/plusAssign|<R|() -> kotlin/Unit|>(A@fun <anonymous>(): R|kotlin/Unit| <kind=UNKNOWN> {
|
||||
R|<local>/resolve|.R|FakeOverride<kotlin/Function1.invoke: R|kotlin/Unit|>|(R|<local>/computation|.R|FakeOverride<kotlin/Function0.invoke: R|T|>|())
|
||||
}
|
||||
)
|
||||
}
|
||||
)"];
|
||||
34 [label="Stub" style="filled" fillcolor=gray];
|
||||
35 [label="Exit block" style="filled" fillcolor=gray];
|
||||
}
|
||||
36 [label="Exit function postpone" style="filled" fillcolor=red];
|
||||
}
|
||||
26 -> {27};
|
||||
27 -> {28};
|
||||
28 -> {29};
|
||||
29 -> {30};
|
||||
30 -> {31 37};
|
||||
31 -> {32};
|
||||
32 -> {33};
|
||||
33 -> {36};
|
||||
33 -> {34} [style=dotted];
|
||||
34 -> {35} [style=dotted];
|
||||
35 -> {36} [style=dotted];
|
||||
37 -> {38};
|
||||
38 -> {39};
|
||||
39 -> {40};
|
||||
40 -> {45};
|
||||
40 -> {41} [color=red];
|
||||
41 -> {42};
|
||||
42 -> {43};
|
||||
43 -> {44};
|
||||
45 -> {50 46};
|
||||
46 -> {47};
|
||||
47 -> {48};
|
||||
48 -> {49};
|
||||
49 -> {50};
|
||||
50 -> {41} [color=green];
|
||||
50 -> {45} [color=green style=dashed];
|
||||
|
||||
}
|
||||
19
compiler/fir/analysis-tests/testData/resolveWithStdlib/inference/plusAssignWithLambdaInRhs.kt
vendored
Normal file
19
compiler/fir/analysis-tests/testData/resolveWithStdlib/inference/plusAssignWithLambdaInRhs.kt
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
// ISSUE: KT-39005
|
||||
// !DUMP_CFG
|
||||
|
||||
fun test() {
|
||||
val list: MutableList<(String) -> String> = null!!
|
||||
list += { it }
|
||||
}
|
||||
|
||||
class A<T>(private val executor: ((T) -> Unit) -> Unit)
|
||||
|
||||
fun <T> postpone(computation: () -> T): A<T> {
|
||||
val queue = mutableListOf<() -> Unit>()
|
||||
|
||||
return A { resolve ->
|
||||
queue += {
|
||||
resolve(computation())
|
||||
}
|
||||
}
|
||||
}
|
||||
27
compiler/fir/analysis-tests/testData/resolveWithStdlib/inference/plusAssignWithLambdaInRhs.txt
vendored
Normal file
27
compiler/fir/analysis-tests/testData/resolveWithStdlib/inference/plusAssignWithLambdaInRhs.txt
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
FILE: plusAssignWithLambdaInRhs.kt
|
||||
public final fun test(): R|kotlin/Unit| {
|
||||
lval list: R|kotlin/collections/MutableList<kotlin/Function1<kotlin/String, kotlin/String>>| = Null(null)!!
|
||||
R|<local>/list|.R|kotlin/collections/plusAssign|<R|(kotlin/String) -> kotlin/String|>(fun <anonymous>(it: R|kotlin/String|): R|kotlin/String| <kind=UNKNOWN> {
|
||||
^ R|<local>/it|
|
||||
}
|
||||
)
|
||||
}
|
||||
public final class A<T> : R|kotlin/Any| {
|
||||
public constructor<T>(executor: R|(kotlin/Function1<T, kotlin/Unit>) -> kotlin/Unit|): R|A<T>| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
private final val executor: R|(kotlin/Function1<T, kotlin/Unit>) -> kotlin/Unit| = R|<local>/executor|
|
||||
private get(): R|(kotlin/Function1<T, kotlin/Unit>) -> kotlin/Unit|
|
||||
|
||||
}
|
||||
public final fun <T> postpone(computation: R|() -> T|): R|A<T>| {
|
||||
lval queue: R|kotlin/collections/MutableList<kotlin/Function0<kotlin/Unit>>| = R|kotlin/collections/mutableListOf|<R|() -> kotlin/Unit|>()
|
||||
^postpone R|/A.A|<R|T|>(<L> = A@fun <anonymous>(resolve: R|(T) -> kotlin/Unit|): R|kotlin/Unit| {
|
||||
R|<local>/queue|.R|kotlin/collections/plusAssign|<R|() -> kotlin/Unit|>(A@fun <anonymous>(): R|kotlin/Unit| <kind=UNKNOWN> {
|
||||
R|<local>/resolve|.R|FakeOverride<kotlin/Function1.invoke: R|kotlin/Unit|>|(R|<local>/computation|.R|FakeOverride<kotlin/Function0.invoke: R|T|>|())
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -133,6 +133,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/exhaustiveness_enum.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("exhaustiveness_enumJava.kt")
|
||||
public void testExhaustiveness_enumJava() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/exhaustiveness_enumJava.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("exhaustiveness_sealedClass.kt")
|
||||
public void testExhaustiveness_sealedClass() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/exhaustiveness_sealedClass.kt");
|
||||
|
||||
@@ -133,6 +133,11 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/exhaustiveness_enum.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("exhaustiveness_enumJava.kt")
|
||||
public void testExhaustiveness_enumJava() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/exhaustiveness_enumJava.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("exhaustiveness_sealedClass.kt")
|
||||
public void testExhaustiveness_sealedClass() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/exhaustiveness_sealedClass.kt");
|
||||
|
||||
@@ -716,6 +716,11 @@ public class FirDiagnosticsWithStdlibTestGenerated extends AbstractFirDiagnostic
|
||||
public void testIfElvisReturn() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/inference/ifElvisReturn.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("plusAssignWithLambdaInRhs.kt")
|
||||
public void testPlusAssignWithLambdaInRhs() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolveWithStdlib/inference/plusAssignWithLambdaInRhs.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/fir/analysis-tests/testData/resolveWithStdlib/j+k")
|
||||
|
||||
@@ -1924,6 +1924,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
|
||||
runTest("compiler/testData/diagnostics/tests/callableReference/noAmbiguityWhenAllReferencesAreInapplicable.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("noCompatibilityResolveWithProressiveModeForNI.kt")
|
||||
public void testNoCompatibilityResolveWithProressiveModeForNI() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/callableReference/noCompatibilityResolveWithProressiveModeForNI.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("noExceptionOnRedCodeWithArrayLikeCall.kt")
|
||||
public void testNoExceptionOnRedCodeWithArrayLikeCall() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/callableReference/noExceptionOnRedCodeWithArrayLikeCall.kt");
|
||||
@@ -19501,6 +19506,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/overloadConflicts/kt31758_compat.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt37692.kt")
|
||||
public void testKt37692() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/overloadConflicts/kt37692.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("numberOfDefaults.kt")
|
||||
public void testNumberOfDefaults() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/overloadConflicts/numberOfDefaults.kt");
|
||||
|
||||
@@ -9,12 +9,14 @@ import org.jetbrains.kotlin.fir.FirRenderer
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.FirCallableMemberDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.FirDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.FirEnumEntry
|
||||
import org.jetbrains.kotlin.fir.java.declarations.FirJavaClass
|
||||
import org.jetbrains.kotlin.fir.java.declarations.FirJavaConstructor
|
||||
import org.jetbrains.kotlin.fir.java.declarations.FirJavaField
|
||||
import org.jetbrains.kotlin.fir.java.declarations.FirJavaMethod
|
||||
import org.jetbrains.kotlin.fir.resolve.ScopeSession
|
||||
import org.jetbrains.kotlin.fir.resolve.buildUseSiteMemberScope
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
|
||||
|
||||
fun renderJavaClass(renderer: FirRenderer, javaClass: FirJavaClass, session: FirSession) {
|
||||
val memberScope = javaClass.buildUseSiteMemberScope(session, ScopeSession())
|
||||
@@ -28,6 +30,16 @@ fun renderJavaClass(renderer: FirRenderer, javaClass: FirJavaClass, session: Fir
|
||||
renderer.renderSupertypes(javaClass)
|
||||
renderer.renderInBraces {
|
||||
val renderedDeclarations = mutableListOf<FirDeclaration>()
|
||||
|
||||
fun renderAndCache(symbol: FirCallableSymbol<*>) {
|
||||
val enhanced = symbol.fir
|
||||
if (enhanced !in renderedDeclarations) {
|
||||
enhanced.accept(renderer, null)
|
||||
renderer.newLine()
|
||||
renderedDeclarations += enhanced
|
||||
}
|
||||
}
|
||||
|
||||
for (declaration in javaClass.declarations) {
|
||||
if (declaration in renderedDeclarations) continue
|
||||
|
||||
@@ -38,30 +50,10 @@ fun renderJavaClass(renderer: FirRenderer, javaClass: FirJavaClass, session: Fir
|
||||
memberScope
|
||||
|
||||
when (declaration) {
|
||||
is FirJavaConstructor -> scopeToUse!!.processDeclaredConstructors { symbol ->
|
||||
val enhanced = symbol.fir
|
||||
if (enhanced !in renderedDeclarations) {
|
||||
enhanced.accept(renderer, null)
|
||||
renderer.newLine()
|
||||
renderedDeclarations += enhanced
|
||||
}
|
||||
}
|
||||
is FirJavaMethod -> scopeToUse!!.processFunctionsByName(declaration.name) { symbol ->
|
||||
val enhanced = symbol.fir
|
||||
if (enhanced !in renderedDeclarations) {
|
||||
enhanced.accept(renderer, null)
|
||||
renderer.newLine()
|
||||
renderedDeclarations += enhanced
|
||||
}
|
||||
}
|
||||
is FirJavaField -> scopeToUse!!.processPropertiesByName(declaration.name) { symbol ->
|
||||
val enhanced = symbol.fir
|
||||
if (enhanced !in renderedDeclarations) {
|
||||
enhanced.accept(renderer, null)
|
||||
renderer.newLine()
|
||||
renderedDeclarations += enhanced
|
||||
}
|
||||
}
|
||||
is FirJavaConstructor -> scopeToUse!!.processDeclaredConstructors(::renderAndCache)
|
||||
is FirJavaMethod -> scopeToUse!!.processFunctionsByName(declaration.name, ::renderAndCache)
|
||||
is FirJavaField -> scopeToUse!!.processPropertiesByName(declaration.name, ::renderAndCache)
|
||||
is FirEnumEntry -> scopeToUse!!.processPropertiesByName(declaration.name, ::renderAndCache)
|
||||
else -> {
|
||||
declaration.accept(renderer, null)
|
||||
renderer.newLine()
|
||||
|
||||
@@ -475,10 +475,6 @@ class CallAndReferenceGenerator(
|
||||
private fun FirQualifiedAccess.findIrReceiver(explicitReceiverExpression: IrExpression?, isDispatch: Boolean): IrExpression? {
|
||||
val firReceiver = if (isDispatch) dispatchReceiver else extensionReceiver
|
||||
if (firReceiver == explicitReceiver) {
|
||||
// TODO: remove after fix of KT-35730 (temporary hack to prevent receiver duplication)
|
||||
if (!isDispatch && dispatchReceiver is FirNoReceiverExpression) {
|
||||
return visitor.convertToIrExpression(firReceiver)
|
||||
}
|
||||
return explicitReceiverExpression
|
||||
}
|
||||
if (firReceiver is FirResolvedQualifier) {
|
||||
|
||||
@@ -1708,6 +1708,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/builderInference/lackOfNullCheckOnNullableInsideBuild.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("substituteStubTypeIntoCR.kt")
|
||||
public void testSubstituteStubTypeIntoCR() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/builderInference/substituteStubTypeIntoCR.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("substituteStubTypeIntolambdaParameterDescriptor.kt")
|
||||
public void testSubstituteStubTypeIntolambdaParameterDescriptor() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/builderInference/substituteStubTypeIntolambdaParameterDescriptor.kt");
|
||||
|
||||
@@ -1082,6 +1082,11 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest {
|
||||
runTest("compiler/testData/ir/irText/expressions/kt30796.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt35730.kt")
|
||||
public void testKt35730() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/expressions/kt35730.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt36956.kt")
|
||||
public void testKt36956() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/expressions/kt36956.kt");
|
||||
|
||||
@@ -11,16 +11,10 @@ import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin
|
||||
import org.jetbrains.kotlin.fir.declarations.FirRegularClass
|
||||
import org.jetbrains.kotlin.fir.declarations.FirTypeParameter
|
||||
import org.jetbrains.kotlin.fir.declarations.addDefaultBoundIfNecessary
|
||||
import org.jetbrains.kotlin.fir.declarations.builder.FirTypeParameterBuilder
|
||||
import org.jetbrains.kotlin.fir.declarations.builder.buildConstructedClassTypeParameterRef
|
||||
import org.jetbrains.kotlin.fir.declarations.builder.buildOuterClassTypeParameterRef
|
||||
import org.jetbrains.kotlin.fir.generateValueOfFunction
|
||||
import org.jetbrains.kotlin.fir.generateValuesFunction
|
||||
import org.jetbrains.kotlin.fir.*
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.declarations.builder.*
|
||||
import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl
|
||||
import org.jetbrains.kotlin.fir.java.declarations.*
|
||||
import org.jetbrains.kotlin.fir.resolve.constructType
|
||||
import org.jetbrains.kotlin.fir.resolve.providers.AbstractFirSymbolProvider
|
||||
@@ -30,7 +24,6 @@ import org.jetbrains.kotlin.fir.scopes.impl.lazyNestedClassifierScope
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.nestedClassifierScope
|
||||
import org.jetbrains.kotlin.fir.symbols.CallableId
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||
import org.jetbrains.kotlin.fir.toFirPsiSourceElement
|
||||
import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl
|
||||
import org.jetbrains.kotlin.load.java.JavaClassFinder
|
||||
@@ -191,22 +184,38 @@ class JavaSymbolProvider(
|
||||
for (javaField in javaClass.fields) {
|
||||
val fieldName = javaField.name
|
||||
val fieldId = CallableId(classId.packageFqName, classId.relativeClassName, fieldName)
|
||||
val fieldSymbol = FirFieldSymbol(fieldId)
|
||||
val returnType = javaField.type
|
||||
val firJavaField = buildJavaField {
|
||||
source = (javaField as? JavaElementImpl<*>)?.psi?.toFirPsiSourceElement()
|
||||
session = this@JavaSymbolProvider.session
|
||||
symbol = fieldSymbol
|
||||
name = fieldName
|
||||
visibility = javaField.visibility
|
||||
modality = javaField.modality
|
||||
returnTypeRef = returnType.toFirJavaTypeRef(this@JavaSymbolProvider.session, javaTypeParameterStack)
|
||||
isVar = !javaField.isFinal
|
||||
isStatic = javaField.isStatic
|
||||
isEnumEntry = javaField.isEnumEntry
|
||||
addAnnotationsFrom(this@JavaSymbolProvider.session, javaField, javaTypeParameterStack)
|
||||
val firJavaDeclaration = when {
|
||||
javaField.isEnumEntry -> buildEnumEntry {
|
||||
source = (javaField as? JavaElementImpl<*>)?.psi?.toFirPsiSourceElement()
|
||||
session = this@JavaSymbolProvider.session
|
||||
symbol = FirVariableSymbol(fieldId)
|
||||
name = fieldName
|
||||
status = FirDeclarationStatusImpl(javaField.visibility, javaField.modality).apply {
|
||||
isStatic = javaField.isStatic
|
||||
isExpect = false
|
||||
isActual = false
|
||||
isOverride = false
|
||||
}
|
||||
returnTypeRef = returnType.toFirJavaTypeRef(this@JavaSymbolProvider.session, javaTypeParameterStack)
|
||||
resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
|
||||
origin = FirDeclarationOrigin.Java
|
||||
addAnnotationsFrom(this@JavaSymbolProvider.session, javaField, javaTypeParameterStack)
|
||||
}
|
||||
else -> buildJavaField {
|
||||
source = (javaField as? JavaElementImpl<*>)?.psi?.toFirPsiSourceElement()
|
||||
session = this@JavaSymbolProvider.session
|
||||
symbol = FirFieldSymbol(fieldId)
|
||||
name = fieldName
|
||||
visibility = javaField.visibility
|
||||
modality = javaField.modality
|
||||
returnTypeRef = returnType.toFirJavaTypeRef(this@JavaSymbolProvider.session, javaTypeParameterStack)
|
||||
isVar = !javaField.isFinal
|
||||
isStatic = javaField.isStatic
|
||||
addAnnotationsFrom(this@JavaSymbolProvider.session, javaField, javaTypeParameterStack)
|
||||
}
|
||||
}
|
||||
declarations += firJavaField
|
||||
declarations += firJavaDeclaration
|
||||
}
|
||||
for (javaMethod in javaClass.methods) {
|
||||
val methodName = javaMethod.name
|
||||
|
||||
@@ -143,6 +143,7 @@ internal class FirJavaClassBuilder : FirRegularClassBuilder(), FirAnnotationCont
|
||||
isCompanion = false
|
||||
isData = false
|
||||
isInline = false
|
||||
isFun = classKind == ClassKind.INTERFACE
|
||||
}
|
||||
|
||||
return FirJavaClass(
|
||||
|
||||
@@ -42,7 +42,6 @@ class FirJavaField @FirImplementationDetail constructor(
|
||||
override val isVar: Boolean,
|
||||
override val annotations: MutableList<FirAnnotationCall>,
|
||||
override val typeParameters: MutableList<FirTypeParameter>,
|
||||
val isEnumEntry: Boolean
|
||||
) : FirField() {
|
||||
init {
|
||||
symbol.bind(this)
|
||||
@@ -138,7 +137,6 @@ internal class FirJavaFieldBuilder : FirFieldBuilder() {
|
||||
var modality: Modality? = null
|
||||
lateinit var visibility: Visibility
|
||||
var isStatic: Boolean by Delegates.notNull()
|
||||
var isEnumEntry: Boolean by Delegates.notNull()
|
||||
|
||||
override var resolvePhase: FirResolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
|
||||
|
||||
@@ -162,7 +160,6 @@ internal class FirJavaFieldBuilder : FirFieldBuilder() {
|
||||
isVar,
|
||||
annotations,
|
||||
typeParameters,
|
||||
isEnumEntry
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -69,21 +69,22 @@ class FirSignatureEnhancement(
|
||||
name: Name
|
||||
): FirVariableSymbol<*> {
|
||||
when (val firElement = original.fir) {
|
||||
is FirField -> {
|
||||
is FirEnumEntry -> {
|
||||
if (firElement.returnTypeRef !is FirJavaTypeRef) return original
|
||||
val memberContext = context.copyWithNewDefaultTypeQualifiers(typeQualifierResolver, jsr305State, firElement.annotations)
|
||||
val isEnumEntry = (firElement as? FirJavaField)?.isEnumEntry ?: false
|
||||
|
||||
val predefinedInfo = if (isEnumEntry) {
|
||||
val predefinedInfo =
|
||||
PredefinedFunctionEnhancementInfo(
|
||||
TypeEnhancementInfo(0 to JavaTypeQualifiers(NullabilityQualifier.NOT_NULL, null, false)),
|
||||
emptyList()
|
||||
)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
|
||||
val newReturnTypeRef = enhanceReturnType(firElement, emptyList(), memberContext, predefinedInfo)
|
||||
return firElement.symbol.apply { this.fir.replaceReturnTypeRef(newReturnTypeRef) }
|
||||
}
|
||||
is FirField -> {
|
||||
if (firElement.returnTypeRef !is FirJavaTypeRef) return original
|
||||
val memberContext = context.copyWithNewDefaultTypeQualifiers(typeQualifierResolver, jsr305State, firElement.annotations)
|
||||
val newReturnTypeRef = enhanceReturnType(firElement, emptyList(), memberContext, null)
|
||||
|
||||
val symbol = FirFieldSymbol(original.callableId)
|
||||
buildJavaField {
|
||||
@@ -97,7 +98,6 @@ class FirSignatureEnhancement(
|
||||
isVar = firElement.isVar
|
||||
isStatic = firElement.isStatic
|
||||
annotations += firElement.annotations
|
||||
this.isEnumEntry = isEnumEntry
|
||||
}
|
||||
return symbol
|
||||
}
|
||||
|
||||
@@ -14,7 +14,8 @@ object ModifierSets {
|
||||
ANNOTATION_KEYWORD,
|
||||
DATA_KEYWORD,
|
||||
INNER_KEYWORD,
|
||||
COMPANION_KEYWORD
|
||||
COMPANION_KEYWORD,
|
||||
FUN_KEYWORD
|
||||
)
|
||||
val MEMBER_MODIFIER = TokenSet.create(OVERRIDE_KEYWORD, LATEINIT_KEYWORD)
|
||||
val VISIBILITY_MODIFIER = TokenSet.create(
|
||||
|
||||
@@ -58,14 +58,22 @@ class FirCallResolver(
|
||||
inferenceComponents.session.callConflictResolverFactory
|
||||
.create(TypeSpecificityComparator.NONE, inferenceComponents)
|
||||
|
||||
@PrivateForInline
|
||||
var needTransformArguments: Boolean = true
|
||||
|
||||
@OptIn(PrivateForInline::class)
|
||||
fun resolveCallAndSelectCandidate(functionCall: FirFunctionCall): FirFunctionCall {
|
||||
qualifiedResolver.reset()
|
||||
@Suppress("NAME_SHADOWING")
|
||||
val functionCall = functionCall.transformExplicitReceiver(transformer, ResolutionMode.ContextIndependent)
|
||||
.also {
|
||||
dataFlowAnalyzer.enterQualifiedAccessExpression()
|
||||
functionCall.argumentList.transformArguments(transformer, ResolutionMode.ContextDependent)
|
||||
}
|
||||
val functionCall = if (needTransformArguments) {
|
||||
functionCall.transformExplicitReceiver(transformer, ResolutionMode.ContextIndependent)
|
||||
.also {
|
||||
dataFlowAnalyzer.enterQualifiedAccessExpression()
|
||||
functionCall.argumentList.transformArguments(transformer, ResolutionMode.ContextDependent)
|
||||
}
|
||||
} else {
|
||||
functionCall
|
||||
}
|
||||
|
||||
val name = functionCall.calleeReference.name
|
||||
val result = collectCandidates(functionCall, name)
|
||||
@@ -289,6 +297,17 @@ class FirCallResolver(
|
||||
return callResolver.selectDelegatingConstructorCall(delegatedConstructorCall, name, result, callInfo)
|
||||
}
|
||||
|
||||
@OptIn(PrivateForInline::class)
|
||||
inline fun <T> withNoArgumentsTransform(block: () -> T): T {
|
||||
val oldValue = needTransformArguments
|
||||
needTransformArguments = false
|
||||
return try {
|
||||
block()
|
||||
} finally {
|
||||
needTransformArguments = oldValue
|
||||
}
|
||||
}
|
||||
|
||||
private fun selectDelegatingConstructorCall(
|
||||
call: FirDelegatedConstructorCall, name: Name, result: CandidateCollector, callInfo: CallInfo
|
||||
): FirDelegatedConstructorCall {
|
||||
|
||||
@@ -202,6 +202,7 @@ class FirSamResolverImpl(
|
||||
|
||||
private fun resolveFunctionTypeIfSamInterface(firRegularClass: FirRegularClass): ConeKotlinType? {
|
||||
return resolvedFunctionType.getOrPut(firRegularClass) {
|
||||
if (!firRegularClass.status.isFun) return@getOrPut NULL_STUB
|
||||
val abstractMethod = firRegularClass.getSingleAbstractMethodOrNull(firSession, scopeSession) ?: return@getOrPut NULL_STUB
|
||||
// TODO: val shouldConvertFirstParameterToDescriptor = samWithReceiverResolvers.any { it.shouldConvertFirstSamParameterToReceiver(abstractMethod) }
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
|
||||
package org.jetbrains.kotlin.fir.resolve.calls.tower
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.FirConstructor
|
||||
import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin
|
||||
import org.jetbrains.kotlin.fir.declarations.isInner
|
||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||
import org.jetbrains.kotlin.fir.expressions.builder.buildResolvedQualifier
|
||||
@@ -20,7 +20,6 @@ import org.jetbrains.kotlin.fir.resolve.typeForQualifier
|
||||
import org.jetbrains.kotlin.fir.scopes.FirScope
|
||||
import org.jetbrains.kotlin.fir.scopes.ProcessorAction
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.FirAbstractImportingScope
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.FirExplicitSimpleImportingScope
|
||||
import org.jetbrains.kotlin.fir.scopes.processClassifiersByName
|
||||
import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||
@@ -204,13 +203,11 @@ class ScopeTowerLevel(
|
||||
else -> true
|
||||
}
|
||||
|
||||
private fun dispatchReceiverValue(scope: FirScope, candidate: FirCallableSymbol<*>): ReceiverValue? {
|
||||
private fun dispatchReceiverValue(candidate: FirCallableSymbol<*>): ReceiverValue? {
|
||||
val holderId = candidate.callableId.classId
|
||||
if (holderId != null && scope is FirExplicitSimpleImportingScope) {
|
||||
if (holderId != null && candidate.fir.origin == FirDeclarationOrigin.ImportedFromObject) {
|
||||
val symbol = session.firSymbolProvider.getClassLikeSymbolByFqName(holderId)
|
||||
if (symbol is FirRegularClassSymbol &&
|
||||
symbol.fir.classKind.let { it == ClassKind.OBJECT || it == ClassKind.ENUM_ENTRY }
|
||||
) {
|
||||
if (symbol is FirRegularClassSymbol) {
|
||||
val resolvedQualifier = buildResolvedQualifier {
|
||||
packageFqName = holderId.packageFqName
|
||||
relativeClassFqName = holderId.relativeClassName
|
||||
@@ -234,6 +231,23 @@ class ScopeTowerLevel(
|
||||
}
|
||||
}
|
||||
|
||||
private fun <T : AbstractFirBasedSymbol<*>> consumeCallableCandidate(
|
||||
candidate: FirCallableSymbol<*>,
|
||||
processor: TowerScopeLevel.TowerScopeLevelProcessor<T>
|
||||
) {
|
||||
if (candidate.hasConsistentReceivers(extensionReceiver)) {
|
||||
val dispatchReceiverValue = dispatchReceiverValue(candidate)
|
||||
val unwrappedCandidate = if (candidate.fir.origin == FirDeclarationOrigin.ImportedFromObject) {
|
||||
candidate.overriddenSymbol!!
|
||||
} else candidate
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
processor.consumeCandidate(
|
||||
unwrappedCandidate as T, dispatchReceiverValue,
|
||||
implicitExtensionReceiverValue = extensionReceiver as? ImplicitReceiverValue<*>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun <T : AbstractFirBasedSymbol<*>> processElementsByName(
|
||||
token: TowerScopeLevel.Token<T>,
|
||||
name: Name,
|
||||
@@ -244,13 +258,7 @@ class ScopeTowerLevel(
|
||||
when (token) {
|
||||
TowerScopeLevel.Token.Properties -> scope.processPropertiesByName(name) { candidate ->
|
||||
empty = false
|
||||
if (candidate.hasConsistentReceivers(extensionReceiver)) {
|
||||
val dispatchReceiverValue = dispatchReceiverValue(scope, candidate)
|
||||
processor.consumeCandidate(
|
||||
candidate as T, dispatchReceiverValue,
|
||||
implicitExtensionReceiverValue = extensionReceiver as? ImplicitReceiverValue<*>
|
||||
)
|
||||
}
|
||||
consumeCallableCandidate(candidate, processor)
|
||||
}
|
||||
TowerScopeLevel.Token.Functions -> scope.processFunctionsAndConstructorsByName(
|
||||
name,
|
||||
@@ -259,13 +267,7 @@ class ScopeTowerLevel(
|
||||
includeInnerConstructors = includeInnerConstructors
|
||||
) { candidate ->
|
||||
empty = false
|
||||
if (candidate.hasConsistentReceivers(extensionReceiver)) {
|
||||
val dispatchReceiverValue = dispatchReceiverValue(scope, candidate)
|
||||
processor.consumeCandidate(
|
||||
candidate as T, dispatchReceiverValue,
|
||||
implicitExtensionReceiverValue = extensionReceiver as? ImplicitReceiverValue<*>
|
||||
)
|
||||
}
|
||||
consumeCallableCandidate(candidate, processor)
|
||||
}
|
||||
TowerScopeLevel.Token.Objects -> scope.processClassifiersByName(name) {
|
||||
empty = false
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
package org.jetbrains.kotlin.fir.resolve.dfa
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.PrivateForInline
|
||||
import org.jetbrains.kotlin.fir.contracts.FirResolvedContractDescription
|
||||
import org.jetbrains.kotlin.fir.contracts.description.ConeBooleanConstantReference
|
||||
import org.jetbrains.kotlin.fir.contracts.description.ConeConditionalEffectDeclaration
|
||||
@@ -106,6 +107,9 @@ abstract class FirDataFlowAnalyzer<FLOW : Flow>(
|
||||
protected val any = components.session.builtinTypes.anyType.type
|
||||
private val nullableNothing = components.session.builtinTypes.nullableNothingType.type
|
||||
|
||||
@PrivateForInline
|
||||
var ignoreFunctionCalls: Boolean = false
|
||||
|
||||
// ----------------------------------- Requests -----------------------------------
|
||||
|
||||
fun getTypeUsingSmartcastInfo(qualifiedAccessExpression: FirQualifiedAccessExpression): MutableList<ConeKotlinType>? {
|
||||
@@ -133,6 +137,17 @@ abstract class FirDataFlowAnalyzer<FLOW : Flow>(
|
||||
graphBuilder.dropSubgraphFromCall(call)
|
||||
}
|
||||
|
||||
@OptIn(PrivateForInline::class)
|
||||
inline fun <T> withIgnoreFunctionCalls(block: () -> T): T {
|
||||
val oldValue = ignoreFunctionCalls
|
||||
ignoreFunctionCalls = true
|
||||
return try {
|
||||
block()
|
||||
} finally {
|
||||
ignoreFunctionCalls = oldValue
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------- Named function -----------------------------------
|
||||
|
||||
fun enterFunction(function: FirFunction<*>) {
|
||||
@@ -683,7 +698,12 @@ abstract class FirDataFlowAnalyzer<FLOW : Flow>(
|
||||
graphBuilder.enterCall()
|
||||
}
|
||||
|
||||
@OptIn(PrivateForInline::class)
|
||||
fun exitFunctionCall(functionCall: FirFunctionCall, callCompleted: Boolean) {
|
||||
if (ignoreFunctionCalls) {
|
||||
graphBuilder.exitIgnoredCall(functionCall)
|
||||
return
|
||||
}
|
||||
val (functionCallNode, unionNode) = graphBuilder.exitFunctionCall(functionCall, callCompleted)
|
||||
unionNode?.let { unionFlowFromArguments(it) }
|
||||
functionCallNode.mergeIncomingFlow()
|
||||
|
||||
@@ -93,6 +93,25 @@ class ControlFlowGraphBuilder {
|
||||
private val exitSafeCallNodes: Stack<ExitSafeCallNode> = stackOf()
|
||||
private val exitElvisExpressionNodes: Stack<ElvisExitNode> = stackOf()
|
||||
|
||||
/*
|
||||
* ignoredFunctionCalls is needed for resolve of += operator:
|
||||
* we have two different calls for resolve, but we left only one of them,
|
||||
* so we twice call `enterCall` and twice increase `levelCounter`, but
|
||||
* `exitFunctionCall` we call only once.
|
||||
*
|
||||
* So workflow looks like that:
|
||||
* Calls:
|
||||
* - a.plus(b) // (1)
|
||||
* - a.plusAssign(b) // (2)
|
||||
*
|
||||
* enterCall(a.plus(b)), increase counter
|
||||
* exitIgnoredCall(a.plus(b)) // decrease counter
|
||||
* enterCall(a.plusAssign(b)) // increase counter
|
||||
* exitIgnoredCall(a.plusAssign(b)) // decrease counter
|
||||
* exitFunctionCall(a.plus(b) | a.plusAssign(b)) // don't touch counter
|
||||
*/
|
||||
private val ignoredFunctionCalls: MutableSet<FirFunctionCall> = mutableSetOf()
|
||||
|
||||
// ----------------------------------- API for node builders -----------------------------------
|
||||
|
||||
private var idCounter: Int = Random.nextInt()
|
||||
@@ -818,8 +837,18 @@ class ControlFlowGraphBuilder {
|
||||
levelCounter++
|
||||
}
|
||||
|
||||
fun exitFunctionCall(functionCall: FirFunctionCall, callCompleted: Boolean): Pair<FunctionCallNode, UnionFunctionCallArgumentsNode?> {
|
||||
fun exitIgnoredCall(functionCall: FirFunctionCall) {
|
||||
levelCounter--
|
||||
ignoredFunctionCalls += functionCall
|
||||
}
|
||||
|
||||
fun exitFunctionCall(functionCall: FirFunctionCall, callCompleted: Boolean): Pair<FunctionCallNode, UnionFunctionCallArgumentsNode?> {
|
||||
val callWasIgnored = ignoredFunctionCalls.remove(functionCall)
|
||||
if (!callWasIgnored) {
|
||||
levelCounter--
|
||||
} else {
|
||||
ignoredFunctionCalls.clear()
|
||||
}
|
||||
val returnsNothing = functionCall.resultType.isNothing
|
||||
val node = createFunctionCallNode(functionCall)
|
||||
val (kind, unionNode) = processUnionOfArguments(node, callCompleted)
|
||||
|
||||
@@ -14,25 +14,7 @@ import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintStorage
|
||||
|
||||
abstract class FirInferenceSession {
|
||||
companion object {
|
||||
val DEFAULT: FirInferenceSession = object : FirInferenceSession() {
|
||||
override fun <T> shouldRunCompletion(call: T): Boolean where T : FirResolvable, T : FirStatement = true
|
||||
|
||||
override val currentConstraintSystem: ConstraintStorage
|
||||
get() = ConstraintStorage.Empty
|
||||
|
||||
override fun <T> addPartiallyResolvedCall(call: T) where T : FirResolvable, T : FirStatement {}
|
||||
override fun <T> addErrorCall(call: T) where T : FirResolvable, T : FirStatement {}
|
||||
override fun <T> addCompetedCall(call: T, candidate: Candidate) where T : FirResolvable, T : FirStatement {}
|
||||
|
||||
override fun inferPostponedVariables(
|
||||
lambda: ResolvedLambdaAtom,
|
||||
initialStorage: ConstraintStorage
|
||||
): Map<ConeTypeVariableTypeConstructor, ConeKotlinType>? = null
|
||||
|
||||
override fun <T> writeOnlyStubs(call: T): Boolean where T : FirResolvable, T : FirStatement = false
|
||||
override fun <T> callCompleted(call: T): Boolean where T : FirResolvable, T : FirStatement = false
|
||||
override fun <T> shouldCompleteResolvedSubAtomsOf(call: T): Boolean where T : FirResolvable, T : FirStatement = true
|
||||
}
|
||||
val DEFAULT: FirInferenceSession = object : FirStubInferenceSession() {}
|
||||
}
|
||||
|
||||
abstract fun <T> shouldRunCompletion(call: T): Boolean where T : FirResolvable, T : FirStatement
|
||||
@@ -51,4 +33,24 @@ abstract class FirInferenceSession {
|
||||
abstract fun <T> writeOnlyStubs(call: T): Boolean where T : FirResolvable, T : FirStatement
|
||||
abstract fun <T> callCompleted(call: T): Boolean where T : FirResolvable, T : FirStatement
|
||||
abstract fun <T> shouldCompleteResolvedSubAtomsOf(call: T): Boolean where T : FirResolvable, T : FirStatement
|
||||
}
|
||||
}
|
||||
|
||||
abstract class FirStubInferenceSession : FirInferenceSession() {
|
||||
override fun <T> shouldRunCompletion(call: T): Boolean where T : FirResolvable, T : FirStatement = true
|
||||
|
||||
override val currentConstraintSystem: ConstraintStorage
|
||||
get() = ConstraintStorage.Empty
|
||||
|
||||
override fun <T> addPartiallyResolvedCall(call: T) where T : FirResolvable, T : FirStatement {}
|
||||
override fun <T> addErrorCall(call: T) where T : FirResolvable, T : FirStatement {}
|
||||
override fun <T> addCompetedCall(call: T, candidate: Candidate) where T : FirResolvable, T : FirStatement {}
|
||||
|
||||
override fun inferPostponedVariables(
|
||||
lambda: ResolvedLambdaAtom,
|
||||
initialStorage: ConstraintStorage
|
||||
): Map<ConeTypeVariableTypeConstructor, ConeKotlinType>? = null
|
||||
|
||||
override fun <T> writeOnlyStubs(call: T): Boolean where T : FirResolvable, T : FirStatement = false
|
||||
override fun <T> callCompleted(call: T): Boolean where T : FirResolvable, T : FirStatement = false
|
||||
override fun <T> shouldCompleteResolvedSubAtomsOf(call: T): Boolean where T : FirResolvable, T : FirStatement = true
|
||||
}
|
||||
|
||||
@@ -22,10 +22,10 @@ import org.jetbrains.kotlin.fir.references.builder.buildExplicitSuperReference
|
||||
import org.jetbrains.kotlin.fir.references.builder.buildSimpleNamedReference
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirSimpleNamedReference
|
||||
import org.jetbrains.kotlin.fir.resolve.*
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.ImplicitDispatchReceiverValue
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.*
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.candidate
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.mapArguments
|
||||
import org.jetbrains.kotlin.fir.resolve.diagnostics.*
|
||||
import org.jetbrains.kotlin.fir.resolve.inference.FirStubInferenceSession
|
||||
import org.jetbrains.kotlin.fir.resolve.transformers.InvocationKindTransformer
|
||||
import org.jetbrains.kotlin.fir.resolve.transformers.StoreReceiver
|
||||
import org.jetbrains.kotlin.fir.resolve.transformers.firClassLike
|
||||
@@ -199,6 +199,7 @@ open class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransform
|
||||
storeTypeFromCallee(functionCall)
|
||||
}
|
||||
if (functionCall.calleeReference !is FirSimpleNamedReference) return functionCall.compose()
|
||||
if (functionCall.calleeReference is FirNamedReferenceWithCandidate) return functionCall.compose()
|
||||
dataFlowAnalyzer.enterCall()
|
||||
functionCall.annotations.forEach { it.accept(this, data) }
|
||||
functionCall.transform<FirFunctionCall, Nothing?>(InvocationKindTransformer, null)
|
||||
@@ -302,9 +303,10 @@ open class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransform
|
||||
require(operatorCall.operation != FirOperation.ASSIGN)
|
||||
|
||||
operatorCall.annotations.forEach { it.accept(this, data) }
|
||||
var (leftArgument, rightArgument) = operatorCall.arguments
|
||||
@Suppress("NAME_SHADOWING")
|
||||
operatorCall.argumentList.transformArguments(this, ResolutionMode.ContextIndependent)
|
||||
val (leftArgument, rightArgument) = operatorCall.arguments
|
||||
leftArgument = leftArgument.transformSingle(transformer, ResolutionMode.ContextIndependent)
|
||||
rightArgument = rightArgument.transformSingle(transformer, ResolutionMode.ContextDependent)
|
||||
|
||||
fun createFunctionCall(name: Name) = buildFunctionCall {
|
||||
source = operatorCall.source?.withKind(FirFakeSourceElementKind.DesugaredCompoundAssignment)
|
||||
@@ -317,24 +319,35 @@ open class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransform
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: disable DataFlowAnalyzer for resolving that two calls
|
||||
// x.plusAssign(y)
|
||||
val assignmentOperatorName = FirOperationNameConventions.ASSIGNMENTS.getValue(operatorCall.operation)
|
||||
val assignOperatorCall = createFunctionCall(assignmentOperatorName)
|
||||
val resolvedAssignCall = assignOperatorCall.transformSingle(this, ResolutionMode.ContextIndependent)
|
||||
val assignCallReference = resolvedAssignCall.toResolvedCallableReference()
|
||||
val assignIsError = resolvedAssignCall.typeRef is FirErrorTypeRef
|
||||
val resolvedAssignCall = resolveCandidateForAssignmentOperatorCall {
|
||||
assignOperatorCall.transformSingle(this, ResolutionMode.ContextDependent)
|
||||
}
|
||||
val assignCallReference = resolvedAssignCall.calleeReference as? FirNamedReferenceWithCandidate
|
||||
val assignIsError = assignCallReference?.isError ?: true
|
||||
// x = x + y
|
||||
val simpleOperatorName = FirOperationNameConventions.ASSIGNMENTS_TO_SIMPLE_OPERATOR.getValue(operatorCall.operation)
|
||||
val simpleOperatorCall = createFunctionCall(simpleOperatorName)
|
||||
val resolvedOperatorCall = simpleOperatorCall.transformSingle(this, ResolutionMode.ContextIndependent)
|
||||
val operatorCallReference = resolvedOperatorCall.toResolvedCallableReference()
|
||||
val resolvedOperatorCall = resolveCandidateForAssignmentOperatorCall {
|
||||
simpleOperatorCall.transformSingle(this, ResolutionMode.ContextDependent)
|
||||
}
|
||||
val operatorCallReference = resolvedOperatorCall.calleeReference as? FirNamedReferenceWithCandidate
|
||||
val operatorIsError = operatorCallReference?.isError ?: true
|
||||
|
||||
val lhsReference = leftArgument.toResolvedCallableReference()
|
||||
val lhsIsVar = (lhsReference?.resolvedSymbol as? FirVariableSymbol<*>)?.fir?.isVar == true
|
||||
val lhsVariable = (lhsReference?.resolvedSymbol as? FirVariableSymbol<*>)?.fir
|
||||
val lhsIsVar = lhsVariable?.isVar == true
|
||||
return when {
|
||||
operatorCallReference == null || (!lhsIsVar && !assignIsError) -> resolvedAssignCall.compose()
|
||||
assignCallReference == null -> {
|
||||
operatorIsError || (!lhsIsVar && !assignIsError) -> {
|
||||
callCompleter.completeCall(resolvedAssignCall, noExpectedType)
|
||||
dataFlowAnalyzer.exitFunctionCall(resolvedAssignCall, callCompleted = true)
|
||||
resolvedAssignCall.compose()
|
||||
}
|
||||
assignIsError -> {
|
||||
callCompleter.completeCall(resolvedOperatorCall, lhsVariable?.returnTypeRef ?: noExpectedType)
|
||||
dataFlowAnalyzer.exitFunctionCall(resolvedOperatorCall, callCompleted = true)
|
||||
val assignment =
|
||||
buildVariableAssignment {
|
||||
source = operatorCall.source
|
||||
@@ -353,17 +366,39 @@ open class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransform
|
||||
}
|
||||
assignment.transform(transformer, ResolutionMode.ContextIndependent)
|
||||
}
|
||||
else -> buildErrorExpression {
|
||||
source = operatorCall.source
|
||||
diagnostic =
|
||||
ConeOperatorAmbiguityError(listOf(operatorCallReference.resolvedSymbol, assignCallReference.resolvedSymbol))
|
||||
}.compose()
|
||||
else -> {
|
||||
val operatorCallSymbol = operatorCallReference?.candidateSymbol
|
||||
val assignmentCallSymbol = assignCallReference?.candidateSymbol
|
||||
|
||||
requireNotNull(operatorCallSymbol)
|
||||
requireNotNull(assignmentCallSymbol)
|
||||
|
||||
buildErrorExpression {
|
||||
source = operatorCall.source
|
||||
diagnostic =
|
||||
ConeOperatorAmbiguityError(listOf(operatorCallSymbol, assignmentCallSymbol))
|
||||
}.compose()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw IllegalArgumentException(operatorCall.render())
|
||||
}
|
||||
|
||||
private inline fun <T> resolveCandidateForAssignmentOperatorCall(block: () -> T): T {
|
||||
return dataFlowAnalyzer.withIgnoreFunctionCalls {
|
||||
callResolver.withNoArgumentsTransform {
|
||||
inferenceComponents.withInferenceSession(InferenceSessionForAssignmentOperatorCall) {
|
||||
block()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private object InferenceSessionForAssignmentOperatorCall : FirStubInferenceSession() {
|
||||
override fun <T> shouldRunCompletion(call: T): Boolean where T : FirStatement, T : FirResolvable = false
|
||||
}
|
||||
|
||||
private fun FirTypeRef.withTypeArgumentsForBareType(argument: FirExpression): FirTypeRef {
|
||||
// TODO: Everything should also work for case of checked-type itself is a type alias
|
||||
val baseTypeArguments =
|
||||
@@ -530,7 +565,13 @@ open class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransform
|
||||
}
|
||||
|
||||
override fun transformGetClassCall(getClassCall: FirGetClassCall, data: ResolutionMode): CompositeTransformResult<FirStatement> {
|
||||
val transformedGetClassCall = transformExpression(getClassCall, data).single as FirGetClassCall
|
||||
val arg = getClassCall.argument
|
||||
val dataWithExpectedType = if (arg is FirConstExpression<*>) {
|
||||
withExpectedType(arg.typeRef.resolvedTypeFromPrototype(arg.kind.expectedConeType()))
|
||||
} else {
|
||||
data
|
||||
}
|
||||
val transformedGetClassCall = transformExpression(getClassCall, dataWithExpectedType).single as FirGetClassCall
|
||||
|
||||
val typeOfExpression = when (val lhs = transformedGetClassCall.argument) {
|
||||
is FirResolvedQualifier -> {
|
||||
@@ -569,17 +610,12 @@ open class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransform
|
||||
return transformedGetClassCall.compose()
|
||||
}
|
||||
|
||||
override fun <T> transformConstExpression(
|
||||
constExpression: FirConstExpression<T>,
|
||||
data: ResolutionMode,
|
||||
): CompositeTransformResult<FirStatement> {
|
||||
constExpression.annotations.forEach { it.accept(this, data) }
|
||||
private fun FirConstKind<*>.expectedConeType(): ConeKotlinType {
|
||||
fun constructLiteralType(classId: ClassId, isNullable: Boolean = false): ConeKotlinType {
|
||||
val symbol = symbolProvider.getClassLikeSymbolByFqName(classId) ?: return ConeClassErrorType("Missing stdlib class: $classId")
|
||||
return symbol.toLookupTag().constructClassType(emptyArray(), isNullable)
|
||||
}
|
||||
|
||||
val type = when (val kind = constExpression.kind) {
|
||||
return when (this) {
|
||||
FirConstKind.Null -> session.builtinTypes.nullableNothingType.type
|
||||
FirConstKind.Boolean -> session.builtinTypes.booleanType.type
|
||||
FirConstKind.Char -> constructLiteralType(StandardClassIds.Char)
|
||||
@@ -591,6 +627,23 @@ open class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransform
|
||||
FirConstKind.Float -> constructLiteralType(StandardClassIds.Float)
|
||||
FirConstKind.Double -> constructLiteralType(StandardClassIds.Double)
|
||||
|
||||
FirConstKind.UnsignedByte -> constructLiteralType(StandardClassIds.UByte)
|
||||
FirConstKind.UnsignedShort -> constructLiteralType(StandardClassIds.UShort)
|
||||
FirConstKind.UnsignedInt -> constructLiteralType(StandardClassIds.UInt)
|
||||
FirConstKind.UnsignedLong -> constructLiteralType(StandardClassIds.ULong)
|
||||
|
||||
FirConstKind.IntegerLiteral -> constructLiteralType(StandardClassIds.Int)
|
||||
FirConstKind.UnsignedIntegerLiteral -> constructLiteralType(StandardClassIds.UInt)
|
||||
}
|
||||
}
|
||||
|
||||
override fun <T> transformConstExpression(
|
||||
constExpression: FirConstExpression<T>,
|
||||
data: ResolutionMode,
|
||||
): CompositeTransformResult<FirStatement> {
|
||||
constExpression.annotations.forEach { it.accept(this, data) }
|
||||
|
||||
val type = when (val kind = constExpression.kind) {
|
||||
FirConstKind.IntegerLiteral, FirConstKind.UnsignedIntegerLiteral -> {
|
||||
val integerLiteralType =
|
||||
ConeIntegerLiteralTypeImpl(constExpression.value as Long, isUnsigned = kind == FirConstKind.UnsignedIntegerLiteral)
|
||||
@@ -615,11 +668,7 @@ open class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransform
|
||||
integerLiteralType
|
||||
}
|
||||
}
|
||||
|
||||
FirConstKind.UnsignedByte -> constructLiteralType(StandardClassIds.UByte)
|
||||
FirConstKind.UnsignedShort -> constructLiteralType(StandardClassIds.UShort)
|
||||
FirConstKind.UnsignedInt -> constructLiteralType(StandardClassIds.UInt)
|
||||
FirConstKind.UnsignedLong -> constructLiteralType(StandardClassIds.ULong)
|
||||
else -> kind.expectedConeType()
|
||||
}
|
||||
|
||||
dataFlowAnalyzer.exitConstExpresion(constExpression as FirConstExpression<*>)
|
||||
|
||||
@@ -37,7 +37,7 @@ abstract class FirAbstractImportingScope(
|
||||
val firClass = (symbol as FirClassSymbol<*>).fir
|
||||
|
||||
return if (firClass.classKind == ClassKind.OBJECT)
|
||||
firClass.unsubstitutedScope(session, scopeSession)
|
||||
FirObjectImportedCallableScope(classId, firClass.unsubstitutedScope(session, scopeSession))
|
||||
else
|
||||
firClass.scopeProvider.getStaticScope(firClass, session, scopeSession)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.fir.scopes.impl
|
||||
|
||||
import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin
|
||||
import org.jetbrains.kotlin.fir.declarations.builder.buildProperty
|
||||
import org.jetbrains.kotlin.fir.declarations.builder.buildSimpleFunction
|
||||
import org.jetbrains.kotlin.fir.scopes.FirScope
|
||||
import org.jetbrains.kotlin.fir.symbols.CallableId
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
class FirObjectImportedCallableScope(
|
||||
private val importedClassId: ClassId,
|
||||
private val objectUseSiteScope: FirScope
|
||||
) : FirScope() {
|
||||
override fun processFunctionsByName(name: Name, processor: (FirFunctionSymbol<*>) -> Unit) {
|
||||
objectUseSiteScope.processFunctionsByName(name) wrapper@{ symbol ->
|
||||
if (symbol !is FirNamedFunctionSymbol) {
|
||||
processor(symbol)
|
||||
return@wrapper
|
||||
}
|
||||
val function = symbol.fir
|
||||
val syntheticFunction = buildSimpleFunction {
|
||||
source = function.source
|
||||
session = function.session
|
||||
origin = FirDeclarationOrigin.ImportedFromObject
|
||||
returnTypeRef = function.returnTypeRef
|
||||
receiverTypeRef = function.receiverTypeRef
|
||||
this.name = function.name
|
||||
status = function.status
|
||||
this.symbol = FirNamedFunctionSymbol(CallableId(importedClassId, name), overriddenSymbol = symbol)
|
||||
resolvePhase = function.resolvePhase
|
||||
typeParameters.addAll(function.typeParameters)
|
||||
valueParameters.addAll(function.valueParameters)
|
||||
annotations.addAll(function.annotations)
|
||||
}
|
||||
processor(syntheticFunction.symbol)
|
||||
}
|
||||
}
|
||||
|
||||
override fun processPropertiesByName(name: Name, processor: (FirVariableSymbol<*>) -> Unit) {
|
||||
objectUseSiteScope.processPropertiesByName(name) wrapper@{ symbol ->
|
||||
if (symbol !is FirPropertySymbol) {
|
||||
processor(symbol)
|
||||
return@wrapper
|
||||
}
|
||||
val property = symbol.fir
|
||||
val syntheticFunction = buildProperty {
|
||||
source = property.source
|
||||
session = property.session
|
||||
origin = FirDeclarationOrigin.ImportedFromObject
|
||||
returnTypeRef = property.returnTypeRef
|
||||
receiverTypeRef = property.receiverTypeRef
|
||||
this.name = property.name
|
||||
status = property.status
|
||||
isVar = property.isVar
|
||||
isLocal = property.isLocal
|
||||
this.symbol = FirPropertySymbol(CallableId(importedClassId, name), overriddenSymbol = symbol)
|
||||
resolvePhase = property.resolvePhase
|
||||
typeParameters.addAll(property.typeParameters)
|
||||
annotations.addAll(property.annotations)
|
||||
}
|
||||
processor(syntheticFunction.symbol)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -342,7 +342,6 @@ class FirRenderer(builder: StringBuilder, private val mode: RenderMode = RenderM
|
||||
}
|
||||
|
||||
override fun visitEnumEntry(enumEntry: FirEnumEntry) {
|
||||
enumEntry.annotations.renderAnnotations()
|
||||
visitCallableDeclaration(enumEntry)
|
||||
enumEntry.initializer?.let {
|
||||
print(" = ")
|
||||
|
||||
@@ -13,6 +13,7 @@ sealed class FirDeclarationOrigin {
|
||||
object SamConstructor : FirDeclarationOrigin()
|
||||
object FakeOverride : FirDeclarationOrigin()
|
||||
object Enhancement : FirDeclarationOrigin()
|
||||
object ImportedFromObject : FirDeclarationOrigin()
|
||||
|
||||
class Plugin(val key: FirPluginKey) : FirDeclarationOrigin()
|
||||
}
|
||||
|
||||
@@ -5,22 +5,15 @@
|
||||
|
||||
package org.jetbrains.kotlin.resolve.calls.inference
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor
|
||||
import org.jetbrains.kotlin.psi.KtDotQualifiedExpression
|
||||
import org.jetbrains.kotlin.psi.KtDoubleColonExpression
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
import org.jetbrains.kotlin.psi.KtReferenceExpression
|
||||
import org.jetbrains.kotlin.descriptors.impl.*
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.anyDescendantOfType
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
|
||||
import org.jetbrains.kotlin.psi.psiUtil.isAncestor
|
||||
import org.jetbrains.kotlin.resolve.BindingTrace
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.MissingSupertypesResolver
|
||||
import org.jetbrains.kotlin.resolve.TemporaryBindingTrace
|
||||
import org.jetbrains.kotlin.resolve.*
|
||||
import org.jetbrains.kotlin.resolve.calls.ArgumentTypeResolver
|
||||
import org.jetbrains.kotlin.resolve.calls.components.CompletedCallInfo
|
||||
import org.jetbrains.kotlin.resolve.calls.components.NewConstraintSystemImpl
|
||||
@@ -34,10 +27,7 @@ import org.jetbrains.kotlin.resolve.calls.model.*
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.*
|
||||
import org.jetbrains.kotlin.resolve.calls.util.FakeCallableDescriptorForObject
|
||||
import org.jetbrains.kotlin.resolve.deprecation.DeprecationResolver
|
||||
import org.jetbrains.kotlin.types.StubType
|
||||
import org.jetbrains.kotlin.types.TypeApproximator
|
||||
import org.jetbrains.kotlin.types.TypeConstructor
|
||||
import org.jetbrains.kotlin.types.UnwrappedType
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.expressions.DoubleColonExpressionResolver
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices
|
||||
import org.jetbrains.kotlin.types.typeUtil.contains
|
||||
@@ -64,6 +54,10 @@ class CoroutineInferenceSession(
|
||||
psiCallResolver, postponedArgumentsAnalyzer, kotlinConstraintSystemCompleter, callComponents, builtIns
|
||||
) {
|
||||
private val commonCalls = arrayListOf<PSICompletedCallInfo>()
|
||||
|
||||
// Simple calls are calls which might not have gone through type inference, but may contain unsubstituted postponed variables inside their types.
|
||||
private val simpleCommonCalls = arrayListOf<KtExpression>()
|
||||
|
||||
private val diagnostics = arrayListOf<KotlinCallDiagnostic>()
|
||||
private var hasInapplicableCall = false
|
||||
|
||||
@@ -85,6 +79,10 @@ class CoroutineInferenceSession(
|
||||
} || candidate.getSubResolvedAtoms().any { it.hasPostponed() }
|
||||
}
|
||||
|
||||
fun addSimpleCall(callExpression: KtExpression) {
|
||||
simpleCommonCalls.add(callExpression)
|
||||
}
|
||||
|
||||
override fun addCompletedCallInfo(callInfo: CompletedCallInfo) {
|
||||
require(callInfo is PSICompletedCallInfo) { "Wrong instance of callInfo: $callInfo" }
|
||||
|
||||
@@ -260,38 +258,43 @@ class CoroutineInferenceSession(
|
||||
return commonSystem to effectivelyEmptyCommonSystem
|
||||
}
|
||||
|
||||
private fun reportDiagnostics(completedCall: CallInfo, resolvedCall: ResolvedCall<*>, diagnostics: List<KotlinCallDiagnostic>) {
|
||||
kotlinToResolvedCallTransformer.reportCallDiagnostic(
|
||||
completedCall.context,
|
||||
trace,
|
||||
completedCall.callResolutionResult.resultCallAtom,
|
||||
resolvedCall.resultingDescriptor,
|
||||
diagnostics
|
||||
)
|
||||
}
|
||||
|
||||
private fun updateCalls(lambda: ResolvedLambdaAtom, commonSystem: NewConstraintSystemImpl) {
|
||||
val nonFixedToVariablesSubstitutor = createNonFixedTypeToVariableSubstitutor()
|
||||
val commonSystemSubstitutor = commonSystem.buildCurrentSubstitutor() as NewTypeSubstitutor
|
||||
|
||||
val nonFixedTypesToResult = nonFixedToVariablesSubstitutor.map.mapValues { commonSystemSubstitutor.safeSubstitute(it.value) }
|
||||
|
||||
val nonFixedTypesToResultSubstitutor = ComposedSubstitutor(commonSystemSubstitutor, nonFixedToVariablesSubstitutor)
|
||||
|
||||
val atomCompleter = createResolvedAtomCompleter(nonFixedTypesToResultSubstitutor, topLevelCallContext)
|
||||
|
||||
for (completedCall in commonCalls) {
|
||||
updateCall(completedCall, nonFixedTypesToResultSubstitutor, nonFixedTypesToResult)
|
||||
|
||||
kotlinToResolvedCallTransformer.reportCallDiagnostic(
|
||||
completedCall.context,
|
||||
trace,
|
||||
completedCall.callResolutionResult.resultCallAtom,
|
||||
completedCall.resolvedCall.resultingDescriptor,
|
||||
commonSystem.diagnostics
|
||||
)
|
||||
reportDiagnostics(completedCall, completedCall.resolvedCall, commonSystem.diagnostics)
|
||||
}
|
||||
|
||||
val lambdaAtomCompleter = createResolvedAtomCompleter(nonFixedTypesToResultSubstitutor, topLevelCallContext)
|
||||
for (callInfo in partiallyResolvedCallsInfo) {
|
||||
val resolvedCall = completeCall(callInfo, lambdaAtomCompleter) ?: continue
|
||||
kotlinToResolvedCallTransformer.reportCallDiagnostic(
|
||||
callInfo.context,
|
||||
trace,
|
||||
callInfo.callResolutionResult.resultCallAtom,
|
||||
resolvedCall.resultingDescriptor,
|
||||
commonSystem.diagnostics
|
||||
)
|
||||
val resolvedCall = completeCall(callInfo, atomCompleter) ?: continue
|
||||
reportDiagnostics(callInfo, resolvedCall, commonSystem.diagnostics)
|
||||
}
|
||||
lambdaAtomCompleter.completeAll(lambda)
|
||||
|
||||
for (simpleCall in simpleCommonCalls) {
|
||||
when (simpleCall) {
|
||||
is KtCallableReferenceExpression -> updateCallableReferenceType(simpleCall, nonFixedTypesToResultSubstitutor)
|
||||
else -> throw Exception("Unsupported call expression type")
|
||||
}
|
||||
}
|
||||
|
||||
atomCompleter.completeAll(lambda)
|
||||
}
|
||||
|
||||
private fun updateCall(
|
||||
@@ -313,6 +316,28 @@ class CoroutineInferenceSession(
|
||||
completeCall(completedCall, atomCompleter)
|
||||
}
|
||||
|
||||
private fun updateCallableReferenceType(expression: KtCallableReferenceExpression, substitutor: NewTypeSubstitutor) {
|
||||
val functionDescriptor = trace.get(BindingContext.DECLARATION_TO_DESCRIPTOR, expression) as? SimpleFunctionDescriptorImpl ?: return
|
||||
val returnType = functionDescriptor.returnType
|
||||
|
||||
fun KotlinType.substituteAndApproximate() = typeApproximator.approximateDeclarationType(
|
||||
substitutor.safeSubstitute(this.unwrap()),
|
||||
local = true,
|
||||
languageVersionSettings = topLevelCallContext.languageVersionSettings
|
||||
)
|
||||
|
||||
if (returnType != null && returnType.contains { it is StubType }) {
|
||||
functionDescriptor.setReturnType(returnType.substituteAndApproximate())
|
||||
}
|
||||
|
||||
for (valueParameter in functionDescriptor.valueParameters) {
|
||||
if (valueParameter !is ValueParameterDescriptorImpl || valueParameter.type !is StubType)
|
||||
continue
|
||||
|
||||
valueParameter.setOutType(valueParameter.type.substituteAndApproximate())
|
||||
}
|
||||
}
|
||||
|
||||
private fun completeCall(
|
||||
callInfo: CallInfo,
|
||||
atomCompleter: ResolvedAtomCompleter
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getCalleeExpressionIfAny
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.checkers.isBuiltInCoroutineContext
|
||||
import org.jetbrains.kotlin.resolve.calls.context.*
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.CoroutineInferenceSession
|
||||
import org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResults
|
||||
import org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResultsUtil
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo
|
||||
@@ -49,10 +50,7 @@ import org.jetbrains.kotlin.types.checker.KotlinTypeRefiner
|
||||
import org.jetbrains.kotlin.types.expressions.FunctionWithBigAritySupport.LanguageVersionDependent
|
||||
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.createTypeInfo
|
||||
import org.jetbrains.kotlin.types.refinement.TypeRefinement
|
||||
import org.jetbrains.kotlin.types.typeUtil.builtIns
|
||||
import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf
|
||||
import org.jetbrains.kotlin.types.typeUtil.makeNotNullable
|
||||
import org.jetbrains.kotlin.types.typeUtil.makeNullable
|
||||
import org.jetbrains.kotlin.types.typeUtil.*
|
||||
import org.jetbrains.kotlin.utils.yieldIfNotNull
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
@@ -558,6 +556,11 @@ class DoubleColonExpressionResolver(
|
||||
val (lhs, resolutionResults) = resolveCallableReference(expression, c, ResolveArgumentsMode.RESOLVE_FUNCTION_ARGUMENTS)
|
||||
val result = getCallableReferenceType(expression, lhs, resolutionResults, c)
|
||||
val dataFlowInfo = (lhs as? DoubleColonLHS.Expression)?.dataFlowInfo ?: c.dataFlowInfo
|
||||
|
||||
if (c.inferenceSession is CoroutineInferenceSession && result?.contains { it is StubType } == true) {
|
||||
c.inferenceSession.addSimpleCall(expression)
|
||||
}
|
||||
|
||||
return dataFlowAnalyzer.checkType(createTypeInfo(result, dataFlowInfo), expression, c)
|
||||
}
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@ import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||
import org.jetbrains.kotlin.ir.builders.Scope
|
||||
import org.jetbrains.kotlin.ir.builders.declarations.IrTypeParameterBuilder
|
||||
@@ -190,9 +190,13 @@ fun IrTypeParameter.copyToWithoutSuperTypes(
|
||||
|
||||
@OptIn(ObsoleteDescriptorBasedAPI::class)
|
||||
fun IrFunction.copyReceiverParametersFrom(from: IrFunction) {
|
||||
dispatchReceiverParameter = from.dispatchReceiverParameter?.let {
|
||||
IrValueParameterImpl(it.startOffset, it.endOffset, it.origin, it.descriptor, it.type, it.varargElementType).also {
|
||||
it.parent = this
|
||||
dispatchReceiverParameter = from.dispatchReceiverParameter?.run {
|
||||
IrValueParameterImpl(
|
||||
startOffset, endOffset, origin, IrValueParameterSymbolImpl(descriptor), descriptor.name,
|
||||
descriptor.indexOrMinusOne, type, varargElementType, descriptor.isCrossinline,
|
||||
descriptor.isNoinline
|
||||
).also { parameter ->
|
||||
parameter.parent = this@copyReceiverParametersFrom
|
||||
}
|
||||
}
|
||||
extensionReceiverParameter = from.extensionReceiverParameter?.copyTo(this)
|
||||
|
||||
@@ -21,11 +21,9 @@ import org.jetbrains.kotlin.ir.IrStatement
|
||||
import org.jetbrains.kotlin.ir.builders.*
|
||||
import org.jetbrains.kotlin.ir.builders.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||
import org.jetbrains.kotlin.ir.expressions.IrGetValue
|
||||
import org.jetbrains.kotlin.ir.expressions.IrTypeOperator
|
||||
import org.jetbrains.kotlin.ir.expressions.IrTypeOperatorCall
|
||||
import org.jetbrains.kotlin.ir.expressions.*
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrInstanceInitializerCallImpl
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.ir.types.classifierOrFail
|
||||
import org.jetbrains.kotlin.ir.types.isNullable
|
||||
@@ -58,9 +56,9 @@ abstract class SingleAbstractMethodLowering(val context: CommonBackendContext) :
|
||||
// Coming from the frontend, every SAM interface is associated with exactly one function type
|
||||
// (see SamType.getKotlinFunctionType). This is why we can cache implementations just based on
|
||||
// the superType.
|
||||
private val cachedImplementations = mutableMapOf<IrType, IrClass>()
|
||||
private val inlineCachedImplementations = mutableMapOf<IrType, IrClass>()
|
||||
private var enclosingContainer: IrDeclarationContainer? = null
|
||||
protected val cachedImplementations = mutableMapOf<IrType, IrClass>()
|
||||
protected val inlineCachedImplementations = mutableMapOf<IrType, IrClass>()
|
||||
protected var enclosingContainer: IrDeclarationContainer? = null
|
||||
|
||||
abstract fun getWrapperVisibility(expression: IrTypeOperatorCall, scopes: List<ScopeWithIr>): Visibility
|
||||
|
||||
@@ -81,6 +79,10 @@ abstract class SingleAbstractMethodLowering(val context: CommonBackendContext) :
|
||||
}
|
||||
}
|
||||
|
||||
protected open fun currentScopeSymbol(): IrSymbol? {
|
||||
return currentScope?.scope?.scopeOwnerSymbol
|
||||
}
|
||||
|
||||
override fun visitClassNew(declaration: IrClass): IrStatement {
|
||||
val prevContainer = enclosingContainer
|
||||
if (prevContainer == null || prevContainer is IrFile)
|
||||
@@ -99,7 +101,7 @@ abstract class SingleAbstractMethodLowering(val context: CommonBackendContext) :
|
||||
val erasedSuperType = getSuperTypeForWrapper(expression.typeOperand)
|
||||
val superType = if (expression.typeOperand.isNullable()) erasedSuperType.makeNullable() else erasedSuperType
|
||||
val invokable = expression.argument.transform(this, null)
|
||||
context.createIrBuilder(currentScope!!.scope.scopeOwnerSymbol).apply {
|
||||
context.createIrBuilder(currentScopeSymbol()!!).apply {
|
||||
// Do not generate a wrapper class for null, it has no invoke() anyway.
|
||||
if (invokable.isNullConst())
|
||||
return invokable
|
||||
|
||||
@@ -205,9 +205,6 @@ fun usefulDeclarations(roots: Iterable<IrDeclaration>, context: JsIrBackendConte
|
||||
while (queue.isNotEmpty()) {
|
||||
val declaration = queue.pollFirst()
|
||||
|
||||
// TODO remove?
|
||||
stageController.lazyLower(declaration)
|
||||
|
||||
fun IrDeclaration.enqueue(description: String, isContagious: Boolean = true) {
|
||||
enqueue(declaration, description, isContagious)
|
||||
}
|
||||
@@ -217,15 +214,6 @@ fun usefulDeclarations(roots: Iterable<IrDeclaration>, context: JsIrBackendConte
|
||||
(it.classifierOrNull as? IrClassSymbol)?.owner?.enqueue("superTypes")
|
||||
}
|
||||
|
||||
// TODO find out how `doResume` gets removed
|
||||
if (declaration.symbol == context.ir.symbols.coroutineImpl) {
|
||||
declaration.declarations.toList().forEach {
|
||||
if (it is IrSimpleFunction && it.name.asString() == "doResume") {
|
||||
it.enqueue("hack for CoroutineImpl::doResume")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
declaration.annotations.forEach {
|
||||
val annotationClass = it.symbol.owner.constructedClass
|
||||
if (annotationClass.isAssociatedObjectAnnotatedAnnotation) {
|
||||
@@ -254,9 +242,6 @@ fun usefulDeclarations(roots: Iterable<IrDeclaration>, context: JsIrBackendConte
|
||||
else -> null
|
||||
}
|
||||
|
||||
// TODO remove?
|
||||
(body as? IrBody)?.let { stageController.lazyLower(it) }
|
||||
|
||||
body?.acceptVoid(object : IrElementVisitorVoid {
|
||||
override fun visitElement(element: IrElement) {
|
||||
element.acceptChildrenVoid(this)
|
||||
@@ -401,11 +386,9 @@ fun usefulDeclarations(roots: Iterable<IrDeclaration>, context: JsIrBackendConte
|
||||
) {
|
||||
declaration.enqueue(klass, "annotated by @JsName")
|
||||
}
|
||||
}
|
||||
|
||||
// TODO is this needed?
|
||||
for (declaration in ArrayList(klass.declarations)) {
|
||||
// TODO this is a hack.
|
||||
// A hack to enforce property lowering.
|
||||
// Until a getter is accessed it doesn't get moved to the declaration list.
|
||||
if (declaration is IrProperty) {
|
||||
fun IrSimpleFunction.enqueue(description: String) {
|
||||
findOverriddenContagiousDeclaration()?.let { enqueue(it, description) }
|
||||
@@ -415,16 +398,6 @@ fun usefulDeclarations(roots: Iterable<IrDeclaration>, context: JsIrBackendConte
|
||||
declaration.setter?.enqueue("(setter) overrides useful declaration")
|
||||
}
|
||||
}
|
||||
|
||||
// TODO find out how `doResume` gets removed
|
||||
if (klass.symbol == context.ir.symbols.coroutineImpl) {
|
||||
ArrayList(klass.declarations).forEach {
|
||||
// TODO: fix the heck
|
||||
// if (it is IrSimpleFunction && it.name.asString() == "doResume") {
|
||||
it.enqueue(klass, "hack for CoroutineImpl::doResume")
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -521,11 +521,11 @@ private val bridgesConstructionPhase = makeDeclarationTransformerPhase(
|
||||
prerequisite = setOf(suspendFunctionsLoweringPhase)
|
||||
)
|
||||
|
||||
private val singleAbstractMethodPhase = makeJsModulePhase(
|
||||
private val singleAbstractMethodPhase = makeBodyLoweringPhase(
|
||||
::JsSingleAbstractMethodLowering,
|
||||
name = "SingleAbstractMethod",
|
||||
description = "Replace SAM conversions with instances of interface-implementing classes"
|
||||
).toModuleLowering()
|
||||
)
|
||||
|
||||
private val typeOperatorLoweringPhase = makeBodyLoweringPhase(
|
||||
::TypeOperatorLowering,
|
||||
|
||||
@@ -13,7 +13,7 @@ import org.jetbrains.kotlin.ir.declarations.impl.IrDeclarationBase
|
||||
import org.jetbrains.kotlin.ir.expressions.IrBody
|
||||
import org.jetbrains.kotlin.ir.util.isLocal
|
||||
|
||||
open class MutableController(val context: JsIrBackendContext, val lowerings: List<Lowering>) : StageController {
|
||||
open class MutableController(val context: JsIrBackendContext, val lowerings: List<Lowering>) : StageController() {
|
||||
|
||||
override var currentStage: Int = 0
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ fun compile(
|
||||
multiModule: Boolean = false,
|
||||
relativeRequirePath: Boolean = false
|
||||
): CompilerResult {
|
||||
stageController = object : StageController {}
|
||||
stageController = StageController()
|
||||
|
||||
val (moduleFragment: IrModuleFragment, dependencyModules, irBuiltIns, symbolTable, deserializer) =
|
||||
loadIr(project, mainModule, analyzer, configuration, allDependencies, friendDependencies)
|
||||
@@ -86,9 +86,7 @@ fun compile(
|
||||
eliminateDeadDeclarations(allModules, context)
|
||||
|
||||
// TODO investigate whether this is needed anymore
|
||||
stageController = object : StageController {
|
||||
override val currentStage: Int = controller.currentStage
|
||||
}
|
||||
stageController = StageController(controller.currentStage)
|
||||
|
||||
val transformer = IrModuleToJsTransformer(
|
||||
context,
|
||||
|
||||
@@ -9,10 +9,7 @@ import org.jetbrains.kotlin.backend.common.CommonBackendContext
|
||||
import org.jetbrains.kotlin.backend.common.DeclarationTransformer
|
||||
import org.jetbrains.kotlin.backend.common.bridges.FunctionHandle
|
||||
import org.jetbrains.kotlin.backend.common.bridges.generateBridges
|
||||
import org.jetbrains.kotlin.backend.common.ir.copyTo
|
||||
import org.jetbrains.kotlin.backend.common.ir.copyTypeParametersFrom
|
||||
import org.jetbrains.kotlin.backend.common.ir.isMethodOfAny
|
||||
import org.jetbrains.kotlin.backend.common.ir.isSuspend
|
||||
import org.jetbrains.kotlin.backend.common.ir.*
|
||||
import org.jetbrains.kotlin.backend.common.lower.*
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||
@@ -23,7 +20,6 @@ import org.jetbrains.kotlin.ir.backend.js.utils.functionSignature
|
||||
import org.jetbrains.kotlin.ir.backend.js.utils.getJsName
|
||||
import org.jetbrains.kotlin.ir.builders.*
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrBlockBodyImpl
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
@@ -138,11 +134,7 @@ class BridgesConstruction(val context: CommonBackendContext) : DeclarationTransf
|
||||
origin = origin
|
||||
).apply {
|
||||
copyTypeParametersFrom(bridge)
|
||||
// TODO: should dispatch receiver be copied?
|
||||
dispatchReceiverParameter = bridge.dispatchReceiverParameter?.run {
|
||||
IrValueParameterImpl(startOffset, endOffset, origin, descriptor, type, varargElementType).also { it.parent = this@apply }
|
||||
}
|
||||
extensionReceiverParameter = bridge.extensionReceiverParameter?.copyTo(this)
|
||||
copyReceiverParametersFrom(bridge)
|
||||
valueParameters += bridge.valueParameters.map { p -> p.copyTo(this) }
|
||||
annotations += bridge.annotations
|
||||
overriddenSymbols += delegateTo.overriddenSymbols
|
||||
|
||||
@@ -5,22 +5,55 @@
|
||||
|
||||
package org.jetbrains.kotlin.ir.backend.js.lower
|
||||
|
||||
import org.jetbrains.kotlin.backend.common.ScopeWithIr
|
||||
import org.jetbrains.kotlin.backend.common.BodyLoweringPass
|
||||
import org.jetbrains.kotlin.backend.common.lower.SingleAbstractMethodLowering
|
||||
import org.jetbrains.kotlin.backend.common.ScopeWithIr
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.ir.backend.js.JsIrBackendContext
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.expressions.IrBody
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||
import org.jetbrains.kotlin.ir.expressions.IrTypeOperatorCall
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.ir.types.classOrNull
|
||||
import org.jetbrains.kotlin.ir.types.defaultType
|
||||
import org.jetbrains.kotlin.ir.util.file
|
||||
import org.jetbrains.kotlin.ir.util.parentClassOrNull
|
||||
import org.jetbrains.kotlin.ir.util.render
|
||||
|
||||
class JsSingleAbstractMethodLowering(context: JsIrBackendContext) : SingleAbstractMethodLowering(context) {
|
||||
class JsSingleAbstractMethodLowering(context: JsIrBackendContext) : SingleAbstractMethodLowering(context), BodyLoweringPass {
|
||||
|
||||
override fun getWrapperVisibility(expression: IrTypeOperatorCall, scopes: List<ScopeWithIr>): Visibility {
|
||||
return Visibilities.PRIVATE
|
||||
}
|
||||
|
||||
private var enclosingBodyContainer: IrDeclaration? = null
|
||||
|
||||
override fun lower(irFile: IrFile) {
|
||||
super<SingleAbstractMethodLowering>.lower(irFile)
|
||||
}
|
||||
|
||||
override fun lower(irBody: IrBody, container: IrDeclaration) {
|
||||
cachedImplementations.clear()
|
||||
inlineCachedImplementations.clear()
|
||||
enclosingContainer = container.parentClassOrNull ?: container.file
|
||||
enclosingBodyContainer = container
|
||||
|
||||
irBody.transformChildrenVoid()
|
||||
|
||||
for (wrapper in cachedImplementations.values + inlineCachedImplementations.values) {
|
||||
val parentClass = wrapper.parent as IrDeclarationContainer
|
||||
stageController.unrestrictDeclarationListsAccess {
|
||||
parentClass.declarations += wrapper
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun currentScopeSymbol(): IrSymbol? {
|
||||
return super.currentScopeSymbol() ?: (enclosingBodyContainer as? IrSymbolOwner)?.symbol
|
||||
}
|
||||
|
||||
override fun getSuperTypeForWrapper(typeOperand: IrType): IrType {
|
||||
// FE doesn't allow type parameters for now.
|
||||
// And since there is a to-do in common SingleAbstractMethodLowering (at function visitTypeOperator),
|
||||
|
||||
@@ -59,7 +59,10 @@ abstract class AbstractSuspendFunctionsLowering<C : CommonBackendContext>(val co
|
||||
|
||||
protected abstract fun IrBlockBodyBuilder.generateCoroutineStart(invokeSuspendFunction: IrFunction, receiver: IrExpression)
|
||||
|
||||
protected abstract fun initializeStateMachine(coroutineConstructors: List<IrConstructor>, coroutineClassThis: IrValueDeclaration)
|
||||
protected fun initializeStateMachine(coroutineConstructors: List<IrConstructor>, coroutineClassThis: IrValueDeclaration) {
|
||||
// Do nothing by default
|
||||
// TODO find out if Kotlin/Native needs this method.
|
||||
}
|
||||
|
||||
protected open fun IrBuilderWithScope.generateDelegatedCall(expectedType: IrType, delegatingCall: IrExpression): IrExpression =
|
||||
delegatingCall
|
||||
@@ -470,7 +473,7 @@ abstract class AbstractSuspendFunctionsLowering<C : CommonBackendContext>(val co
|
||||
|
||||
coroutineClass.addFakeOverridesViaIncorrectHeuristic(implementedMembers)
|
||||
|
||||
// TODO: to meet PIR lower model constructor modification shouldn't be performed here
|
||||
// TODO: find out whether Kotlin/Native needs this call
|
||||
initializeStateMachine(listOf(coroutineConstructor), coroutineClassThis)
|
||||
|
||||
return BuiltCoroutine(
|
||||
|
||||
@@ -18,7 +18,6 @@ import org.jetbrains.kotlin.ir.expressions.impl.*
|
||||
import org.jetbrains.kotlin.ir.symbols.*
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.ir.util.explicitParameters
|
||||
import org.jetbrains.kotlin.ir.util.patchDeclarationParents
|
||||
import org.jetbrains.kotlin.ir.visitors.*
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.utils.DFS
|
||||
@@ -35,7 +34,6 @@ class JsSuspendFunctionsLowering(ctx: JsIrBackendContext) : AbstractSuspendFunct
|
||||
private val coroutineImplResultSymbolGetter = ctx.coroutineImplResultSymbolGetter
|
||||
private val coroutineImplResultSymbolSetter = ctx.coroutineImplResultSymbolSetter
|
||||
|
||||
private var exceptionTrapId = -1
|
||||
private var coroutineId = 0
|
||||
|
||||
override val stateMachineMethodName = Name.identifier("doResume")
|
||||
@@ -124,7 +122,17 @@ class JsSuspendFunctionsLowering(ctx: JsIrBackendContext) : AbstractSuspendFunct
|
||||
|
||||
assignStateIds(stateMachineBuilder.entryState, stateVar.symbol, switch, rootLoop)
|
||||
|
||||
exceptionTrapId = stateMachineBuilder.rootExceptionTrap.id
|
||||
// Set exceptionState to the global catch block
|
||||
stateMachineBuilder.entryState.entryBlock.run {
|
||||
val receiver = JsIrBuilder.buildGetValue(coroutineClass.thisReceiver!!.symbol)
|
||||
val exceptionTrapId = stateMachineBuilder.rootExceptionTrap.id
|
||||
assert(exceptionTrapId >= 0)
|
||||
val id = JsIrBuilder.buildInt(context.irBuiltIns.intType, exceptionTrapId)
|
||||
statements.add(0, JsIrBuilder.buildCall(coroutineImplExceptionStatePropertySetter.symbol).also { call ->
|
||||
call.dispatchReceiver = receiver
|
||||
call.putValueArgument(0, id)
|
||||
})
|
||||
}
|
||||
|
||||
val functionBody =
|
||||
IrBlockBodyImpl(stateMachineFunction.startOffset, stateMachineFunction.endOffset, listOf(suspendResult, rootLoop))
|
||||
@@ -210,20 +218,6 @@ class JsSuspendFunctionsLowering(ctx: JsIrBackendContext) : AbstractSuspendFunct
|
||||
return result
|
||||
}
|
||||
|
||||
override fun initializeStateMachine(coroutineConstructors: List<IrConstructor>, coroutineClassThis: IrValueDeclaration) {
|
||||
for (it in coroutineConstructors) {
|
||||
(it.body as? IrBlockBody)?.run {
|
||||
val receiver = JsIrBuilder.buildGetValue(coroutineClassThis.symbol)
|
||||
assert(exceptionTrapId >= 0)
|
||||
val id = JsIrBuilder.buildInt(context.irBuiltIns.intType, exceptionTrapId)
|
||||
statements += JsIrBuilder.buildCall(coroutineImplExceptionStatePropertySetter.symbol).also { call ->
|
||||
call.dispatchReceiver = receiver
|
||||
call.putValueArgument(0, id)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun IrBuilderWithScope.generateDelegatedCall(expectedType: IrType, delegatingCall: IrExpression): IrExpression {
|
||||
val fromType = (delegatingCall as? IrCall)?.symbol?.owner?.returnType ?: delegatingCall.type
|
||||
if (!needUnboxingOrUnit(fromType, expectedType)) return delegatingCall
|
||||
|
||||
@@ -45,7 +45,9 @@ class JsGenerationContext(
|
||||
|
||||
private fun isCoroutineDoResume(): Boolean {
|
||||
val overriddenSymbols = (currentFunction as? IrSimpleFunction)?.overriddenSymbols ?: return false
|
||||
return staticContext.doResumeFunctionSymbol in overriddenSymbols
|
||||
return overriddenSymbols.any {
|
||||
it.owner.name.asString() == "doResume" && it.owner.parent == staticContext.coroutineImplDeclaration
|
||||
}
|
||||
}
|
||||
|
||||
fun checkIfJsCode(symbol: IrFunctionSymbol): Boolean = symbol == staticContext.backendContext.intrinsics.jsCode
|
||||
|
||||
@@ -21,8 +21,6 @@ class JsStaticContext(
|
||||
val intrinsics = JsIntrinsicTransformers(backendContext)
|
||||
val classModels = mutableMapOf<IrClassSymbol, JsIrClassModel>()
|
||||
val coroutineImplDeclaration = backendContext.ir.symbols.coroutineImpl.owner
|
||||
val doResumeFunctionSymbol = coroutineImplDeclaration.declarations
|
||||
.filterIsInstance<IrSimpleFunction>().single { it.name.asString() == "doResume" }.symbol
|
||||
|
||||
val initializerBlock = JsGlobalBlock()
|
||||
}
|
||||
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.ir.expressions.impl.*
|
||||
import org.jetbrains.kotlin.ir.expressions.mapValueParameters
|
||||
import org.jetbrains.kotlin.ir.expressions.putTypeArguments
|
||||
import org.jetbrains.kotlin.ir.expressions.typeParametersCount
|
||||
import org.jetbrains.kotlin.ir.util.createIrClassFromDescriptor
|
||||
import org.jetbrains.kotlin.ir.util.declareSimpleFunctionWithOverrides
|
||||
import org.jetbrains.kotlin.ir.util.properties
|
||||
import org.jetbrains.kotlin.ir.util.referenceFunction
|
||||
@@ -84,12 +85,12 @@ class ClassGenerator(
|
||||
val modality = getEffectiveModality(ktClassOrObject, classDescriptor)
|
||||
|
||||
return context.symbolTable.declareClass(classDescriptor) {
|
||||
IrClassImpl(
|
||||
startOffset, endOffset, IrDeclarationOrigin.DEFINED, it,
|
||||
classDescriptor,
|
||||
context.symbolTable.nameProvider.nameForDeclaration(classDescriptor),
|
||||
visibility = visibility, modality = modality,
|
||||
).apply { metadata = MetadataSource.Class(it.descriptor) }
|
||||
createIrClassFromDescriptor(
|
||||
startOffset, endOffset, IrDeclarationOrigin.DEFINED, it, classDescriptor,
|
||||
context.symbolTable.nameProvider.nameForDeclaration(classDescriptor), visibility, modality
|
||||
).apply {
|
||||
(this as IrClassImpl).metadata = MetadataSource.Class(it.descriptor)
|
||||
}
|
||||
}.buildWithScope { irClass ->
|
||||
declarationGenerator.generateGlobalTypeParametersDeclarations(irClass, classDescriptor.declaredTypeParameters)
|
||||
|
||||
|
||||
@@ -16,7 +16,10 @@
|
||||
|
||||
package org.jetbrains.kotlin.psi2ir.generators
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrErrorDeclarationImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrTypeAliasImpl
|
||||
@@ -79,20 +82,17 @@ class DeclarationGenerator(override val context: GeneratorContext) : Generator {
|
||||
fun generateClassOrObjectDeclaration(ktClassOrObject: KtPureClassOrObject): IrClass =
|
||||
ClassGenerator(this).generateClass(ktClassOrObject)
|
||||
|
||||
private fun generateTypeAliasDeclaration(ktTypeAlias: KtTypeAlias): IrTypeAlias {
|
||||
val typeAliasDescriptor = getOrFail(BindingContext.TYPE_ALIAS, ktTypeAlias)
|
||||
val irTypeAlias = context.symbolTable.declareTypeAlias(typeAliasDescriptor) { symbol ->
|
||||
IrTypeAliasImpl.fromSymbolDescriptor(
|
||||
ktTypeAlias.startOffsetSkippingComments, ktTypeAlias.endOffset,
|
||||
symbol,
|
||||
typeAliasDescriptor.expandedType.toIrType(),
|
||||
IrDeclarationOrigin.DEFINED,
|
||||
typeAliasDescriptor
|
||||
)
|
||||
private fun generateTypeAliasDeclaration(ktTypeAlias: KtTypeAlias): IrTypeAlias =
|
||||
with(getOrFail(BindingContext.TYPE_ALIAS, ktTypeAlias)) {
|
||||
context.symbolTable.declareTypeAlias(this) { symbol ->
|
||||
IrTypeAliasImpl(
|
||||
ktTypeAlias.startOffsetSkippingComments, ktTypeAlias.endOffset, symbol,
|
||||
name, visibility, expandedType.toIrType(), isActual, IrDeclarationOrigin.DEFINED
|
||||
)
|
||||
}.also {
|
||||
generateGlobalTypeParametersDeclarations(it, declaredTypeParameters)
|
||||
}
|
||||
}
|
||||
generateGlobalTypeParametersDeclarations(irTypeAlias, typeAliasDescriptor.declaredTypeParameters)
|
||||
return irTypeAlias
|
||||
}
|
||||
|
||||
fun generateGlobalTypeParametersDeclarations(
|
||||
irTypeParametersOwner: IrTypeParametersContainer,
|
||||
|
||||
@@ -133,7 +133,10 @@ class DelegatedPropertyGenerator(declarationGenerator: DeclarationGenerator) : D
|
||||
context.symbolTable.declareField(
|
||||
startOffset, endOffset, origin, delegateDescriptor, type
|
||||
) {
|
||||
IrFieldImpl(startOffset, endOffset, origin, delegateDescriptor, type, symbol = it).apply {
|
||||
IrFieldImpl(
|
||||
startOffset, endOffset, origin, it, delegateDescriptor.name, type, delegateDescriptor.visibility,
|
||||
!delegateDescriptor.isVar, false, delegateDescriptor.dispatchReceiverParameter == null
|
||||
).apply {
|
||||
metadata = MetadataSource.Property(propertyDescriptor)
|
||||
}
|
||||
}.also { irDelegate ->
|
||||
|
||||
@@ -251,15 +251,13 @@ class FunctionGenerator(declarationGenerator: DeclarationGenerator) : Declaratio
|
||||
val startOffset = ktConstructorElement.getStartOffsetOfConstructorDeclarationKeywordOrNull() ?: ktConstructorElement.pureStartOffset
|
||||
val endOffset = ktConstructorElement.pureEndOffset
|
||||
val origin = IrDeclarationOrigin.DEFINED
|
||||
return context.symbolTable.declareConstructor(
|
||||
constructorDescriptor
|
||||
) {
|
||||
IrConstructorImpl(
|
||||
startOffset, endOffset, origin, it,
|
||||
returnType = IrUninitializedType,
|
||||
descriptor = constructorDescriptor,
|
||||
name = context.symbolTable.nameProvider.nameForDeclaration(constructorDescriptor),
|
||||
).apply {
|
||||
return context.symbolTable.declareConstructor(constructorDescriptor) {
|
||||
with(constructorDescriptor) {
|
||||
IrConstructorImpl(
|
||||
startOffset, endOffset, origin, it, context.symbolTable.nameProvider.nameForDeclaration(this),
|
||||
visibility, IrUninitializedType, isInline, isEffectivelyExternal(), isPrimary, isExpect
|
||||
)
|
||||
}.apply {
|
||||
metadata = MetadataSource.Function(it.descriptor)
|
||||
}
|
||||
}.buildWithScope { irConstructor ->
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.jetbrains.kotlin.ir.declarations.impl.*
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
|
||||
import org.jetbrains.kotlin.ir.symbols.*
|
||||
import org.jetbrains.kotlin.ir.types.impl.IrUninitializedType
|
||||
import org.jetbrains.kotlin.ir.util.createIrClassFromDescriptor
|
||||
import org.jetbrains.kotlin.ir.util.withScope
|
||||
import org.jetbrains.kotlin.psi.KtParameter
|
||||
import org.jetbrains.kotlin.psi.KtPureElement
|
||||
@@ -75,11 +76,10 @@ class StandaloneDeclarationGenerator(private val context: GeneratorContext) {
|
||||
}
|
||||
|
||||
fun generateClass(startOffset: Int, endOffset: Int, origin: IrDeclarationOrigin, descriptor: ClassDescriptor, symbol: IrClassSymbol): IrClass {
|
||||
|
||||
val irClass = IrClassImpl(startOffset, endOffset, origin, symbol, descriptor)
|
||||
val irClass = createIrClassFromDescriptor(startOffset, endOffset, origin, symbol, descriptor)
|
||||
|
||||
symbolTable.withScope(irClass) {
|
||||
irClass.metadata = MetadataSource.Class(descriptor)
|
||||
(irClass as IrClassImpl).metadata = MetadataSource.Class(descriptor)
|
||||
|
||||
generateGlobalTypeParametersDeclarations(irClass, descriptor.declaredTypeParameters)
|
||||
irClass.superTypes = descriptor.typeConstructor.supertypes.map {
|
||||
@@ -110,14 +110,10 @@ class StandaloneDeclarationGenerator(private val context: GeneratorContext) {
|
||||
origin: IrDeclarationOrigin,
|
||||
descriptor: TypeAliasDescriptor,
|
||||
symbol: IrTypeAliasSymbol
|
||||
): IrTypeAlias {
|
||||
val irAlias = IrTypeAliasImpl.fromSymbolDescriptor(
|
||||
startOffset, endOffset, symbol, descriptor.expandedType.toIrType(), origin, descriptor
|
||||
)
|
||||
|
||||
generateGlobalTypeParametersDeclarations(irAlias, descriptor.declaredTypeParameters)
|
||||
|
||||
return irAlias
|
||||
): IrTypeAlias = with(descriptor) {
|
||||
IrTypeAliasImpl(startOffset, endOffset, symbol, name, visibility, expandedType.toIrType(), isActual, origin).also {
|
||||
generateGlobalTypeParametersDeclarations(it, declaredTypeParameters)
|
||||
}
|
||||
}
|
||||
|
||||
protected fun declareParameter(descriptor: ParameterDescriptor, ktElement: KtPureElement?, irOwnerElement: IrElement): IrValueParameter {
|
||||
@@ -133,7 +129,7 @@ class StandaloneDeclarationGenerator(private val context: GeneratorContext) {
|
||||
protected fun generateValueParameterDeclarations(
|
||||
irFunction: IrFunction,
|
||||
functionDescriptor: FunctionDescriptor,
|
||||
defaultArgumentFactory: IrFunction.(ValueParameterDescriptor) -> IrExpressionBody?
|
||||
defaultArgumentFactory: IrFunction.(IrValueParameter) -> IrExpressionBody?
|
||||
) {
|
||||
|
||||
// TODO: KtElements
|
||||
@@ -150,16 +146,21 @@ class StandaloneDeclarationGenerator(private val context: GeneratorContext) {
|
||||
irFunction.valueParameters = functionDescriptor.valueParameters.map { valueParameterDescriptor ->
|
||||
val ktParameter = DescriptorToSourceUtils.getSourceFromDescriptor(valueParameterDescriptor) as? KtParameter
|
||||
declareParameter(valueParameterDescriptor, ktParameter, irFunction).also {
|
||||
it.defaultValue = irFunction.defaultArgumentFactory(valueParameterDescriptor)
|
||||
it.defaultValue = irFunction.defaultArgumentFactory(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun generateConstructor(
|
||||
startOffset: Int, endOffset: Int, origin: IrDeclarationOrigin, descriptor: ClassConstructorDescriptor, symbol: IrConstructorSymbol,
|
||||
defaultArgumentFactory: IrFunction.(ValueParameterDescriptor) -> IrExpressionBody? = { null }
|
||||
defaultArgumentFactory: IrFunction.(IrValueParameter) -> IrExpressionBody? = { null }
|
||||
): IrConstructor {
|
||||
val irConstructor = IrConstructorImpl(startOffset, endOffset, origin, symbol, IrUninitializedType, descriptor)
|
||||
val irConstructor = with(descriptor) {
|
||||
IrConstructorImpl(
|
||||
startOffset, endOffset, origin, symbol, name, visibility, IrUninitializedType, isInline,
|
||||
isEffectivelyExternal(), isPrimary, isExpect
|
||||
)
|
||||
}
|
||||
irConstructor.metadata = MetadataSource.Function(descriptor)
|
||||
|
||||
symbolTable.withScope(irConstructor) {
|
||||
@@ -178,9 +179,14 @@ class StandaloneDeclarationGenerator(private val context: GeneratorContext) {
|
||||
|
||||
fun generateSimpleFunction(
|
||||
startOffset: Int, endOffset: Int, origin: IrDeclarationOrigin, descriptor: FunctionDescriptor, symbol: IrSimpleFunctionSymbol,
|
||||
defaultArgumentFactory: IrFunction.(ValueParameterDescriptor) -> IrExpressionBody? = { null }
|
||||
defaultArgumentFactory: IrFunction.(IrValueParameter) -> IrExpressionBody? = { null }
|
||||
): IrSimpleFunction {
|
||||
val irFunction = IrFunctionImpl(startOffset, endOffset, origin, symbol, IrUninitializedType, descriptor)
|
||||
val irFunction = with(descriptor) {
|
||||
IrFunctionImpl(
|
||||
startOffset, endOffset, origin, symbol, name, visibility, modality, IrUninitializedType,
|
||||
isInline, isExternal, isTailrec, isSuspend, isOperator, isExpect
|
||||
)
|
||||
}
|
||||
irFunction.metadata = MetadataSource.Function(descriptor)
|
||||
|
||||
symbolTable.withScope(descriptor) {
|
||||
@@ -211,4 +217,4 @@ class StandaloneDeclarationGenerator(private val context: GeneratorContext) {
|
||||
|
||||
return irProperty
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,16 +31,15 @@ class SyntheticDeclarationsGenerator(context: GeneratorContext) : DeclarationDes
|
||||
return this
|
||||
}
|
||||
|
||||
private val errorType = IrErrorTypeImpl(null, emptyList(), Variance.INVARIANT)
|
||||
|
||||
private fun IrFunction.defaultArgumentFactory(descriptor: ValueParameterDescriptor): IrExpressionBody? {
|
||||
private fun IrFunction.defaultArgumentFactory(parameter: IrValueParameter): IrExpressionBody? {
|
||||
val descriptor = parameter.descriptor as ValueParameterDescriptor
|
||||
if (!descriptor.declaresDefaultValue()) return null
|
||||
|
||||
val description = "Default Argument Value stub for ${descriptor.name}|${descriptor.index}"
|
||||
return IrExpressionBodyImpl(IrErrorExpressionImpl(startOffset, endOffset, errorType, description))
|
||||
return IrExpressionBodyImpl(IrErrorExpressionImpl(startOffset, endOffset, parameter.type, description))
|
||||
}
|
||||
|
||||
private val defaultFactoryReference: IrFunction.(ValueParameterDescriptor) -> IrExpressionBody? = { defaultArgumentFactory(it) }
|
||||
private val defaultFactoryReference: IrFunction.(IrValueParameter) -> IrExpressionBody? = { defaultArgumentFactory(it) }
|
||||
|
||||
override fun visitPackageFragmentDescriptor(descriptor: PackageFragmentDescriptor, data: IrDeclarationContainer?) {
|
||||
error("Unexpected declaration descriptor $descriptor")
|
||||
|
||||
@@ -39,6 +39,7 @@ import org.jetbrains.kotlin.ir.types.impl.originalKotlinType
|
||||
import org.jetbrains.kotlin.ir.util.SymbolTable
|
||||
import org.jetbrains.kotlin.ir.util.TypeTranslator
|
||||
import org.jetbrains.kotlin.ir.util.coerceToUnit
|
||||
import org.jetbrains.kotlin.ir.util.render
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementTransformerVoid
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid
|
||||
import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid
|
||||
@@ -341,7 +342,7 @@ internal class InsertImplicitCasts(
|
||||
|
||||
val notNullableExpectedType = expectedType.makeNotNullable()
|
||||
|
||||
val valueType = this.type.originalKotlinType!!
|
||||
val valueType = this.type.originalKotlinType ?: error("Expecting original kotlin type for IrType ${type.render()}")
|
||||
|
||||
return when {
|
||||
expectedType.isUnit() ->
|
||||
|
||||
@@ -81,13 +81,10 @@ class Scope(val scopeOwnerSymbol: IrSymbol) {
|
||||
endOffset: Int = UNDEFINED_OFFSET
|
||||
): IrVariable {
|
||||
val originalKotlinType = type ?: irType.toKotlinType()
|
||||
val descriptor = createDescriptorForTemporaryVariable(originalKotlinType, nameHint, isMutable)
|
||||
return IrVariableImpl(
|
||||
startOffset, endOffset, origin,
|
||||
createDescriptorForTemporaryVariable(
|
||||
originalKotlinType,
|
||||
nameHint, isMutable
|
||||
),
|
||||
irType
|
||||
startOffset, endOffset, origin, IrVariableSymbolImpl(descriptor), descriptor.name,
|
||||
irType, isMutable, isConst = false, isLateinit = false
|
||||
).apply {
|
||||
parent = getLocalDeclarationParent()
|
||||
}
|
||||
|
||||
@@ -10,31 +10,29 @@ import org.jetbrains.kotlin.ir.expressions.IrBody
|
||||
|
||||
// TODO threadlocal
|
||||
// TODO make a IrDeclarationBase field? (requires IR factory)
|
||||
var stageController: StageController = object : StageController {}
|
||||
var stageController: StageController = StageController()
|
||||
|
||||
// TODO make a class
|
||||
interface StageController {
|
||||
val currentStage: Int get() = 0
|
||||
open class StageController(open val currentStage: Int = 0) {
|
||||
open fun lazyLower(declaration: IrDeclaration) {}
|
||||
|
||||
fun lazyLower(declaration: IrDeclaration) {}
|
||||
open fun lazyLower(body: IrBody) {}
|
||||
|
||||
fun lazyLower(body: IrBody) {}
|
||||
open fun <T> withStage(stage: Int, fn: () -> T): T = fn()
|
||||
|
||||
fun <T> withStage(stage: Int, fn: () -> T): T = fn()
|
||||
open val bodiesEnabled: Boolean get() = true
|
||||
|
||||
val bodiesEnabled: Boolean get() = true
|
||||
open fun <T> withInitialIr(block: () -> T): T = block()
|
||||
|
||||
fun <T> withInitialIr(block: () -> T): T = block()
|
||||
open fun <T> restrictTo(declaration: IrDeclaration, fn: () -> T): T = fn()
|
||||
|
||||
fun <T> restrictTo(declaration: IrDeclaration, fn: () -> T): T = fn()
|
||||
open fun <T> bodyLowering(fn: () -> T): T = fn()
|
||||
|
||||
fun <T> bodyLowering(fn: () -> T): T = fn()
|
||||
open fun canModify(element: IrElement): Boolean = true
|
||||
|
||||
fun canModify(element: IrElement): Boolean = true
|
||||
open fun <T> unrestrictDeclarationListsAccess(fn: () -> T): T = fn()
|
||||
|
||||
fun <T> unrestrictDeclarationListsAccess(fn: () -> T): T = fn()
|
||||
|
||||
fun canAccessDeclarationsOf(irClass: IrClass): Boolean = true
|
||||
open fun canAccessDeclarationsOf(irClass: IrClass): Boolean = true
|
||||
}
|
||||
|
||||
@Suppress("NOTHING_TO_INLINE")
|
||||
|
||||
@@ -27,7 +27,6 @@ import org.jetbrains.kotlin.ir.util.transformIfNeeded
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.isEffectivelyExternal
|
||||
import java.util.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
@@ -53,26 +52,6 @@ class IrClassImpl(
|
||||
IrClass,
|
||||
ClassCarrier {
|
||||
|
||||
constructor(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
symbol: IrClassSymbol,
|
||||
descriptor: ClassDescriptor,
|
||||
name: Name = descriptor.name,
|
||||
visibility: Visibility = descriptor.visibility,
|
||||
modality: Modality = descriptor.modality
|
||||
) : this(
|
||||
startOffset, endOffset, origin, symbol,
|
||||
name, kind = descriptor.kind,
|
||||
visibility = visibility, modality = modality,
|
||||
isCompanion = descriptor.isCompanionObject, isInner = descriptor.isInner,
|
||||
isData = descriptor.isData, isExternal = descriptor.isEffectivelyExternal(),
|
||||
isInline = descriptor.isInline, isExpect = descriptor.isExpect,
|
||||
isFun = descriptor.isFun,
|
||||
source = descriptor.source
|
||||
)
|
||||
|
||||
init {
|
||||
symbol.bind(this)
|
||||
}
|
||||
|
||||
@@ -19,13 +19,13 @@ package org.jetbrains.kotlin.ir.declarations.impl
|
||||
import org.jetbrains.kotlin.descriptors.ClassConstructorDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.IrConstructor
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.carriers.ConstructorCarrier
|
||||
import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.isEffectivelyExternal
|
||||
|
||||
class IrConstructorImpl(
|
||||
startOffset: Int,
|
||||
@@ -49,24 +49,6 @@ class IrConstructorImpl(
|
||||
IrConstructor,
|
||||
ConstructorCarrier {
|
||||
|
||||
constructor(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
symbol: IrConstructorSymbol,
|
||||
returnType: IrType,
|
||||
descriptor: ClassConstructorDescriptor,
|
||||
name: Name = descriptor.name
|
||||
) : this(
|
||||
startOffset, endOffset, origin, symbol,
|
||||
name = name, visibility = descriptor.visibility,
|
||||
returnType = returnType,
|
||||
isInline = descriptor.isInline,
|
||||
isExternal = descriptor.isEffectivelyExternal(),
|
||||
isPrimary = descriptor.isPrimary,
|
||||
isExpect = descriptor.isExpect
|
||||
)
|
||||
|
||||
init {
|
||||
symbol.bind(this)
|
||||
}
|
||||
|
||||
@@ -24,13 +24,13 @@ import org.jetbrains.kotlin.ir.declarations.impl.carriers.DeclarationCarrier
|
||||
import org.jetbrains.kotlin.ir.expressions.IrBody
|
||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||
|
||||
abstract class IrDeclarationBase<T : DeclarationCarrier<T>>(
|
||||
abstract class IrDeclarationBase<T : DeclarationCarrier>(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin
|
||||
) : IrPersistingElementBase<T>(startOffset, endOffset),
|
||||
IrDeclaration,
|
||||
DeclarationCarrier<T> {
|
||||
DeclarationCarrier {
|
||||
|
||||
override var parentField: IrDeclarationParent? = null
|
||||
|
||||
@@ -75,18 +75,18 @@ abstract class IrDeclarationBase<T : DeclarationCarrier<T>>(
|
||||
}
|
||||
}
|
||||
|
||||
abstract class IrPersistingElementBase<T : Carrier<T>>(
|
||||
abstract class IrPersistingElementBase<T : Carrier>(
|
||||
startOffset: Int,
|
||||
endOffset: Int
|
||||
) : IrElementBase(startOffset, endOffset),
|
||||
Carrier<T> {
|
||||
Carrier {
|
||||
|
||||
override var lastModified: Int = stageController.currentStage
|
||||
|
||||
var loweredUpTo = stageController.currentStage
|
||||
|
||||
// TODO Array<T>?
|
||||
private var values: Array<Any?>? = null
|
||||
private var values: Array<Carrier>? = null
|
||||
|
||||
val createdOn: Int = stageController.currentStage
|
||||
// get() = values?.let { (it[0] as T).lastModified } ?: lastModified
|
||||
@@ -140,13 +140,7 @@ abstract class IrPersistingElementBase<T : Carrier<T>>(
|
||||
if (stage == lastModified) {
|
||||
return this as T
|
||||
} else {
|
||||
val newValues = values?.let { oldValues ->
|
||||
oldValues.copyOf(oldValues.size + 1)
|
||||
} ?: arrayOfNulls<Any?>(1)
|
||||
|
||||
newValues[newValues.size - 1] = this.clone()
|
||||
|
||||
values = newValues
|
||||
values = (values ?: emptyArray()) + this.clone() as T
|
||||
}
|
||||
|
||||
this.lastModified = stage
|
||||
|
||||
@@ -19,18 +19,17 @@ package org.jetbrains.kotlin.ir.declarations.impl
|
||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.declarations.IrField
|
||||
import org.jetbrains.kotlin.ir.declarations.MetadataSource
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.carriers.FieldCarrier
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
|
||||
import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.IrFieldSymbolImpl
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.isEffectivelyExternal
|
||||
|
||||
|
||||
class IrFieldImpl(
|
||||
startOffset: Int,
|
||||
@@ -47,24 +46,6 @@ class IrFieldImpl(
|
||||
IrField,
|
||||
FieldCarrier {
|
||||
|
||||
constructor(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
descriptor: PropertyDescriptor,
|
||||
type: IrType,
|
||||
name: Name = descriptor.name,
|
||||
symbol: IrFieldSymbol = IrFieldSymbolImpl(descriptor),
|
||||
visibility: Visibility = descriptor.visibility
|
||||
) : this(
|
||||
startOffset, endOffset, origin, symbol,
|
||||
name = name, type,
|
||||
visibility = visibility,
|
||||
isFinal = !descriptor.isVar,
|
||||
isExternal = descriptor.isEffectivelyExternal(),
|
||||
isStatic = descriptor.dispatchReceiverParameter == null
|
||||
)
|
||||
|
||||
init {
|
||||
symbol.bind(this)
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
abstract class IrFunctionBase<T : FunctionBaseCarrier<T>>(
|
||||
abstract class IrFunctionBase<T : FunctionBaseCarrier>(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
@@ -40,7 +40,7 @@ abstract class IrFunctionBase<T : FunctionBaseCarrier<T>>(
|
||||
) :
|
||||
IrDeclarationBase<T>(startOffset, endOffset, origin),
|
||||
IrFunction,
|
||||
FunctionBaseCarrier<T> {
|
||||
FunctionBaseCarrier {
|
||||
|
||||
override var returnTypeFieldField: IrType = returnType
|
||||
|
||||
|
||||
@@ -9,12 +9,13 @@ import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.IrAttributeContainer
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.carriers.FunctionCarrier
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedSimpleFunctionDescriptor
|
||||
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.IrSimpleFunctionSymbolImpl
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
@@ -95,40 +96,6 @@ class IrFunctionImpl(
|
||||
) : IrFunctionCommonImpl(startOffset, endOffset, origin, name, visibility, modality, returnType, isInline,
|
||||
isExternal, isTailrec, isSuspend, isOperator, isExpect, isFakeOverride) {
|
||||
|
||||
constructor(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
symbol: IrSimpleFunctionSymbol,
|
||||
returnType: IrType,
|
||||
descriptor: FunctionDescriptor,
|
||||
name: Name = descriptor.name
|
||||
) : this(
|
||||
startOffset, endOffset, origin, symbol,
|
||||
name = name,
|
||||
visibility = descriptor.visibility,
|
||||
modality = descriptor.modality,
|
||||
returnType = returnType,
|
||||
isInline = descriptor.isInline,
|
||||
isExternal = descriptor.isExternal,
|
||||
isTailrec = descriptor.isTailrec,
|
||||
isSuspend = descriptor.isSuspend,
|
||||
isOperator = descriptor.isOperator,
|
||||
isExpect = descriptor.isExpect
|
||||
)
|
||||
|
||||
// Used by kotlin-native in InteropLowering.kt and IrUtils2.kt
|
||||
constructor(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
descriptor: FunctionDescriptor,
|
||||
returnType: IrType
|
||||
) : this(
|
||||
startOffset, endOffset, origin,
|
||||
IrSimpleFunctionSymbolImpl(descriptor), returnType, descriptor
|
||||
)
|
||||
|
||||
@ObsoleteDescriptorBasedAPI
|
||||
override val descriptor: FunctionDescriptor get() = symbol.descriptor
|
||||
|
||||
|
||||
@@ -26,16 +26,12 @@ import org.jetbrains.kotlin.name.Name
|
||||
|
||||
class IrModuleFragmentImpl(
|
||||
override val descriptor: ModuleDescriptor,
|
||||
override val irBuiltins: IrBuiltIns
|
||||
override val irBuiltins: IrBuiltIns,
|
||||
files: List<IrFile> = emptyList(),
|
||||
) : IrModuleFragment {
|
||||
|
||||
constructor(descriptor: ModuleDescriptor, irBuiltins: IrBuiltIns, files: List<IrFile>) : this(descriptor, irBuiltins) {
|
||||
this.files.addAll(files)
|
||||
}
|
||||
|
||||
override val name: Name get() = descriptor.name // TODO
|
||||
|
||||
override val files: MutableList<IrFile> = ArrayList()
|
||||
override val files: MutableList<IrFile> = files.toMutableList()
|
||||
|
||||
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D): R =
|
||||
visitor.visitModuleFragment(this, data)
|
||||
@@ -49,4 +45,4 @@ class IrModuleFragmentImpl(
|
||||
files[i] = irFile.transform(transformer, data)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,11 +24,9 @@ import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.carriers.PropertyCarrier
|
||||
import org.jetbrains.kotlin.ir.descriptors.WrappedPropertyDescriptor
|
||||
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.IrPropertySymbolImpl
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.isEffectivelyExternal
|
||||
|
||||
abstract class IrPropertyCommonImpl(
|
||||
startOffset: Int,
|
||||
@@ -126,91 +124,6 @@ class IrPropertyImpl(
|
||||
override val isFakeOverride: Boolean = origin == IrDeclarationOrigin.FAKE_OVERRIDE
|
||||
) : IrPropertyCommonImpl(startOffset, endOffset, origin, name, visibility, modality, isVar, isConst, isLateinit, isDelegated, isExternal, isExpect, isFakeOverride) {
|
||||
|
||||
@Deprecated(message = "Don't use descriptor-based API for IrProperty", level = DeprecationLevel.WARNING)
|
||||
constructor(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
descriptor: PropertyDescriptor,
|
||||
symbol: IrPropertySymbol = IrPropertySymbolImpl(descriptor),
|
||||
name: Name = descriptor.name,
|
||||
visibility: Visibility = descriptor.visibility,
|
||||
modality: Modality = descriptor.modality,
|
||||
isVar: Boolean = descriptor.isVar,
|
||||
isConst: Boolean = descriptor.isConst,
|
||||
isLateinit: Boolean = descriptor.isLateInit,
|
||||
isDelegated: Boolean = descriptor.isDelegated,
|
||||
isExternal: Boolean = descriptor.isExternal
|
||||
) : this(
|
||||
startOffset, endOffset, origin,
|
||||
symbol,
|
||||
name, visibility, modality,
|
||||
isVar = isVar,
|
||||
isConst = isConst,
|
||||
isLateinit = isLateinit,
|
||||
isDelegated = isDelegated,
|
||||
isExternal = isExternal,
|
||||
isExpect = descriptor.isExpect
|
||||
)
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
@Deprecated(message = "Don't use descriptor-based API for IrProperty", level = DeprecationLevel.WARNING)
|
||||
constructor(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
isDelegated: Boolean,
|
||||
descriptor: PropertyDescriptor
|
||||
) : this(
|
||||
startOffset, endOffset, origin, descriptor,
|
||||
name = descriptor.name,
|
||||
visibility = descriptor.visibility,
|
||||
modality = descriptor.modality,
|
||||
isVar = descriptor.isVar,
|
||||
isConst = descriptor.isConst,
|
||||
isLateinit = descriptor.isLateInit,
|
||||
isDelegated = isDelegated,
|
||||
isExternal = descriptor.isEffectivelyExternal()
|
||||
)
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
@Deprecated(message = "Don't use descriptor-based API for IrProperty", level = DeprecationLevel.WARNING)
|
||||
constructor(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
descriptor: PropertyDescriptor
|
||||
) : this(startOffset, endOffset, origin, descriptor.isDelegated, descriptor)
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
@Deprecated(message = "Don't use descriptor-based API for IrProperty", level = DeprecationLevel.WARNING)
|
||||
constructor(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
isDelegated: Boolean,
|
||||
descriptor: PropertyDescriptor,
|
||||
backingField: IrField?
|
||||
) : this(startOffset, endOffset, origin, isDelegated, descriptor) {
|
||||
this.backingField = backingField
|
||||
}
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
@Deprecated(message = "Don't use descriptor-based API for IrProperty", level = DeprecationLevel.WARNING)
|
||||
constructor(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
isDelegated: Boolean,
|
||||
descriptor: PropertyDescriptor,
|
||||
backingField: IrField?,
|
||||
getter: IrSimpleFunction?,
|
||||
setter: IrSimpleFunction?
|
||||
) : this(startOffset, endOffset, origin, isDelegated, descriptor, backingField) {
|
||||
this.getter = getter
|
||||
this.setter = setter
|
||||
}
|
||||
|
||||
init {
|
||||
symbol.bind(this)
|
||||
}
|
||||
|
||||
@@ -61,24 +61,4 @@ class IrTypeAliasImpl(
|
||||
override fun <D> transformChildren(transformer: IrElementTransformer<D>, data: D) {
|
||||
typeParameters = typeParameters.transformIfNeeded(transformer, data)
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun fromSymbolDescriptor(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
symbol: IrTypeAliasSymbol,
|
||||
expandedType: IrType,
|
||||
origin: IrDeclarationOrigin,
|
||||
descriptor: TypeAliasDescriptor
|
||||
) =
|
||||
IrTypeAliasImpl(
|
||||
startOffset, endOffset,
|
||||
symbol,
|
||||
descriptor.name,
|
||||
descriptor.visibility,
|
||||
expandedType,
|
||||
descriptor.isActual,
|
||||
origin
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.declarations.IrTypeParameter
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.carriers.TypeParameterCarrier
|
||||
import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.IrTypeParameterSymbolImpl
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
@@ -44,19 +43,6 @@ class IrTypeParameterImpl(
|
||||
IrTypeParameter,
|
||||
TypeParameterCarrier {
|
||||
|
||||
@Deprecated("Use constructor which takes symbol instead of descriptor")
|
||||
constructor(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
descriptor: TypeParameterDescriptor,
|
||||
name: Name = descriptor.name,
|
||||
symbol: IrTypeParameterSymbol = IrTypeParameterSymbolImpl(descriptor)
|
||||
) : this(
|
||||
startOffset, endOffset, origin, symbol, name,
|
||||
index = descriptor.index, isReified = descriptor.isReified, variance = descriptor.variance
|
||||
)
|
||||
|
||||
init {
|
||||
symbol.bind(this)
|
||||
}
|
||||
@@ -79,4 +65,4 @@ class IrTypeParameterImpl(
|
||||
override fun <D> transformChildren(transformer: IrElementTransformer<D>, data: D) {
|
||||
// no children
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,19 +17,16 @@
|
||||
package org.jetbrains.kotlin.ir.declarations.impl
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.ParameterDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
|
||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.declarations.IrValueParameter
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.carriers.ValueParameterCarrier
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
|
||||
import org.jetbrains.kotlin.ir.symbols.IrValueParameterSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.IrValueParameterSymbolImpl
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
|
||||
class IrValueParameterImpl(
|
||||
startOffset: Int,
|
||||
@@ -47,25 +44,6 @@ class IrValueParameterImpl(
|
||||
IrValueParameter,
|
||||
ValueParameterCarrier {
|
||||
|
||||
@ObsoleteDescriptorBasedAPI
|
||||
constructor(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
descriptor: ParameterDescriptor,
|
||||
type: IrType,
|
||||
varargElementType: IrType?,
|
||||
name: Name = descriptor.name,
|
||||
symbol: IrValueParameterSymbol = IrValueParameterSymbolImpl(descriptor)
|
||||
) : this(
|
||||
startOffset, endOffset, origin, symbol,
|
||||
name,
|
||||
index = descriptor.safeAs<ValueParameterDescriptor>()?.index ?: -1,
|
||||
type = type, varargElementType = varargElementType,
|
||||
isCrossinline = descriptor.safeAs<ValueParameterDescriptor>()?.isCrossinline ?: false,
|
||||
isNoinline = descriptor.safeAs<ValueParameterDescriptor>()?.isNoinline ?: false
|
||||
)
|
||||
|
||||
@ObsoleteDescriptorBasedAPI
|
||||
override val descriptor: ParameterDescriptor = symbol.descriptor
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ import org.jetbrains.kotlin.ir.declarations.MetadataSource
|
||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
||||
import org.jetbrains.kotlin.ir.symbols.IrVariableSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.IrVariableSymbolImpl
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementTransformer
|
||||
import org.jetbrains.kotlin.ir.visitors.IrElementVisitor
|
||||
@@ -54,33 +53,6 @@ class IrVariableImpl(
|
||||
override var annotations: List<IrConstructorCall> = emptyList()
|
||||
override val metadata: MetadataSource? get() = null
|
||||
|
||||
constructor(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
descriptor: VariableDescriptor,
|
||||
type: IrType,
|
||||
name: Name = descriptor.name,
|
||||
symbol: IrVariableSymbol = IrVariableSymbolImpl(descriptor)
|
||||
) : this(
|
||||
startOffset, endOffset, origin,
|
||||
symbol, name, type,
|
||||
isVar = descriptor.isVar,
|
||||
isConst = descriptor.isConst,
|
||||
isLateinit = descriptor.isLateInit
|
||||
)
|
||||
|
||||
constructor(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
descriptor: VariableDescriptor,
|
||||
type: IrType,
|
||||
initializer: IrExpression?
|
||||
) : this(startOffset, endOffset, origin, descriptor, type) {
|
||||
this.initializer = initializer
|
||||
}
|
||||
|
||||
init {
|
||||
symbol.bind(this)
|
||||
}
|
||||
@@ -100,4 +72,4 @@ class IrVariableImpl(
|
||||
override fun <D> transformChildren(transformer: IrElementTransformer<D>, data: D) {
|
||||
initializer = initializer?.transform(transformer, data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent
|
||||
import org.jetbrains.kotlin.ir.expressions.IrBlockBody
|
||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||
|
||||
interface AnonymousInitializerCarrier : DeclarationCarrier<AnonymousInitializerCarrier> {
|
||||
interface AnonymousInitializerCarrier : DeclarationCarrier {
|
||||
var bodyField: IrBlockBody?
|
||||
|
||||
override fun clone(): AnonymousInitializerCarrier {
|
||||
|
||||
@@ -7,7 +7,7 @@ package org.jetbrains.kotlin.ir.declarations.impl.carriers
|
||||
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclaration
|
||||
|
||||
interface BodyCarrier : Carrier<BodyCarrier> {
|
||||
interface BodyCarrier : Carrier {
|
||||
|
||||
var containerField: IrDeclaration?
|
||||
|
||||
|
||||
@@ -5,10 +5,8 @@
|
||||
|
||||
package org.jetbrains.kotlin.ir.declarations.impl.carriers
|
||||
|
||||
// TODO degenerify
|
||||
// TODO degenerify
|
||||
interface Carrier<in T : Carrier<T>> {
|
||||
interface Carrier {
|
||||
val lastModified: Int
|
||||
|
||||
fun clone(): Carrier<T>
|
||||
fun clone(): Carrier
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
|
||||
interface ClassCarrier : DeclarationCarrier<ClassCarrier> {
|
||||
interface ClassCarrier : DeclarationCarrier {
|
||||
var thisReceiverField: IrValueParameter?
|
||||
var metadataField: MetadataSource?
|
||||
var visibilityField: Visibility
|
||||
|
||||
@@ -12,7 +12,7 @@ import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
|
||||
|
||||
interface ConstructorCarrier : FunctionBaseCarrier<ConstructorCarrier> {
|
||||
interface ConstructorCarrier : FunctionBaseCarrier {
|
||||
|
||||
override fun clone(): ConstructorCarrier {
|
||||
return ConstructorCarrierImpl(
|
||||
|
||||
@@ -10,7 +10,7 @@ import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent
|
||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||
import org.jetbrains.kotlin.utils.SmartList
|
||||
|
||||
interface DeclarationCarrier<in T : DeclarationCarrier<T>>: Carrier<T> {
|
||||
interface DeclarationCarrier: Carrier {
|
||||
var parentField: IrDeclarationParent?
|
||||
var originField: IrDeclarationOrigin
|
||||
var annotationsField: List<IrConstructorCall>
|
||||
|
||||
@@ -11,7 +11,7 @@ import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent
|
||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
|
||||
|
||||
interface EnumEntryCarrier : DeclarationCarrier<EnumEntryCarrier> {
|
||||
interface EnumEntryCarrier : DeclarationCarrier {
|
||||
var correspondingClassField: IrClass?
|
||||
var initializerExpressionField: IrExpressionBody?
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent
|
||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||
|
||||
interface ErrorCarrier : DeclarationCarrier<ErrorCarrier> {
|
||||
interface ErrorCarrier : DeclarationCarrier {
|
||||
|
||||
override fun clone(): ErrorCarrier {
|
||||
return ErrorCarrierImpl(lastModified, parentField, originField, annotationsField)
|
||||
@@ -21,4 +21,4 @@ class ErrorCarrierImpl(
|
||||
override var parentField: IrDeclarationParent?,
|
||||
override var originField: IrDeclarationOrigin,
|
||||
override var annotationsField: List<IrConstructorCall>
|
||||
) : ErrorCarrier
|
||||
) : ErrorCarrier
|
||||
@@ -12,7 +12,7 @@ import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
|
||||
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
|
||||
|
||||
interface FieldCarrier : DeclarationCarrier<FieldCarrier> {
|
||||
interface FieldCarrier : DeclarationCarrier {
|
||||
var initializerField: IrExpressionBody?
|
||||
var correspondingPropertySymbolField: IrPropertySymbol?
|
||||
var metadataField: MetadataSource?
|
||||
|
||||
@@ -12,7 +12,7 @@ import org.jetbrains.kotlin.ir.declarations.MetadataSource
|
||||
import org.jetbrains.kotlin.ir.expressions.IrBody
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
|
||||
interface FunctionBaseCarrier<T : FunctionBaseCarrier<T>> : DeclarationCarrier<T> {
|
||||
interface FunctionBaseCarrier : DeclarationCarrier {
|
||||
var returnTypeFieldField: IrType
|
||||
var dispatchReceiverParameterField: IrValueParameter?
|
||||
var extensionReceiverParameterField: IrValueParameter?
|
||||
|
||||
@@ -13,7 +13,7 @@ import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
|
||||
interface FunctionCarrier : FunctionBaseCarrier<FunctionCarrier> {
|
||||
interface FunctionCarrier : FunctionBaseCarrier {
|
||||
var correspondingPropertySymbolField: IrPropertySymbol?
|
||||
var overriddenSymbolsField: List<IrSimpleFunctionSymbol>
|
||||
var attributeOwnerIdField: IrAttributeContainer
|
||||
|
||||
@@ -8,7 +8,7 @@ package org.jetbrains.kotlin.ir.declarations.impl.carriers
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||
|
||||
interface LocalDelegatedPropertyCarrier : DeclarationCarrier<LocalDelegatedPropertyCarrier> {
|
||||
interface LocalDelegatedPropertyCarrier : DeclarationCarrier {
|
||||
var delegateField: IrVariable?
|
||||
var getterField: IrFunction?
|
||||
var setterField: IrFunction?
|
||||
|
||||
@@ -8,7 +8,7 @@ package org.jetbrains.kotlin.ir.declarations.impl.carriers
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||
|
||||
interface PropertyCarrier : DeclarationCarrier<PropertyCarrier> {
|
||||
interface PropertyCarrier : DeclarationCarrier {
|
||||
var backingFieldField: IrField?
|
||||
var getterField: IrSimpleFunction?
|
||||
var setterField: IrSimpleFunction?
|
||||
|
||||
@@ -10,7 +10,7 @@ import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent
|
||||
import org.jetbrains.kotlin.ir.declarations.IrTypeParameter
|
||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||
|
||||
interface TypeAliasCarrier : DeclarationCarrier<TypeAliasCarrier> {
|
||||
interface TypeAliasCarrier : DeclarationCarrier {
|
||||
|
||||
var typeParametersField: List<IrTypeParameter>
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent
|
||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||
|
||||
interface TypeParameterCarrier : DeclarationCarrier<TypeParameterCarrier> {
|
||||
interface TypeParameterCarrier : DeclarationCarrier {
|
||||
|
||||
override fun clone(): TypeParameterCarrier {
|
||||
return TypeParameterCarrierImpl(lastModified, parentField, originField, annotationsField)
|
||||
@@ -21,4 +21,4 @@ class TypeParameterCarrierImpl(
|
||||
override var parentField: IrDeclarationParent?,
|
||||
override var originField: IrDeclarationOrigin,
|
||||
override var annotationsField: List<IrConstructorCall>
|
||||
) : TypeParameterCarrier
|
||||
) : TypeParameterCarrier
|
||||
@@ -10,7 +10,7 @@ import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent
|
||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
|
||||
|
||||
interface ValueParameterCarrier : DeclarationCarrier<ValueParameterCarrier> {
|
||||
interface ValueParameterCarrier : DeclarationCarrier {
|
||||
var defaultValueField: IrExpressionBody?
|
||||
|
||||
override fun clone(): ValueParameterCarrier {
|
||||
|
||||
@@ -6,12 +6,13 @@
|
||||
package org.jetbrains.kotlin.ir.declarations.lazy
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||
import org.jetbrains.kotlin.ir.IrElementBase
|
||||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
|
||||
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrValueParameterImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.IrValueParameterSymbolImpl
|
||||
import org.jetbrains.kotlin.ir.util.DeclarationStubGenerator
|
||||
import org.jetbrains.kotlin.ir.util.TypeTranslator
|
||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||
@@ -30,8 +31,8 @@ abstract class IrLazyDeclarationBase(
|
||||
|
||||
protected fun ReceiverParameterDescriptor.generateReceiverParameterStub(): IrValueParameter =
|
||||
IrValueParameterImpl(
|
||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET, origin, this,
|
||||
type.toIrType(), null
|
||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET, origin, IrValueParameterSymbolImpl(this),
|
||||
name, -1, type.toIrType(), null, isCrossinline = false, isNoinline = false
|
||||
)
|
||||
|
||||
protected fun generateMemberStubs(memberScope: MemberScope, container: MutableList<IrDeclaration>) {
|
||||
|
||||
@@ -19,9 +19,7 @@ import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.IrValueParameterSymbolImpl
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.ir.types.impl.*
|
||||
import org.jetbrains.kotlin.ir.util.SYNTHETIC_OFFSET
|
||||
import org.jetbrains.kotlin.ir.util.SymbolTable
|
||||
import org.jetbrains.kotlin.ir.util.referenceClassifier
|
||||
import org.jetbrains.kotlin.ir.util.*
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.isEffectivelyExternal
|
||||
@@ -356,19 +354,12 @@ class IrFunctionFactory(private val irBuiltIns: IrBuiltIns, private val symbolTa
|
||||
}
|
||||
}
|
||||
|
||||
private fun IrFunction.createValueParameter(descriptor: ParameterDescriptor): IrValueParameter {
|
||||
val symbol = IrValueParameterSymbolImpl(descriptor)
|
||||
val varargType = if (descriptor is ValueParameterDescriptor) descriptor.varargElementType else null
|
||||
return IrValueParameterImpl(
|
||||
offset,
|
||||
offset,
|
||||
memberOrigin,
|
||||
descriptor,
|
||||
symbol = symbol,
|
||||
type = toIrType(descriptor.type),
|
||||
varargElementType = varargType?.let { toIrType(it) }
|
||||
private fun IrFunction.createValueParameter(descriptor: ParameterDescriptor): IrValueParameter = with(descriptor) {
|
||||
IrValueParameterImpl(
|
||||
offset, offset, memberOrigin, IrValueParameterSymbolImpl(this), name, indexOrMinusOne, toIrType(type),
|
||||
(this as? ValueParameterDescriptor)?.varargElementType?.let(::toIrType), isCrossinline, isNoinline
|
||||
).also {
|
||||
it.parent = this
|
||||
it.parent = this@createValueParameter
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.ir.linkage.IrProvider
|
||||
import org.jetbrains.kotlin.ir.symbols.IrFieldSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.IrValueParameterSymbolImpl
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.isEffectivelyExternal
|
||||
@@ -247,10 +248,10 @@ class DeclarationStubGenerator(
|
||||
|
||||
private fun KotlinType.toIrType() = typeTranslator.translateType(this)
|
||||
|
||||
internal fun generateValueParameterStub(descriptor: ValueParameterDescriptor): IrValueParameter {
|
||||
return IrValueParameterImpl(
|
||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET, computeOrigin(descriptor),
|
||||
descriptor, descriptor.type.toIrType(), descriptor.varargElementType?.toIrType()
|
||||
internal fun generateValueParameterStub(descriptor: ValueParameterDescriptor): IrValueParameter = with(descriptor) {
|
||||
IrValueParameterImpl(
|
||||
UNDEFINED_OFFSET, UNDEFINED_OFFSET, computeOrigin(this), IrValueParameterSymbolImpl(this), name, index, type.toIrType(),
|
||||
varargElementType?.toIrType(), isCrossinline, isNoinline
|
||||
).also { irValueParameter ->
|
||||
if (descriptor.declaresDefaultValue()) {
|
||||
irValueParameter.defaultValue =
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.ir.util
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.ir.declarations.IrClass
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrClassImpl
|
||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.isEffectivelyExternal
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
|
||||
val ParameterDescriptor.indexOrMinusOne: Int
|
||||
get() = if (this is ValueParameterDescriptor) index else -1
|
||||
|
||||
val ParameterDescriptor.varargElementType: KotlinType?
|
||||
get() = (this as? ValueParameterDescriptor)?.varargElementType
|
||||
|
||||
val ParameterDescriptor.isCrossinline: Boolean
|
||||
get() = this is ValueParameterDescriptor && isCrossinline
|
||||
|
||||
val ParameterDescriptor.isNoinline: Boolean
|
||||
get() = this is ValueParameterDescriptor && isNoinline
|
||||
|
||||
fun createIrClassFromDescriptor(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
origin: IrDeclarationOrigin,
|
||||
symbol: IrClassSymbol,
|
||||
descriptor: ClassDescriptor,
|
||||
name: Name = descriptor.name,
|
||||
visibility: Visibility = descriptor.visibility,
|
||||
modality: Modality = descriptor.modality
|
||||
): IrClass = IrClassImpl(
|
||||
startOffset, endOffset, origin, symbol, name, descriptor.kind, visibility, modality,
|
||||
descriptor.isCompanionObject, descriptor.isInner, descriptor.isData, descriptor.isEffectivelyExternal(),
|
||||
descriptor.isInline, descriptor.isExpect, descriptor.isFun, descriptor.source
|
||||
)
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user