mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-15 00:21:28 +00:00
Compare commits
265 Commits
v1.5.0-RC
...
rr/ilmir/i
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ccaa4a1cf1 | ||
|
|
f025a357f7 | ||
|
|
75954dd1a4 | ||
|
|
2a46da906c | ||
|
|
4a381d4b83 | ||
|
|
d96921e287 | ||
|
|
872effc21e | ||
|
|
3e17317f31 | ||
|
|
d4b0688690 | ||
|
|
2cbdad0bb1 | ||
|
|
1c210c2386 | ||
|
|
694d69fbfa | ||
|
|
19bffc694b | ||
|
|
76b124a9c0 | ||
|
|
7b4624aac4 | ||
|
|
6c051b2be4 | ||
|
|
a9322a01ce | ||
|
|
37a702b962 | ||
|
|
83e3201677 | ||
|
|
266432a482 | ||
|
|
065d0c66ab | ||
|
|
64c5608f31 | ||
|
|
0e8f4294f0 | ||
|
|
04017b00a1 | ||
|
|
f9e5584a3e | ||
|
|
c75d2c05f0 | ||
|
|
dcb47d9934 | ||
|
|
391f53154a | ||
|
|
250040bab7 | ||
|
|
94e66acd54 | ||
|
|
9f7d7e55da | ||
|
|
27dcd07a5e | ||
|
|
4d5ec6e52a | ||
|
|
955f86ef9f | ||
|
|
33c1ca01f4 | ||
|
|
6c92ea518b | ||
|
|
cb226e74a5 | ||
|
|
08111031ec | ||
|
|
a68837451a | ||
|
|
0d1f493b6c | ||
|
|
f1ab5d1fbd | ||
|
|
bbd1da7b71 | ||
|
|
a564f92eef | ||
|
|
cd189c0812 | ||
|
|
fb296b5b95 | ||
|
|
35ec6b4f5c | ||
|
|
d5deccd2e9 | ||
|
|
dacf012a78 | ||
|
|
cdb488149f | ||
|
|
c9cb7bc0fd | ||
|
|
ae738e9c59 | ||
|
|
c6242ad167 | ||
|
|
8be7e6064e | ||
|
|
2a424ad2af | ||
|
|
924a7b009b | ||
|
|
218c246111 | ||
|
|
95140f35f8 | ||
|
|
ca02573d1e | ||
|
|
771b1acbc1 | ||
|
|
29b96aa15d | ||
|
|
21c493a854 | ||
|
|
acd8c4503b | ||
|
|
5f71cd5476 | ||
|
|
02f845636e | ||
|
|
a30a961cf5 | ||
|
|
52e22796e1 | ||
|
|
73113c1041 | ||
|
|
53204661e3 | ||
|
|
d3b4df7da8 | ||
|
|
f1682cba13 | ||
|
|
ba0d60853d | ||
|
|
7523a5e97f | ||
|
|
cc55580300 | ||
|
|
b32db1ac02 | ||
|
|
b2017a9c9c | ||
|
|
87e130e77a | ||
|
|
ebced14db2 | ||
|
|
459a2886a0 | ||
|
|
923a4427c5 | ||
|
|
60a05dded0 | ||
|
|
7942bd0b3b | ||
|
|
2535e5d5c9 | ||
|
|
bd45a6c11d | ||
|
|
d901ceb734 | ||
|
|
5a55d56320 | ||
|
|
8712772a5f | ||
|
|
c51798d46f | ||
|
|
e7669ef9d6 | ||
|
|
29ac4cb9cc | ||
|
|
173a852273 | ||
|
|
8b2279072f | ||
|
|
e0b6d4d917 | ||
|
|
99b5e5a373 | ||
|
|
ab20a8ffff | ||
|
|
088448043a | ||
|
|
d94912ed62 | ||
|
|
0bc386cb08 | ||
|
|
bb8bf28b8b | ||
|
|
690fb47cbb | ||
|
|
de3678a805 | ||
|
|
d6e74b9620 | ||
|
|
ca314c5bb9 | ||
|
|
3a07ca4c64 | ||
|
|
80d5a1a1db | ||
|
|
4ef1e1119f | ||
|
|
0dd5b94556 | ||
|
|
b48835f3ce | ||
|
|
571c4ce398 | ||
|
|
8277c96933 | ||
|
|
bd205317aa | ||
|
|
496d857db1 | ||
|
|
6a959fefd0 | ||
|
|
62897a194b | ||
|
|
ff45e58543 | ||
|
|
c8a938275c | ||
|
|
318dd22bd1 | ||
|
|
6fe5f85da7 | ||
|
|
2438265ba8 | ||
|
|
9c4af5070b | ||
|
|
a4438ad64f | ||
|
|
55c37183d9 | ||
|
|
dfd1a53624 | ||
|
|
1c8cd242bf | ||
|
|
9d6c0e56ed | ||
|
|
b39a205671 | ||
|
|
80b95a22a4 | ||
|
|
3b91d1c5e5 | ||
|
|
585cd64b9a | ||
|
|
5ff6b5ef42 | ||
|
|
f67a9615b8 | ||
|
|
e5aa772639 | ||
|
|
4c640e3f81 | ||
|
|
d610837caf | ||
|
|
2bcaf1fa63 | ||
|
|
e28c1fd310 | ||
|
|
9551e0fff2 | ||
|
|
701374a646 | ||
|
|
08cc904a71 | ||
|
|
85f79695b9 | ||
|
|
4bf6e58f2b | ||
|
|
3f10914f05 | ||
|
|
165533fdb7 | ||
|
|
f42f2fa743 | ||
|
|
26ce6b5131 | ||
|
|
bbc6d2b993 | ||
|
|
3c0b226344 | ||
|
|
0ebb39a26e | ||
|
|
17d59e0daa | ||
|
|
81ba7aa833 | ||
|
|
e9cb30b4f3 | ||
|
|
c432efc364 | ||
|
|
dea3c954f1 | ||
|
|
2ae35b0b08 | ||
|
|
e79d02f482 | ||
|
|
a4e9ab90a0 | ||
|
|
c969a34644 | ||
|
|
53e5aa4364 | ||
|
|
09ec3f6eaf | ||
|
|
93741ced5c | ||
|
|
a3ad626f99 | ||
|
|
b351ca6bd4 | ||
|
|
3199ce03a6 | ||
|
|
e62b118351 | ||
|
|
99cb85ab00 | ||
|
|
6f3713af5f | ||
|
|
49c2bfe637 | ||
|
|
64a300bfcd | ||
|
|
3a0eee64b8 | ||
|
|
8973e3f362 | ||
|
|
92e21e76ba | ||
|
|
e3ab3d6be3 | ||
|
|
60e0831c11 | ||
|
|
13a778fd9c | ||
|
|
fc83dc17fe | ||
|
|
3f758a3fa2 | ||
|
|
0768a7089c | ||
|
|
5075484c8e | ||
|
|
9ba41c5b88 | ||
|
|
5c8d555808 | ||
|
|
1ea4fa4464 | ||
|
|
c13f38f6df | ||
|
|
1a044e5af4 | ||
|
|
5b64ceceb3 | ||
|
|
16928d6e3f | ||
|
|
0b0ba7d987 | ||
|
|
d953a03807 | ||
|
|
21000f4174 | ||
|
|
465261e611 | ||
|
|
b9c33a0c6e | ||
|
|
2fce6a4af9 | ||
|
|
5de34b052f | ||
|
|
e2b7aba086 | ||
|
|
59551eb037 | ||
|
|
9fa5feeeea | ||
|
|
daa65a2fff | ||
|
|
bf67308cc2 | ||
|
|
6891ad0dfc | ||
|
|
bb66b2fd04 | ||
|
|
c5068b7d45 | ||
|
|
484b884d04 | ||
|
|
d6bb1f2d4e | ||
|
|
24d82c63e0 | ||
|
|
ba5193870e | ||
|
|
06498c0efd | ||
|
|
f255f93ad9 | ||
|
|
eff13d24dc | ||
|
|
e47dfcbe64 | ||
|
|
18cebe5131 | ||
|
|
e529a7bf9b | ||
|
|
56db4bd1ac | ||
|
|
5d4606daaa | ||
|
|
2812034896 | ||
|
|
c1cdf273a6 | ||
|
|
9f282e0ddc | ||
|
|
659d2c13b4 | ||
|
|
019635189a | ||
|
|
65b6a95f64 | ||
|
|
5480faf5c5 | ||
|
|
3e59adc7f3 | ||
|
|
90f9dd5b33 | ||
|
|
206b38f0ab | ||
|
|
78c6e0733c | ||
|
|
1f62fee4f9 | ||
|
|
593fb8770b | ||
|
|
4ec369ac5b | ||
|
|
8172ae5d89 | ||
|
|
bd3bc13e75 | ||
|
|
ad53fc931e | ||
|
|
0f2ca5d84c | ||
|
|
4a17228621 | ||
|
|
cbeadba15d | ||
|
|
573aac7252 | ||
|
|
a16aaa3824 | ||
|
|
913c298be8 | ||
|
|
558338f997 | ||
|
|
8f675fe757 | ||
|
|
9ad88a5a0d | ||
|
|
5c0231b727 | ||
|
|
d8549d6292 | ||
|
|
e9436da858 | ||
|
|
adfa8c788c | ||
|
|
64e97225b8 | ||
|
|
d022bb0248 | ||
|
|
509ed64917 | ||
|
|
771600077c | ||
|
|
297288e984 | ||
|
|
772ca2715c | ||
|
|
6265ac8c19 | ||
|
|
16b3fedcd4 | ||
|
|
e7cf34a2a9 | ||
|
|
f08733eb75 | ||
|
|
2ef4ca4e6e | ||
|
|
2bbe3db041 | ||
|
|
9f9c8e3d77 | ||
|
|
21f022dec2 | ||
|
|
021a63827d | ||
|
|
6a29097a8c | ||
|
|
be9ef8f3c8 | ||
|
|
482e217b5e | ||
|
|
6747084fe2 | ||
|
|
338aad98eb | ||
|
|
7d4eaefd36 | ||
|
|
0ee4f1f393 | ||
|
|
e72ddbcbfe | ||
|
|
4b823eca21 |
138
ChangeLog.md
138
ChangeLog.md
@@ -1,7 +1,7 @@
|
||||
# CHANGELOG
|
||||
|
||||
|
||||
## 1.4.30-M1
|
||||
## 1.4.30
|
||||
|
||||
### Android
|
||||
|
||||
@@ -13,23 +13,20 @@
|
||||
- [`KT-42234`](https://youtrack.jetbrains.com/issue/KT-42234) Move LLVM optimization parameters into konan.properties
|
||||
- [`KT-42649`](https://youtrack.jetbrains.com/issue/KT-42649) IndexOutOfBoundsException during InlineClassTransformer lowering
|
||||
- [`KT-42942`](https://youtrack.jetbrains.com/issue/KT-42942) Native: optimize peak backend memory by clearing BindingContext after psi2ir
|
||||
- [`KT-43198`](https://youtrack.jetbrains.com/issue/KT-43198) init blocks inside inline classes
|
||||
- [`KT-31072`](https://youtrack.jetbrains.com/issue/KT-31072) Don't use non-reified arguments to specialize type operations in IR inliner
|
||||
|
||||
### Backend. JS
|
||||
- [`KT-41227`](https://youtrack.jetbrains.com/issue/KT-41227) KJS IR: don't copy to child's prototype references to the function from parent
|
||||
|
||||
### Backend. IR
|
||||
- [`KT-41227`](https://youtrack.jetbrains.com/issue/KT-41227) KJS IR: don't copy to child's prototype references to the function from parent
|
||||
- [`KT-43198`](https://youtrack.jetbrains.com/issue/KT-43198) Native: support `init` blocks inside inline classes
|
||||
|
||||
### Compiler
|
||||
|
||||
#### New Features
|
||||
|
||||
- [`KT-28055`](https://youtrack.jetbrains.com/issue/KT-28055) Consider supporting `init` blocks inside inline classes
|
||||
- [`KT-28055`](https://youtrack.jetbrains.com/issue/KT-28055) Support `init` blocks inside inline classes
|
||||
- [`KT-28056`](https://youtrack.jetbrains.com/issue/KT-28056) Consider supporting non-public primary constructors for inline classes
|
||||
- [`KT-41265`](https://youtrack.jetbrains.com/issue/KT-41265) Support noarg compiler plugin for JVM IR
|
||||
- [`KT-42094`](https://youtrack.jetbrains.com/issue/KT-42094) Allow open callable members in expect interfaces
|
||||
- [`KT-43129`](https://youtrack.jetbrains.com/issue/KT-43129) FIR: Support OverloadResolutionByLambdaReturnType
|
||||
- [`KT-43592`](https://youtrack.jetbrains.com/issue/KT-43592) Promote JVM IR compiler backend to Beta
|
||||
- [`KT-43919`](https://youtrack.jetbrains.com/issue/KT-43919) Support loading Java annotations on base classes and implementing interfaces' type arguments
|
||||
- [`KT-44021`](https://youtrack.jetbrains.com/issue/KT-44021) Enable JVM IR backend by default in 1.5
|
||||
|
||||
#### Performance Improvements
|
||||
|
||||
@@ -40,12 +37,25 @@
|
||||
|
||||
#### Fixes
|
||||
|
||||
- [`KT-11454`](https://youtrack.jetbrains.com/issue/KT-11454) Load annotations on TYPE_USE/TYPE_PARAMETER positions from Java class-files
|
||||
- [`KT-11732`](https://youtrack.jetbrains.com/issue/KT-11732) Verify error for generic interface method invocation with default parameters
|
||||
- [`KT-14612`](https://youtrack.jetbrains.com/issue/KT-14612) "ISE: Recursive call in a lazy value" during processing of a (weakly) recursive type alias
|
||||
- [`KT-18344`](https://youtrack.jetbrains.com/issue/KT-18344) Upper bound of a typealias type parameter is not reported correctly if it contains the typealias itself
|
||||
- [`KT-18768`](https://youtrack.jetbrains.com/issue/KT-18768) @Notnull annotation from Java does not work with varargs
|
||||
- [`KT-20548`](https://youtrack.jetbrains.com/issue/KT-20548) java.lang.IllegalStateException: Illegal class container on simple Java code parsing
|
||||
- [`KT-22465`](https://youtrack.jetbrains.com/issue/KT-22465) Excessive synthetic method for private setter from superclass
|
||||
- [`KT-23816`](https://youtrack.jetbrains.com/issue/KT-23816) Inline classes: constants and annotations
|
||||
- [`KT-24158`](https://youtrack.jetbrains.com/issue/KT-24158) AE: No receiver found on incomplete code with $-signs
|
||||
- [`KT-24392`](https://youtrack.jetbrains.com/issue/KT-24392) Nullability of Java arrays is read incorrectly if @Nullable annotation has both targets TYPE_USE and VALUE_PARAMETER
|
||||
- [`KT-26229`](https://youtrack.jetbrains.com/issue/KT-26229) Lambda/anonymous function argument in parentheses is not supported for callsInPlace effect
|
||||
- [`KT-29735`](https://youtrack.jetbrains.com/issue/KT-29735) KNPE at `KtEnumEntrySuperclassReferenceExpression.getReferencedElement` with explicit type argument inside enum member constructor
|
||||
- [`KT-31389`](https://youtrack.jetbrains.com/issue/KT-31389) ClassFormatError with companion object in annotation with @JvmStatic
|
||||
- [`KT-31907`](https://youtrack.jetbrains.com/issue/KT-31907) ISE: UNIT_EXPECTED_TYPE on parsing array literal inside lambda with Unit return type
|
||||
- [`KT-32228`](https://youtrack.jetbrains.com/issue/KT-32228) Inconsistent boxing/unboxing for inline classes when interface is specialized by object expression
|
||||
- [`KT-32450`](https://youtrack.jetbrains.com/issue/KT-32450) Inline class incorrectly gets re-wrapped when provided to a function
|
||||
- [`KT-35849`](https://youtrack.jetbrains.com/issue/KT-35849) Missing nullability assertion on lambda return value if expected type has generic return value type
|
||||
- [`KT-35902`](https://youtrack.jetbrains.com/issue/KT-35902) Kotlin generates a private parameterless constructor for constructors taking inline class arguments with default values
|
||||
- [`KT-36399`](https://youtrack.jetbrains.com/issue/KT-36399) Gradually support TYPE_USE nullability annotations read from class-files
|
||||
- [`KT-36769`](https://youtrack.jetbrains.com/issue/KT-36769) JVM IR: Missing LVT entries for inline function (default) parameters at call site
|
||||
- [`KT-36982`](https://youtrack.jetbrains.com/issue/KT-36982) JVM IR: SAM adapter classes are generated as synthetic
|
||||
- [`KT-37007`](https://youtrack.jetbrains.com/issue/KT-37007) JVM IR: extraneous property accessors are generated in multifile facade for InlineOnly property
|
||||
@@ -57,11 +67,18 @@
|
||||
- [`KT-39709`](https://youtrack.jetbrains.com/issue/KT-39709) [FIR] False positive UNINITIALIZED_VARIABLE in presence of complex graph with jumps
|
||||
- [`KT-39923`](https://youtrack.jetbrains.com/issue/KT-39923) Result.Failure will get wrapped with Success when using with RxJava
|
||||
- [`KT-40198`](https://youtrack.jetbrains.com/issue/KT-40198) '$default' methods in 'kotlin/test/AssertionsKt' generated as non-synthetic by JVM_IR
|
||||
- [`KT-40200`](https://youtrack.jetbrains.com/issue/KT-40200) IDE: Multiple top-level main functions in different files: broken highlighting, "No descriptor resolved for FUN"
|
||||
- [`KT-40262`](https://youtrack.jetbrains.com/issue/KT-40262) ACC_DEPRECATED flag not generated for property getter delegate in multifile class facade in JVM_IR
|
||||
- [`KT-40282`](https://youtrack.jetbrains.com/issue/KT-40282) Inline class wrapping Any gets double boxed
|
||||
- [`KT-40464`](https://youtrack.jetbrains.com/issue/KT-40464) JVM_IR does not generate LINENUMBER at closing brace of (suspend) lambda
|
||||
- [`KT-40500`](https://youtrack.jetbrains.com/issue/KT-40500) Warnings reporting by Java nullability annotations doesn't work for not top-level types
|
||||
- [`KT-40926`](https://youtrack.jetbrains.com/issue/KT-40926) IDE import actions do not add required import for convention `invoke()` extension call
|
||||
- [`KT-40948`](https://youtrack.jetbrains.com/issue/KT-40948) IllegalAccessError while initializing val property in EXACTLY_ONCE lambda that is passed to another function
|
||||
- [`KT-40991`](https://youtrack.jetbrains.com/issue/KT-40991) NI: UNRESOLVED_REFERENCE_WRONG_RECEIVER instead of FUNCTION_EXPECTED with convention `invoke` call
|
||||
- [`KT-41163`](https://youtrack.jetbrains.com/issue/KT-41163) Double wrapped value in Result class after map operation
|
||||
- [`KT-41284`](https://youtrack.jetbrains.com/issue/KT-41284) Spring CGLIB proxies break auto-generated data class componentN and copy methods when using JVM IR
|
||||
- [`KT-41468`](https://youtrack.jetbrains.com/issue/KT-41468) JVM IR: IllegalAccessError on access to abstract base member from another package, from anonymous object inside abstract class
|
||||
- [`KT-41491`](https://youtrack.jetbrains.com/issue/KT-41491) UNRESOLVED_REFERENCE_WRONG_RECEIVER instead of FUNCTION_EXPECTED when invoking non-functional value as a function
|
||||
- [`KT-41493`](https://youtrack.jetbrains.com/issue/KT-41493) JVM IR: names of classes for local delegated variables contain the variable name twice
|
||||
- [`KT-41792`](https://youtrack.jetbrains.com/issue/KT-41792) [FIR] Introduce & use ConeAttribute.UnsafeVariance
|
||||
- [`KT-41793`](https://youtrack.jetbrains.com/issue/KT-41793) [FIR] Make captured types accessible at the end of resolve
|
||||
@@ -70,13 +87,16 @@
|
||||
- [`KT-41841`](https://youtrack.jetbrains.com/issue/KT-41841) JVM IR: delegates for private functions with default arguments are generated in multifile classes
|
||||
- [`KT-41857`](https://youtrack.jetbrains.com/issue/KT-41857) Flaky 'ConcurrentModificationException' through `kotlin.serialization.DescriptorSerializer`
|
||||
- [`KT-41903`](https://youtrack.jetbrains.com/issue/KT-41903) JVM IR: do not generate LineNumberTable in auto-generated members of data classes
|
||||
- [`KT-41911`](https://youtrack.jetbrains.com/issue/KT-41911) JVM IR: nested big-arity function calls are not lowered
|
||||
- [`KT-41957`](https://youtrack.jetbrains.com/issue/KT-41957) JVM IR: step into suspend function goes to the first line of the file
|
||||
- [`KT-41960`](https://youtrack.jetbrains.com/issue/KT-41960) JVM IR: smart step into members implemented with delegation to interface doesn't work
|
||||
- [`KT-41961`](https://youtrack.jetbrains.com/issue/KT-41961) JVM IR: line numbers are not generated in JvmMultifileClass facade declarations
|
||||
- [`KT-41962`](https://youtrack.jetbrains.com/issue/KT-41962) JVM IR: intermittent -1 line numbers in the state machine cause double stepping in the debugger
|
||||
- [`KT-42001`](https://youtrack.jetbrains.com/issue/KT-42001) Cannot resolve symbol: AssertionError: Module <sdk 1.8> is not contained in his own dependencies
|
||||
- [`KT-42002`](https://youtrack.jetbrains.com/issue/KT-42002) JVM / IR: IllegalStateException: "No mapping for symbol: VAR IR_TEMPORARY_VARIABLE" caused by named arguments
|
||||
- [`KT-42021`](https://youtrack.jetbrains.com/issue/KT-42021) JVM / IR: "IndexOutOfBoundsException: Index 0 out of bounds for length 0" during IR lowering with suspend conversion
|
||||
- [`KT-42033`](https://youtrack.jetbrains.com/issue/KT-42033) JVM IR: accidental override in Map subclass with custom implementations of some members
|
||||
- [`KT-42036`](https://youtrack.jetbrains.com/issue/KT-42036) IR: "AssertionError: TypeAliasDescriptor expected: deserialized class Nothing" when referencing typealias with @UnsafeVariance
|
||||
- [`KT-42043`](https://youtrack.jetbrains.com/issue/KT-42043) JVM IR: Don't generate collection stubs when implementing methods with more specific return types
|
||||
- [`KT-42044`](https://youtrack.jetbrains.com/issue/KT-42044) Compiler error when lambda with contract surrounded with parentheses
|
||||
- [`KT-42114`](https://youtrack.jetbrains.com/issue/KT-42114) JVM_IR generates stub for 'removeIf' in abstract classes implementing 'List' and 'Set'
|
||||
@@ -103,7 +123,9 @@
|
||||
- [`KT-42384`](https://youtrack.jetbrains.com/issue/KT-42384) FIR (BE): top-level field has no parent class in BE
|
||||
- [`KT-42496`](https://youtrack.jetbrains.com/issue/KT-42496) FIR resolve: synthetic property is written but has no setter
|
||||
- [`KT-42517`](https://youtrack.jetbrains.com/issue/KT-42517) FIR: exception in BE for recursive inline call
|
||||
- [`KT-42530`](https://youtrack.jetbrains.com/issue/KT-42530) "AssertionError: No type for resolved lambda argument" on attempting to assign a Pair to a couple of values in a scratch file
|
||||
- [`KT-42601`](https://youtrack.jetbrains.com/issue/KT-42601) [FIR] Inherited declaration clash for stdlib inheritors
|
||||
- [`KT-42622`](https://youtrack.jetbrains.com/issue/KT-42622) NI: IllegalStateException for if expression with method reference inside flow
|
||||
- [`KT-42642`](https://youtrack.jetbrains.com/issue/KT-42642) ISE: No `getProgressionLastElement` for progression type IntProgressionType
|
||||
- [`KT-42650`](https://youtrack.jetbrains.com/issue/KT-42650) JVM IR: extraneous nullability annotation on a generic function of a flexible type
|
||||
- [`KT-42656`](https://youtrack.jetbrains.com/issue/KT-42656) FIR2IR: unsupported callable reference for Java field
|
||||
@@ -117,6 +139,8 @@
|
||||
- [`KT-42933`](https://youtrack.jetbrains.com/issue/KT-42933) JVM / IR: "AnalyzerException: Expected an object reference, but found I" with local delegate in inline class
|
||||
- [`KT-43006`](https://youtrack.jetbrains.com/issue/KT-43006) JVM/JVM_IR: do not generate no-arg constructor for constructor with default arguments if there are inline class types in the signature
|
||||
- [`KT-43017`](https://youtrack.jetbrains.com/issue/KT-43017) JVM / IR: AssertionError when callable reference passed into a function requiring a suspendable function
|
||||
- [`KT-43051`](https://youtrack.jetbrains.com/issue/KT-43051) JVM IR: extraneous methods overridding default (Java 8) collection methods in inline class that extends MutableList
|
||||
- [`KT-43067`](https://youtrack.jetbrains.com/issue/KT-43067) Inner class declaration inside inline class should be prohibited
|
||||
- [`KT-43068`](https://youtrack.jetbrains.com/issue/KT-43068) JVM IR: no generic signatures for explicitly written methods in a List subclass, whose signature coincides with MutableList methods
|
||||
- [`KT-43132`](https://youtrack.jetbrains.com/issue/KT-43132) JVM / IR: Method name '<get-...>' in class '...$screenTexts$1$1' cannot be represented in dex format.
|
||||
- [`KT-43145`](https://youtrack.jetbrains.com/issue/KT-43145) JVM IR: $default methods in multi-file facades are generated as non-synthetic final
|
||||
@@ -125,6 +149,7 @@
|
||||
- [`KT-43199`](https://youtrack.jetbrains.com/issue/KT-43199) JVM IR: synthetic flag for deprecated-hidden is not generated for DeprecatedSinceKotlin and deprecation from override
|
||||
- [`KT-43207`](https://youtrack.jetbrains.com/issue/KT-43207) JVM IR: no collection stub for `iterator` is generated on extending AbstractCollection
|
||||
- [`KT-43217`](https://youtrack.jetbrains.com/issue/KT-43217) JVM_IR: Multiple FAKE_OVERRIDES for java methods using @NonNull Double and java double
|
||||
- [`KT-43225`](https://youtrack.jetbrains.com/issue/KT-43225) Confusing message of warning NULLABLE_TYPE_PARAMETER_AGAINST_NOT_NULL_TYPE_PARAMETER
|
||||
- [`KT-43226`](https://youtrack.jetbrains.com/issue/KT-43226) "Incompatible stack heights" with non-local return to outer lambda inside suspend lambda
|
||||
- [`KT-43242`](https://youtrack.jetbrains.com/issue/KT-43242) JVM / IR: "AnalyzerException: Expected I, but found R" caused by `when` inside object with @Nullable Integer subject
|
||||
- [`KT-43249`](https://youtrack.jetbrains.com/issue/KT-43249) Wrong code generated for suspend lambdas with inline class parameters
|
||||
@@ -133,25 +158,59 @@
|
||||
- [`KT-43327`](https://youtrack.jetbrains.com/issue/KT-43327) JVM_IR: No deprecated or synthetic flag for accessors of deprecated-hidden property of unsigned type
|
||||
- [`KT-43332`](https://youtrack.jetbrains.com/issue/KT-43332) FIR: Smart casts lead to false-positive ambiguity
|
||||
- [`KT-43370`](https://youtrack.jetbrains.com/issue/KT-43370) JVM IR: No deprecated flag for getter of deprecated property copied via delegation by interface
|
||||
- [`KT-43459`](https://youtrack.jetbrains.com/issue/KT-43459) JVM_IR. Wrong signature for synthetic $annotations method for extension property on nullable primitive
|
||||
- [`KT-43478`](https://youtrack.jetbrains.com/issue/KT-43478) NI: "IndexOutOfBoundsException: Index: 3, Size: 3" caused by `is` check with raw type inside `if` condition with `when` inside
|
||||
- [`KT-43519`](https://youtrack.jetbrains.com/issue/KT-43519) JVM_IR. External functions generated differently in multi file facades
|
||||
- [`KT-43524`](https://youtrack.jetbrains.com/issue/KT-43524) JVM_IR. Missed deprecation flag on companion @JvmStatic property accessor
|
||||
- [`KT-43525`](https://youtrack.jetbrains.com/issue/KT-43525) Prohibit JvmOverloads on declarations with inline class types in parameters
|
||||
- [`KT-43536`](https://youtrack.jetbrains.com/issue/KT-43536) JVM IR: IllegalStateException is not caught by runCatching under Deferred.await() with kotlinx.coroutines
|
||||
- [`KT-43562`](https://youtrack.jetbrains.com/issue/KT-43562) JVM IR: incorrect mangling for Collection.size in unsigned arrays
|
||||
- [`KT-43584`](https://youtrack.jetbrains.com/issue/KT-43584) [FIR] Java annotations with named arguments aren't loaded correctly
|
||||
- [`KT-43587`](https://youtrack.jetbrains.com/issue/KT-43587) Invalid default parameter value in expect actual declaration on jvm
|
||||
- [`KT-43630`](https://youtrack.jetbrains.com/issue/KT-43630) "AssertionError: Number of arguments should not be less than number of parameters" during capturing intersection raw type with star projection
|
||||
- [`KT-43698`](https://youtrack.jetbrains.com/issue/KT-43698) NoSuchMethodError for inline class implementing interface with @JvmDefault methods, -Xjvm-default=enable
|
||||
- [`KT-43741`](https://youtrack.jetbrains.com/issue/KT-43741) Report error on inline class implementing 'kotlin.Cloneable'
|
||||
- [`KT-43845`](https://youtrack.jetbrains.com/issue/KT-43845) org.jetbrains.kotlin.codegen.CompilationException: Back-end (JVM) Internal error: Failed to generate expression: KtBlockExpression
|
||||
- [`KT-43956`](https://youtrack.jetbrains.com/issue/KT-43956) NI: "Error type encountered – UninferredParameterTypeConstructor" on "try" and other constructs with code block as a value
|
||||
- [`KT-44055`](https://youtrack.jetbrains.com/issue/KT-44055) Left uninferred type parameter for callable references inside special calls
|
||||
- [`KT-44113`](https://youtrack.jetbrains.com/issue/KT-44113) Compiler frontend exception: Number of arguments should not be less than number of parameters, but: parameters=2, args=1
|
||||
- [`KT-44145`](https://youtrack.jetbrains.com/issue/KT-44145) No highlighting for not initialized base constructor and NoSuchMethodError in Android plugin
|
||||
|
||||
### IDE
|
||||
|
||||
#### New Features
|
||||
|
||||
- [`KT-44075`](https://youtrack.jetbrains.com/issue/KT-44075) Sealed interfaces: New Kotlin Class/File menu update
|
||||
|
||||
#### Fixes
|
||||
|
||||
- [`KT-29454`](https://youtrack.jetbrains.com/issue/KT-29454) Light class with unexpected name when using obfuscated library
|
||||
- [`KT-31553`](https://youtrack.jetbrains.com/issue/KT-31553) Complete Statement: Wrong auto-insertion of closing curly brace for a code block
|
||||
- [`KT-33466`](https://youtrack.jetbrains.com/issue/KT-33466) IDE generates incorrect `external override` with body for overriding `open external` method
|
||||
- [`KT-39458`](https://youtrack.jetbrains.com/issue/KT-39458) Add CLI support for UL classes
|
||||
- [`KT-40403`](https://youtrack.jetbrains.com/issue/KT-40403) UAST: PsiMethod for invoked extension function/property misses `@receiver:` annotations
|
||||
- [`KT-41406`](https://youtrack.jetbrains.com/issue/KT-41406) Kotlin doesn't report annotations for type arguments (no way to add `@Nls`, `@NonNls` annotations to String collections in Kotlin)
|
||||
- [`KT-41420`](https://youtrack.jetbrains.com/issue/KT-41420) UAST does not return information about type annotations
|
||||
- [`KT-42194`](https://youtrack.jetbrains.com/issue/KT-42194) OOME: Java heap space from incremental compilation
|
||||
- [`KT-42754`](https://youtrack.jetbrains.com/issue/KT-42754) MPP: no smart cast for Common nullable property used in platform module
|
||||
- [`KT-42821`](https://youtrack.jetbrains.com/issue/KT-42821) MPP, IDE: Platform-specific errors are reported even when build doesn't target that platform
|
||||
- [`KT-44116`](https://youtrack.jetbrains.com/issue/KT-44116) Add language version 1.5 to the compiler configuration preferences
|
||||
- [`KT-44523`](https://youtrack.jetbrains.com/issue/KT-44523) IDE notification for trying new JVM backend
|
||||
- [`KT-44543`](https://youtrack.jetbrains.com/issue/KT-44543) Kotlin's LowMemoryWatcher leaks on Kotlin plugin unload
|
||||
|
||||
### IDE. Android
|
||||
|
||||
- [`KT-42381`](https://youtrack.jetbrains.com/issue/KT-42381) MPP: Bad IDEA dependencies: JVM module depending on built artifact instead of sources of module with Android Plugin applied
|
||||
|
||||
### IDE. Completion
|
||||
|
||||
- [`KT-44016`](https://youtrack.jetbrains.com/issue/KT-44016) Code completion: support for "sealed interface"
|
||||
- [`KT-44250`](https://youtrack.jetbrains.com/issue/KT-44250) Code completion does not work in when expression with sealed type argument
|
||||
|
||||
### IDE. Gradle. Script
|
||||
|
||||
- [`KT-39105`](https://youtrack.jetbrains.com/issue/KT-39105) AE “JvmBuiltins has not been initialized properly” after creating new Gradle/Kotlin-based project via old Project Wizard
|
||||
|
||||
### IDE. Inspections and Intentions
|
||||
|
||||
#### New Features
|
||||
@@ -162,6 +221,9 @@
|
||||
- [`KT-34533`](https://youtrack.jetbrains.com/issue/KT-34533) INLINE_CLASS_CONSTRUCTOR_NOT_FINAL_READ_ONLY_PARAMETER: Add quickfix "Add val to parameter"
|
||||
- [`KT-35215`](https://youtrack.jetbrains.com/issue/KT-35215) Quickfix for CONST_VAL_NOT_TOP_LEVEL_OR_OBJECT to remove `const` modifier
|
||||
- [`KT-40251`](https://youtrack.jetbrains.com/issue/KT-40251) Intention action to evaluate compile time expression
|
||||
- [`KT-44017`](https://youtrack.jetbrains.com/issue/KT-44017) Sealed interfaces: Java side Inspection "implementation of Kotlin sealed interface is forbidden"
|
||||
- [`KT-43941`](https://youtrack.jetbrains.com/issue/KT-43941) Sealed interfaces: intention to extend class/interface
|
||||
- [`KT-44043`](https://youtrack.jetbrains.com/issue/KT-44043) Sealed interfaces: quickfix to move class/interface to proper location
|
||||
|
||||
#### Fixes
|
||||
|
||||
@@ -200,10 +262,27 @@
|
||||
|
||||
- [`KT-43760`](https://youtrack.jetbrains.com/issue/KT-43760) KJS: Debugging Kotlin code for Node.js runtime doesn't work
|
||||
|
||||
### IDE. Misc
|
||||
|
||||
- [`KT-44018`](https://youtrack.jetbrains.com/issue/KT-44018) Sealed interfaces: IDE side implementation for hierarchy provider
|
||||
|
||||
### IDE. Multiplatform
|
||||
|
||||
- [`KT-40814`](https://youtrack.jetbrains.com/issue/KT-40814) MISSING_DEPENDENCY_CLASS when consuming native-shared library in a source-set with fewer targets than library has
|
||||
|
||||
### IDE. Run Configurations
|
||||
|
||||
- [`KT-34535`](https://youtrack.jetbrains.com/issue/KT-34535) Unable to run common tests on Android via gutter icon in a multiplatform project
|
||||
|
||||
### IDE. Scratch
|
||||
|
||||
- [`KT-25038`](https://youtrack.jetbrains.com/issue/KT-25038) Scratch: Destructuring declaration produces an unresolved reference
|
||||
- [`KT-43415`](https://youtrack.jetbrains.com/issue/KT-43415) Kotlin scratch file could not be run and could lead to dead lock
|
||||
|
||||
### IDE. Script
|
||||
|
||||
- [`KT-44117`](https://youtrack.jetbrains.com/issue/KT-44117) IDE / Scripts: custom kotlin script definitions aren't loaded
|
||||
|
||||
### JavaScript
|
||||
|
||||
#### Fixes
|
||||
@@ -214,35 +293,37 @@
|
||||
- [`KT-40686`](https://youtrack.jetbrains.com/issue/KT-40686) KJS: Uncaught ReferenceError caused by external class as type inside eventListener in init block
|
||||
- [`KT-40771`](https://youtrack.jetbrains.com/issue/KT-40771) KJS / IR: "ReferenceError: Metadata is not defined" caused by default parameter value in inner class constructor
|
||||
- [`KT-41032`](https://youtrack.jetbrains.com/issue/KT-41032) KJS / IR: "AssertionError: Assertion failed" caused by class that is delegated to inherited interface
|
||||
- [`KT-41076`](https://youtrack.jetbrains.com/issue/KT-41076) KJS / IR: "AssertionError: Assertion failed" caused by overridden extensiion function in child class
|
||||
- [`KT-41771`](https://youtrack.jetbrains.com/issue/KT-41771) KJS / IR: IndexOutOfBoundsException "Index 0 out of bounds for length 0" caused by inline class with List in primary constructor and vararg in secondary
|
||||
- [`KT-42025`](https://youtrack.jetbrains.com/issue/KT-42025) KJS / IR: IrConstructorCallImpl: No such type argument slot: 0
|
||||
- [`KT-42112`](https://youtrack.jetbrains.com/issue/KT-42112) KJS: StackOverflowError on @JsExport in case of name clash with function with Enum parameter with star-projection
|
||||
- [`KT-42262`](https://youtrack.jetbrains.com/issue/KT-42262) KJS: `break`-statements without label are ignored in a `when`
|
||||
- [`KT-42357`](https://youtrack.jetbrains.com/issue/KT-42357) KotlinJS - external class constructor with vararg does not correctly handle spread operator.
|
||||
- [`KT-42364`](https://youtrack.jetbrains.com/issue/KT-42364) KJS: Properties of interface delegate are non-configurable
|
||||
- [`KT-43212`](https://youtrack.jetbrains.com/issue/KT-43212) JS IR: support `init` blocks inside inline classes
|
||||
- [`KT-43222`](https://youtrack.jetbrains.com/issue/KT-43222) KJS IR: prototype lazy initialization for top-level properties like in JVM
|
||||
- [`KT-43313`](https://youtrack.jetbrains.com/issue/KT-43313) KJS / IR: "Can't find name for declaration FUN" for secondary constructor
|
||||
- [`KT-43901`](https://youtrack.jetbrains.com/issue/KT-43901) Call to enum values() method from enum companion object leads to non-initialized enum instances
|
||||
|
||||
### KMM Plugin
|
||||
|
||||
- [`KT-41677`](https://youtrack.jetbrains.com/issue/KT-41677) Could not launch iOS project with custom display name
|
||||
- [`KT-42463`](https://youtrack.jetbrains.com/issue/KT-42463) Launch common tests on local JVM via run gutter
|
||||
- [`KT-42463`](https://youtrack.jetbrains.com/issue/KT-42463) Launch common tests for Android on local JVM via run gutter
|
||||
- [`KT-43188`](https://youtrack.jetbrains.com/issue/KT-43188) NoSuchMethodError in New Module Wizard of KMM Project
|
||||
|
||||
### Libraries
|
||||
|
||||
- [`KT-41112`](https://youtrack.jetbrains.com/issue/KT-41112) Docs: add more details about bit shift operations
|
||||
- [`KT-41278`](https://youtrack.jetbrains.com/issue/KT-41278) map.entries.contains can return false if the argument is not MutableEntry
|
||||
- [`KT-41356`](https://youtrack.jetbrains.com/issue/KT-41356) Incorrect documentation for `rangeTo` function
|
||||
- [`KT-44456`](https://youtrack.jetbrains.com/issue/KT-44456) Introduce locale-agnostic API for case conversions
|
||||
- [`KT-44458`](https://youtrack.jetbrains.com/issue/KT-44458) Introduce new Char-to-code and Char-to-digit conversions
|
||||
|
||||
### Middle-end. IR
|
||||
|
||||
- [`KT-41765`](https://youtrack.jetbrains.com/issue/KT-41765) [Native/IR] Could not resolveFakeOverride()
|
||||
- [`KT-42054`](https://youtrack.jetbrains.com/issue/KT-42054) Psi2ir: "RuntimeException: IrSimpleFunctionSymbolImpl is already bound" when using result of function with overload resolution by lambda return type
|
||||
|
||||
### Native
|
||||
|
||||
- [`KT-42822`](https://youtrack.jetbrains.com/issue/KT-42822) Kotlin/Native Worker leaks ObjC/Swift autorelease references (and indirectly bridged K/N references) on Darwin targets
|
||||
- [`KT-42397`](https://youtrack.jetbrains.com/issue/KT-42397) Reverse C interop usage of companion object reports spurious leaks
|
||||
|
||||
### Native. C and ObjC Import
|
||||
|
||||
- [`KT-42412`](https://youtrack.jetbrains.com/issue/KT-42412) [C-interop] Modality of generated property accessors is always FINAL
|
||||
@@ -250,6 +331,7 @@
|
||||
### Native. ObjC Export
|
||||
|
||||
- [`KT-38530`](https://youtrack.jetbrains.com/issue/KT-38530) Native: values() method of enum classes is not exposed to Objective-C/Swift
|
||||
- [`KT-43599`](https://youtrack.jetbrains.com/issue/KT-43599) K/N: Unbound symbols not allowed
|
||||
|
||||
### Native. Platform libraries
|
||||
|
||||
@@ -265,6 +347,7 @@
|
||||
|
||||
### Native. Stdlib
|
||||
|
||||
- [`KT-42172`](https://youtrack.jetbrains.com/issue/KT-42172) Kotlin/Native: StableRef.dispose race condition on Kotlin deinitRuntime
|
||||
- [`KT-42428`](https://youtrack.jetbrains.com/issue/KT-42428) Inconsistent behavior of map.entries on Kotlin.Native
|
||||
|
||||
### Reflection
|
||||
@@ -273,6 +356,7 @@
|
||||
|
||||
### Tools. CLI
|
||||
|
||||
- [`KT-43294`](https://youtrack.jetbrains.com/issue/KT-43294) Support `-no-stdlib` option for the `kotlin` runner
|
||||
- [`KT-43406`](https://youtrack.jetbrains.com/issue/KT-43406) JVM: produce deterministic jar files if -d option value is a .jar file
|
||||
|
||||
### Tools. CLI. Native
|
||||
@@ -283,6 +367,7 @@
|
||||
|
||||
- [`KT-41764`](https://youtrack.jetbrains.com/issue/KT-41764) KJS /IR IllegalStateException: "Symbol for public kotlin/arrayOf is unbound" with serialization plugin
|
||||
- [`KT-42976`](https://youtrack.jetbrains.com/issue/KT-42976) kotlinx.serialization + JVM IR: NPE on annotation with @SerialInfo
|
||||
- [`KT-43725`](https://youtrack.jetbrains.com/issue/KT-43725) Prohibit inner and local classes in kotlin-noarg
|
||||
|
||||
### Tools. Gradle
|
||||
|
||||
@@ -292,6 +377,8 @@
|
||||
- [`KT-42058`](https://youtrack.jetbrains.com/issue/KT-42058) Support moduleName option in Kotlin Gradle plugin for JVM
|
||||
- [`KT-43054`](https://youtrack.jetbrains.com/issue/KT-43054) Implementation of `AbstractKotlinTarget#buildAdhocComponentsFromKotlinVariants` breaks configuration caching
|
||||
- [`KT-43489`](https://youtrack.jetbrains.com/issue/KT-43489) Incremental compilation - unable to find history files causing full recompilation
|
||||
- [`KT-43740`](https://youtrack.jetbrains.com/issue/KT-43740) Gradle out-of-process runner fails with unclear diagnostics if build directory does not exist
|
||||
- [`KT-43895`](https://youtrack.jetbrains.com/issue/KT-43895) Fix cacheability warnings for the Kotlin plugins
|
||||
|
||||
### Tools. Gradle. JS
|
||||
|
||||
@@ -299,6 +386,10 @@
|
||||
- [`KT-42462`](https://youtrack.jetbrains.com/issue/KT-42462) NPM dependency declaration with Groovy interpolated string
|
||||
- [`KT-42954`](https://youtrack.jetbrains.com/issue/KT-42954) Kotlin/JS: IDE import after changing `kotlin.js.externals.output.format` does not re-generate externals
|
||||
- [`KT-43535`](https://youtrack.jetbrains.com/issue/KT-43535) Common webpack configuration breaks on lambda serialization in some cases
|
||||
- [`KT-43668`](https://youtrack.jetbrains.com/issue/KT-43668) PackageJson task use file dependencies as is (files and directories), but only files necessary
|
||||
- [`KT-43793`](https://youtrack.jetbrains.com/issue/KT-43793) nodeArgs in NodeJsExec task
|
||||
- [`KT-43842`](https://youtrack.jetbrains.com/issue/KT-43842) KJS: Invalid `output.library` support for `null` value
|
||||
- [`KT-44104`](https://youtrack.jetbrains.com/issue/KT-44104) KJS / Gradle: An ability to pass jvm args to K2JSDce process
|
||||
|
||||
### Tools. Gradle. Multiplatform
|
||||
|
||||
@@ -306,6 +397,7 @@
|
||||
- [`KT-42413`](https://youtrack.jetbrains.com/issue/KT-42413) [MPP/gradle] `withJava` breaks build on 1.4.20-M1
|
||||
- [`KT-43141`](https://youtrack.jetbrains.com/issue/KT-43141) Gradle / Configuration cache: NPE from org.jetbrains.kotlin.gradle.tasks.KotlinCompileCommon.getKotlinOptions() on reusing configuration cache for task compileCommonMainKotlinMetadata
|
||||
- [`KT-43329`](https://youtrack.jetbrains.com/issue/KT-43329) Gradle / Configuration cache: IAE “Parameter specified as non-null is null: method KotlinMetadataTargetConfiguratorKt.isCompatibilityMetadataVariantEnabled, parameter $this$isCompatibilityMetadataVariantEnabled” on reusing configuration cache for task compileKotlinMetadata
|
||||
- [`KT-44298`](https://youtrack.jetbrains.com/issue/KT-44298) Kotlin 1.4.20+ MPP "root" module publication does not include the source JAR that used to be published in the -metadata modules
|
||||
|
||||
### Tools. Gradle. Native
|
||||
|
||||
@@ -315,12 +407,24 @@
|
||||
- [`KT-42849`](https://youtrack.jetbrains.com/issue/KT-42849) Gradle / Configuration cache: tasks nativeMetadataJar, runReleaseExecutableNative, runDebugExecutableNative are unsupported and fails on reusing configuration cache
|
||||
- [`KT-42938`](https://youtrack.jetbrains.com/issue/KT-42938) CocoaPods Gradle plugin: podBuildDependencies doesn't properly report xcodebuild failures
|
||||
- [`KT-43151`](https://youtrack.jetbrains.com/issue/KT-43151) Gradle / Configuration cache: UPAE “lateinit property binary has not been initialized” on reusing configuration cache for linkDebugExecutableNative, linkDebugTestNative, linkReleaseExecutableNative tasks
|
||||
- [`KT-40999`](https://youtrack.jetbrains.com/issue/KT-40999) CocoaPods Gradle plugin: Support custom cinterop options when declaring a pod dependency.
|
||||
- [`KT-43516`](https://youtrack.jetbrains.com/issue/KT-43516) Failed to resolve Kotin library [Multiple Multiplatform modules]
|
||||
|
||||
### Tools. Incremental Compile
|
||||
|
||||
- [`KT-42937`](https://youtrack.jetbrains.com/issue/KT-42937) another compilation fail (problem with compilation caches?)
|
||||
|
||||
### Tools. JPS
|
||||
|
||||
- [`KT-39536`](https://youtrack.jetbrains.com/issue/KT-39536) JPS compilation fails with IOException "storage is already closed"
|
||||
|
||||
### Tools. Parcelize
|
||||
|
||||
- [`KT-41553`](https://youtrack.jetbrains.com/issue/KT-41553) JVM IR, Parcelize: IrStarProjectionImpl cannot be cast to class IrTypeProjection
|
||||
|
||||
### Tools. Scripts
|
||||
|
||||
- [`KT-43534`](https://youtrack.jetbrains.com/issue/KT-43534) Allow running "main.kts" script that does not end in a "main.kts" filename (would allow kotlin scripting on GitHub Actions)
|
||||
|
||||
### Tools. kapt
|
||||
|
||||
- [`KT-34340`](https://youtrack.jetbrains.com/issue/KT-34340) Incremental annotation processor recompile all files (only if KAPT enabled).
|
||||
|
||||
10
ReadMe.md
10
ReadMe.md
@@ -59,8 +59,8 @@ You also can use [Gradle properties](https://docs.gradle.org/current/userguide/b
|
||||
Note: The JDK 6 for MacOS is not available on Oracle's site. You can install it by
|
||||
|
||||
```bash
|
||||
$ brew tap caskroom/versions
|
||||
$ brew cask install java6
|
||||
$ brew tap homebrew/cask-versions
|
||||
$ brew install --cask java6
|
||||
```
|
||||
|
||||
On Windows you might need to add long paths setting to the repo:
|
||||
@@ -109,13 +109,13 @@ Refer to [libraries/ReadMe.md](libraries/ReadMe.md) for details.
|
||||
|
||||
### Building for different versions of IntelliJ IDEA and Android Studio
|
||||
|
||||
Kotlin plugin is intended to work with several recent versions of IntelliJ IDEA and Android Studio. Each platform is allowed to have a different set of features and might provide a slightly different API. Instead of using several parallel Git branches, project stores everything in a single branch, but files may have counterparts with version extensions (\*.as32, \*.172, \*.181). The primary file is expected to be replaced with its counterpart when targeting non-default platform.
|
||||
Kotlin plugin is intended to work with several recent versions of IntelliJ IDEA and Android Studio. Each platform is allowed to have a different set of features and might provide a slightly different API. Instead of using several parallel Git branches, the project stores everything in a single branch, but files may have counterparts with version extensions (\*.as32, \*.172, \*.181). The primary file is expected to be replaced with its counterpart when targeting a non-default platform.
|
||||
|
||||
More detailed description of this scheme can be found at https://github.com/JetBrains/bunches/blob/master/ReadMe.md.
|
||||
A More detailed description of this scheme can be found at https://github.com/JetBrains/bunches/blob/master/ReadMe.md.
|
||||
|
||||
Usually, there's no need to care about multiple platforms as all features are enabled everywhere by default. Additional counterparts should be created if there's an expected difference in behavior or an incompatible API usage is required **and** there's no reasonable workaround to save source compatibility. Kotlin plugin contains a pre-commit check that shows a warning if a file has been updated without its counterparts.
|
||||
|
||||
Development for some particular platform is possible after 'switching' that can be done with [Bunch Tool](https://github.com/JetBrains/bunches/releases) from the command line.
|
||||
Development for some particular platform is possible after 'switching' that can be done with the [Bunch Tool](https://github.com/JetBrains/bunches/releases) from the command line.
|
||||
|
||||
```sh
|
||||
cd kotlin-project-dir
|
||||
|
||||
@@ -21,6 +21,7 @@ data class IncrementalModuleEntry(
|
||||
|
||||
class IncrementalModuleInfo(
|
||||
val projectRoot: File,
|
||||
val rootProjectBuildDir: File,
|
||||
val dirToModule: Map<File, IncrementalModuleEntry>,
|
||||
val nameToModules: Map<String, Set<IncrementalModuleEntry>>,
|
||||
val jarToClassListFile: Map<File, File>,
|
||||
@@ -28,6 +29,6 @@ class IncrementalModuleInfo(
|
||||
val jarToModule: Map<File, IncrementalModuleEntry>
|
||||
) : Serializable {
|
||||
companion object {
|
||||
private const val serialVersionUID = 0L
|
||||
private const val serialVersionUID = 1L
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,6 @@ pill {
|
||||
excludedDirs(
|
||||
"out",
|
||||
"buildSrc/build",
|
||||
"buildSrc/prepare-deps/android-dx/build",
|
||||
"buildSrc/prepare-deps/intellij-sdk/build"
|
||||
)
|
||||
}
|
||||
@@ -332,6 +331,7 @@ extra["tasksWithWarnings"] = listOf(
|
||||
":compiler:fir:checkers:compileKotlin",
|
||||
":compiler:fir:java:compileKotlin",
|
||||
":kotlin-scripting-compiler:compileKotlin",
|
||||
":kotlin-scripting-compiler:compileTestKotlin",
|
||||
":plugins:uast-kotlin:compileKotlin",
|
||||
":plugins:uast-kotlin:compileTestKotlin",
|
||||
":plugins:uast-kotlin-idea:compileKotlin"
|
||||
@@ -345,6 +345,7 @@ val coreLibProjects = listOfNotNull(
|
||||
":kotlin-stdlib-js",
|
||||
":kotlin-stdlib-jdk7",
|
||||
":kotlin-stdlib-jdk8",
|
||||
":kotlin-test",
|
||||
":kotlin-test:kotlin-test-annotations-common",
|
||||
":kotlin-test:kotlin-test-common",
|
||||
":kotlin-test:kotlin-test-jvm",
|
||||
@@ -471,7 +472,7 @@ allprojects {
|
||||
}
|
||||
}
|
||||
|
||||
if (!kotlinBuildProperties.isInJpsBuildIdeaSync && !kotlinBuildProperties.useFir) {
|
||||
if (!kotlinBuildProperties.isInJpsBuildIdeaSync && !kotlinBuildProperties.useFir && !kotlinBuildProperties.disableWerror) {
|
||||
// For compiler and stdlib, allWarningsAsErrors is configured in the corresponding "root" projects
|
||||
// (compiler/build.gradle.kts and libraries/commonConfiguration.gradle).
|
||||
val projectsWithWarningsAsErrors = listOf("core", "plugins").map { File(it).absoluteFile }
|
||||
@@ -637,7 +638,10 @@ tasks {
|
||||
|
||||
listOf("clean", "assemble", "install").forEach { taskName ->
|
||||
register("coreLibs${taskName.capitalize()}") {
|
||||
coreLibProjects.forEach { projectName -> dependsOn("$projectName:$taskName") }
|
||||
for (projectName in coreLibProjects) {
|
||||
if (projectName.startsWith(":kotlin-test:") && taskName == "install") continue
|
||||
dependsOn("$projectName:$taskName")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -953,7 +957,6 @@ tasks {
|
||||
dependsOn(
|
||||
":prepare:ide-plugin-dependencies:android-extensions-compiler-plugin-for-ide:publish",
|
||||
":prepare:ide-plugin-dependencies:allopen-compiler-plugin-for-ide:publish",
|
||||
":prepare:ide-plugin-dependencies:allopen-compiler-plugin-tests-for-ide:publish",
|
||||
":prepare:ide-plugin-dependencies:incremental-compilation-impl-tests-for-ide:publish",
|
||||
":prepare:ide-plugin-dependencies:kotlin-build-common-tests-for-ide:publish",
|
||||
":prepare:ide-plugin-dependencies:kotlin-compiler-for-ide:publish",
|
||||
@@ -975,9 +978,7 @@ tasks {
|
||||
":kotlin-stdlib-jdk7:publish",
|
||||
":kotlin-stdlib-jdk8:publish",
|
||||
":kotlin-reflect:publish",
|
||||
":kotlin-main-kts:publish",
|
||||
":kotlin-stdlib-js:publish",
|
||||
":kotlin-test:kotlin-test-js:publish"
|
||||
":kotlin-main-kts:publish"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,8 +81,6 @@ extra["intellijReleaseType"] = when {
|
||||
else -> "releases"
|
||||
}
|
||||
|
||||
extra["versions.androidDxSources"] = "5.0.0_r2"
|
||||
|
||||
extra["customDepsOrg"] = "kotlin.build"
|
||||
|
||||
repositories {
|
||||
|
||||
@@ -18,3 +18,5 @@ val KotlinBuildProperties.proguard: Boolean get() = postProcessing && getBoolean
|
||||
val KotlinBuildProperties.jarCompression: Boolean get() = getBoolean("kotlin.build.jar.compression", isTeamcityBuild)
|
||||
|
||||
val KotlinBuildProperties.ignoreTestFailures: Boolean get() = getBoolean("ignoreTestFailures", isTeamcityBuild)
|
||||
|
||||
val KotlinBuildProperties.disableWerror: Boolean get() = getBoolean("kotlin.build.disable.werror", false)
|
||||
|
||||
@@ -9,10 +9,13 @@
|
||||
|
||||
import org.gradle.api.GradleException
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.artifacts.Dependency
|
||||
import org.gradle.api.artifacts.ExternalModuleDependency
|
||||
import org.gradle.api.artifacts.ProjectDependency
|
||||
import org.gradle.api.artifacts.dsl.DependencyHandler
|
||||
import org.gradle.api.file.ConfigurableFileCollection
|
||||
import org.gradle.api.file.FileCollection
|
||||
import org.gradle.kotlin.dsl.accessors.runtime.addDependencyTo
|
||||
import org.gradle.kotlin.dsl.extra
|
||||
import org.gradle.kotlin.dsl.project
|
||||
import java.io.File
|
||||
@@ -112,6 +115,50 @@ fun DependencyHandler.projectTests(name: String): ProjectDependency = project(na
|
||||
fun DependencyHandler.projectRuntimeJar(name: String): ProjectDependency = project(name, configuration = "runtimeJar")
|
||||
fun DependencyHandler.projectArchives(name: String): ProjectDependency = project(name, configuration = "archives")
|
||||
|
||||
fun Project.testApiJUnit5(
|
||||
vintageEngine: Boolean = false,
|
||||
runner: Boolean = false,
|
||||
suiteApi: Boolean = false
|
||||
) {
|
||||
with(dependencies) {
|
||||
val platformVersion = commonVer("org.junit", "junit-bom")
|
||||
testApi(platform("org.junit:junit-bom:$platformVersion"))
|
||||
testApi("org.junit.jupiter:junit-jupiter")
|
||||
if (vintageEngine) {
|
||||
testApi("org.junit.vintage:junit-vintage-engine:$platformVersion")
|
||||
}
|
||||
val componentsVersion = commonVer("org.junit.platform", "")
|
||||
|
||||
val components = mutableListOf(
|
||||
"org.junit.platform:junit-platform-commons",
|
||||
"org.junit.platform:junit-platform-launcher"
|
||||
)
|
||||
if (runner) {
|
||||
components += "org.junit.platform:junit-platform-runner"
|
||||
}
|
||||
if (suiteApi) {
|
||||
components += "org.junit.platform:junit-platform-suite-api"
|
||||
}
|
||||
|
||||
for (component in components) {
|
||||
testApi("$component:$componentsVersion")
|
||||
}
|
||||
|
||||
addDependencyTo<ExternalModuleDependency>(this, "testImplementation", intellijDep()) {
|
||||
// This dependency is needed only for FileComparisonFailure
|
||||
includeJars("idea_rt", rootProject = rootProject)
|
||||
isTransitive = false
|
||||
}
|
||||
|
||||
// This is needed only for using FileComparisonFailure, which relies on JUnit 3 classes
|
||||
add("testRuntimeOnly", commonDep("junit:junit"))
|
||||
}
|
||||
}
|
||||
|
||||
private fun DependencyHandler.testApi(dependencyNotation: Any) {
|
||||
add("testApi", dependencyNotation)
|
||||
}
|
||||
|
||||
val Project.protobufVersion: String get() = findProperty("versions.protobuf") as String
|
||||
|
||||
val Project.protobufRepo: String
|
||||
|
||||
@@ -76,8 +76,6 @@ fun Project.jpsStandalone() = "kotlin.build:jps-standalone:${rootProject.extra["
|
||||
|
||||
fun Project.nodeJSPlugin() = "kotlin.build:NodeJS:${rootProject.extra["versions.idea.NodeJS"]}"
|
||||
|
||||
fun Project.androidDxJar() = "org.jetbrains.kotlin:android-dx:${rootProject.extra["versions.androidBuildTools"]}"
|
||||
|
||||
fun Project.jpsBuildTest() = "com.jetbrains.intellij.idea:jps-build-test:${rootProject.extra["versions.intellijSdk"]}"
|
||||
|
||||
fun Project.kotlinxCollectionsImmutable() = "org.jetbrains.kotlinx:kotlinx-collections-immutable-jvm:${rootProject.extra["versions.kotlinx-collections-immutable"]}"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2021 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.
|
||||
*/
|
||||
|
||||
@@ -71,62 +71,11 @@ class KotlinBuildPublishingPlugin @Inject constructor(
|
||||
create<MavenPublication>(PUBLICATION_NAME) {
|
||||
from(kotlinLibraryComponent)
|
||||
|
||||
pom {
|
||||
packaging = "jar"
|
||||
name.set(humanReadableName(project))
|
||||
description.set(project.description ?: humanReadableName(project))
|
||||
url.set("https://kotlinlang.org/")
|
||||
licenses {
|
||||
license {
|
||||
name.set("The Apache License, Version 2.0")
|
||||
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
|
||||
}
|
||||
}
|
||||
scm {
|
||||
url.set("https://github.com/JetBrains/kotlin")
|
||||
connection.set("scm:git:https://github.com/JetBrains/kotlin.git")
|
||||
developerConnection.set("scm:git:https://github.com/JetBrains/kotlin.git")
|
||||
}
|
||||
developers {
|
||||
developer {
|
||||
name.set("Kotlin Team")
|
||||
organization.set("JetBrains")
|
||||
organizationUrl.set("https://www.jetbrains.com")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
name = REPOSITORY_NAME
|
||||
url = file("${project.rootDir}/build/repo").toURI()
|
||||
configureKotlinPomAttributes(project)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val signingRequired = provider {
|
||||
project.findProperty("signingRequired")?.toString()?.toBoolean()
|
||||
?: project.property("isSonatypeRelease") as Boolean
|
||||
}
|
||||
|
||||
configure<SigningExtension> {
|
||||
setRequired(signingRequired)
|
||||
sign(extensions.getByType<PublishingExtension>().publications[PUBLICATION_NAME])
|
||||
useGpgCmd()
|
||||
}
|
||||
|
||||
tasks.withType<Sign>().configureEach {
|
||||
setOnlyIf { signingRequired.get() }
|
||||
}
|
||||
|
||||
tasks.register("install") {
|
||||
dependsOn(tasks.named("publishToMavenLocal"))
|
||||
}
|
||||
|
||||
tasks.named<PublishToMavenRepository>("publish${PUBLICATION_NAME}PublicationTo${REPOSITORY_NAME}Repository")
|
||||
.configureRepository()
|
||||
configureDefaultPublishing()
|
||||
}
|
||||
|
||||
companion object {
|
||||
@@ -137,13 +86,84 @@ class KotlinBuildPublishingPlugin @Inject constructor(
|
||||
const val COMPILE_CONFIGURATION = "publishedCompile"
|
||||
const val RUNTIME_CONFIGURATION = "publishedRuntime"
|
||||
|
||||
@OptIn(ExperimentalStdlibApi::class)
|
||||
fun humanReadableName(project: Project) =
|
||||
project.name.split("-").joinToString(separator = " ") { it.capitalize(Locale.ROOT) }
|
||||
}
|
||||
}
|
||||
|
||||
fun TaskProvider<PublishToMavenRepository>.configureRepository() = configure {
|
||||
@OptIn(ExperimentalStdlibApi::class)
|
||||
private fun humanReadableName(name: String) =
|
||||
name.split("-").joinToString(separator = " ") { it.capitalize(Locale.ROOT) }
|
||||
|
||||
fun MavenPublication.configureKotlinPomAttributes(project: Project, explicitDescription: String? = null) {
|
||||
val publication = this
|
||||
pom {
|
||||
packaging = "jar"
|
||||
name.set(humanReadableName(publication.artifactId))
|
||||
description.set(explicitDescription ?: project.description ?: humanReadableName(publication.artifactId))
|
||||
url.set("https://kotlinlang.org/")
|
||||
licenses {
|
||||
license {
|
||||
name.set("The Apache License, Version 2.0")
|
||||
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
|
||||
}
|
||||
}
|
||||
scm {
|
||||
url.set("https://github.com/JetBrains/kotlin")
|
||||
connection.set("scm:git:https://github.com/JetBrains/kotlin.git")
|
||||
developerConnection.set("scm:git:https://github.com/JetBrains/kotlin.git")
|
||||
}
|
||||
developers {
|
||||
developer {
|
||||
name.set("Kotlin Team")
|
||||
organization.set("JetBrains")
|
||||
organizationUrl.set("https://www.jetbrains.com")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun Project.configureDefaultPublishing() {
|
||||
configure<PublishingExtension> {
|
||||
repositories {
|
||||
maven {
|
||||
name = KotlinBuildPublishingPlugin.REPOSITORY_NAME
|
||||
url = file("${project.rootDir}/build/repo").toURI()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
configureSigning()
|
||||
|
||||
tasks.register("install") {
|
||||
dependsOn(tasks.named("publishToMavenLocal"))
|
||||
}
|
||||
|
||||
tasks.withType<PublishToMavenRepository>()
|
||||
.matching { it.name.endsWith("PublicationTo${KotlinBuildPublishingPlugin.REPOSITORY_NAME}Repository") }
|
||||
.all { configureRepository() }
|
||||
}
|
||||
|
||||
private fun Project.configureSigning() {
|
||||
val signingRequired = provider {
|
||||
project.findProperty("signingRequired")?.toString()?.toBoolean()
|
||||
?: project.property("isSonatypeRelease") as Boolean
|
||||
}
|
||||
|
||||
configure<SigningExtension> {
|
||||
setRequired(signingRequired)
|
||||
sign(extensions.getByType<PublishingExtension>().publications) // all publications
|
||||
useGpgCmd()
|
||||
}
|
||||
|
||||
tasks.withType<Sign>().configureEach {
|
||||
setOnlyIf { signingRequired.get() }
|
||||
}
|
||||
}
|
||||
|
||||
fun TaskProvider<PublishToMavenRepository>.configureRepository() =
|
||||
configure { configureRepository() }
|
||||
|
||||
private fun PublishToMavenRepository.configureRepository() {
|
||||
dependsOn(project.rootProject.tasks.named("preparePublication"))
|
||||
doFirst {
|
||||
val preparePublication = project.rootProject.tasks.named("preparePublication").get()
|
||||
|
||||
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright 2010-2021 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.
|
||||
*/
|
||||
|
||||
|
||||
@@ -51,11 +40,7 @@ fun Task.dependsOnKotlinPluginInstall() {
|
||||
":kotlin-gradle-plugin-model:install",
|
||||
":kotlin-reflect:install",
|
||||
":kotlin-annotation-processing-gradle:install",
|
||||
":kotlin-test:kotlin-test-common:install",
|
||||
":kotlin-test:kotlin-test-annotations-common:install",
|
||||
":kotlin-test:kotlin-test-jvm:install",
|
||||
":kotlin-test:kotlin-test-js:install",
|
||||
":kotlin-test:kotlin-test-junit:install",
|
||||
":kotlin-test:install",
|
||||
":kotlin-gradle-subplugin-example:install",
|
||||
":kotlin-stdlib-common:install",
|
||||
":kotlin-stdlib:install",
|
||||
|
||||
@@ -80,14 +80,6 @@ android {
|
||||
reflect0 {
|
||||
dimension "box"
|
||||
}
|
||||
|
||||
jvm80 {
|
||||
dimension "box"
|
||||
}
|
||||
|
||||
reflectjvm80 {
|
||||
dimension "box"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -44,10 +44,8 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager
|
||||
//keep it globally to avoid test grouping on TC
|
||||
private val generatedTestNames = hashSetOf<String>()
|
||||
|
||||
private val COMMON = FlavorConfig("common", 3);
|
||||
private val REFLECT = FlavorConfig("reflect", 1);
|
||||
private val JVM8 = FlavorConfig("jvm8", 1);
|
||||
private val JVM8REFLECT = FlavorConfig("reflectjvm8", 1);
|
||||
private val COMMON = FlavorConfig("common", 3)
|
||||
private val REFLECT = FlavorConfig("reflect", 1)
|
||||
|
||||
class FlavorConfig(private val prefix: String, val limit: Int) {
|
||||
|
||||
@@ -100,7 +98,7 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager
|
||||
it.setExecutable(true)
|
||||
}
|
||||
}
|
||||
File("./gradlew.bat").copyTo(File(projectRoot, "gradlew.bat"));
|
||||
File("./gradlew.bat").copyTo(File(projectRoot, "gradlew.bat"))
|
||||
val file = File(target, "gradle-wrapper.properties")
|
||||
file.readLines().map {
|
||||
when {
|
||||
@@ -156,8 +154,6 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager
|
||||
|
||||
COMMON.printStatistics()
|
||||
REFLECT.printStatistics()
|
||||
JVM8.printStatistics()
|
||||
JVM8REFLECT.printStatistics()
|
||||
}
|
||||
|
||||
internal inner class FilesWriter(
|
||||
@@ -279,14 +275,16 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager
|
||||
//TODO support JvmPackageName
|
||||
if (fullFileText.contains("@file:JvmPackageName(")) continue
|
||||
// TODO: Support jvm assertions
|
||||
if (fullFileText.contains("// KOTLIN_CONFIGURATION_FLAGS: ASSERTIONS_MODE=jvm")) continue
|
||||
if (fullFileText.contains("// ASSERTIONS_MODE: jvm")) continue
|
||||
if (fullFileText.contains("// MODULE: ")) continue
|
||||
val targets = InTextDirectivesUtils.findLinesWithPrefixesRemoved(fullFileText, "// JVM_TARGET:")
|
||||
.also { it.remove(JvmTarget.JVM_1_6.description) }
|
||||
|
||||
val isJvm8Target =
|
||||
if (targets.isEmpty()) false
|
||||
else if (targets.contains(JvmTarget.JVM_1_8.description) && targets.size == 1) true
|
||||
else continue //TODO: support other targets on Android
|
||||
val isAtLeastJvm8Target = !targets.contains(JvmTarget.JVM_1_6.description)
|
||||
|
||||
if (isAtLeastJvm8Target && fullFileText.contains("@Target(AnnotationTarget.TYPE)")) {
|
||||
//TODO: type annotations supported on sdk 26 emulator
|
||||
continue
|
||||
}
|
||||
|
||||
// TODO: support SKIP_JDK6 on new platforms
|
||||
if (fullFileText.contains("// SKIP_JDK6")) continue
|
||||
@@ -299,9 +297,7 @@ class CodegenTestsOnAndroidGenerator private constructor(private val pathManager
|
||||
KotlinBaseTest.updateConfigurationByDirectivesInTestFiles(testFiles, keyConfiguration)
|
||||
|
||||
val key = ConfigurationKey(kind, jdkKind, keyConfiguration.toString())
|
||||
val compiler = if (isJvm8Target) {
|
||||
if (kind.withReflection) JVM8REFLECT else JVM8
|
||||
} else if (kind.withReflection) REFLECT else COMMON
|
||||
val compiler = if (kind.withReflection) REFLECT else COMMON
|
||||
val filesHolder = holders.getOrPut(key) {
|
||||
FilesWriter(compiler, KotlinTestUtils.newConfiguration(kind, jdkKind,
|
||||
KtTestUtil.getAnnotationsJar()
|
||||
|
||||
@@ -14,7 +14,6 @@ import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class AsmTypes {
|
||||
private static final Map<Class<?>, Type> TYPES_MAP = new HashMap<>();
|
||||
|
||||
@@ -58,7 +58,7 @@ class OriginCollectingClassBuilderFactory(private val builderMode: ClassBuilderM
|
||||
}
|
||||
|
||||
override fun asBytes(builder: ClassBuilder): ByteArray {
|
||||
val classWriter = ClassWriter(0)
|
||||
val classWriter = ClassWriter(ClassWriter.COMPUTE_FRAMES or ClassWriter.COMPUTE_MAXS)
|
||||
(builder as OriginCollectingClassBuilder).classNode.accept(classWriter)
|
||||
return classWriter.toByteArray()
|
||||
}
|
||||
@@ -66,4 +66,4 @@ class OriginCollectingClassBuilderFactory(private val builderMode: ClassBuilderM
|
||||
override fun asText(builder: ClassBuilder) = throw UnsupportedOperationException()
|
||||
|
||||
override fun close() {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -629,7 +629,11 @@ public abstract class StackValue {
|
||||
}
|
||||
|
||||
public static void coerce(@NotNull Type fromType, @NotNull Type toType, @NotNull InstructionAdapter v) {
|
||||
if (toType.equals(fromType)) return;
|
||||
coerce(fromType, toType, v, false);
|
||||
}
|
||||
|
||||
public static void coerce(@NotNull Type fromType, @NotNull Type toType, @NotNull InstructionAdapter v, boolean forceSelfCast) {
|
||||
if (toType.equals(fromType) && !forceSelfCast) return;
|
||||
|
||||
if (toType.getSort() == Type.VOID) {
|
||||
pop(v, fromType);
|
||||
|
||||
@@ -319,7 +319,7 @@ class AnonymousObjectTransformer(
|
||||
), null
|
||||
)
|
||||
|
||||
val result = inliner.doInline(deferringVisitor, LocalVarRemapper(parameters, 0), false, ReturnLabelOwner.NOT_APPLICABLE)
|
||||
val result = inliner.doInline(deferringVisitor, LocalVarRemapper(parameters, 0), false, mapOf())
|
||||
result.reifiedTypeParametersUsages.mergeAll(typeParametersToReify)
|
||||
deferringVisitor.visitMaxs(-1, -1)
|
||||
return result
|
||||
|
||||
@@ -243,12 +243,10 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
|
||||
//hack to keep linenumber info, otherwise jdi will skip begin of linenumber chain
|
||||
adapter.visitInsn(Opcodes.NOP)
|
||||
|
||||
val result = inliner.doInline(adapter, remapper, true, ReturnLabelOwner.SKIP_ALL)
|
||||
val result = inliner.doInline(adapter, remapper, true, mapOf())
|
||||
result.reifiedTypeParametersUsages.mergeAll(reificationResult)
|
||||
|
||||
val labels = sourceCompiler.getContextLabels()
|
||||
|
||||
val infos = MethodInliner.processReturns(adapter, ReturnLabelOwner { labels.contains(it) }, true, null)
|
||||
val infos = MethodInliner.processReturns(adapter, sourceCompiler.getContextLabels(), null)
|
||||
generateAndInsertFinallyBlocks(
|
||||
adapter, infos, (remapper.remap(parameters.argsSizeOnStack + 1).value as StackValue.Local).index
|
||||
)
|
||||
@@ -319,7 +317,9 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
|
||||
frameMap.enterTemp(Type.INT_TYPE)
|
||||
}
|
||||
|
||||
sourceCompiler.generateFinallyBlocksIfNeeded(finallyCodegen, extension.returnType, extension.finallyIntervalEnd.label)
|
||||
sourceCompiler.generateFinallyBlocksIfNeeded(
|
||||
finallyCodegen, extension.returnType, extension.finallyIntervalEnd.label, extension.jumpTarget
|
||||
)
|
||||
|
||||
//Exception table for external try/catch/finally blocks will be generated in original codegen after exiting this method
|
||||
insertNodeBefore(finallyNode, intoNode, curInstr)
|
||||
|
||||
@@ -30,17 +30,14 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCallWithAssert
|
||||
import org.jetbrains.kotlin.resolve.jvm.AsmTypes.*
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||
import org.jetbrains.org.objectweb.asm.ClassReader
|
||||
import org.jetbrains.org.objectweb.asm.ClassVisitor
|
||||
import org.jetbrains.org.objectweb.asm.Opcodes
|
||||
import org.jetbrains.org.objectweb.asm.Type
|
||||
import org.jetbrains.org.objectweb.asm.*
|
||||
import org.jetbrains.org.objectweb.asm.commons.Method
|
||||
import org.jetbrains.org.objectweb.asm.tree.FieldInsnNode
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
interface FunctionalArgument
|
||||
|
||||
abstract class LambdaInfo(@JvmField val isCrossInline: Boolean) : FunctionalArgument, ReturnLabelOwner {
|
||||
abstract class LambdaInfo(@JvmField val isCrossInline: Boolean) : FunctionalArgument {
|
||||
|
||||
abstract val isBoundCallableReference: Boolean
|
||||
|
||||
@@ -54,6 +51,9 @@ abstract class LambdaInfo(@JvmField val isCrossInline: Boolean) : FunctionalArgu
|
||||
|
||||
abstract val capturedVars: List<CapturedParamDesc>
|
||||
|
||||
open val returnLabels: Map<String, Label?>
|
||||
get() = mapOf()
|
||||
|
||||
lateinit var node: SMAPAndMethodNode
|
||||
|
||||
abstract fun generateLambdaBody(sourceCompiler: SourceCompilerForInline, reifiedTypeInliner: ReifiedTypeInliner<*>)
|
||||
@@ -129,8 +129,6 @@ abstract class DefaultLambda(
|
||||
final override lateinit var capturedVars: List<CapturedParamDesc>
|
||||
private set
|
||||
|
||||
override fun isReturnFromMe(labelName: String): Boolean = false
|
||||
|
||||
var originalBoundReceiverType: Type? = null
|
||||
private set
|
||||
|
||||
@@ -247,7 +245,7 @@ class PsiExpressionLambda(
|
||||
|
||||
val functionWithBodyOrCallableReference: KtExpression = (expression as? KtLambdaExpression)?.functionLiteral ?: expression
|
||||
|
||||
private val labels: Set<String>
|
||||
override val returnLabels: Map<String, Label?>
|
||||
|
||||
override val isSuspend: Boolean
|
||||
|
||||
@@ -284,7 +282,7 @@ class PsiExpressionLambda(
|
||||
closure = it!!
|
||||
}
|
||||
|
||||
labels = InlineCodegen.getDeclarationLabels(expression, invokeMethodDescriptor)
|
||||
returnLabels = InlineCodegen.getDeclarationLabels(expression, invokeMethodDescriptor).associateWith { null }
|
||||
invokeMethod = typeMapper.mapAsmMethod(invokeMethodDescriptor)
|
||||
isSuspend = invokeMethodDescriptor.isSuspend
|
||||
}
|
||||
@@ -324,10 +322,6 @@ class PsiExpressionLambda(
|
||||
}
|
||||
}
|
||||
|
||||
override fun isReturnFromMe(labelName: String): Boolean {
|
||||
return labels.contains(labelName)
|
||||
}
|
||||
|
||||
val isPropertyReference: Boolean
|
||||
get() = propertyReferenceInfo != null
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.jetbrains.kotlin.codegen.optimization.common.isMeaningful
|
||||
import org.jetbrains.kotlin.codegen.optimization.fixStack.peek
|
||||
import org.jetbrains.kotlin.codegen.optimization.fixStack.top
|
||||
import org.jetbrains.kotlin.codegen.optimization.nullCheck.isCheckParameterIsNotNull
|
||||
import org.jetbrains.kotlin.codegen.pseudoInsns.PseudoInsn
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ParameterDescriptor
|
||||
@@ -72,9 +73,9 @@ class MethodInliner(
|
||||
adapter: MethodVisitor,
|
||||
remapper: LocalVarRemapper,
|
||||
remapReturn: Boolean,
|
||||
returnLabelOwner: ReturnLabelOwner
|
||||
returnLabels: Map<String, Label?>
|
||||
): InlineResult {
|
||||
return doInline(adapter, remapper, remapReturn, returnLabelOwner, 0)
|
||||
return doInline(adapter, remapper, remapReturn, returnLabels, 0)
|
||||
}
|
||||
|
||||
private fun recordTransformation(info: TransformationInfo) {
|
||||
@@ -91,11 +92,11 @@ class MethodInliner(
|
||||
adapter: MethodVisitor,
|
||||
remapper: LocalVarRemapper,
|
||||
remapReturn: Boolean,
|
||||
returnLabelOwner: ReturnLabelOwner,
|
||||
returnLabels: Map<String, Label?>,
|
||||
finallyDeepShift: Int
|
||||
): InlineResult {
|
||||
//analyze body
|
||||
var transformedNode = markPlacesForInlineAndRemoveInlinable(node, returnLabelOwner, finallyDeepShift)
|
||||
var transformedNode = markPlacesForInlineAndRemoveInlinable(node, returnLabels, finallyDeepShift)
|
||||
if (inliningContext.isInliningLambda && isDefaultLambdaWithReification(inliningContext.lambdaInfo!!)) {
|
||||
//TODO maybe move reification in one place
|
||||
inliningContext.root.inlineMethodReifier.reifyInstructions(transformedNode)
|
||||
@@ -139,7 +140,9 @@ class MethodInliner(
|
||||
)
|
||||
}
|
||||
|
||||
processReturns(resultNode, returnLabelOwner, remapReturn, end)
|
||||
if (remapReturn) {
|
||||
processReturns(resultNode, returnLabels, end)
|
||||
}
|
||||
//flush transformed node to output
|
||||
resultNode.accept(SkipMaxAndEndVisitor(adapter))
|
||||
return result
|
||||
@@ -297,7 +300,7 @@ class MethodInliner(
|
||||
|
||||
val varRemapper = LocalVarRemapper(lambdaParameters, valueParamShift)
|
||||
//TODO add skipped this and receiver
|
||||
val lambdaResult = inliner.doInline(localVariablesSorter, varRemapper, true, info, invokeCall.finallyDepthShift)
|
||||
val lambdaResult = inliner.doInline(localVariablesSorter, varRemapper, true, info.returnLabels, invokeCall.finallyDepthShift)
|
||||
result.mergeWithNotChangeInfo(lambdaResult)
|
||||
result.reifiedTypeParametersUsages.mergeAll(lambdaResult.reifiedTypeParametersUsages)
|
||||
|
||||
@@ -486,11 +489,11 @@ class MethodInliner(
|
||||
}
|
||||
|
||||
private fun markPlacesForInlineAndRemoveInlinable(
|
||||
node: MethodNode, returnLabelOwner: ReturnLabelOwner, finallyDeepShift: Int
|
||||
node: MethodNode, returnLabels: Map<String, Label?>, finallyDeepShift: Int
|
||||
): MethodNode {
|
||||
val processingNode = prepareNode(node, finallyDeepShift)
|
||||
|
||||
preprocessNodeBeforeInline(processingNode, returnLabelOwner)
|
||||
preprocessNodeBeforeInline(processingNode, returnLabels)
|
||||
|
||||
replaceContinuationAccessesWithFakeContinuationsIfNeeded(processingNode)
|
||||
|
||||
@@ -765,7 +768,7 @@ class MethodInliner(
|
||||
}
|
||||
}
|
||||
|
||||
private fun preprocessNodeBeforeInline(node: MethodNode, returnLabelOwner: ReturnLabelOwner) {
|
||||
private fun preprocessNodeBeforeInline(node: MethodNode, returnLabels: Map<String, Label?>) {
|
||||
try {
|
||||
FixStackWithLabelNormalizationMethodTransformer().transform("fake", node)
|
||||
} catch (e: Throwable) {
|
||||
@@ -787,16 +790,13 @@ class MethodInliner(
|
||||
|
||||
if (!isReturnOpcode(insnNode.opcode)) continue
|
||||
|
||||
var insertBeforeInsn = insnNode
|
||||
|
||||
// TODO extract isLocalReturn / isNonLocalReturn, see processReturns
|
||||
val labelName = getMarkedReturnLabelOrNull(insnNode)
|
||||
if (labelName != null) {
|
||||
if (!returnLabelOwner.isReturnFromMe(labelName)) continue
|
||||
insertBeforeInsn = insnNode.previous
|
||||
if (labelName == null) {
|
||||
localReturnsNormalizer.addLocalReturnToTransform(insnNode, insnNode, frame)
|
||||
} else if (labelName in returnLabels) {
|
||||
localReturnsNormalizer.addLocalReturnToTransform(insnNode, insnNode.previous, frame)
|
||||
}
|
||||
|
||||
localReturnsNormalizer.addLocalReturnToTransform(insnNode, insertBeforeInsn, frame)
|
||||
}
|
||||
|
||||
localReturnsNormalizer.transform(node)
|
||||
@@ -1001,7 +1001,8 @@ class MethodInliner(
|
||||
class PointForExternalFinallyBlocks(
|
||||
@JvmField val beforeIns: AbstractInsnNode,
|
||||
@JvmField val returnType: Type,
|
||||
@JvmField val finallyIntervalEnd: LabelNode
|
||||
@JvmField val finallyIntervalEnd: LabelNode,
|
||||
@JvmField val jumpTarget: Label?
|
||||
)
|
||||
|
||||
companion object {
|
||||
@@ -1115,55 +1116,44 @@ class MethodInliner(
|
||||
//process local and global returns (local substituted with goto end-label global kept unchanged)
|
||||
@JvmStatic
|
||||
fun processReturns(
|
||||
node: MethodNode, returnLabelOwner: ReturnLabelOwner, remapReturn: Boolean, endLabel: Label?
|
||||
node: MethodNode, returnLabels: Map<String, Label?>, endLabel: Label?
|
||||
): List<PointForExternalFinallyBlocks> {
|
||||
if (!remapReturn) {
|
||||
return emptyList()
|
||||
}
|
||||
val result = ArrayList<PointForExternalFinallyBlocks>()
|
||||
val instructions = node.instructions
|
||||
var insnNode: AbstractInsnNode? = instructions.first
|
||||
while (insnNode != null) {
|
||||
if (isReturnOpcode(insnNode.opcode)) {
|
||||
var isLocalReturn = true
|
||||
val labelName = getMarkedReturnLabelOrNull(insnNode)
|
||||
val returnType = getReturnType(insnNode.opcode)
|
||||
|
||||
if (labelName != null) {
|
||||
isLocalReturn = returnLabelOwner.isReturnFromMe(labelName)
|
||||
//remove global return flag
|
||||
if (isLocalReturn) {
|
||||
instructions.remove(insnNode.previous)
|
||||
}
|
||||
val isLocalReturn = labelName == null || labelName in returnLabels
|
||||
val jumpTarget = returnLabels[labelName] ?: endLabel
|
||||
|
||||
if (isLocalReturn && labelName != null) {
|
||||
// remove non-local return flag
|
||||
instructions.remove(insnNode.previous)
|
||||
}
|
||||
|
||||
if (isLocalReturn && endLabel != null) {
|
||||
val nop = InsnNode(Opcodes.NOP)
|
||||
instructions.insert(insnNode, nop)
|
||||
|
||||
val labelNode = endLabel.info as LabelNode
|
||||
val jumpInsnNode = JumpInsnNode(Opcodes.GOTO, labelNode)
|
||||
instructions.insert(nop, jumpInsnNode)
|
||||
|
||||
if (isLocalReturn && jumpTarget != null) {
|
||||
val jumpInsnNode = JumpInsnNode(Opcodes.GOTO, jumpTarget.info as LabelNode)
|
||||
instructions.insertBefore(insnNode, InsnNode(Opcodes.NOP))
|
||||
if (jumpTarget != endLabel) {
|
||||
instructions.insertBefore(insnNode, PseudoInsn.FIX_STACK_BEFORE_JUMP.createInsnNode())
|
||||
}
|
||||
instructions.insertBefore(insnNode, jumpInsnNode)
|
||||
instructions.remove(insnNode)
|
||||
insnNode = jumpInsnNode
|
||||
}
|
||||
|
||||
//generate finally block before nonLocalReturn flag/return/goto
|
||||
val label = LabelNode()
|
||||
instructions.insert(insnNode, label)
|
||||
result.add(
|
||||
PointForExternalFinallyBlocks(
|
||||
getInstructionToInsertFinallyBefore(insnNode, isLocalReturn), getReturnType(insnNode.opcode), label
|
||||
)
|
||||
)
|
||||
// generate finally blocks before the non-local return flag or the stack fixup pseudo instruction
|
||||
val finallyInsertionPoint = if (isLocalReturn && jumpTarget == endLabel) insnNode else insnNode.previous
|
||||
result.add(PointForExternalFinallyBlocks(finallyInsertionPoint, returnType, label, jumpTarget))
|
||||
}
|
||||
insnNode = insnNode.next
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
private fun getInstructionToInsertFinallyBefore(nonLocalReturnOrJump: AbstractInsnNode, isLocal: Boolean): AbstractInsnNode {
|
||||
return if (isLocal) nonLocalReturnOrJump else nonLocalReturnOrJump.previous
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.codegen.inline;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface ReturnLabelOwner {
|
||||
boolean isReturnFromMe(@NotNull String labelName);
|
||||
|
||||
ReturnLabelOwner SKIP_ALL = name -> false;
|
||||
|
||||
ReturnLabelOwner NOT_APPLICABLE = name -> {
|
||||
throw new RuntimeException("This operation not applicable for current context");
|
||||
};
|
||||
}
|
||||
@@ -64,7 +64,7 @@ interface SourceCompilerForInline {
|
||||
curFinallyDepth: Int
|
||||
): BaseExpressionCodegen
|
||||
|
||||
fun generateFinallyBlocksIfNeeded(finallyCodegen: BaseExpressionCodegen, returnType: Type, afterReturnLabel: Label)
|
||||
fun generateFinallyBlocksIfNeeded(codegen: BaseExpressionCodegen, returnType: Type, afterReturnLabel: Label, target: Label?)
|
||||
|
||||
fun isCallInsideSameModuleAsDeclared(functionDescriptor: FunctionDescriptor): Boolean
|
||||
|
||||
@@ -74,7 +74,7 @@ interface SourceCompilerForInline {
|
||||
|
||||
val compilationContextFunctionDescriptor: FunctionDescriptor
|
||||
|
||||
fun getContextLabels(): Set<String>
|
||||
fun getContextLabels(): Map<String, Label?>
|
||||
|
||||
fun reportSuspensionPointInsideMonitor(stackTraceElement: String)
|
||||
}
|
||||
@@ -311,9 +311,10 @@ class PsiSourceCompilerForInline(private val codegen: ExpressionCodegen, overrid
|
||||
|
||||
override fun hasFinallyBlocks() = codegen.hasFinallyBlocks()
|
||||
|
||||
override fun generateFinallyBlocksIfNeeded(finallyCodegen: BaseExpressionCodegen, returnType: Type, afterReturnLabel: Label) {
|
||||
require(finallyCodegen is ExpressionCodegen)
|
||||
finallyCodegen.generateFinallyBlocksIfNeeded(returnType, null, afterReturnLabel)
|
||||
override fun generateFinallyBlocksIfNeeded(codegen: BaseExpressionCodegen, returnType: Type, afterReturnLabel: Label, target: Label?) {
|
||||
// TODO use the target label for non-local break/continue
|
||||
require(codegen is ExpressionCodegen)
|
||||
codegen.generateFinallyBlocksIfNeeded(returnType, null, afterReturnLabel)
|
||||
}
|
||||
|
||||
override fun createCodegenForExternalFinallyBlockGenerationOnNonLocalReturn(finallyNode: MethodNode, curFinallyDepth: Int) =
|
||||
@@ -337,14 +338,15 @@ class PsiSourceCompilerForInline(private val codegen: ExpressionCodegen, overrid
|
||||
override val compilationContextFunctionDescriptor
|
||||
get() = codegen.getContext().functionDescriptor
|
||||
|
||||
override fun getContextLabels(): Set<String> {
|
||||
override fun getContextLabels(): Map<String, Label?> {
|
||||
val context = codegen.getContext()
|
||||
val parentContext = context.parentContext
|
||||
val descriptor = if (parentContext is ClosureContext && parentContext.originalSuspendLambdaDescriptor != null) {
|
||||
parentContext.originalSuspendLambdaDescriptor!!
|
||||
} else context.contextDescriptor
|
||||
|
||||
return InlineCodegen.getDeclarationLabels(DescriptorToSourceUtils.descriptorToDeclaration(descriptor), descriptor)
|
||||
val labels = InlineCodegen.getDeclarationLabels(DescriptorToSourceUtils.descriptorToDeclaration(descriptor), descriptor)
|
||||
return labels.associateWith { null } // TODO add break/continue labels
|
||||
}
|
||||
|
||||
fun initializeInlineFunctionContext(functionDescriptor: FunctionDescriptor) {
|
||||
|
||||
@@ -84,9 +84,11 @@ private fun createSpecialEnumMethodBody(
|
||||
Opcodes.INVOKESTATIC, ENUM_TYPE.internalName, "valueOf",
|
||||
Type.getMethodDescriptor(ENUM_TYPE, JAVA_CLASS_TYPE, JAVA_STRING_TYPE), false
|
||||
)
|
||||
node.visitTypeInsn(Opcodes.CHECKCAST, ENUM_TYPE.internalName)
|
||||
} else {
|
||||
node.visitInsn(Opcodes.ICONST_0)
|
||||
node.visitTypeInsn(Opcodes.ANEWARRAY, ENUM_TYPE.internalName)
|
||||
node.visitTypeInsn(Opcodes.CHECKCAST, AsmUtil.getArrayType(ENUM_TYPE).internalName)
|
||||
}
|
||||
node.visitInsn(Opcodes.ARETURN)
|
||||
node.visitMaxs(if (isValueOf) 3 else 2, if (isValueOf) 1 else 0)
|
||||
|
||||
@@ -37,17 +37,9 @@ class CapturedVarsOptimizationMethodTransformer : MethodTransformer() {
|
||||
|
||||
// Tracks proper usages of objects corresponding to captured variables.
|
||||
//
|
||||
// The 'kotlin.jvm.internal.Ref.*' instance can be replaced with a local variable,
|
||||
// if all of the following conditions are satisfied:
|
||||
// * It is created inside a current method.
|
||||
// * The only permitted operations on it are:
|
||||
// - store to a local variable
|
||||
// - ALOAD, ASTORE
|
||||
// - DUP, POP
|
||||
// - GETFIELD <owner>.element, PUTFIELD <owner>.element
|
||||
// * There's a corresponding local variable definition,
|
||||
// and all ALOAD/ASTORE instructions operate on that particular local variable.
|
||||
// * Its 'element' field is initialized at start of local variable visibility range.
|
||||
// The 'kotlin.jvm.internal.Ref.*' instance can be replaced with a local variable, if
|
||||
// * it is created inside a current method;
|
||||
// * the only operations on it are ALOAD, ASTORE, DUP, POP, GETFIELD element, PUTFIELD element.
|
||||
//
|
||||
// Note that for code that doesn't create Ref objects explicitly these conditions are true,
|
||||
// unless the Ref object escapes to a local class constructor (including local classes for lambdas).
|
||||
@@ -58,18 +50,9 @@ class CapturedVarsOptimizationMethodTransformer : MethodTransformer() {
|
||||
var initCallInsn: MethodInsnNode? = null
|
||||
var localVar: LocalVariableNode? = null
|
||||
var localVarIndex = -1
|
||||
val astoreInsns: MutableCollection<VarInsnNode> = LinkedHashSet()
|
||||
val aloadInsns: MutableCollection<VarInsnNode> = LinkedHashSet()
|
||||
val stackInsns: MutableCollection<AbstractInsnNode> = LinkedHashSet()
|
||||
val wrapperInsns: MutableCollection<AbstractInsnNode> = LinkedHashSet()
|
||||
val getFieldInsns: MutableCollection<FieldInsnNode> = LinkedHashSet()
|
||||
val putFieldInsns: MutableCollection<FieldInsnNode> = LinkedHashSet()
|
||||
var cleanVarInstruction: VarInsnNode? = null
|
||||
|
||||
fun canRewrite(): Boolean =
|
||||
!hazard &&
|
||||
initCallInsn != null &&
|
||||
localVar != null &&
|
||||
localVarIndex >= 0
|
||||
|
||||
override fun onUseAsTainted() {
|
||||
hazard = true
|
||||
@@ -79,26 +62,29 @@ class CapturedVarsOptimizationMethodTransformer : MethodTransformer() {
|
||||
private class Transformer(private val internalClassName: String, private val methodNode: MethodNode) {
|
||||
private val refValues = ArrayList<CapturedVarDescriptor>()
|
||||
private val refValuesByNewInsn = LinkedHashMap<TypeInsnNode, CapturedVarDescriptor>()
|
||||
private val insns = methodNode.instructions.toArray()
|
||||
private lateinit var frames: Array<out Frame<BasicValue>?>
|
||||
|
||||
val hasRewritableRefValues: Boolean
|
||||
get() = refValues.isNotEmpty()
|
||||
|
||||
fun run() {
|
||||
createRefValues()
|
||||
if (!hasRewritableRefValues) return
|
||||
if (refValues.isEmpty()) return
|
||||
|
||||
analyze()
|
||||
if (!hasRewritableRefValues) return
|
||||
val frames = analyze(internalClassName, methodNode, Interpreter())
|
||||
trackPops(frames)
|
||||
assignLocalVars(frames)
|
||||
|
||||
rewrite()
|
||||
for (refValue in refValues) {
|
||||
if (!refValue.hazard) {
|
||||
rewriteRefValue(refValue)
|
||||
}
|
||||
}
|
||||
|
||||
methodNode.removeEmptyCatchBlocks()
|
||||
methodNode.removeUnusedLocalVariables()
|
||||
}
|
||||
|
||||
private fun AbstractInsnNode.getIndex() = methodNode.instructions.indexOf(this)
|
||||
|
||||
private fun createRefValues() {
|
||||
for (insn in insns) {
|
||||
for (insn in methodNode.instructions.asSequence()) {
|
||||
if (insn.opcode == Opcodes.NEW && insn is TypeInsnNode) {
|
||||
val type = Type.getObjectType(insn.desc)
|
||||
if (AsmTypes.isSharedVarType(type)) {
|
||||
@@ -113,19 +99,15 @@ class CapturedVarsOptimizationMethodTransformer : MethodTransformer() {
|
||||
|
||||
private inner class Interpreter : ReferenceTrackingInterpreter() {
|
||||
override fun newOperation(insn: AbstractInsnNode): BasicValue =
|
||||
refValuesByNewInsn[insn]?.let { descriptor ->
|
||||
ProperTrackedReferenceValue(descriptor.refType, descriptor)
|
||||
}
|
||||
?: super.newOperation(insn)
|
||||
refValuesByNewInsn[insn]?.let { ProperTrackedReferenceValue(it.refType, it) } ?: super.newOperation(insn)
|
||||
|
||||
override fun processRefValueUsage(value: TrackedReferenceValue, insn: AbstractInsnNode, position: Int) {
|
||||
for (descriptor in value.descriptors) {
|
||||
if (descriptor !is CapturedVarDescriptor) throw AssertionError("Unexpected descriptor: $descriptor")
|
||||
when {
|
||||
insn.opcode == Opcodes.ALOAD ->
|
||||
descriptor.aloadInsns.add(insn as VarInsnNode)
|
||||
insn.opcode == Opcodes.ASTORE ->
|
||||
descriptor.astoreInsns.add(insn as VarInsnNode)
|
||||
insn.opcode == Opcodes.DUP -> descriptor.wrapperInsns.add(insn)
|
||||
insn.opcode == Opcodes.ALOAD -> descriptor.wrapperInsns.add(insn)
|
||||
insn.opcode == Opcodes.ASTORE -> descriptor.wrapperInsns.add(insn)
|
||||
insn.opcode == Opcodes.GETFIELD && insn is FieldInsnNode && insn.name == REF_ELEMENT_FIELD && position == 0 ->
|
||||
descriptor.getFieldInsns.add(insn)
|
||||
insn.opcode == Opcodes.PUTFIELD && insn is FieldInsnNode && insn.name == REF_ELEMENT_FIELD && position == 0 ->
|
||||
@@ -135,32 +117,18 @@ class CapturedVarsOptimizationMethodTransformer : MethodTransformer() {
|
||||
descriptor.hazard = true
|
||||
else
|
||||
descriptor.initCallInsn = insn
|
||||
insn.opcode == Opcodes.DUP ->
|
||||
descriptor.stackInsns.add(insn)
|
||||
else ->
|
||||
descriptor.hazard = true
|
||||
else -> descriptor.hazard = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun analyze() {
|
||||
frames = MethodTransformer.analyze(internalClassName, methodNode, Interpreter())
|
||||
trackPops()
|
||||
assignLocalVars()
|
||||
|
||||
refValues.removeAll { !it.canRewrite() }
|
||||
}
|
||||
|
||||
private fun trackPops() {
|
||||
for (i in insns.indices) {
|
||||
private fun trackPops(frames: Array<out Frame<BasicValue>?>) {
|
||||
for ((i, insn) in methodNode.instructions.asSequence().withIndex()) {
|
||||
val frame = frames[i] ?: continue
|
||||
val insn = insns[i]
|
||||
|
||||
when (insn.opcode) {
|
||||
Opcodes.POP -> {
|
||||
frame.top()?.getCapturedVarOrNull()?.run { stackInsns.add(insn) }
|
||||
frame.top()?.getCapturedVarOrNull()?.run { wrapperInsns.add(insn) }
|
||||
}
|
||||
Opcodes.POP2 -> {
|
||||
val top = frame.top()
|
||||
@@ -176,7 +144,7 @@ class CapturedVarsOptimizationMethodTransformer : MethodTransformer() {
|
||||
private fun BasicValue.getCapturedVarOrNull() =
|
||||
safeAs<ProperTrackedReferenceValue>()?.descriptor?.safeAs<CapturedVarDescriptor>()
|
||||
|
||||
private fun assignLocalVars() {
|
||||
private fun assignLocalVars(frames: Array<out Frame<BasicValue>?>) {
|
||||
for (localVar in methodNode.localVariables) {
|
||||
val type = Type.getType(localVar.desc)
|
||||
if (!AsmTypes.isSharedVarType(type)) continue
|
||||
@@ -197,51 +165,20 @@ class CapturedVarsOptimizationMethodTransformer : MethodTransformer() {
|
||||
|
||||
for (refValue in refValues) {
|
||||
if (refValue.hazard) continue
|
||||
val localVar = refValue.localVar ?: continue
|
||||
val oldVarIndex = localVar.index
|
||||
|
||||
if (refValue.valueType.size != 1) {
|
||||
if (refValue.localVar == null || refValue.valueType.size != 1) {
|
||||
refValue.localVarIndex = methodNode.maxLocals
|
||||
methodNode.maxLocals += 2
|
||||
localVar.index = refValue.localVarIndex
|
||||
methodNode.maxLocals += refValue.valueType.size
|
||||
} else {
|
||||
refValue.localVarIndex = localVar.index
|
||||
refValue.localVarIndex = refValue.localVar!!.index
|
||||
}
|
||||
|
||||
val cleanInstructions = findCleanInstructions(refValue, oldVarIndex, methodNode.instructions)
|
||||
if (cleanInstructions.size > 1) {
|
||||
refValue.hazard = true
|
||||
continue
|
||||
}
|
||||
refValue.cleanVarInstruction = cleanInstructions.firstOrNull()
|
||||
}
|
||||
}
|
||||
|
||||
private fun findCleanInstructions(refValue: CapturedVarDescriptor, oldVarIndex: Int, instructions: InsnList): List<VarInsnNode> {
|
||||
return InsnSequence(instructions).filterIsInstance<VarInsnNode>().filter {
|
||||
it.opcode == Opcodes.ASTORE && it.`var` == oldVarIndex
|
||||
}.filter {
|
||||
it.previous?.opcode == Opcodes.ACONST_NULL
|
||||
}.filter {
|
||||
val operationIndex = instructions.indexOf(it)
|
||||
val localVariableNode = refValue.localVar!!
|
||||
instructions.indexOf(localVariableNode.start) < operationIndex && operationIndex < instructions.indexOf(
|
||||
localVariableNode.end
|
||||
)
|
||||
}.toList()
|
||||
}
|
||||
|
||||
private fun rewrite() {
|
||||
for (refValue in refValues) {
|
||||
if (!refValue.canRewrite()) continue
|
||||
|
||||
rewriteRefValue(refValue)
|
||||
private fun LocalVariableNode.findCleanInstructions() =
|
||||
InsnSequence(methodNode.instructions).dropWhile { it != start }.takeWhile { it != end }.filter {
|
||||
it is VarInsnNode && it.opcode == Opcodes.ASTORE && it.`var` == index && it.previous?.opcode == Opcodes.ACONST_NULL
|
||||
}
|
||||
|
||||
methodNode.removeEmptyCatchBlocks()
|
||||
methodNode.removeUnusedLocalVariables()
|
||||
}
|
||||
|
||||
// Be careful to not remove instructions that are the only instruction for a line number. That will
|
||||
// break debugging. If the previous instruction is a line number and the following instruction is
|
||||
// a label followed by a line number, insert a nop instead of deleting the instruction.
|
||||
@@ -255,34 +192,38 @@ class CapturedVarsOptimizationMethodTransformer : MethodTransformer() {
|
||||
|
||||
private fun rewriteRefValue(capturedVar: CapturedVarDescriptor) {
|
||||
methodNode.instructions.run {
|
||||
val localVar = capturedVar.localVar!!
|
||||
localVar.signature = null
|
||||
localVar.desc = capturedVar.valueType.descriptor
|
||||
|
||||
val loadOpcode = capturedVar.valueType.getOpcode(Opcodes.ILOAD)
|
||||
val storeOpcode = capturedVar.valueType.getOpcode(Opcodes.ISTORE)
|
||||
|
||||
if (capturedVar.putFieldInsns.none { it.getIndex() < localVar.start.getIndex() }) {
|
||||
// variable needs to be initialized before its live range can begin
|
||||
insertBefore(capturedVar.newInsn, InsnNode(AsmUtil.defaultValueOpcode(capturedVar.valueType)))
|
||||
insertBefore(capturedVar.newInsn, VarInsnNode(storeOpcode, capturedVar.localVarIndex))
|
||||
val localVar = capturedVar.localVar
|
||||
if (localVar != null) {
|
||||
if (capturedVar.putFieldInsns.none { it.getIndex() < localVar.start.getIndex() }) {
|
||||
// variable needs to be initialized before its live range can begin
|
||||
insertBefore(capturedVar.newInsn, InsnNode(AsmUtil.defaultValueOpcode(capturedVar.valueType)))
|
||||
insertBefore(capturedVar.newInsn, VarInsnNode(storeOpcode, capturedVar.localVarIndex))
|
||||
}
|
||||
|
||||
for (insn in localVar.findCleanInstructions()) {
|
||||
// after visiting block codegen tries to delete all allocated references:
|
||||
// see ExpressionCodegen.addLeaveTaskToRemoveLocalVariableFromFrameMap
|
||||
if (storeOpcode == Opcodes.ASTORE) {
|
||||
set(insn.previous, InsnNode(AsmUtil.defaultValueOpcode(capturedVar.valueType)))
|
||||
} else {
|
||||
remove(insn.previous)
|
||||
remove(insn)
|
||||
}
|
||||
}
|
||||
|
||||
localVar.index = capturedVar.localVarIndex
|
||||
localVar.desc = capturedVar.valueType.descriptor
|
||||
localVar.signature = null
|
||||
}
|
||||
|
||||
remove(capturedVar.newInsn)
|
||||
remove(capturedVar.initCallInsn!!)
|
||||
|
||||
capturedVar.stackInsns.forEach { removeOrReplaceByNop(it) }
|
||||
capturedVar.aloadInsns.forEach { removeOrReplaceByNop(it) }
|
||||
capturedVar.astoreInsns.forEach { removeOrReplaceByNop(it) }
|
||||
capturedVar.wrapperInsns.forEach { removeOrReplaceByNop(it) }
|
||||
capturedVar.getFieldInsns.forEach { set(it, VarInsnNode(loadOpcode, capturedVar.localVarIndex)) }
|
||||
capturedVar.putFieldInsns.forEach { set(it, VarInsnNode(storeOpcode, capturedVar.localVarIndex)) }
|
||||
|
||||
//after visiting block codegen tries to delete all allocated references:
|
||||
// see ExpressionCodegen.addLeaveTaskToRemoveLocalVariableFromFrameMap
|
||||
capturedVar.cleanVarInstruction?.let {
|
||||
remove(it.previous)
|
||||
remove(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,8 @@ import org.jetbrains.org.objectweb.asm.tree.TypeInsnNode
|
||||
class RedundantCheckCastEliminationMethodTransformer : MethodTransformer() {
|
||||
override fun transform(internalClassName: String, methodNode: MethodNode) {
|
||||
val insns = methodNode.instructions.toArray()
|
||||
if (!insns.any { it.opcode == Opcodes.CHECKCAST }) return
|
||||
if (!insns.any { it.opcode == Opcodes.CHECKCAST}) return
|
||||
if (insns.any { ReifiedTypeInliner.isOperationReifiedMarker(it) }) return
|
||||
|
||||
val redundantCheckCasts = ArrayList<TypeInsnNode>()
|
||||
|
||||
@@ -36,7 +37,6 @@ class RedundantCheckCastEliminationMethodTransformer : MethodTransformer() {
|
||||
for (i in insns.indices) {
|
||||
val valueType = frames[i]?.top()?.type ?: continue
|
||||
val insn = insns[i]
|
||||
if (ReifiedTypeInliner.isOperationReifiedMarker(insn.previous)) continue
|
||||
|
||||
if (insn is TypeInsnNode) {
|
||||
val insnType = Type.getObjectType(insn.desc)
|
||||
|
||||
@@ -208,11 +208,21 @@ class GenerationState private constructor(
|
||||
else JvmStringConcat.INLINE
|
||||
|
||||
val samConversionsScheme = run {
|
||||
val fromConfig = configuration.get(JVMConfigurationKeys.SAM_CONVERSIONS) ?: JvmSamConversions.DEFAULT
|
||||
val fromConfig = configuration.get(JVMConfigurationKeys.SAM_CONVERSIONS)
|
||||
?: JvmClosureGenerationScheme.DEFAULT
|
||||
if (target >= fromConfig.minJvmTarget)
|
||||
fromConfig
|
||||
else
|
||||
JvmSamConversions.DEFAULT
|
||||
JvmClosureGenerationScheme.DEFAULT
|
||||
}
|
||||
|
||||
val lambdasScheme = run {
|
||||
val fromConfig = configuration.get(JVMConfigurationKeys.LAMBDAS)
|
||||
?: JvmClosureGenerationScheme.DEFAULT
|
||||
if (target >= fromConfig.minJvmTarget)
|
||||
fromConfig
|
||||
else
|
||||
JvmClosureGenerationScheme.DEFAULT
|
||||
}
|
||||
|
||||
val moduleName: String = moduleName ?: JvmCodegenUtil.getModuleName(module)
|
||||
|
||||
@@ -65,7 +65,6 @@ dependencies {
|
||||
testRuntimeOnly(intellijPluginDep("java"))
|
||||
|
||||
testRuntime(project(":kotlin-reflect"))
|
||||
testRuntime(androidDxJar())
|
||||
testRuntime(toolsJar())
|
||||
|
||||
antLauncherJar(commonDep("org.apache.ant", "ant"))
|
||||
@@ -87,7 +86,7 @@ if (kotlinBuildProperties.isInJpsBuildIdeaSync) {
|
||||
idea {
|
||||
this.module.generatedSourceDirs.add(generationRoot)
|
||||
}
|
||||
} else {
|
||||
} else if (!kotlinBuildProperties.useFir && !kotlinBuildProperties.disableWerror) {
|
||||
allprojects {
|
||||
tasks.withType<KotlinCompile<*>> {
|
||||
if (path !in tasksWithWarnings) {
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2010-2015 JetBrains s.r.o.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# Copyright 2010-2021 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.
|
||||
|
||||
export KOTLIN_TOOL=kotlin-annotation-processing-cli.jar
|
||||
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
@echo off
|
||||
|
||||
rem Copyright 2010-2015 JetBrains s.r.o.
|
||||
rem
|
||||
rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
rem you may not use this file except in compliance with the License.
|
||||
rem You may obtain a copy of the License at
|
||||
rem
|
||||
rem http://www.apache.org/licenses/LICENSE-2.0
|
||||
rem
|
||||
rem Unless required by applicable law or agreed to in writing, software
|
||||
rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
rem See the License for the specific language governing permissions and
|
||||
rem limitations under the License.
|
||||
rem Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
rem Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
|
||||
setlocal
|
||||
set _KOTLIN_COMPILER=org.jetbrains.kotlin.kapt.cli.KaptCli
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2010-2015 JetBrains s.r.o.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# Copyright 2010-2021 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.
|
||||
|
||||
export KOTLIN_RUNNER=1
|
||||
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2010-2017 JetBrains s.r.o.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# Copyright 2010-2021 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.
|
||||
|
||||
export KOTLIN_COMPILER=org.jetbrains.kotlin.cli.js.dce.K2JSDce
|
||||
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
@echo off
|
||||
|
||||
rem Copyright 2010-2015 JetBrains s.r.o.
|
||||
rem
|
||||
rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
rem you may not use this file except in compliance with the License.
|
||||
rem You may obtain a copy of the License at
|
||||
rem
|
||||
rem http://www.apache.org/licenses/LICENSE-2.0
|
||||
rem
|
||||
rem Unless required by applicable law or agreed to in writing, software
|
||||
rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
rem See the License for the specific language governing permissions and
|
||||
rem limitations under the License.
|
||||
rem Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
rem Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
|
||||
setlocal
|
||||
set _KOTLIN_COMPILER=org.jetbrains.kotlin.cli.js.dce.K2JSDce
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
@echo off
|
||||
|
||||
rem Copyright 2010-2015 JetBrains s.r.o.
|
||||
rem
|
||||
rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
rem you may not use this file except in compliance with the License.
|
||||
rem You may obtain a copy of the License at
|
||||
rem
|
||||
rem http://www.apache.org/licenses/LICENSE-2.0
|
||||
rem
|
||||
rem Unless required by applicable law or agreed to in writing, software
|
||||
rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
rem See the License for the specific language governing permissions and
|
||||
rem limitations under the License.
|
||||
rem Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
rem Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
|
||||
setlocal
|
||||
set _KOTLIN_RUNNER=1
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Based on scalac from the Scala distribution
|
||||
# Copyright 2002-2011, LAMP/EPFL
|
||||
# Copyright 2011-2015, JetBrains
|
||||
#
|
||||
# This is free software; see the distribution for copying conditions.
|
||||
# There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
##############################################################################
|
||||
# Copyright 2010-2021 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.
|
||||
|
||||
cygwin=false;
|
||||
case "`uname`" in
|
||||
@@ -25,6 +21,17 @@ findKotlinHome() {
|
||||
(cd -P "$(dirname "$source")/.." && pwd)
|
||||
}
|
||||
|
||||
findJavaVersion() {
|
||||
# Note that this only loads the first component of the version, so "1.8.0_265" -> "1".
|
||||
# But it's fine because major version is 9 for JDK 9, and so on.
|
||||
regex='^.*version "([[:digit:]]+).*$'
|
||||
while read -r line; do
|
||||
if [[ "$line" =~ $regex ]]; then
|
||||
echo ${BASH_REMATCH[1]}
|
||||
fi
|
||||
done <<< $("${JAVACMD:=java}" -version 2>&1)
|
||||
}
|
||||
|
||||
KOTLIN_HOME="$(findKotlinHome)"
|
||||
|
||||
if $cygwin; then
|
||||
@@ -60,17 +67,24 @@ fi
|
||||
|
||||
declare -a kotlin_app
|
||||
|
||||
if [ -n "$KOTLIN_RUNNER" ];
|
||||
then
|
||||
java_version="$(findJavaVersion)"
|
||||
if [[ $java_version -ge 9 ]]; then
|
||||
# Workaround the illegal reflective access warning from ReflectionUtil to ResourceBundle.setParent, see IDEA-248785.
|
||||
java_args=("${java_args[@]}" "--add-opens" "java.base/java.util=ALL-UNNAMED")
|
||||
fi
|
||||
|
||||
if [ -n "$KOTLIN_RUNNER" ]; then
|
||||
java_args=("${java_args[@]}" "-Dkotlin.home=${KOTLIN_HOME}")
|
||||
kotlin_app=("${KOTLIN_HOME}/lib/kotlin-runner.jar" "org.jetbrains.kotlin.runner.Main")
|
||||
else
|
||||
[ -n "$KOTLIN_COMPILER" ] || KOTLIN_COMPILER=org.jetbrains.kotlin.cli.jvm.K2JVMCompiler
|
||||
java_args=("${java_args[@]}" "-noverify")
|
||||
|
||||
if [[ $java_version < 13 ]]; then
|
||||
java_args=("${java_args[@]}" "-noverify")
|
||||
fi
|
||||
|
||||
declare additional_classpath=""
|
||||
if [ -n "$KOTLIN_TOOL" ];
|
||||
then
|
||||
if [ -n "$KOTLIN_TOOL" ]; then
|
||||
additional_classpath=":${KOTLIN_HOME}/lib/${KOTLIN_TOOL}"
|
||||
fi
|
||||
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2010-2015 JetBrains s.r.o.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# Copyright 2010-2021 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.
|
||||
|
||||
export KOTLIN_COMPILER=org.jetbrains.kotlin.cli.js.K2JSCompiler
|
||||
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
@echo off
|
||||
|
||||
rem Copyright 2010-2015 JetBrains s.r.o.
|
||||
rem
|
||||
rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
rem you may not use this file except in compliance with the License.
|
||||
rem You may obtain a copy of the License at
|
||||
rem
|
||||
rem http://www.apache.org/licenses/LICENSE-2.0
|
||||
rem
|
||||
rem Unless required by applicable law or agreed to in writing, software
|
||||
rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
rem See the License for the specific language governing permissions and
|
||||
rem limitations under the License.
|
||||
rem Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
rem Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
|
||||
setlocal
|
||||
set _KOTLIN_COMPILER=org.jetbrains.kotlin.cli.js.K2JSCompiler
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Copyright 2010-2015 JetBrains s.r.o.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# Copyright 2010-2021 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.
|
||||
|
||||
DIR="${BASH_SOURCE[0]%/*}"
|
||||
: ${DIR:="."}
|
||||
|
||||
@@ -1,17 +1,6 @@
|
||||
@echo off
|
||||
|
||||
rem Copyright 2010-2015 JetBrains s.r.o.
|
||||
rem
|
||||
rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
rem you may not use this file except in compliance with the License.
|
||||
rem You may obtain a copy of the License at
|
||||
rem
|
||||
rem http://www.apache.org/licenses/LICENSE-2.0
|
||||
rem
|
||||
rem Unless required by applicable law or agreed to in writing, software
|
||||
rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
rem See the License for the specific language governing permissions and
|
||||
rem limitations under the License.
|
||||
rem Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
rem Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
|
||||
call %~dps0kotlinc.bat %*
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
@echo off
|
||||
rem based on scalac.bat from the Scala distribution
|
||||
rem ##########################################################################
|
||||
rem # Copyright 2002-2011, LAMP/EPFL
|
||||
rem # Copyright 2011-2015, JetBrains
|
||||
rem #
|
||||
rem # This is free software; see the distribution for copying conditions.
|
||||
rem # There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
|
||||
rem # PARTICULAR PURPOSE.
|
||||
rem ##########################################################################
|
||||
|
||||
rem Based on scalac.bat from the Scala distribution
|
||||
rem Copyright 2002-2011, LAMP/EPFL
|
||||
rem Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
rem Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
|
||||
rem We adopt the following conventions:
|
||||
rem - System/user environment variables start with a letter
|
||||
@@ -19,11 +15,10 @@ call :set_home
|
||||
if "%_KOTLIN_COMPILER%"=="" set _KOTLIN_COMPILER=org.jetbrains.kotlin.cli.jvm.K2JVMCompiler
|
||||
|
||||
if not "%JAVA_HOME%"=="" (
|
||||
if exist "%JAVA_HOME%\bin\java.exe" set "_JAVACMD=%JAVA_HOME%\bin\java.exe"
|
||||
rem Prepend JAVA_HOME to local PATH to be able to simply execute "java" later in the script.
|
||||
set "PATH=%JAVA_HOME%\bin;%PATH%"
|
||||
)
|
||||
|
||||
if "%_JAVACMD%"=="" set _JAVACMD=java
|
||||
|
||||
rem We use the value of the JAVA_OPTS environment variable if defined
|
||||
if "%JAVA_OPTS%"=="" set JAVA_OPTS=-Xmx256M -Xms32M
|
||||
|
||||
@@ -45,18 +40,29 @@ shift
|
||||
goto loop
|
||||
:loopend
|
||||
|
||||
if "%_KOTLIN_RUNNER%"=="1" (
|
||||
"%_JAVACMD%" %JAVA_OPTS% "-Dkotlin.home=%_KOTLIN_HOME%" -cp "%_KOTLIN_HOME%\lib\kotlin-runner.jar" ^
|
||||
setlocal EnableDelayedExpansion
|
||||
|
||||
call :set_java_version
|
||||
if !_java_major_version! geq 9 (
|
||||
rem Workaround the illegal reflective access warning from ReflectionUtil to ResourceBundle.setParent, see IDEA-248785.
|
||||
set JAVA_OPTS=!JAVA_OPTS! "--add-opens" "java.base/java.util=ALL-UNNAMED"
|
||||
)
|
||||
|
||||
if "!_KOTLIN_RUNNER!"=="1" (
|
||||
java !JAVA_OPTS! "-Dkotlin.home=%_KOTLIN_HOME%" -cp "%_KOTLIN_HOME%\lib\kotlin-runner.jar" ^
|
||||
org.jetbrains.kotlin.runner.Main %KOTLIN_OPTS%
|
||||
) else (
|
||||
setlocal EnableDelayedExpansion
|
||||
SET _ADDITIONAL_CLASSPATH=
|
||||
set _ADDITIONAL_CLASSPATH=
|
||||
|
||||
if !_java_major_version! lss 13 (
|
||||
set JAVA_OPTS=!JAVA_OPTS! "-noverify"
|
||||
)
|
||||
|
||||
if not "%_KOTLIN_TOOL%"=="" (
|
||||
set _ADDITIONAL_CLASSPATH=;%_KOTLIN_HOME%\lib\%_KOTLIN_TOOL%
|
||||
)
|
||||
|
||||
"%_JAVACMD%" %JAVA_OPTS% -noverify -cp "%_KOTLIN_HOME%\lib\kotlin-preloader.jar" ^
|
||||
java !JAVA_OPTS! -cp "%_KOTLIN_HOME%\lib\kotlin-preloader.jar" ^
|
||||
org.jetbrains.kotlin.preloading.Preloader -cp "%_KOTLIN_HOME%\lib\kotlin-compiler.jar!_ADDITIONAL_CLASSPATH!" ^
|
||||
%_KOTLIN_COMPILER% %KOTLIN_OPTS%
|
||||
)
|
||||
@@ -73,6 +79,29 @@ rem # subroutines
|
||||
set _KOTLIN_HOME=%_BIN_DIR%..
|
||||
goto :eof
|
||||
|
||||
rem Parses "java -version" output and stores the major version to _java_major_version.
|
||||
rem Note that this only loads the first component of the version, so "1.8.0_265" -> "1".
|
||||
rem But it's fine because major version is 9 for JDK 9, and so on.
|
||||
rem Needs to be executed in the EnableDelayedExpansion mode.
|
||||
:set_java_version
|
||||
set _version=
|
||||
rem Parse output and take the third token from the string containing " version ".
|
||||
rem It should be something like "1.8.0_275" or "15.0.1".
|
||||
for /f "tokens=3" %%i in ('java -version 2^>^&1 ^| findstr /i " version "') do (
|
||||
rem Split the string by "-" or "." and take the first token.
|
||||
for /f "delims=-. tokens=1" %%j in ("%%i") do (
|
||||
rem At this point, _version should be something like "1 or "15. Note the leading quote.
|
||||
set _version=%%j
|
||||
)
|
||||
)
|
||||
if "!_version!"=="" (
|
||||
rem If failed to parse the output, set the version to 1.
|
||||
set _java_major_version=1
|
||||
) else (
|
||||
rem Strip the leading quote.
|
||||
set _java_major_version=!_version:~1!
|
||||
)
|
||||
goto :eof
|
||||
|
||||
:end
|
||||
endlocal
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ dependencies {
|
||||
compile(project(":compiler:fir:checkers"))
|
||||
compile(project(":kotlin-util-klib"))
|
||||
compile(project(":kotlin-util-io"))
|
||||
compile(project(":compiler:ir.serialization.common"))
|
||||
|
||||
// TODO: as soon as cli-jvm is extracted out of this module, move this dependency there
|
||||
compileOnly(project(":compiler:ir.tree.impl"))
|
||||
|
||||
@@ -351,6 +351,19 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
||||
)
|
||||
var inferenceCompatibility: Boolean by FreezableVar(false)
|
||||
|
||||
@Argument(
|
||||
value = "-Xsuppress-version-warnings",
|
||||
description = "Suppress warnings about outdated, inconsistent or experimental language or API versions"
|
||||
)
|
||||
var suppressVersionWarnings: Boolean by FreezableVar(false)
|
||||
|
||||
@Argument(
|
||||
value = "-Xextended-compiler-checks",
|
||||
description = "Enable additional compiler checks that might provide verbose diagnostic information for certain errors.\n" +
|
||||
"Warning: this mode is not backward-compatible and might cause compilation errors in previously compiled code."
|
||||
)
|
||||
var extendedCompilerChecks: Boolean by FreezableVar(false)
|
||||
|
||||
open fun configureAnalysisFlags(collector: MessageCollector): MutableMap<AnalysisFlag<*>, Any> {
|
||||
return HashMap<AnalysisFlag<*>, Any>().apply {
|
||||
put(AnalysisFlags.skipMetadataVersionCheck, skipMetadataVersionCheck)
|
||||
@@ -369,6 +382,7 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
||||
CompilerMessageSeverity.ERROR,
|
||||
"Unknown value for parameter -Xexplicit-api: '$explicitApi'. Value should be one of ${ExplicitApiMode.availableValues()}"
|
||||
)
|
||||
put(AnalysisFlags.extendedCompilerChecks, extendedCompilerChecks)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -496,9 +510,6 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
||||
val apiVersion = parseVersion(collector, apiVersion, "API") ?: languageVersion
|
||||
|
||||
checkApiVersionIsNotGreaterThenLanguageVersion(languageVersion, apiVersion, collector)
|
||||
checkLanguageVersionIsStable(languageVersion, collector)
|
||||
checkOutdatedVersions(languageVersion, apiVersion, collector)
|
||||
checkProgressiveMode(languageVersion, collector)
|
||||
|
||||
val languageVersionSettings = LanguageVersionSettingsImpl(
|
||||
languageVersion,
|
||||
@@ -507,7 +518,13 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
||||
configureLanguageFeatures(collector)
|
||||
)
|
||||
|
||||
checkIrSupport(languageVersionSettings, collector)
|
||||
if (!suppressVersionWarnings) {
|
||||
checkLanguageVersionIsStable(languageVersion, collector)
|
||||
checkOutdatedVersions(languageVersion, apiVersion, collector)
|
||||
checkProgressiveMode(languageVersion, collector)
|
||||
|
||||
checkIrSupport(languageVersionSettings, collector)
|
||||
}
|
||||
|
||||
return languageVersionSettings
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
|
||||
@Argument(
|
||||
value = "-jvm-target",
|
||||
valueDescription = "<version>",
|
||||
description = "Target version of the generated JVM bytecode (1.6, 1.8, 9, 10, 11, 12, 13, 14 or 15), default is 1.6"
|
||||
description = "Target version of the generated JVM bytecode (1.6 (DEPRECATED), 1.8, 9, 10, 11, 12, 13, 14 or 15), default is 1.8"
|
||||
)
|
||||
var jvmTarget: String? by NullableStringFreezableVar(JvmTarget.DEFAULT.description)
|
||||
|
||||
@@ -355,10 +355,10 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
|
||||
@Argument(
|
||||
value = "-Xstring-concat",
|
||||
valueDescription = "{indy-with-constants|indy|inline}",
|
||||
description = """Switch a way in which string concatenation is performed.
|
||||
-Xstring-concat=indy-with-constants Performs string concatenation via `invokedynamic` 'makeConcatWithConstants'. Works only with `-jvm-target 9` or greater
|
||||
-Xstring-concat=indy Performs string concatenation via `invokedynamic` 'makeConcat'. Works only with `-jvm-target 9` or greater
|
||||
-Xstring-concat=inline Performs string concatenation via `StringBuilder`"""
|
||||
description = """Select code generation scheme for string concatenation.
|
||||
-Xstring-concat=indy-with-constants Concatenate strings using `invokedynamic` `makeConcatWithConstants`. Requires `-jvm-target 9` or greater.
|
||||
-Xstring-concat=indy Concatenate strings using `invokedynamic` `makeConcat`. Requires `-jvm-target 9` or greater.
|
||||
-Xstring-concat=inline Concatenate strings using `StringBuilder`"""
|
||||
)
|
||||
var stringConcat: String? by NullableStringFreezableVar(JvmStringConcat.INLINE.description)
|
||||
|
||||
@@ -366,10 +366,20 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
|
||||
value = "-Xsam-conversions",
|
||||
valueDescription = "{class|indy}",
|
||||
description = """Select code generation scheme for SAM conversions.
|
||||
-Xsam-conversions=indy Generate SAM conversions using `invokedynamic` with `LambdaMetafactory.metafactory`. Requires `-jvm-target 8` or greater.
|
||||
-Xsam-conversions=indy Generate SAM conversions using `invokedynamic` with `LambdaMetafactory.metafactory`. Requires `-jvm-target 1.8` or greater.
|
||||
-Xsam-conversions=class Generate SAM conversions as explicit classes"""
|
||||
)
|
||||
var samConversions: String? by NullableStringFreezableVar(JvmSamConversions.CLASS.description)
|
||||
var samConversions: String? by NullableStringFreezableVar(null)
|
||||
|
||||
@Argument(
|
||||
value = "-Xlambdas",
|
||||
valueDescription = "{class|indy}",
|
||||
description = """Select code generation scheme for lambdas.
|
||||
-Xlambdas=indy Generate lambdas using `invokedynamic` with `LambdaMetafactory.metafactory`. Requires `-jvm-target 1.8` or greater.
|
||||
Lambda objects created using `LambdaMetafactory.metafactory` will have different `toString()`.
|
||||
-Xlambdas=class Generate lambdas as explicit classes"""
|
||||
)
|
||||
var lambdas: String? by NullableStringFreezableVar(null)
|
||||
|
||||
@Argument(
|
||||
value = "-Xklib",
|
||||
@@ -438,6 +448,12 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
|
||||
)
|
||||
var enableJvmPreview: Boolean by FreezableVar(false)
|
||||
|
||||
@Argument(
|
||||
value = "-Xsuppress-deprecated-jvm-target-warning",
|
||||
description = "Suppress deprecation warning about deprecated JVM target versions"
|
||||
)
|
||||
var suppressDeprecatedJvmTargetWarning: Boolean by FreezableVar(false)
|
||||
|
||||
override fun configureAnalysisFlags(collector: MessageCollector): MutableMap<AnalysisFlag<*>, Any> {
|
||||
val result = super.configureAnalysisFlags(collector)
|
||||
result[JvmAnalysisFlags.strictMetadataVersionSemantics] = strictMetadataVersionSemantics
|
||||
|
||||
@@ -192,21 +192,17 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
|
||||
require(outputFile.extension == KLIB_FILE_EXTENSION) { "Please set up .klib file as output" }
|
||||
}
|
||||
|
||||
try {
|
||||
generateKLib(
|
||||
project = config.project,
|
||||
files = sourcesFiles,
|
||||
analyzer = AnalyzerWithCompilerReport(config.configuration),
|
||||
configuration = config.configuration,
|
||||
allDependencies = resolvedLibraries,
|
||||
friendDependencies = friendDependencies,
|
||||
irFactory = PersistentIrFactory,
|
||||
outputKlibPath = outputFile.path,
|
||||
nopack = arguments.irProduceKlibDir
|
||||
)
|
||||
} catch (e: JsIrCompilationError) {
|
||||
return COMPILATION_ERROR
|
||||
}
|
||||
generateKLib(
|
||||
project = config.project,
|
||||
files = sourcesFiles,
|
||||
analyzer = AnalyzerWithCompilerReport(config.configuration),
|
||||
configuration = config.configuration,
|
||||
allDependencies = resolvedLibraries,
|
||||
friendDependencies = friendDependencies,
|
||||
irFactory = PersistentIrFactory,
|
||||
outputKlibPath = outputFile.path,
|
||||
nopack = arguments.irProduceKlibDir
|
||||
)
|
||||
}
|
||||
|
||||
if (arguments.irProduceJs) {
|
||||
@@ -252,26 +248,22 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
|
||||
return OK
|
||||
}
|
||||
|
||||
val compiledModule = try {
|
||||
compile(
|
||||
projectJs,
|
||||
mainModule,
|
||||
AnalyzerWithCompilerReport(config.configuration),
|
||||
config.configuration,
|
||||
phaseConfig,
|
||||
allDependencies = resolvedLibraries,
|
||||
friendDependencies = friendDependencies,
|
||||
mainArguments = mainCallArguments,
|
||||
generateFullJs = !arguments.irDce,
|
||||
generateDceJs = arguments.irDce,
|
||||
dceDriven = arguments.irDceDriven,
|
||||
multiModule = arguments.irPerModule,
|
||||
relativeRequirePath = true,
|
||||
propertyLazyInitialization = arguments.irPropertyLazyInitialization,
|
||||
)
|
||||
} catch (e: JsIrCompilationError) {
|
||||
return COMPILATION_ERROR
|
||||
}
|
||||
val compiledModule = compile(
|
||||
projectJs,
|
||||
mainModule,
|
||||
AnalyzerWithCompilerReport(config.configuration),
|
||||
config.configuration,
|
||||
phaseConfig,
|
||||
allDependencies = resolvedLibraries,
|
||||
friendDependencies = friendDependencies,
|
||||
mainArguments = mainCallArguments,
|
||||
generateFullJs = !arguments.irDce,
|
||||
generateDceJs = arguments.irDce,
|
||||
dceDriven = arguments.irDceDriven,
|
||||
multiModule = arguments.irPerModule,
|
||||
relativeRequirePath = true,
|
||||
propertyLazyInitialization = arguments.irPropertyLazyInitialization,
|
||||
)
|
||||
|
||||
val jsCode = if (arguments.irDce && !arguments.irDceDriven) compiledModule.dceJsCode!! else compiledModule.jsCode!!
|
||||
outputFile.writeText(jsCode.mainModule)
|
||||
|
||||
@@ -76,17 +76,23 @@ class K2JSDce : CLITool<K2JSDceArguments>() {
|
||||
messageCollector.report(severity, message)
|
||||
}
|
||||
|
||||
val dceResult = DeadCodeElimination.run(files, includedDeclarations, logConsumer)
|
||||
val dceResult = DeadCodeElimination.run(
|
||||
files,
|
||||
includedDeclarations,
|
||||
arguments.printReachabilityInfo,
|
||||
logConsumer
|
||||
)
|
||||
if (dceResult.status == DeadCodeEliminationStatus.FAILED) return ExitCode.COMPILATION_ERROR
|
||||
val nodes = dceResult.reachableNodes.filterTo(mutableSetOf()) { it.reachable }
|
||||
|
||||
val reachabilitySeverity = if (arguments.printReachabilityInfo) CompilerMessageSeverity.INFO else CompilerMessageSeverity.LOGGING
|
||||
messageCollector.report(reachabilitySeverity, "")
|
||||
for (node in nodes.extractRoots()) {
|
||||
printTree(
|
||||
node, { messageCollector.report(reachabilitySeverity, it) },
|
||||
printNestedMembers = false, showLocations = true
|
||||
)
|
||||
if (arguments.printReachabilityInfo) {
|
||||
val reachabilitySeverity = CompilerMessageSeverity.INFO
|
||||
messageCollector.report(reachabilitySeverity, "")
|
||||
for (node in dceResult.reachableNodes.extractReachableRoots(dceResult.context!!)) {
|
||||
printTree(
|
||||
node, { messageCollector.report(reachabilitySeverity, it) },
|
||||
printNestedMembers = false, showLocations = true
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return ExitCode.OK
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.cli.jvm.plugins.PluginCliParser
|
||||
import org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.config.Services
|
||||
import org.jetbrains.kotlin.ir.util.IrMessageLogger
|
||||
import org.jetbrains.kotlin.metadata.deserialization.BinaryVersion
|
||||
import org.jetbrains.kotlin.progress.CompilationCanceledException
|
||||
import org.jetbrains.kotlin.progress.CompilationCanceledStatus
|
||||
@@ -39,7 +40,7 @@ import org.jetbrains.kotlin.utils.KotlinPaths
|
||||
import org.jetbrains.kotlin.utils.PathUtil
|
||||
import java.io.File
|
||||
import java.io.PrintStream
|
||||
import java.util.ArrayList
|
||||
import java.util.*
|
||||
|
||||
abstract class CLICompiler<A : CommonCompilerArguments> : CLITool<A>() {
|
||||
|
||||
@@ -69,6 +70,8 @@ abstract class CLICompiler<A : CommonCompilerArguments> : CLITool<A>() {
|
||||
configuration.put(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, it)
|
||||
}
|
||||
|
||||
configuration.put(IrMessageLogger.IR_MESSAGE_LOGGER, IrMessageCollector(collector))
|
||||
|
||||
configuration.put(CLIConfigurationKeys.PERF_MANAGER, performanceManager)
|
||||
try {
|
||||
setupCommonArguments(configuration, arguments)
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.analyzer.AnalysisResult
|
||||
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
|
||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.*
|
||||
import org.jetbrains.kotlin.codegen.state.IncompatibleClassTrackerImpl
|
||||
import org.jetbrains.kotlin.config.AnalysisFlags
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.config.languageVersionSettings
|
||||
@@ -72,6 +73,9 @@ class AnalyzerWithCompilerReport(
|
||||
.append(", unresolved supertypes: ").append(unresolved!!.joinToString())
|
||||
.append("\n")
|
||||
}
|
||||
if (!languageVersionSettings.getFlag(AnalysisFlags.extendedCompilerChecks)) {
|
||||
message.append("Adding -Xextended-compiler-checks argument might provide additional information.\n")
|
||||
}
|
||||
messageCollector.report(ERROR, message.toString())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright 2010-2021 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.common.messages
|
||||
|
||||
import org.jetbrains.kotlin.ir.util.IrMessageLogger
|
||||
|
||||
class IrMessageCollector(private val messageCollector: MessageCollector) : IrMessageLogger {
|
||||
override fun report(severity: IrMessageLogger.Severity, message: String, location: IrMessageLogger.Location?) {
|
||||
messageCollector.report(severityToCLISeverity(severity), message, locationToCLILocation(location))
|
||||
}
|
||||
|
||||
companion object {
|
||||
private fun severityToCLISeverity(severity: IrMessageLogger.Severity): CompilerMessageSeverity {
|
||||
return when (severity) {
|
||||
IrMessageLogger.Severity.INFO -> CompilerMessageSeverity.INFO
|
||||
IrMessageLogger.Severity.WARNING -> CompilerMessageSeverity.WARNING
|
||||
IrMessageLogger.Severity.ERROR -> CompilerMessageSeverity.ERROR
|
||||
}
|
||||
}
|
||||
|
||||
private fun locationToCLILocation(location: IrMessageLogger.Location?): CompilerMessageLocation? {
|
||||
return location?.run {
|
||||
CompilerMessageLocation.Companion.create(filePath, line, column, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,10 +12,7 @@ import com.intellij.psi.search.GlobalSearchScope
|
||||
import com.intellij.psi.search.PsiSearchScopeUtil
|
||||
import com.intellij.util.SmartList
|
||||
import org.jetbrains.kotlin.asJava.KotlinAsJavaSupport
|
||||
import org.jetbrains.kotlin.asJava.classes.KtLightClass
|
||||
import org.jetbrains.kotlin.asJava.classes.KtLightClassForFacade
|
||||
import org.jetbrains.kotlin.asJava.classes.KtLightClassForScript
|
||||
import org.jetbrains.kotlin.asJava.classes.KtLightClassForSourceDeclaration
|
||||
import org.jetbrains.kotlin.asJava.classes.*
|
||||
import org.jetbrains.kotlin.descriptors.PackageViewDescriptor
|
||||
import org.jetbrains.kotlin.fileClasses.javaFileFacadeFqName
|
||||
import org.jetbrains.kotlin.load.java.components.FilesByFacadeFqNameIndexer
|
||||
@@ -81,6 +78,8 @@ class CliKotlinAsJavaSupport(
|
||||
}.orEmpty()
|
||||
}
|
||||
|
||||
override fun getFakeLightClass(classOrObject: KtClassOrObject): KtFakeLightClass =
|
||||
KtDescriptorBasedFakeLightClass(classOrObject)
|
||||
|
||||
override fun findClassOrObjectDeclarationsInPackage(
|
||||
packageFqName: FqName, searchScope: GlobalSearchScope
|
||||
|
||||
@@ -23,11 +23,17 @@ import org.jetbrains.kotlin.asJava.builder.InvalidLightClassDataHolder
|
||||
import org.jetbrains.kotlin.asJava.builder.LightClassConstructionContext
|
||||
import org.jetbrains.kotlin.asJava.builder.LightClassDataHolder
|
||||
import org.jetbrains.kotlin.asJava.builder.LightClassDataHolderImpl
|
||||
import org.jetbrains.kotlin.asJava.classes.*
|
||||
import org.jetbrains.kotlin.asJava.classes.KtUltraLightSupport
|
||||
import org.jetbrains.kotlin.asJava.classes.cleanFromAnonymousTypes
|
||||
import org.jetbrains.kotlin.asJava.classes.lazyPub
|
||||
import org.jetbrains.kotlin.asJava.classes.tryGetPredefinedName
|
||||
import org.jetbrains.kotlin.codegen.ClassBuilderMode
|
||||
import org.jetbrains.kotlin.codegen.JvmCodegenUtil
|
||||
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper
|
||||
import org.jetbrains.kotlin.config.*
|
||||
import org.jetbrains.kotlin.config.JvmAnalysisFlags
|
||||
import org.jetbrains.kotlin.config.JvmTarget
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.load.java.components.JavaDeprecationSettings
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
@@ -57,7 +63,8 @@ class CliLightClassGenerationSupport(
|
||||
|
||||
private class CliLightClassSupport(
|
||||
private val project: Project,
|
||||
override val languageVersionSettings: LanguageVersionSettings
|
||||
override val languageVersionSettings: LanguageVersionSettings,
|
||||
private val jvmTarget: JvmTarget
|
||||
) : KtUltraLightSupport {
|
||||
|
||||
// This is the way to untie CliLightClassSupport and CliLightClassGenerationSupport to prevent descriptors leak
|
||||
@@ -88,7 +95,7 @@ class CliLightClassGenerationSupport(
|
||||
moduleName,
|
||||
languageVersionSettings,
|
||||
useOldInlineClassesManglingScheme = false,
|
||||
jvmTarget = JvmTarget.JVM_1_8,
|
||||
jvmTarget = jvmTarget,
|
||||
typePreprocessor = KotlinType::cleanFromAnonymousTypes,
|
||||
namePreprocessor = ::tryGetPredefinedName
|
||||
)
|
||||
@@ -96,7 +103,7 @@ class CliLightClassGenerationSupport(
|
||||
}
|
||||
|
||||
private val ultraLightSupport: KtUltraLightSupport by lazyPub {
|
||||
CliLightClassSupport(project, traceHolder.languageVersionSettings)
|
||||
CliLightClassSupport(project, traceHolder.languageVersionSettings, traceHolder.jvmTarget)
|
||||
}
|
||||
|
||||
override fun getUltraLightClassSupport(element: KtElement): KtUltraLightSupport {
|
||||
@@ -129,7 +136,9 @@ class CliLightClassGenerationSupport(
|
||||
}
|
||||
|
||||
private fun getContext(): LightClassConstructionContext =
|
||||
LightClassConstructionContext(traceHolder.bindingContext, traceHolder.module)
|
||||
LightClassConstructionContext(
|
||||
traceHolder.bindingContext, traceHolder.module, null /* TODO: traceHolder.languageVersionSettings? */, traceHolder.jvmTarget
|
||||
)
|
||||
|
||||
override fun resolveToDescriptor(declaration: KtDeclaration): DeclarationDescriptor? {
|
||||
return traceHolder.bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, declaration)
|
||||
@@ -140,4 +149,4 @@ class CliLightClassGenerationSupport(
|
||||
override fun analyzeAnnotation(element: KtAnnotationEntry) = traceHolder.bindingContext.get(BindingContext.ANNOTATION, element)
|
||||
|
||||
override fun analyzeWithContent(element: KtClassOrObject) = traceHolder.bindingContext
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
package org.jetbrains.kotlin.cli.jvm.compiler
|
||||
|
||||
import org.jetbrains.annotations.TestOnly
|
||||
import org.jetbrains.kotlin.config.JvmTarget
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
@@ -13,30 +14,32 @@ import org.jetbrains.kotlin.psi.KtPsiUtil
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.BindingTrace
|
||||
import org.jetbrains.kotlin.resolve.BindingTraceContext
|
||||
import org.jetbrains.kotlin.resolve.CodeAnalyzerInitializer
|
||||
import org.jetbrains.kotlin.resolve.jvm.JvmCodeAnalyzerInitializer
|
||||
import org.jetbrains.kotlin.resolve.lazy.KotlinCodeAnalyzer
|
||||
import org.jetbrains.kotlin.util.slicedMap.ReadOnlySlice
|
||||
import org.jetbrains.kotlin.util.slicedMap.WritableSlice
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
class CliTraceHolder : CodeAnalyzerInitializer {
|
||||
var bindingContext: BindingContext by Delegates.notNull()
|
||||
class CliTraceHolder : JvmCodeAnalyzerInitializer() {
|
||||
lateinit var bindingContext: BindingContext
|
||||
private set
|
||||
var module: ModuleDescriptor by Delegates.notNull()
|
||||
lateinit var module: ModuleDescriptor
|
||||
private set
|
||||
var languageVersionSettings: LanguageVersionSettings by Delegates.notNull()
|
||||
lateinit var languageVersionSettings: LanguageVersionSettings
|
||||
private set
|
||||
lateinit var jvmTarget: JvmTarget
|
||||
private set
|
||||
|
||||
|
||||
override fun initialize(
|
||||
trace: BindingTrace,
|
||||
module: ModuleDescriptor,
|
||||
codeAnalyzer: KotlinCodeAnalyzer,
|
||||
languageVersionSettings: LanguageVersionSettings
|
||||
languageVersionSettings: LanguageVersionSettings,
|
||||
jvmTarget: JvmTarget
|
||||
) {
|
||||
this.bindingContext = trace.bindingContext
|
||||
this.module = module
|
||||
this.languageVersionSettings = languageVersionSettings
|
||||
this.jvmTarget = jvmTarget
|
||||
|
||||
if (trace !is CliBindingTrace) {
|
||||
throw IllegalArgumentException("Shared trace is expected to be subclass of ${CliBindingTrace::class.java.simpleName} class")
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.jetbrains.kotlin.cli.common.messages.MessageCollector;
|
||||
import org.jetbrains.kotlin.cli.common.modules.ModuleChunk;
|
||||
import org.jetbrains.kotlin.cli.common.modules.ModuleXmlParser;
|
||||
import org.jetbrains.kotlin.name.FqName;
|
||||
import org.jetbrains.kotlin.serialization.deserialization.builtins.BuiltInSerializerProtocol;
|
||||
import org.jetbrains.kotlin.utils.ExceptionUtilsKt;
|
||||
import org.jetbrains.kotlin.utils.PathUtil;
|
||||
|
||||
@@ -60,6 +61,7 @@ public class CompileEnvironmentUtil {
|
||||
OutputStream fos,
|
||||
@Nullable FqName mainClass,
|
||||
boolean includeRuntime,
|
||||
boolean noReflect,
|
||||
boolean resetJarTimestamps
|
||||
) {
|
||||
try {
|
||||
@@ -89,6 +91,9 @@ public class CompileEnvironmentUtil {
|
||||
}
|
||||
if (includeRuntime) {
|
||||
writeRuntimeToJar(stream, resetJarTimestamps);
|
||||
if (!noReflect) {
|
||||
writeReflectToJar(stream, resetJarTimestamps);
|
||||
}
|
||||
}
|
||||
stream.finish();
|
||||
}
|
||||
@@ -98,12 +103,12 @@ public class CompileEnvironmentUtil {
|
||||
}
|
||||
|
||||
public static void writeToJar(
|
||||
File jarPath, boolean jarRuntime, boolean resetJarTimestamps, FqName mainClass, OutputFileCollection outputFiles
|
||||
File jarPath, boolean jarRuntime, boolean noReflect, boolean resetJarTimestamps, FqName mainClass, OutputFileCollection outputFiles
|
||||
) {
|
||||
FileOutputStream outputStream = null;
|
||||
try {
|
||||
outputStream = new FileOutputStream(jarPath);
|
||||
doWriteToJar(outputFiles, outputStream, mainClass, jarRuntime, resetJarTimestamps);
|
||||
doWriteToJar(outputFiles, outputStream, mainClass, jarRuntime, noReflect, resetJarTimestamps);
|
||||
outputStream.close();
|
||||
}
|
||||
catch (FileNotFoundException e) {
|
||||
@@ -125,13 +130,22 @@ public class CompileEnvironmentUtil {
|
||||
copyJarImpl(stream, stdlibPath, resetJarTimestamps);
|
||||
}
|
||||
|
||||
private static void writeReflectToJar(JarOutputStream stream, boolean resetJarTimestamps) throws IOException {
|
||||
File reflectPath = PathUtil.getKotlinPathsForCompiler().getReflectPath();
|
||||
if (!reflectPath.exists()) {
|
||||
throw new CompileEnvironmentException("Couldn't find kotlin-reflect at " + reflectPath);
|
||||
}
|
||||
copyJarImpl(stream, reflectPath, resetJarTimestamps);
|
||||
}
|
||||
|
||||
private static void copyJarImpl(JarOutputStream stream, File jarPath, boolean resetJarTimestamps) throws IOException {
|
||||
try (JarInputStream jis = new JarInputStream(new FileInputStream(jarPath))) {
|
||||
while (true) {
|
||||
JarEntry e = jis.getNextJarEntry();
|
||||
if (e == null) break;
|
||||
|
||||
if (!FileUtilRt.extensionEquals(e.getName(), "class") ||
|
||||
if ((!FileUtilRt.extensionEquals(e.getName(), "class") &&
|
||||
!FileUtilRt.extensionEquals(e.getName(), BuiltInSerializerProtocol.BUILTINS_FILE_EXTENSION)) ||
|
||||
StringsKt.substringAfterLast(e.getName(), "/", e.getName()).equals("module-info.class")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -19,10 +19,11 @@ package org.jetbrains.kotlin.cli.jvm.compiler
|
||||
import com.intellij.core.JavaCoreProjectEnvironment
|
||||
import com.intellij.openapi.Disposable
|
||||
import com.intellij.psi.PsiManager
|
||||
import org.jetbrains.kotlin.resolve.jvm.KotlinCliJavaFileManager
|
||||
|
||||
open class KotlinCoreProjectEnvironment(
|
||||
disposable: Disposable,
|
||||
applicationEnvironment: KotlinCoreApplicationEnvironment
|
||||
) : JavaCoreProjectEnvironment(disposable, applicationEnvironment) {
|
||||
override fun createCoreFileManager() = KotlinCliJavaFileManagerImpl(PsiManager.getInstance(project))
|
||||
override fun createCoreFileManager(): KotlinCliJavaFileManager = KotlinCliJavaFileManagerImpl(PsiManager.getInstance(project))
|
||||
}
|
||||
|
||||
@@ -86,8 +86,9 @@ object KotlinToJVMBytecodeCompiler {
|
||||
val messageCollector = configuration.get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, MessageCollector.NONE)
|
||||
if (jarPath != null) {
|
||||
val includeRuntime = configuration.get(JVMConfigurationKeys.INCLUDE_RUNTIME, false)
|
||||
val noReflect = configuration.get(JVMConfigurationKeys.NO_REFLECT, false)
|
||||
val resetJarTimestamps = !configuration.get(JVMConfigurationKeys.NO_RESET_JAR_TIMESTAMPS, false)
|
||||
CompileEnvironmentUtil.writeToJar(jarPath, includeRuntime, resetJarTimestamps, mainClassFqName, outputFiles)
|
||||
CompileEnvironmentUtil.writeToJar(jarPath, includeRuntime, noReflect, resetJarTimestamps, mainClassFqName, outputFiles)
|
||||
if (reportOutputFiles) {
|
||||
val message = OutputMessageUtil.formatOutputMessage(outputFiles.asList().flatMap { it.sourceFiles }.distinct(), jarPath)
|
||||
messageCollector.report(OUTPUT, message)
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.io.File
|
||||
|
||||
fun CompilerConfiguration.setupJvmSpecificArguments(arguments: K2JVMCompilerArguments) {
|
||||
put(JVMConfigurationKeys.INCLUDE_RUNTIME, arguments.includeRuntime)
|
||||
put(JVMConfigurationKeys.NO_REFLECT, arguments.noReflect)
|
||||
|
||||
putIfNotNull(JVMConfigurationKeys.FRIEND_PATHS, arguments.friendPaths?.asList())
|
||||
|
||||
@@ -28,6 +29,12 @@ fun CompilerConfiguration.setupJvmSpecificArguments(arguments: K2JVMCompilerArgu
|
||||
val jvmTarget = JvmTarget.fromString(arguments.jvmTarget!!)
|
||||
if (jvmTarget != null) {
|
||||
put(JVMConfigurationKeys.JVM_TARGET, jvmTarget)
|
||||
if (jvmTarget == JvmTarget.JVM_1_6 && !arguments.suppressDeprecatedJvmTargetWarning) {
|
||||
messageCollector.report(
|
||||
STRONG_WARNING,
|
||||
"JVM target 1.6 is deprecated and will be removed in a future release. Please migrate to JVM target 1.8 or above"
|
||||
)
|
||||
}
|
||||
} else {
|
||||
messageCollector.report(
|
||||
ERROR, "Unknown JVM target version: ${arguments.jvmTarget}\n" +
|
||||
@@ -65,27 +72,37 @@ fun CompilerConfiguration.setupJvmSpecificArguments(arguments: K2JVMCompilerArgu
|
||||
}
|
||||
}
|
||||
|
||||
if (arguments.samConversions != null) {
|
||||
val samConversions = JvmSamConversions.fromString(arguments.samConversions)
|
||||
if (samConversions != null) {
|
||||
put(JVMConfigurationKeys.SAM_CONVERSIONS, samConversions)
|
||||
if (jvmTarget < samConversions.minJvmTarget) {
|
||||
handleClosureGenerationSchemeArgument("-Xsam-conversions", arguments.samConversions, JVMConfigurationKeys.SAM_CONVERSIONS, jvmTarget)
|
||||
handleClosureGenerationSchemeArgument("-Xlambdas", arguments.lambdas, JVMConfigurationKeys.LAMBDAS, jvmTarget)
|
||||
|
||||
addAll(JVMConfigurationKeys.ADDITIONAL_JAVA_MODULES, arguments.additionalJavaModules?.asList())
|
||||
}
|
||||
|
||||
private fun CompilerConfiguration.handleClosureGenerationSchemeArgument(
|
||||
flag: String,
|
||||
value: String?,
|
||||
key: CompilerConfigurationKey<JvmClosureGenerationScheme>,
|
||||
jvmTarget: JvmTarget
|
||||
) {
|
||||
if (value != null) {
|
||||
val parsedValue = JvmClosureGenerationScheme.fromString(value)
|
||||
if (parsedValue != null) {
|
||||
put(key, parsedValue)
|
||||
if (jvmTarget < parsedValue.minJvmTarget) {
|
||||
messageCollector.report(
|
||||
WARNING,
|
||||
"`-Xsam-conversions=${arguments.samConversions}` requires JVM target at least " +
|
||||
"${samConversions.minJvmTarget.description} and is ignored."
|
||||
"`$flag=$value` requires JVM target at least " +
|
||||
"${parsedValue.minJvmTarget.description} and is ignored."
|
||||
)
|
||||
}
|
||||
} else {
|
||||
messageCollector.report(
|
||||
ERROR,
|
||||
"Unknown `-Xsam-conversions` argument: ${arguments.samConversions}\n" +
|
||||
"Supported arguments: ${JvmSamConversions.values().joinToString { it.description }}"
|
||||
"Unknown `$flag` argument: ${value}\n." +
|
||||
"Supported arguments: ${JvmClosureGenerationScheme.values().joinToString { it.description }}"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
addAll(JVMConfigurationKeys.ADDITIONAL_JAVA_MODULES, arguments.additionalJavaModules?.asList())
|
||||
}
|
||||
|
||||
fun CompilerConfiguration.configureJdkHome(arguments: K2JVMCompilerArguments): Boolean {
|
||||
|
||||
@@ -114,9 +114,12 @@ public class JVMConfigurationKeys {
|
||||
public static final CompilerConfigurationKey<JvmStringConcat> STRING_CONCAT =
|
||||
CompilerConfigurationKey.create("Specifies string concatenation scheme");
|
||||
|
||||
public static final CompilerConfigurationKey<JvmSamConversions> SAM_CONVERSIONS =
|
||||
public static final CompilerConfigurationKey<JvmClosureGenerationScheme> SAM_CONVERSIONS =
|
||||
CompilerConfigurationKey.create("SAM conversions code generation scheme");
|
||||
|
||||
public static final CompilerConfigurationKey<JvmClosureGenerationScheme> LAMBDAS =
|
||||
CompilerConfigurationKey.create("Lambdas code generation scheme");
|
||||
|
||||
public static final CompilerConfigurationKey<List<String>> KLIB_PATHS =
|
||||
CompilerConfigurationKey.create("Paths to .klib libraries");
|
||||
|
||||
@@ -146,4 +149,7 @@ public class JVMConfigurationKeys {
|
||||
|
||||
public static final CompilerConfigurationKey<Boolean> ENABLE_JVM_PREVIEW =
|
||||
CompilerConfigurationKey.create("Enable Java language preview features");
|
||||
|
||||
public static final CompilerConfigurationKey<Boolean> NO_REFLECT =
|
||||
CompilerConfigurationKey.create("Don't automatically include kotlin-reflect.jar into the output if the output is a jar");
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.config
|
||||
|
||||
enum class JvmSamConversions(
|
||||
enum class JvmClosureGenerationScheme(
|
||||
val description: String,
|
||||
val minJvmTarget: JvmTarget
|
||||
) {
|
||||
@@ -36,7 +36,7 @@ enum class JvmTarget(
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
val DEFAULT = JVM_1_6
|
||||
val DEFAULT = JVM_1_8
|
||||
|
||||
@JvmStatic
|
||||
fun fromString(string: String) = values().find { it.description == string }
|
||||
|
||||
@@ -50,4 +50,7 @@ object AnalysisFlags {
|
||||
|
||||
@JvmStatic
|
||||
val libraryToSourceAnalysis by AnalysisFlag.Delegates.Boolean
|
||||
|
||||
@JvmStatic
|
||||
val extendedCompilerChecks by AnalysisFlag.Delegates.Boolean
|
||||
}
|
||||
|
||||
@@ -374,10 +374,16 @@ object KotlinCompilerClient {
|
||||
// hide daemon window
|
||||
"-Djava.awt.headless=true",
|
||||
"-D$JAVA_RMI_SERVER_HOSTNAME=$serverHostname")
|
||||
val javaVersion = System.getProperty("java.specification.version")?.toIntOrNull()
|
||||
val javaIllegalAccessWorkaround =
|
||||
if (javaVersion != null && javaVersion >= 17)
|
||||
listOf("--illegal-access=permit")
|
||||
else emptyList()
|
||||
val args = listOf(
|
||||
javaExecutable.absolutePath, "-cp", compilerId.compilerClasspath.joinToString(File.pathSeparator)) +
|
||||
platformSpecificOptions +
|
||||
daemonJVMOptions.mappers.flatMap { it.toArgs("-") } +
|
||||
javaIllegalAccessWorkaround +
|
||||
COMPILER_DAEMON_CLASS_FQN +
|
||||
daemonOptions.mappers.flatMap { it.toArgs(COMPILE_DAEMON_CMDLINE_OPTIONS_PREFIX) } +
|
||||
compilerId.mappers.flatMap { it.toArgs(COMPILE_DAEMON_CMDLINE_OPTIONS_PREFIX) }
|
||||
|
||||
@@ -24,26 +24,14 @@ dependencies {
|
||||
testApi(project(":compiler:fir:entrypoint"))
|
||||
testApi(project(":compiler:frontend"))
|
||||
|
||||
testApi(platform("org.junit:junit-bom:5.7.0"))
|
||||
testApi("org.junit.jupiter:junit-jupiter")
|
||||
testApi("org.junit.platform:junit-platform-commons:1.7.0")
|
||||
testApi("org.junit.platform:junit-platform-launcher:1.7.0")
|
||||
testApiJUnit5()
|
||||
|
||||
testCompileOnly(project(":kotlin-reflect-api"))
|
||||
testRuntimeOnly(project(":kotlin-reflect"))
|
||||
testRuntimeOnly(project(":core:descriptors.runtime"))
|
||||
testRuntimeOnly(androidDxJar())
|
||||
testRuntimeOnly(project(":compiler:fir:fir2ir:jvm-backend"))
|
||||
|
||||
testImplementation(intellijCoreDep()) { includeJars("intellij-core") }
|
||||
testImplementation(intellijDep()) {
|
||||
// This dependency is needed only for FileComparisonFailure
|
||||
includeJars("idea_rt", rootProject = rootProject)
|
||||
isTransitive = false
|
||||
}
|
||||
|
||||
// This is needed only for using FileComparisonFailure, which relies on JUnit 3 classes
|
||||
testRuntimeOnly(commonDep("junit:junit"))
|
||||
testRuntimeOnly(intellijDep()) {
|
||||
includeJars(
|
||||
"jps-model",
|
||||
|
||||
@@ -54,6 +54,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/cast.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("catchParameter.kt")
|
||||
public void testCatchParameter() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/catchParameter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("companion.kt")
|
||||
public void testCompanion() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/companion.kt");
|
||||
@@ -414,6 +419,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/syntheticsVsNormalProperties.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("throwableSubclass.kt")
|
||||
public void testThrowableSubclass() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/throwableSubclass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("treeSet.kt")
|
||||
public void testTreeSet() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/treeSet.kt");
|
||||
@@ -3098,6 +3108,39 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/suppress")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Suppress extends AbstractLazyBodyIsNotTouchedTilContractsPhaseTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInSuppress() throws Exception {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/suppress"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@TestMetadata("allWarnings.kt")
|
||||
public void testAllWarnings() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/suppress/allWarnings.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("multipleWarnings.kt")
|
||||
public void testMultipleWarnings() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/suppress/multipleWarnings.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("singleError.kt")
|
||||
public void testSingleError() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/suppress/singleError.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("singleWarning.kt")
|
||||
public void testSingleWarning() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/suppress/singleWarning.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/types")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
FILE: safeCallOnTypeAlias.kt
|
||||
public final typealias MyTypeAlias = R|() -> kotlin/String?|
|
||||
public final fun foo(x: R|MyTypeAlias|): R|kotlin/Unit| {
|
||||
R|<local>/x|?.{ $subj$.R|kotlin/let|<R|() -> kotlin/String?|, R|kotlin/String|>(<L> = let@fun <anonymous>(y: R|() -> kotlin/String?|): R|kotlin/String| <kind=EXACTLY_ONCE> {
|
||||
R|<local>/x|?.{ $subj$.R|kotlin/let|<R|() -> kotlin/String?|, R|kotlin/String?|>(<L> = let@fun <anonymous>(y: R|() -> kotlin/String?|): R|kotlin/String?| <kind=EXACTLY_ONCE> {
|
||||
^ R|<local>/y|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/String?|>|()?.{ $subj$.R|kotlin/let|<R|kotlin/String|, R|kotlin/String|>(<L> = let@fun <anonymous>(result: R|kotlin/String|): R|kotlin/String| <kind=EXACTLY_ONCE> {
|
||||
^ R|/bar|(R|<local>/result|)
|
||||
}
|
||||
|
||||
41
compiler/fir/analysis-tests/testData/resolve/catchParameter.fir.txt
vendored
Normal file
41
compiler/fir/analysis-tests/testData/resolve/catchParameter.fir.txt
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
FILE: catchParameter.kt
|
||||
public final typealias StringType = R|kotlin/String|
|
||||
public final fun <T : R|kotlin/Throwable|> test(): R|kotlin/Unit| {
|
||||
try {
|
||||
}
|
||||
catch (e: R|kotlin/NullPointerException| = R|java/lang/NullPointerException.NullPointerException|()) {
|
||||
}
|
||||
|
||||
try {
|
||||
}
|
||||
catch (e: R|T|) {
|
||||
}
|
||||
|
||||
try {
|
||||
}
|
||||
catch (e: R|() -> kotlin/Int|) {
|
||||
}
|
||||
|
||||
try {
|
||||
}
|
||||
catch (e: R|StringType|) {
|
||||
}
|
||||
|
||||
try {
|
||||
}
|
||||
catch (e: R|kotlin/Int| = Int(5)) {
|
||||
}
|
||||
|
||||
try {
|
||||
}
|
||||
catch (e: R|kotlin/Throwable|) {
|
||||
}
|
||||
|
||||
}
|
||||
public final inline fun <reified T> anotherTest(): R|kotlin/Unit| {
|
||||
try {
|
||||
}
|
||||
catch (e: R|T|) {
|
||||
}
|
||||
|
||||
}
|
||||
23
compiler/fir/analysis-tests/testData/resolve/catchParameter.kt
vendored
Normal file
23
compiler/fir/analysis-tests/testData/resolve/catchParameter.kt
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
typealias StringType = String
|
||||
|
||||
fun <T : Throwable> test() {
|
||||
try {
|
||||
|
||||
} catch (<!CATCH_PARAMETER_WITH_DEFAULT_VALUE!>e: NullPointerException = NullPointerException()<!>) {
|
||||
|
||||
}
|
||||
|
||||
try {} catch (<!TYPE_PARAMETER_IN_CATCH_CLAUSE!>e: T<!>) {}
|
||||
|
||||
try {} catch (<!TYPE_MISMATCH!>e: () -> Int<!>) {}
|
||||
|
||||
try {} catch (<!TYPE_MISMATCH!>e: StringType<!>) {}
|
||||
|
||||
try {} catch (<!CATCH_PARAMETER_WITH_DEFAULT_VALUE, TYPE_MISMATCH!>e: Int = 5<!>) {}
|
||||
|
||||
try {} catch (e: Throwable) {}
|
||||
}
|
||||
|
||||
inline fun <reified T> anotherTest() {
|
||||
try {} catch (<!REIFIED_TYPE_IN_CATCH_CLAUSE, TYPE_MISMATCH!>e: T<!>) {}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ fun test_2(x: Int?) {
|
||||
} else {
|
||||
x
|
||||
}
|
||||
y.<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>inc<!>()<!>
|
||||
y<!UNSAFE_CALL!>.<!>inc()
|
||||
}
|
||||
|
||||
fun test_3(x: Int?) {
|
||||
|
||||
@@ -13,13 +13,12 @@ FILE: delegatedSuperType.kt
|
||||
|
||||
}
|
||||
public final class C : R|A| {
|
||||
local final field <$$delegate_0>: R|A|
|
||||
|
||||
public constructor(b: R|B|): R|C| {
|
||||
super<R|kotlin/Any|>()
|
||||
this@R|/C|.R|<local>/<$$delegate_0>| = R|<local>/b|
|
||||
}
|
||||
|
||||
local final field <$$delegate_0>: R|A| = R|<local>/b|
|
||||
|
||||
public final val b: R|B| = R|<local>/b|
|
||||
public get(): R|B|
|
||||
|
||||
|
||||
@@ -9,25 +9,23 @@ FILE: anonymousObjectByDelegate.kt
|
||||
}
|
||||
public final fun R|A|.test_1(): R|kotlin/Unit| {
|
||||
object : R|B| {
|
||||
local final field <$$delegate_0>: R|B|
|
||||
|
||||
private constructor(): R|<anonymous>| {
|
||||
super<R|kotlin/Any|>()
|
||||
this@R|/<anonymous>|.R|<local>/<$$delegate_0>| = this@R|/test_1|.R|/A.b|
|
||||
}
|
||||
|
||||
local final field <$$delegate_0>: R|B| = this@R|/test_1|.R|/A.b|
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
public final fun R|A|.test_2(): R|kotlin/Unit| {
|
||||
object : R|B| {
|
||||
local final field <$$delegate_0>: R|B|
|
||||
|
||||
private constructor(): R|<anonymous>| {
|
||||
super<R|kotlin/Any|>()
|
||||
this@R|/<anonymous>|.R|<local>/<$$delegate_0>| = this@R|/test_2|.R|/A.b|
|
||||
}
|
||||
|
||||
local final field <$$delegate_0>: R|B| = this@R|/test_2|.R|/A.b|
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,37 +18,37 @@ typealias A1<K> = None<K>
|
||||
typealias A2<K> = None<in K>
|
||||
typealias A3<K> = None<out K>
|
||||
|
||||
typealias A4<<!VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED!>in K<!>> = None<K>
|
||||
typealias A5<<!VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED!>in K<!>> = None<in K>
|
||||
typealias A6<<!VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED!>in K<!>> = None<out K>
|
||||
typealias A4<<!VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED!>in<!> K> = None<K>
|
||||
typealias A5<<!VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED!>in<!> K> = None<in K>
|
||||
typealias A6<<!VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED!>in<!> K> = None<out K>
|
||||
|
||||
typealias A7<<!VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED!>out K<!>> = None<K>
|
||||
typealias A8<<!VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED!>out K<!>> = None<in K>
|
||||
typealias A9<<!VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED!>out K<!>> = None<out K>
|
||||
typealias A7<<!VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED!>out<!> K> = None<K>
|
||||
typealias A8<<!VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED!>out<!> K> = None<in K>
|
||||
typealias A9<<!VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED!>out<!> K> = None<out K>
|
||||
|
||||
typealias A10<K> = In<K>
|
||||
typealias A11<K> = In<in K>
|
||||
typealias A12<K> = <!CONFLICTING_PROJECTION!>In<out K><!>
|
||||
|
||||
typealias A13<<!VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED!>in K<!>> = In<K>
|
||||
typealias A14<<!VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED!>in K<!>> = In<in K>
|
||||
typealias A15<<!VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED!>in K<!>> = <!CONFLICTING_PROJECTION!>In<out K><!>
|
||||
typealias A13<<!VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED!>in<!> K> = In<K>
|
||||
typealias A14<<!VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED!>in<!> K> = In<in K>
|
||||
typealias A15<<!VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED!>in<!> K> = <!CONFLICTING_PROJECTION!>In<out K><!>
|
||||
|
||||
typealias A16<<!VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED!>out K<!>> = In<K>
|
||||
typealias A17<<!VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED!>out K<!>> = In<in K>
|
||||
typealias A18<<!VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED!>out K<!>> = <!CONFLICTING_PROJECTION!>In<out K><!>
|
||||
typealias A16<<!VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED!>out<!> K> = In<K>
|
||||
typealias A17<<!VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED!>out<!> K> = In<in K>
|
||||
typealias A18<<!VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED!>out<!> K> = <!CONFLICTING_PROJECTION!>In<out K><!>
|
||||
|
||||
typealias A19<K> = Out<K>
|
||||
typealias A20<K> = <!CONFLICTING_PROJECTION!>Out<in K><!>
|
||||
typealias A21<K> = Out<out K>
|
||||
|
||||
typealias A22<<!VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED!>in K<!>> = Out<K>
|
||||
typealias A23<<!VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED!>in K<!>> = <!CONFLICTING_PROJECTION!>Out<in K><!>
|
||||
typealias A24<<!VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED!>in K<!>> = Out<out K>
|
||||
typealias A22<<!VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED!>in<!> K> = Out<K>
|
||||
typealias A23<<!VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED!>in<!> K> = <!CONFLICTING_PROJECTION!>Out<in K><!>
|
||||
typealias A24<<!VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED!>in<!> K> = Out<out K>
|
||||
|
||||
typealias A25<<!VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED!>out K<!>> = Out<K>
|
||||
typealias A26<<!VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED!>out K<!>> = <!CONFLICTING_PROJECTION!>Out<in K><!>
|
||||
typealias A27<<!VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED!>out K<!>> = Out<out K>
|
||||
typealias A25<<!VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED!>out<!> K> = Out<K>
|
||||
typealias A26<<!VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED!>out<!> K> = <!CONFLICTING_PROJECTION!>Out<in K><!>
|
||||
typealias A27<<!VARIANCE_ON_TYPE_PARAMETER_NOT_ALLOWED!>out<!> K> = Out<out K>
|
||||
|
||||
class Outer<T> {
|
||||
inner class Intermediate<K> {
|
||||
|
||||
@@ -6,7 +6,7 @@ FILE: delegationInInterface.kt
|
||||
|
||||
}
|
||||
public abstract interface B : R|A| {
|
||||
local final field <$$delegate_0>: R|A|
|
||||
local final field <$$delegate_0>: R|A| = <Unresolved name: a>#
|
||||
|
||||
public abstract val a: R|A|
|
||||
public get(): R|A|
|
||||
@@ -15,6 +15,6 @@ FILE: delegationInInterface.kt
|
||||
public final val test: R|A| = R|/A.A|()
|
||||
public get(): R|A|
|
||||
public abstract interface C : R|A| {
|
||||
local final field <$$delegate_0>: R|A|
|
||||
local final field <$$delegate_0>: R|A| = R|/test|
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class A
|
||||
|
||||
interface B : <!DELEGATION_IN_INTERFACE, INTERFACE_WITH_SUPERCLASS!>A<!> by a {
|
||||
interface B : <!DELEGATION_IN_INTERFACE, INTERFACE_WITH_SUPERCLASS!>A<!> by <!UNRESOLVED_REFERENCE!>a<!> {
|
||||
val a: A
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ open class A {
|
||||
}
|
||||
|
||||
open class B : A {
|
||||
override var test: Double = 20.0
|
||||
override var test: <!VAR_TYPE_MISMATCH_ON_OVERRIDE!>Double<!> = 20.0
|
||||
}
|
||||
|
||||
class C() : A() {
|
||||
@@ -15,7 +15,7 @@ open class D() : B() {
|
||||
}
|
||||
|
||||
class E<T : Double>(val value: T) : B() {
|
||||
override var test: T = value
|
||||
override var test: <!VAR_TYPE_MISMATCH_ON_OVERRIDE!>T<!> = value
|
||||
}
|
||||
|
||||
open class F<T : Number>(val value: T) {
|
||||
|
||||
@@ -4,13 +4,12 @@ FILE: superCallWithDelegation.kt
|
||||
|
||||
}
|
||||
public open class B : R|A| {
|
||||
local final field <$$delegate_0>: R|A|
|
||||
|
||||
public constructor(a: R|A|): R|B| {
|
||||
super<R|kotlin/Any|>()
|
||||
this@R|/B|.R|<local>/<$$delegate_0>| = R|<local>/a|
|
||||
}
|
||||
|
||||
local final field <$$delegate_0>: R|A| = R|<local>/a|
|
||||
|
||||
private final val a: R|A| = R|<local>/a|
|
||||
private get(): R|A|
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ fun test3(x: AnotherClass?) {
|
||||
fun test4(x: SomeClass?) {
|
||||
val bar = x?.bar
|
||||
if (bar != null) {
|
||||
x.bar.<!INAPPLICABLE_CANDIDATE!>length<!>
|
||||
x.bar<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,5 @@ fun main(x: A?) {
|
||||
x?.unit()
|
||||
}
|
||||
|
||||
// lambda has a type (() -> Unit?)
|
||||
foo(lambda)
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ fun test_3(a: A?, b: Boolean) {
|
||||
if (b && a!!.foo()) {
|
||||
a.foo() // OK
|
||||
}
|
||||
a.<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>foo<!>()<!> // Bad
|
||||
a<!UNSAFE_CALL!>.<!>foo() // Bad
|
||||
}
|
||||
|
||||
fun test_4(a: A?, b: Boolean) {
|
||||
@@ -38,9 +38,9 @@ fun test_4(a: A?, b: Boolean) {
|
||||
|
||||
fun test_5(a: A?, b: Boolean) {
|
||||
if (b || a!!.foo()) {
|
||||
a.<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>foo<!>()<!>
|
||||
a<!UNSAFE_CALL!>.<!>foo()
|
||||
}
|
||||
a.<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>foo<!>()<!>
|
||||
a<!UNSAFE_CALL!>.<!>foo()
|
||||
}
|
||||
|
||||
fun <X : A?> test_6(x: X) {
|
||||
|
||||
@@ -8,13 +8,13 @@ fun test_1(b: Boolean?) {
|
||||
if ((b == true) == true) {
|
||||
b.not() // OK
|
||||
} else {
|
||||
b.<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>not<!>()<!> // Bad
|
||||
b<!UNSAFE_CALL!>.<!>not() // Bad
|
||||
}
|
||||
}
|
||||
|
||||
fun test_2(b: Boolean?) {
|
||||
if ((b == true) != true) {
|
||||
b.<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>not<!>()<!> // Bad
|
||||
b<!UNSAFE_CALL!>.<!>not() // Bad
|
||||
} else {
|
||||
b.not() // OK
|
||||
}
|
||||
@@ -22,7 +22,7 @@ fun test_2(b: Boolean?) {
|
||||
|
||||
fun test_3(b: Boolean?) {
|
||||
if ((b == true) == false) {
|
||||
b.<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>not<!>()<!> // Bad
|
||||
b<!UNSAFE_CALL!>.<!>not() // Bad
|
||||
} else {
|
||||
b.not() // OK
|
||||
}
|
||||
@@ -32,13 +32,13 @@ fun test_4(b: Boolean?) {
|
||||
if ((b == true) != false) {
|
||||
b.not() // OK
|
||||
} else {
|
||||
b.<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>not<!>()<!> // Bad
|
||||
b<!UNSAFE_CALL!>.<!>not() // Bad
|
||||
}
|
||||
}
|
||||
|
||||
fun test_5(b: Boolean?) {
|
||||
if ((b != true) == true) {
|
||||
b.<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>not<!>()<!> // Bad
|
||||
b<!UNSAFE_CALL!>.<!>not() // Bad
|
||||
} else {
|
||||
b.not() // OK
|
||||
}
|
||||
@@ -48,7 +48,7 @@ fun test_6(b: Boolean?) {
|
||||
if ((b != true) != true) {
|
||||
b.not() // OK
|
||||
} else {
|
||||
b.<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>not<!>()<!> // Bad
|
||||
b<!UNSAFE_CALL!>.<!>not() // Bad
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,13 +56,13 @@ fun test_7(b: Boolean?) {
|
||||
if ((b != true) == false) {
|
||||
b.not() // OK
|
||||
} else {
|
||||
b.<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>not<!>()<!> // Bad
|
||||
b<!UNSAFE_CALL!>.<!>not() // Bad
|
||||
}
|
||||
}
|
||||
|
||||
fun test_8(b: Boolean?) {
|
||||
if ((b != true) != false) {
|
||||
b.<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>not<!>()<!> // Bad
|
||||
b<!UNSAFE_CALL!>.<!>not() // Bad
|
||||
} else {
|
||||
b.not() // OK
|
||||
}
|
||||
|
||||
@@ -34,24 +34,24 @@ fun test_4(a: A?) {
|
||||
|
||||
fun test_5(a: A?) {
|
||||
a == null || throw Exception()
|
||||
a.<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>foo<!>()<!>
|
||||
a<!UNSAFE_CALL!>.<!>foo()
|
||||
}
|
||||
|
||||
fun teat_6(a: A?) {
|
||||
a != null && throw Exception()
|
||||
a.<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>foo<!>()<!>
|
||||
a<!UNSAFE_CALL!>.<!>foo()
|
||||
}
|
||||
|
||||
fun test_7(a: A?) {
|
||||
if (a == null || throw Exception()) {
|
||||
a.<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>foo<!>()<!>
|
||||
a<!UNSAFE_CALL!>.<!>foo()
|
||||
}
|
||||
a.<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>foo<!>()<!>
|
||||
a<!UNSAFE_CALL!>.<!>foo()
|
||||
}
|
||||
|
||||
fun test_8(a: A?) {
|
||||
if (a != null && throw Exception()) {
|
||||
a.<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>foo<!>()<!>
|
||||
a<!UNSAFE_CALL!>.<!>foo()
|
||||
}
|
||||
a.<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>foo<!>()<!>
|
||||
a<!UNSAFE_CALL!>.<!>foo()
|
||||
}
|
||||
|
||||
@@ -104,18 +104,18 @@ fun test_7() {
|
||||
|
||||
if (x != null) {
|
||||
x.length // OK
|
||||
y.<!INAPPLICABLE_CANDIDATE!>length<!> // Bad
|
||||
y<!UNSAFE_CALL!>.<!>length // Bad
|
||||
z.length // OK
|
||||
}
|
||||
if (y != null) {
|
||||
x.<!INAPPLICABLE_CANDIDATE!>length<!> // Bad
|
||||
x<!UNSAFE_CALL!>.<!>length // Bad
|
||||
y.length // OK
|
||||
z.<!INAPPLICABLE_CANDIDATE!>length<!> // Bad
|
||||
z<!UNSAFE_CALL!>.<!>length // Bad
|
||||
}
|
||||
|
||||
if (z != null) {
|
||||
x.length // OK
|
||||
y.<!INAPPLICABLE_CANDIDATE!>length<!> // Bad
|
||||
y<!UNSAFE_CALL!>.<!>length // Bad
|
||||
z.length // OK
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,12 +16,12 @@ fun test_1(x: A, y: A?) {
|
||||
|
||||
fun test_2(x: A?, y: A?) {
|
||||
if (x == y) {
|
||||
x.<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>foo<!>()<!>
|
||||
y.<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>foo<!>()<!>
|
||||
x<!UNSAFE_CALL!>.<!>foo()
|
||||
y<!UNSAFE_CALL!>.<!>foo()
|
||||
}
|
||||
if (x === y) {
|
||||
x.<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>foo<!>()<!>
|
||||
y.<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>foo<!>()<!>
|
||||
x<!UNSAFE_CALL!>.<!>foo()
|
||||
y<!UNSAFE_CALL!>.<!>foo()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,18 +39,18 @@ fun test_1(x: A?) {
|
||||
if (x != null) {
|
||||
x.foo()
|
||||
} else {
|
||||
x.<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>foo<!>()<!>
|
||||
x<!UNSAFE_CALL!>.<!>foo()
|
||||
}
|
||||
x.<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>foo<!>()<!>
|
||||
x<!UNSAFE_CALL!>.<!>foo()
|
||||
}
|
||||
|
||||
fun test_2(x: A?) {
|
||||
if (x == null) {
|
||||
x.<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>foo<!>()<!>
|
||||
x<!UNSAFE_CALL!>.<!>foo()
|
||||
} else {
|
||||
x.foo()
|
||||
}
|
||||
x.<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>foo<!>()<!>
|
||||
x<!UNSAFE_CALL!>.<!>foo()
|
||||
}
|
||||
|
||||
fun test_3(x: A?) {
|
||||
@@ -67,8 +67,8 @@ fun test_5(q: Q?) {
|
||||
// `q.data` is a property that has an open getter, so we can NOT smartcast it to non-nullable MyData.
|
||||
if (q?.data?.s?.inc() != null) {
|
||||
q.data // good
|
||||
q.data.<!INAPPLICABLE_CANDIDATE!>s<!> // should be bad
|
||||
q.data.<!INAPPLICABLE_CANDIDATE!>s<!>.inc() // should be bad
|
||||
q.data<!UNSAFE_CALL!>.<!>s // should be bad
|
||||
q.data<!UNSAFE_CALL!>.<!>s.inc() // should be bad
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,15 +76,15 @@ fun test_6(q: Q?) {
|
||||
// `q.data` is a property that has an open getter, so we can NOT smartcast it to non-nullable MyData.
|
||||
q?.data?.s?.inc() ?: return
|
||||
q.data // good
|
||||
q.data.<!INAPPLICABLE_CANDIDATE!>s<!> // should be bad
|
||||
q.data.<!INAPPLICABLE_CANDIDATE!>s<!>.inc() // should be bad
|
||||
q.data<!UNSAFE_CALL!>.<!>s // should be bad
|
||||
q.data<!UNSAFE_CALL!>.<!>s.inc() // should be bad
|
||||
}
|
||||
|
||||
fun test_7(q: Q?) {
|
||||
if (q?.fdata()?.fs()?.inc() != null) {
|
||||
q.fdata() // good
|
||||
q.fdata().<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>fs<!>()<!> // bad
|
||||
q.fdata().<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>fs<!>()<!>.inc() // bad
|
||||
q.fdata()<!UNSAFE_CALL!>.<!>fs() // bad
|
||||
q.fdata()<!UNSAFE_CALL!>.<!>fs().inc() // bad
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,44 +98,44 @@ fun test_9(a: Int, b: Int?) {
|
||||
if (a == b) {
|
||||
b.inc()
|
||||
}
|
||||
b.<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>inc<!>()<!>
|
||||
b<!UNSAFE_CALL!>.<!>inc()
|
||||
|
||||
if (a === b) {
|
||||
b.inc()
|
||||
}
|
||||
b.<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>inc<!>()<!>
|
||||
b<!UNSAFE_CALL!>.<!>inc()
|
||||
|
||||
if (b == a) {
|
||||
b.inc()
|
||||
}
|
||||
b.<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>inc<!>()<!>
|
||||
b<!UNSAFE_CALL!>.<!>inc()
|
||||
|
||||
if (b === a) {
|
||||
b.inc()
|
||||
}
|
||||
b.<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>inc<!>()<!>
|
||||
b<!UNSAFE_CALL!>.<!>inc()
|
||||
}
|
||||
|
||||
fun test_10(a: Int?, b: Int?) {
|
||||
if (a == b) {
|
||||
b.<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>inc<!>()<!>
|
||||
b<!UNSAFE_CALL!>.<!>inc()
|
||||
}
|
||||
b.<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>inc<!>()<!>
|
||||
b<!UNSAFE_CALL!>.<!>inc()
|
||||
|
||||
if (a === b) {
|
||||
b.<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>inc<!>()<!>
|
||||
b<!UNSAFE_CALL!>.<!>inc()
|
||||
}
|
||||
b.<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>inc<!>()<!>
|
||||
b<!UNSAFE_CALL!>.<!>inc()
|
||||
|
||||
if (b == a) {
|
||||
b.<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>inc<!>()<!>
|
||||
b<!UNSAFE_CALL!>.<!>inc()
|
||||
}
|
||||
b.<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>inc<!>()<!>
|
||||
b<!UNSAFE_CALL!>.<!>inc()
|
||||
|
||||
if (b === a) {
|
||||
b.<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>inc<!>()<!>
|
||||
b<!UNSAFE_CALL!>.<!>inc()
|
||||
}
|
||||
b.<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>inc<!>()<!>
|
||||
b<!UNSAFE_CALL!>.<!>inc()
|
||||
}
|
||||
|
||||
fun test_11(q: QImpl?, q2: QImpl) {
|
||||
@@ -148,8 +148,8 @@ fun test_11(q: QImpl?, q2: QImpl) {
|
||||
// Smartcasting of `q.data` should have no effect on `q2.data`.
|
||||
// Issue: Smartcasting of QImpl.data affects all instances
|
||||
q2.data
|
||||
q2.data.<!INAPPLICABLE_CANDIDATE!>s<!> // should be bad
|
||||
q2.data.<!INAPPLICABLE_CANDIDATE!>s<!>.inc() // should be bad
|
||||
q2.data<!UNSAFE_CALL!>.<!>s // should be bad
|
||||
q2.data<!UNSAFE_CALL!>.<!>s.inc() // should be bad
|
||||
|
||||
if (q2.data != null) {
|
||||
q2.data.s
|
||||
@@ -162,8 +162,8 @@ fun test_12(q: QImplWithCustomGetter?) {
|
||||
// `q.data` is a property that has an open getter, so we can NOT smartcast it to non-nullable MyData.
|
||||
if (q?.data?.s?.inc() != null) {
|
||||
q.data // good
|
||||
q.data.<!INAPPLICABLE_CANDIDATE!>s<!> // should be bad
|
||||
q.data.<!INAPPLICABLE_CANDIDATE!>s<!>.inc() // should be bad
|
||||
q.data<!UNSAFE_CALL!>.<!>s // should be bad
|
||||
q.data<!UNSAFE_CALL!>.<!>s.inc() // should be bad
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ fun test_13(q: QImplMutable?) {
|
||||
// `q.data` is a property that is mutable, so we can NOT smartcast it to non-nullable MyData.
|
||||
if (q?.data?.s?.inc() != null) {
|
||||
q.data // good
|
||||
q.data.<!INAPPLICABLE_CANDIDATE!>s<!> // should be bad
|
||||
q.data.<!INAPPLICABLE_CANDIDATE!>s<!>.inc() // should be bad
|
||||
q.data<!UNSAFE_CALL!>.<!>s // should be bad
|
||||
q.data<!UNSAFE_CALL!>.<!>s.inc() // should be bad
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,6 @@ fun test_3(a: Any?, b: Boolean) {
|
||||
|
||||
fun test_4(a: Any?, b: Boolean) {
|
||||
if (a is String || b) {
|
||||
a.<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>foo<!>()<!> // Should be Bad
|
||||
a<!UNSAFE_CALL!>.<!>foo() // Should be Bad
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ fun test_1(s: String?) {
|
||||
if (s?.check() == true) {
|
||||
s.length // Should be OK
|
||||
} else {
|
||||
s.<!INAPPLICABLE_CANDIDATE!>length<!> // Should be bad
|
||||
s<!UNSAFE_CALL!>.<!>length // Should be bad
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,13 +13,13 @@ fun test_2(s: String?) {
|
||||
if (s?.check() == false) {
|
||||
s.length // Should be OK
|
||||
} else {
|
||||
s.<!INAPPLICABLE_CANDIDATE!>length<!> // Should be bad
|
||||
s<!UNSAFE_CALL!>.<!>length // Should be bad
|
||||
}
|
||||
}
|
||||
|
||||
fun test_3(s: String?) {
|
||||
if (s?.check() != true) {
|
||||
s.<!INAPPLICABLE_CANDIDATE!>length<!> // Should be bad
|
||||
s<!UNSAFE_CALL!>.<!>length // Should be bad
|
||||
} else {
|
||||
s.length // Should be OK
|
||||
}
|
||||
@@ -27,7 +27,7 @@ fun test_3(s: String?) {
|
||||
|
||||
fun test_4(s: String?) {
|
||||
if (s?.check() != false) {
|
||||
s.<!INAPPLICABLE_CANDIDATE!>length<!> // Should be bad
|
||||
s<!UNSAFE_CALL!>.<!>length // Should be bad
|
||||
} else {
|
||||
s.length // Should be OK
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ fun String.let(block: () -> Unit) {}
|
||||
|
||||
fun test(x: String?) {
|
||||
x?.foo(x.length == 1)
|
||||
x.<!INAPPLICABLE_CANDIDATE!>length<!>
|
||||
x<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
interface A {
|
||||
@@ -27,12 +27,12 @@ fun test_3(x: Any) {
|
||||
|
||||
fun test_4(x: A?) {
|
||||
x?.id()?.bool()
|
||||
x.<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>id<!>()<!>
|
||||
x<!UNSAFE_CALL!>.<!>id()
|
||||
}
|
||||
|
||||
fun Any?.boo(b: Boolean) {}
|
||||
|
||||
fun test_5(x: A?) {
|
||||
x?.let { return }?.boo(x.bool())
|
||||
x.<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>id<!>()<!>
|
||||
x<!UNSAFE_CALL!>.<!>id()
|
||||
}
|
||||
|
||||
@@ -11,5 +11,5 @@ fun test(b: Boolean) {
|
||||
} else {
|
||||
a = null
|
||||
}
|
||||
a.<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>foo<!>()<!>
|
||||
a<!UNSAFE_CALL!>.<!>foo()
|
||||
}
|
||||
|
||||
@@ -18,5 +18,5 @@ fun test_3() {
|
||||
x = ""
|
||||
x.length
|
||||
x = null
|
||||
x.<!INAPPLICABLE_CANDIDATE!>length<!>
|
||||
x<!UNSAFE_CALL!>.<!>length
|
||||
}
|
||||
|
||||
10
compiler/fir/analysis-tests/testData/resolve/suppress/allWarnings.fir.txt
vendored
Normal file
10
compiler/fir/analysis-tests/testData/resolve/suppress/allWarnings.fir.txt
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
FILE: allWarnings.kt
|
||||
@R|kotlin/Suppress|(vararg(String(warnings))) public final class A : R|kotlin/Any| {
|
||||
public constructor(): R|A| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final fun foo(): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
}
|
||||
6
compiler/fir/analysis-tests/testData/resolve/suppress/allWarnings.kt
vendored
Normal file
6
compiler/fir/analysis-tests/testData/resolve/suppress/allWarnings.kt
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
// WITH_EXTENDED_CHECKERS
|
||||
|
||||
@Suppress("warnings")
|
||||
public class A {
|
||||
final fun foo() {}
|
||||
}
|
||||
10
compiler/fir/analysis-tests/testData/resolve/suppress/multipleWarnings.fir.txt
vendored
Normal file
10
compiler/fir/analysis-tests/testData/resolve/suppress/multipleWarnings.fir.txt
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
FILE: multipleWarnings.kt
|
||||
@R|kotlin/Suppress|(vararg(String(REDUNDANT_VISIBILITY_MODIFIER))) public final class A : R|kotlin/Any| {
|
||||
public constructor(): R|A| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
@R|kotlin/Suppress|(vararg(String(REDUNDANT_MODALITY_MODIFIER))) public final fun foo(): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
}
|
||||
7
compiler/fir/analysis-tests/testData/resolve/suppress/multipleWarnings.kt
vendored
Normal file
7
compiler/fir/analysis-tests/testData/resolve/suppress/multipleWarnings.kt
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
// WITH_EXTENDED_CHECKERS
|
||||
|
||||
@Suppress("REDUNDANT_VISIBILITY_MODIFIER")
|
||||
public class A {
|
||||
@Suppress("REDUNDANT_MODALITY_MODIFIER")
|
||||
public final fun foo() {}
|
||||
}
|
||||
6
compiler/fir/analysis-tests/testData/resolve/suppress/singleError.fir.txt
vendored
Normal file
6
compiler/fir/analysis-tests/testData/resolve/suppress/singleError.fir.txt
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
FILE: singleError.kt
|
||||
public final fun foo(x: R|kotlin/String|): R|kotlin/Unit| {
|
||||
}
|
||||
@R|kotlin/Suppress|(vararg(String(INAPPLICABLE_CANDIDATE))) public final fun bar(): R|kotlin/Unit| {
|
||||
<Inapplicable(INAPPLICABLE): /foo>#(Int(10))
|
||||
}
|
||||
6
compiler/fir/analysis-tests/testData/resolve/suppress/singleError.kt
vendored
Normal file
6
compiler/fir/analysis-tests/testData/resolve/suppress/singleError.kt
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
fun foo(x: String) {}
|
||||
|
||||
@Suppress("INAPPLICABLE_CANDIDATE")
|
||||
fun bar() {
|
||||
foo(10)
|
||||
}
|
||||
3
compiler/fir/analysis-tests/testData/resolve/suppress/singleWarning.fir.txt
vendored
Normal file
3
compiler/fir/analysis-tests/testData/resolve/suppress/singleWarning.fir.txt
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
FILE: singleWarning.kt
|
||||
@R|kotlin/Suppress|(vararg(String(REDUNDANT_VISIBILITY_MODIFIER))) public final fun foo(): R|kotlin/Unit| {
|
||||
}
|
||||
4
compiler/fir/analysis-tests/testData/resolve/suppress/singleWarning.kt
vendored
Normal file
4
compiler/fir/analysis-tests/testData/resolve/suppress/singleWarning.kt
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
// WITH_EXTENDED_CHECKERS
|
||||
|
||||
@Suppress("REDUNDANT_VISIBILITY_MODIFIER")
|
||||
public fun foo() {}
|
||||
67
compiler/fir/analysis-tests/testData/resolve/throwableSubclass.fir.txt
vendored
Normal file
67
compiler/fir/analysis-tests/testData/resolve/throwableSubclass.fir.txt
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
FILE: throwableSubclass.kt
|
||||
public final class Test1<T, B> : R|kotlin/Exception| {
|
||||
public constructor<T, B>(): R|Test1<T, B>| {
|
||||
super<R|kotlin/Exception|>()
|
||||
}
|
||||
|
||||
public final inner class Test2<S, T, B> : R|kotlin/Throwable| {
|
||||
public constructor<S>(): R|Test1.Test2<S, T, B>| {
|
||||
super<R|kotlin/Throwable|>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final class Test3 : R|kotlin/NullPointerException| {
|
||||
public constructor(): R|Test1.Test3| {
|
||||
super<R|kotlin/NullPointerException|>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final object Test4 : R|kotlin/Throwable| {
|
||||
private constructor(): R|Test1.Test4| {
|
||||
super<R|kotlin/Throwable|>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
public final class Test5<T, B> : R|kotlin/Any| {
|
||||
public constructor<T, B>(): R|Test5<T, B>| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final inner class Test6<T, B> : R|kotlin/Exception| {
|
||||
public constructor(): R|Test5.Test6<T, B>| {
|
||||
super<R|kotlin/Exception|>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public final fun foo(): R|kotlin/Unit| {
|
||||
local final class Test7 : R|kotlin/Throwable| {
|
||||
public constructor(): R|Test5.Test7| {
|
||||
super<R|kotlin/Throwable|>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
public final fun <Z> topLevelFun(): R|kotlin/Unit| {
|
||||
local final class Test8 : R|kotlin/Error| {
|
||||
public constructor(): R|Test8| {
|
||||
super<R|kotlin/Error|>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
lval obj: R|<anonymous><Z>| = object : R|kotlin/Throwable| {
|
||||
private constructor(): R|<anonymous><Z>| {
|
||||
super<R|kotlin/Throwable|>()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
18
compiler/fir/analysis-tests/testData/resolve/throwableSubclass.kt
vendored
Normal file
18
compiler/fir/analysis-tests/testData/resolve/throwableSubclass.kt
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
class Test1<<!GENERIC_THROWABLE_SUBCLASS!>T<!>, B> : Exception() {
|
||||
inner <!INNER_CLASS_OF_GENERIC_THROWABLE_SUBCLASS!>class Test2<!><<!GENERIC_THROWABLE_SUBCLASS!>S<!>> : Throwable()
|
||||
class Test3 : NullPointerException()
|
||||
object Test4 : Throwable() {}
|
||||
}
|
||||
|
||||
class Test5<T, B> {
|
||||
inner <!INNER_CLASS_OF_GENERIC_THROWABLE_SUBCLASS!>class Test6<!> : Exception()
|
||||
|
||||
fun foo() {
|
||||
<!INNER_CLASS_OF_GENERIC_THROWABLE_SUBCLASS!>class Test7<!> : Throwable()
|
||||
}
|
||||
}
|
||||
|
||||
fun <Z> topLevelFun() {
|
||||
<!INNER_CLASS_OF_GENERIC_THROWABLE_SUBCLASS!>class Test8<!> : Error()
|
||||
val obj = <!INNER_CLASS_OF_GENERIC_THROWABLE_SUBCLASS{LT}!><!INNER_CLASS_OF_GENERIC_THROWABLE_SUBCLASS{PSI}!>object<!> : Throwable() {}<!>
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
<!CONFLICTING_OVERLOADS{LT}!><!CONFLICTING_OVERLOADS!>fun bar(x: String): Int<!> = 1<!>
|
||||
<!CONFLICTING_OVERLOADS{LT}!><!CONFLICTING_OVERLOADS!>fun bar(x: String): Double<!> = 1<!>
|
||||
<!CONFLICTING_OVERLOADS!>fun bar(x: String): Int<!> = 1
|
||||
<!CONFLICTING_OVERLOADS!>fun bar(x: String): Double<!> = 1
|
||||
|
||||
fun baz(x: String): Int = 1
|
||||
fun <T, R> foobaz(x: T): R = TODO()
|
||||
|
||||
@@ -31,16 +31,16 @@ fun main() {
|
||||
foo1(KotlinClass::baz)
|
||||
foo2(KotlinClass::baz)
|
||||
// Ambiguity (companion/class)
|
||||
<!AMBIGUITY!>foo3<!>(KotlinClass::baz)
|
||||
<!AMBIGUITY{LT}!><!AMBIGUITY{PSI}!>foo3<!>(KotlinClass::baz)<!>
|
||||
|
||||
// Type mismatch
|
||||
<!INAPPLICABLE_CANDIDATE!>foo1<!>(<!UNRESOLVED_REFERENCE!>KotlinClass::bar<!>)
|
||||
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>foo1<!>(<!UNRESOLVED_REFERENCE!>KotlinClass::bar<!>)<!>
|
||||
foo2(KotlinClass::bar)
|
||||
foo3(KotlinClass::bar)
|
||||
|
||||
foo1(KotlinClass2::bar)
|
||||
// Type mismatch
|
||||
<!INAPPLICABLE_CANDIDATE!>foo2<!>(<!UNRESOLVED_REFERENCE!>KotlinClass2::bar<!>)
|
||||
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>foo2<!>(<!UNRESOLVED_REFERENCE!>KotlinClass2::bar<!>)<!>
|
||||
foo3(KotlinClass2::bar)
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,6 @@ fun <T> bar(f: (T) -> Unit, e: T) {}
|
||||
fun <T> baz(e: T, f: (T) -> Unit) {}
|
||||
|
||||
fun test(a: A, b: B) {
|
||||
<!INAPPLICABLE_CANDIDATE!>baz<!>(a, <!UNRESOLVED_REFERENCE!>::fooB<!>)
|
||||
<!INAPPLICABLE_CANDIDATE!>bar<!>(<!UNRESOLVED_REFERENCE!>::fooB<!>, a)
|
||||
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>baz<!>(a, <!UNRESOLVED_REFERENCE!>::fooB<!>)<!>
|
||||
<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>bar<!>(<!UNRESOLVED_REFERENCE!>::fooB<!>, a)<!>
|
||||
}
|
||||
|
||||
@@ -3,5 +3,5 @@ fun <T, R> use(x: (T) -> R): (T) -> R = x
|
||||
fun foo() = use(::bar)
|
||||
fun bar(x: String) = 1
|
||||
|
||||
fun loop1() = <!INAPPLICABLE_CANDIDATE!>use<!>(<!UNRESOLVED_REFERENCE!>::loop2<!>)
|
||||
fun loop1() = <!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>use<!>(<!UNRESOLVED_REFERENCE!>::loop2<!>)<!>
|
||||
fun loop2() = loop1()
|
||||
|
||||
@@ -16,5 +16,5 @@ fun foo3(x: (String) -> Int) {}
|
||||
fun main() {
|
||||
foo1(JavaClass::bar)
|
||||
foo2(JavaClass::bar)
|
||||
<!AMBIGUITY!>foo3<!>(JavaClass::bar)
|
||||
<!AMBIGUITY{LT}!><!AMBIGUITY{PSI}!>foo3<!>(JavaClass::bar)<!>
|
||||
}
|
||||
|
||||
@@ -6,5 +6,5 @@ fun bar(): Int = 1
|
||||
fun bar(x: String): Int = 1
|
||||
|
||||
fun main() {
|
||||
<!AMBIGUITY!>foo<!>(<!UNRESOLVED_REFERENCE!>::bar<!>)
|
||||
<!AMBIGUITY{LT}!><!AMBIGUITY{PSI}!>foo<!>(<!UNRESOLVED_REFERENCE!>::bar<!>)<!>
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user