Compare commits

...

265 Commits

Author SHA1 Message Date
Ilmir Usmanov
ccaa4a1cf1 Minor. Ignore test on WASM 2021-02-09 00:23:51 +01:00
Ilmir Usmanov
f025a357f7 JVM_IR. Do not mangle callable reference constructor call
#KT-44703 Fixed
2021-02-08 22:49:45 +01:00
Pavel Kirpichenkov
75954dd1a4 Minor: refactor extended compiler checks
Use an analysis flag instead of a stub language feature
2021-02-08 18:47:30 +03:00
Pavel Kirpichenkov
2a46da906c Provide additional information about missing supertypes
Add -X flag to report extra compiler diagnostics which migth break compatibility.
Use the flag to unconditionally check constructors without fear of
prematurely evaluating lazy supertypes.

KT-19234
KT-42404
KT-44583
2021-02-08 18:47:30 +03:00
Mikhail Glukhikh
4a381d4b83 FIR DFA: update receivers properly in case of single flow in merge point 2021-02-08 18:23:44 +03:00
pyos
d96921e287 FIR2IR: collect annotations when expanding type aliases 2021-02-08 18:23:19 +03:00
Vladimir Dolzhenko
872effc21e Check declaration modifier for actual method to avoid freeze
Checking modifier aims to get rid of unnecessary resolve for methods in non MPP (the most) cases

Relates to #KTIJ-1200
2021-02-08 14:43:19 +00:00
Muhammad Hakim Asy'ari
3e17317f31 Update steps to install JDK 6 on Mac OS (#4052) 2021-02-08 16:41:38 +03:00
Mikhail Glukhikh
d4b0688690 FIR: introduce delegate field initializers
Before this commit we initialized delegate fields in primary constructor,
that could provoke NPE in case delegate is used in initializer of
some property backing field.
Now we initialize delegate fields directly instead.
2021-02-08 14:28:27 +03:00
Mikhail Glukhikh
2cbdad0bb1 FIR2IR: insert implicit cast of receiver to Any for interface Any calls 2021-02-08 14:28:26 +03:00
Mikhail Glukhikh
1c210c2386 FIR: fix of super.methodOfAny resolve in case of one supertype 2021-02-08 14:28:25 +03:00
Mikhail Glukhikh
694d69fbfa FIR2IR: select return target inside accessor properly 2021-02-08 14:28:24 +03:00
Ilya Goncharov
19bffc694b [JS IR] Add test with chain export--not-export--export
^KT-44616 fixed
2021-02-08 13:41:16 +03:00
Ilya Goncharov
76b124a9c0 [JS IR] Method of any is exported
^KT-44616 fixed
2021-02-08 13:40:39 +03:00
Ilya Goncharov
7b4624aac4 [JS IR] Add exported method into exportNestedClass.kt
^KT-44616 fixed
2021-02-08 13:38:47 +03:00
Ilya Goncharov
6c051b2be4 [JS IR] Override method are not exported
[JS IR] Add test with jsexport overrides not js export method with stable name

^KT-44616 fixed
2021-02-08 13:38:30 +03:00
Jinseong Jeon
a9322a01ce FIR checker: avoid redundant casting to resolved type ref 2021-02-08 13:01:12 +03:00
Jinseong Jeon
37a702b962 FIR: coerce to Unit when a lambda has early returns
^KT-39075 Fixed
2021-02-08 13:01:12 +03:00
Jinseong Jeon
83e3201677 FIR DFA: correct exit node retrieval when a safe call is the last expression
^KT-44699 Fixed
2021-02-08 13:01:11 +03:00
Jinseong Jeon
266432a482 FIR checker: fix condition for property type mismatch on override 2021-02-08 13:01:11 +03:00
Jinseong Jeon
065d0c66ab FIR checker: reproduce a false alarm on type mismatch of overridden property 2021-02-08 13:01:11 +03:00
pyos
64c5608f31 FIR: expect nullable type for elvis LHS 2021-02-08 13:00:22 +03:00
Margarita Bobova
0e8f4294f0 Add changelog for 1.4.30 2021-02-08 12:16:00 +03:00
Igor Yakovlev
04017b00a1 [FIR IDE] Fix TypeRef resolve to error type caused by invalid number of arguments 2021-02-08 11:57:39 +03:00
Victor Petukhov
f9e5584a3e Report error about uninferred type parameter for all CallForImplicitInvoke psi calls
^KT-44368 Fixed
2021-02-08 10:40:18 +03:00
Andrey Zinovyev
c75d2c05f0 [KAPT] Correct type for property with accessor
^KT-39060 Fixed
2021-02-08 10:11:50 +03:00
Dmitriy Novozhilov
dcb47d9934 Fix broken compilation after changing kotlin compiler configuration form
Problem was introduced at 391f5315
2021-02-06 13:40:40 +03:00
Vladimir Dolzhenko
391f53154a Fix NPE in Kotlin facets tab 2021-02-05 21:28:33 +01:00
Alexander Dudinsky
250040bab7 Common fix GradleQuickFixTest and GradleUpdateConfigurationQuickFixTest
Started as a result of postponed jdk dispose
71e7449

CodeInsightTestFixtureImpl assertPointersAreDisposed is invoked before
actually removing pointers.

com.intellij.openapi.util.TraceableDisposable$DisposalException: 1708093728
	at com.intellij.openapi.util.TraceableDisposable.getStackTrace(TraceableDisposable.java:121)
	at com.intellij.openapi.vfs.impl.VirtualFilePointerTracker.assertPointersAreDisposed(VirtualFilePointerTracker.java:86)
	at com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl.lambda$tearDown$38(CodeInsightTestFixtureImpl.java:1281)
	at com.intellij.testFramework.RunAll.collectExceptions(RunAll.java:57)
	at com.intellij.testFramework.RunAll.runAll(RunAll.java:35)
	at com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl.tearDown(CodeInsightTestFixtureImpl.java:1234)
	at org.jetbrains.kotlin.idea.codeInsight.gradle.GradleQuickFixTest.tearDownFixtures(GradleQuickFixTest.kt:41)
	at org.jetbrains.kotlin.idea.codeInsight.gradle.ExternalSystemTestCase.lambda$null$5(ExternalSystemTestCase.java:185)
2021-02-05 17:49:28 +03:00
Alexander Dudinsky
94e66acd54 Revert "Fix GradleQuickFixTest"
This reverts commit d5deccd2.
General solution was implemented
2021-02-05 17:45:47 +03:00
Pavel Kirpichenkov
9f7d7e55da Consider platform compatibility in library usage index
Logic of module dependencies is enhanced to filter out incompatible
common -> platform dependencies. However the reversed index for getting
all modules that use libraries doesn't take this filtering into
account and returns all modules based exclusively on order entries.
This leads to incorrect library dependency calculation.

^KT-44638 Verification pending
2021-02-05 16:36:59 +03:00
Dmitriy Dolovov
27dcd07a5e [Commonizer] Remove filter for simd_ functions (no more relevant) 2021-02-05 15:56:33 +03:00
Dmitriy Dolovov
4d5ec6e52a [Commonizer] Minor. Rename: builders.kt -> entityBuilders.kt 2021-02-05 15:56:28 +03:00
Dmitriy Dolovov
955f86ef9f [Commonizer] Minor. Rename: buildingVisitor.kt -> metadataBuilder.kt 2021-02-05 15:56:23 +03:00
Dmitriy Dolovov
33c1ca01f4 [Commonizer] Simplify creation of SerializedMetadataLibraryProvider 2021-02-05 15:56:17 +03:00
Dmitriy Dolovov
6c92ea518b [Commonizer] Add ModulesProvider.loadModuleMetadata() to load raw metadata 2021-02-05 15:56:12 +03:00
Dmitriy Dolovov
cb226e74a5 [Commonizer] Refactor ModulesProvider.loadModuleInfos() function
Change return type from Map<String, ModuleInfo> to Collection<ModuleInfo>
2021-02-05 15:56:06 +03:00
Andrey Zinovyev
08111031ec [KAPT] Keep annotations from kotlin.jvm. in stubs
^KT-35104 Fixed
2021-02-05 13:41:46 +03:00
Mikhail Glukhikh
a68837451a FirCatchParameterChecker: minor fix 2021-02-05 10:46:42 +03:00
Yan Zhulanow
0d1f493b6c Remove unneeded artifacts for Kotlin IDE plugin 2021-02-05 15:53:39 +09:00
Mikhail Glukhikh
f1ab5d1fbd FIR: introduce & use Throwable built-in type 2021-02-05 09:33:54 +03:00
Mikhail Glukhikh
bbd1da7b71 Use reportOn in FirThrowableSubclassChecker & FirCatchParameterChecker 2021-02-05 09:27:01 +03:00
eugenpolytechnic
a564f92eef FIR: introduce ThrowableSubclassChecker 2021-02-05 09:22:12 +03:00
Ilmir Usmanov
cd189c0812 JVM_IR. Do not unbox Result in inline lambda
Since JVM_IR generates inline lambdas differently from old backend,
in this case, it generates them as normal functions.
Thus, there is no need to unbox the lambda argument.
 #KT-44671 Fixed
2021-02-04 20:22:20 +01:00
Alexander Udalov
fb296b5b95 Do not create Array instance in kotlin-reflect where not necessary
Although the previous code of computing JVM internal name from a Class
instance was shorter, it led to unnecessary creation of array types,
which is less performant and makes configuration of kotlin-reflect for
GraalVM native-image more verbose.

Unfortunately I didn't succeed in writing a test for this, since
`Array.newInstance` calls a native method which doesn't record any trace
of it being called in the class loader: the resulting array type never
goes through findClass/loadClass, and is not visible via
findLoadedClass.

 #KT-44594 Fixed
2021-02-04 19:13:42 +01:00
Mikhael Bogdanov
35ec6b4f5c Run IR test on Test Codegen on different platforms 2021-02-04 18:53:06 +01:00
Nikolay Krasko
d5deccd2e9 Fix GradleQuickFixTest
Started as a result of postponed jdk dispose
71e74497b5

CodeInsightTestFixtureImpl assertPointersAreDisposed is invoked before
actually removing pointers.

com.intellij.openapi.util.TraceableDisposable$DisposalException: 1708093728
	at com.intellij.openapi.util.TraceableDisposable.getStackTrace(TraceableDisposable.java:121)
	at com.intellij.openapi.vfs.impl.VirtualFilePointerTracker.assertPointersAreDisposed(VirtualFilePointerTracker.java:86)
	at com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl.lambda$tearDown$38(CodeInsightTestFixtureImpl.java:1281)
	at com.intellij.testFramework.RunAll.collectExceptions(RunAll.java:57)
	at com.intellij.testFramework.RunAll.runAll(RunAll.java:35)
	at com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl.tearDown(CodeInsightTestFixtureImpl.java:1234)
	at org.jetbrains.kotlin.idea.codeInsight.gradle.GradleQuickFixTest.tearDownFixtures(GradleQuickFixTest.kt:41)
	at org.jetbrains.kotlin.idea.codeInsight.gradle.ExternalSystemTestCase.lambda$null$5(ExternalSystemTestCase.java:185)
2021-02-04 18:14:14 +03:00
Andrey Zinovyev
dacf012a78 [KAPT] Add newline after each java compiler log (#4087)
^KT-27123 Fixed
2021-02-04 17:29:13 +03:00
Svyatoslav Kuzmich
cdb488149f [JS IR] Namer improvements
- Compute and store local names locally when translating a body.
  It is a step towards separate JS generation and hopefully reduces memory usage.

- Use stable mangled names for member names. Needed for separate JS generation.

- Add `abstract class IrNamerBase` with just 3 abstract methods to simplify
  creating new IrNamer implementations.

- Fix O(N^2) of findFreshName when it is called wtih the same name suggestion a lot of times.

- Refactor NameTables initialisation: factor out some functions and use descriptive names.

- Use StringBuilder in sanitizeName
2021-02-04 16:17:01 +03:00
Svyatoslav Kuzmich
c9cb7bc0fd [JS IR] Update tests 2021-02-04 16:16:41 +03:00
Svyatoslav Kuzmich
ae738e9c59 [JS] Add basic optional logs to test runner 2021-02-04 16:16:21 +03:00
Svyatoslav Kuzmich
c6242ad167 [JS] String.isValidES5Identifier
- Check Latin letters and numbers first before doing more expensive Character.getType
2021-02-04 16:16:21 +03:00
Svyatoslav Kuzmich
8be7e6064e [JS IR] Optimize sanitization
- Use direct function call instead of lambda
- Don't do anything for already valid names
2021-02-04 16:16:00 +03:00
Svyatoslav Kuzmich
2a424ad2af [IR] Make isExternal mutable and accessible via common interface
JS IR: Mark all effectively external declarations as external to access it
directly instead of computing it every time
2021-02-04 16:15:33 +03:00
Svyatoslav Kuzmich
924a7b009b [JS IR] Fix object getInstance visibility 2021-02-04 15:41:22 +03:00
Svyatoslav Kuzmich
218c246111 [JS] Fix extra js function capturing 2021-02-04 15:41:21 +03:00
Andrey Zinovyev
95140f35f8 [parcelize] Fix codegen for generic classes
Replace type arguments with star projection in static methods
Fix IR function generation

^KT-42652  Fixed
2021-02-04 15:11:51 +03:00
Dmitriy Novozhilov
ca02573d1e [Test] Print bytecode if DxCheckerHandler had failed 2021-02-04 10:53:50 +03:00
Dmitriy Novozhilov
771b1acbc1 [Test] Ignore multimodule tests in AbstractLightAnalysisModeTest 2021-02-04 10:53:50 +03:00
Dmitriy Novozhilov
29b96aa15d [Test] Properly merge box against java testdata into codegen/box
Previous commit about it was 3199ce03 and it was completely wrong
2021-02-04 10:53:50 +03:00
Dmitriy Novozhilov
21c493a854 [Test] Support different backends enumeration in DONT_TARGET_EXACT_BACKEND directive 2021-02-04 10:53:49 +03:00
Alexander Udalov
acd8c4503b Do not generate $suspendImpl for JvmDefault functions in interfaces
#KT-44533 Fixed
2021-02-03 21:37:58 +01:00
Ilmir Usmanov
5f71cd5476 Minor. Mute test on FIR 2021-02-03 19:18:29 +01:00
Ilmir Usmanov
02f845636e JVM_IR: Box generic Result parameter in suspend lambda
#KT-44527 Fixed
2021-02-03 19:18:27 +01:00
Ilmir Usmanov
a30a961cf5 Minor. Throw exceptions in test coroutine builders 2021-02-03 19:18:24 +01:00
Dmitriy Dolovov
52e22796e1 [Commonizer] Prettier message about target with no libraries inside 2021-02-03 20:42:57 +03:00
Dmitriy Dolovov
73113c1041 [Commonizer] Dump every module to disk immediately when it's ready
No need to retain all metadata modules in memory -> lesser memory consumption.
2021-02-03 20:42:50 +03:00
Svyatoslav Kuzmich
53204661e3 [JS] Update stdlib API test data after dukat update 2021-02-03 20:36:24 +03:00
Svyatoslav Kuzmich
d3b4df7da8 [JS] Revert paramter names changed by dukat 2021-02-03 20:36:24 +03:00
Victor Turansky
f1682cba13 KT-40235 Dukat 0.5.8-rc.4 2021-02-03 20:36:24 +03:00
Victor Turansky
ba0d60853d KT-40235 null companion for stdlib external union types 2021-02-03 20:36:24 +03:00
Victor Turansky
7523a5e97f KT-40235 Fix external interface companion support 2021-02-03 20:36:24 +03:00
Ilya Gorbunov
cc55580300 Exclude kotlin-test root project during JPS sync 2021-02-03 19:28:42 +03:00
yaroslav.chernyshev
b32db1ac02 Refactoring: change assertion signature, proper source set copying way 2021-02-03 19:15:33 +03:00
yaroslav.chernyshev
b2017a9c9c Introduce importing checkers with implementation for orphan source sets
* Found diagnostics are attaching to the model
* Diagnostics are collecting into Module's DataNode on IDE side
* Some tests for diagnostics are added
2021-02-03 19:15:33 +03:00
Ilya Gorbunov
87e130e77a Remove obsolete diagnostics suppression
The diagnostic NON_PUBLIC_PRIMARY_CONSTRUCTOR_OF_INLINE_CLASS is now
obsolete because internal constructors of inline classes became allowed.
2021-02-03 18:23:53 +03:00
Dmitriy Novozhilov
ebced14db2 [FIR] Implement suppressing diagnostics with @Suppress 2021-02-03 18:10:48 +03:00
Dmitriy Novozhilov
459a2886a0 [FIR] Add CheckerContext to DiagnosticReporter and refactor diagnostic reporting
Refactoring includes replacing `Diagnostic.report` extensions in
  checkers with `DiagnosticReporter.reportOn` extension declared
  in DiagnosticReporter.kt
2021-02-03 18:10:48 +03:00
Andrey Zinovyev
923a4427c5 [KAPT] Fix stub generation for anonymous delegates
Replace anonymous classes with superclass in delegate properties
#KT-34838 Fixed
2021-02-03 17:27:41 +03:00
Alexander Udalov
60a05dded0 Build: fix default value for kotlin.build.disable.werror 2021-02-03 15:06:20 +01:00
Denis.Zharkov
7942bd0b3b Minor. Regenerate tests 2021-02-03 16:38:13 +03:00
Dmitry Petrov
2535e5d5c9 Minor: LAMBDAS directive in old back-end tests 2021-02-03 15:11:04 +03:00
Alexander Udalov
bd45a6c11d Support -Xsuppress-version-warnings to suppress API/language version warnings
To be used in the project after bootstrap to get rid of warnings like
"Language version 1.3 is deprecated, ..." which prevent us from enabling
`-Werror` in `:compiler:cli` and other modules.
2021-02-03 13:07:04 +01:00
Denis.Zharkov
d901ceb734 FIR: Fix loading Java annotations with Class[]-typed methods 2021-02-03 15:05:22 +03:00
Denis.Zharkov
5a55d56320 IR: Fix offsets for value parameters for bridges
Previously, offsets from super class parameter have been used
and they might belong to a different file and those offsets are irrelevant
to the current file
2021-02-03 15:05:22 +03:00
Denis.Zharkov
8712772a5f FIR: Add test for type resolution when referenced nested class from supertypes 2021-02-03 15:05:22 +03:00
Denis.Zharkov
c51798d46f Fix warning at VMCounters.kt 2021-02-03 15:05:22 +03:00
Denis.Zharkov
e7669ef9d6 FIR: Fix builder inference case with independent calls inside lambda 2021-02-03 15:05:21 +03:00
Denis.Zharkov
29ac4cb9cc Minor. Simplify conditions in shouldRunCompletion 2021-02-03 15:05:21 +03:00
Denis.Zharkov
173a852273 FIR: Fix uninitialized lateinit FirSymbol::symbol for supertype of Java class
Earlier, isForSupertypes has been mapped to different boolean parameter
2021-02-03 15:05:21 +03:00
Alexander Udalov
8b2279072f Fix compilation in tests-compiler-utils 2021-02-03 13:04:21 +01:00
Alexander Udalov
e0b6d4d917 Add -Xsuppress-deprecated-jvm-target-warning to modules compiled with 1.6
Currently this leads to an unknown argument warning, but it'll be
removed automatically on the next bootstrap.
2021-02-03 12:51:39 +01:00
Alexander Udalov
99b5e5a373 Deprecate JVM target 1.6
#KT-44650 Fixed
2021-02-03 12:50:52 +01:00
Dmitry Petrov
ab20a8ffff JVM_IR indy-lambdas: minor updates and fixes
KT-44278 KT-26060 KT-42621
2021-02-03 14:16:25 +03:00
Dmitry Petrov
088448043a JVM_IR indy-lambdas: don't use indy for big arity lambdas
KT-44278 KT-26060 KT-42621
2021-02-03 14:16:24 +03:00
Dmitry Petrov
d94912ed62 JVM_IR indy-lambdas: initial implementation and tests
KT-44278 KT-26060 KT-42621
2021-02-03 14:16:22 +03:00
Igor Chevdar
0bc386cb08 [IR] Fixed bug with reflectionTarget evaluation 2021-02-03 15:26:40 +05:00
Igor Chevdar
bb8bf28b8b [PSI2IR] Set reflectionTarget for all adapted references 2021-02-03 15:26:40 +05:00
Andrei Klunnyi
690fb47cbb KT-44079 [Sealed Interfaces]: move refactoring update
The idea behind this commit is that Move Refactoring should warn
developers in case their intention potentially breaks sealed
hierarchies (members must share the same module and package).

Provided algorithm has two goals:
- prevent destruction of correct hierarchies
- help in fixing broken ones
2021-02-03 10:04:26 +00:00
Ilya Goncharov
de3678a805 [JS IR] Add test with fun interface call inside lambda
^KT-44433 fixed
2021-02-03 12:13:53 +03:00
Ilya Goncharov
d6e74b9620 [JS IR] Use local scope for SAM if there are scopes
[JS IR] Use private for top level sam wrappers and local otherwise

^KT-44433 fixed
2021-02-03 12:13:52 +03:00
Jinseong Jeon
ca314c5bb9 FIR checker: add diagnostic CANNOT_WEAKEN_ACCESS_PRIVILEGE 2021-02-03 12:07:36 +03:00
Jinseong Jeon
3a07ca4c64 FIR checker: add diagnostic VAR_OVERRIDDEN_BY_VAL 2021-02-03 12:07:36 +03:00
Jinseong Jeon
80d5a1a1db FIR checker: add diagnostic OVERRIDING_FINAL_MEMBER 2021-02-03 12:07:36 +03:00
Jinseong Jeon
4ef1e1119f FIR LT: introduce positioning strategies for specific modifiers 2021-02-03 12:07:35 +03:00
Jinseong Jeon
0dd5b94556 FIR checker: rename override checker
We can report more diagnostics than type mismatch, e.g.,
nothing to override, var overridden by val, final override, etc.
2021-02-03 12:07:35 +03:00
Jinseong Jeon
b48835f3ce FIR checker: fix positions of type mismatch on overrides
To handle implicit return types, those should be reported on
declarations with return type positioning strategy, instead of
return type itself.
2021-02-03 12:07:35 +03:00
Dmitriy Novozhilov
571c4ce398 [Test] Support new configuration directives in old codegen tests 2021-02-03 10:03:23 +03:00
pyos
8277c96933 FIR: copy nullability when mapping type alias arguments 2021-02-03 08:38:56 +03:00
scaventz
bd205317aa CLI: improve behavior of -include-runtime
1.fix KT-17344: Include kotlin-reflect to resulting jar if "-include-runtime" is specified, unless the -no-reflect option is specified.
2.fix KT-43220: -include-runtime should add .kotlin_builtins to the output
2021-02-02 12:49:23 -08:00
Alexander Udalov
496d857db1 Add kotlin.build.disable.werror to disable -Werror locally
This can be placed, for example, in `local.properties` to temporarily
disable `-Werror` in compiler/stdlib/plugin/test modules during
development.
2021-02-02 21:47:33 +01:00
Mads Ager
6a959fefd0 [JVM_IR] Fix accessibility bridges for static protected fields.
Super-qualifiers have to be taken into account. Otherwise, too
few accessibility bridges will be generated which can lead to
binary compatibility issues.
2021-02-02 12:46:08 -08:00
Dmitriy Dolovov
62897a194b [Commonizer] Force GC after each serialized target 2021-02-02 23:13:14 +03:00
Dmitriy Dolovov
ff45e58543 [Commonizer] Minor. Post-review changes, p.2 2021-02-02 23:13:06 +03:00
Dmitriy Dolovov
c8a938275c [Commonizer] Minor. Post-review changes 2021-02-02 23:13:00 +03:00
Dmitriy Dolovov
318dd22bd1 [Commonizer] Add tests for CommonizerTarget 2021-02-02 23:12:54 +03:00
Dmitriy Dolovov
6fe5f85da7 [Commonizer] Use kotlin/Any as the default supertype for commonized class 2021-02-02 23:12:49 +03:00
Dmitriy Dolovov
2438265ba8 [Commonizer] Dump every target to disk immediately when it's ready 2021-02-02 23:12:43 +03:00
Dmitriy Dolovov
9c4af5070b [Commonizer] Ignore acceptable (minor) metadata mismatches in tests 2021-02-02 23:12:37 +03:00
Dmitriy Dolovov
a4438ad64f [Commonizer] Fix calculation of type parameter IDs for nested classes and their members 2021-02-02 23:12:30 +03:00
Dmitriy Dolovov
55c37183d9 [Commonizer] Ignore constructors for enum entries 2021-02-02 23:12:23 +03:00
Dmitriy Dolovov
dfd1a53624 [Commonizer] Don't serialize kotlin/Any? as the single type parameter upper bound 2021-02-02 23:12:18 +03:00
Dmitriy Dolovov
1c8cd242bf [Commonizer] Don't write IS_EXPECT flag for synthesized expect functions 2021-02-02 23:12:12 +03:00
Dmitriy Dolovov
9d6c0e56ed [Commonizer] Fix HAS_ANNOTATIONS flag calculation for serialized classes 2021-02-02 23:12:07 +03:00
Dmitriy Dolovov
b39a205671 [Commonizer] Minor. Improved diagnostics message in tests 2021-02-02 23:12:01 +03:00
Dmitriy Dolovov
80b95a22a4 [Commonizer] Fix property backing/delegate field annotations serialization 2021-02-02 23:11:55 +03:00
Dmitriy Dolovov
3b91d1c5e5 [Commonizer] Don't commonize built-ins 2021-02-02 23:11:49 +03:00
Dmitriy Dolovov
585cd64b9a [Commonizer] Drop descriptors for commonized declarations 2021-02-02 23:11:44 +03:00
Dmitriy Dolovov
5ff6b5ef42 [Commonizer] Rework test infrastructure to compare metadata instead of descriptors 2021-02-02 23:11:38 +03:00
Dmitriy Dolovov
f67a9615b8 [Commonizer] Pretty target name output in console 2021-02-02 23:11:31 +03:00
Dmitriy Dolovov
e5aa772639 [Commonizer] Fix approximation for aliases types 2021-02-02 23:11:26 +03:00
Dmitriy Dolovov
4c640e3f81 [Commonizer] Log stats during building metadata 2021-02-02 23:11:19 +03:00
Dmitriy Dolovov
d610837caf [Commonizer] Integrate metadata builder with the commonizer environment 2021-02-02 23:11:13 +03:00
Dmitriy Dolovov
2bcaf1fa63 [Commonizer] Introduce metadata builder 2021-02-02 23:11:04 +03:00
Dmitriy Dolovov
e28c1fd310 Metadata: Chunked KlibModuleFragmentWriteStrategy implementation 2021-02-02 23:10:57 +03:00
Dmitriy Dolovov
9551e0fff2 [Commonizer] Introduce MetadataDeclarationsComparator for metadata-based comparison of KLIBs 2021-02-02 23:10:51 +03:00
Dmitriy Dolovov
701374a646 [Commonizer] Embed :kotlinx-metadata-klib into the commonizer Jar 2021-02-02 23:10:45 +03:00
Dmitriy Dolovov
08cc904a71 [Commonizer] Restore lost nullability for underlying types in TAs 2021-02-02 23:10:39 +03:00
Dmitriy Dolovov
85f79695b9 [Commonizer] Avoid leaking non-commonized underlying types in TAs 2021-02-02 23:10:32 +03:00
Dmitriy Novozhilov
4bf6e58f2b [TD] Fix directive order in codegen testdata 2021-02-02 20:37:47 +03:00
Zalim Bashorov
3f10914f05 [JS] Replace usages of FileUtil.loadTextAndClose with functions from stdlib to avoid crashes on files larger than 10MiB 2021-02-02 18:47:44 +03:00
Anton Bannykh
165533fdb7 JS DCE: use Multimaps to reduce Node fields RAM 2021-02-02 18:39:35 +03:00
Anton Bannykh
f42f2fa743 JS DCE: disable logging by default
Based on Vladislav Saifulin's PR #4031
2021-02-02 18:38:50 +03:00
Anton Bannykh
26ce6b5131 JS DCE: inline Qualifier class to reduce RAM usage 2021-02-02 18:38:49 +03:00
Anton Bannykh
bbc6d2b993 JS DCE: use less LinkedHashSets 2021-02-02 18:38:49 +03:00
Anton Bannykh
3c0b226344 JS DCE: create collections on demand
Based on Vladislav Saifulin's PR #4031
2021-02-02 18:38:49 +03:00
Dmitriy Novozhilov
0ebb39a26e [Test] Exclude multimodule tests from codegen tests on android 2021-02-02 17:54:59 +03:00
Dmitriy Novozhilov
17d59e0daa [Test] Support skip of android codegen tests with new ASSERTION_MODE directive 2021-02-02 17:54:59 +03:00
Dmitriy Novozhilov
81ba7aa833 [Test] Use javac for compilation test java files from runtime by default 2021-02-02 17:54:59 +03:00
Dmitriy Novozhilov
e9cb30b4f3 [Test] Add ability to use custom CompilerConfigurationProvider 2021-02-02 17:54:59 +03:00
Dmitriy Novozhilov
c432efc364 [Build] Extract configuration of JUnit5 dependencies to common helper in buildSrc 2021-02-02 17:54:59 +03:00
Dmitriy Novozhilov
dea3c954f1 [Test] Add ability to stop test pipeline if there was an exception in handler 2021-02-02 17:54:59 +03:00
Dmitriy Novozhilov
2ae35b0b08 [Test] Move fir backend tests back to :compiler:fir2ir module 2021-02-02 17:54:58 +03:00
Dmitriy Novozhilov
e79d02f482 [Test] Don't generate extends clause for nested classes in generated tests for JUnit5
This is fine since all nested classes in tests are inners by JUnit5
  specification, so they will see `runTest` method from outer root class
2021-02-02 17:54:58 +03:00
Dmitriy Novozhilov
a4e9ab90a0 [Test] Migrate :tests-different-jdk on runners which are using JUnit5 2021-02-02 17:54:51 +03:00
Dmitriy Novozhilov
c969a34644 [Test] Set static field with application to null after tests are completed 2021-02-02 17:54:51 +03:00
Dmitriy Novozhilov
53e5aa4364 [Test] Don't use PSI based class reading in codegen BB tests
#KT-34826 is rela ted
2021-02-02 17:54:51 +03:00
Dmitriy Novozhilov
09ec3f6eaf [Test] Support various jdk targets in test infrastructure 2021-02-02 17:54:51 +03:00
Dmitriy Novozhilov
93741ced5c [Test] Read default target version from sys property in new test infra 2021-02-02 17:54:50 +03:00
Dmitriy Novozhilov
a3ad626f99 [Test] Support invoking box method in BB tests in separate process 2021-02-02 17:54:50 +03:00
Dmitriy Novozhilov
b351ca6bd4 [Test] Regenerate spec tests 2021-02-02 17:54:50 +03:00
Dmitriy Novozhilov
3199ce03a6 [Test] Merge box against java testdata into codegen black box testsdata 2021-02-02 17:54:49 +03:00
Dmitriy Novozhilov
e62b118351 [TD] Ignore JS backends in boxAgainstJava tests 2021-02-02 17:54:49 +03:00
Dmitriy Novozhilov
99cb85ab00 [Test] Merge box against java tests into codegen black box tests 2021-02-02 17:54:47 +03:00
Dmitriy Novozhilov
6f3713af5f [Test] Migrate AbstractIrCompileKotlinAgainstKotlinTest to new infrastructure 2021-02-02 17:53:53 +03:00
Dmitriy Novozhilov
49c2bfe637 [Test] Enable SMAP dump handler in boxInline tests 2021-02-02 17:53:53 +03:00
Dmitriy Novozhilov
64a300bfcd [TD] Update testdata according to previous commit 2021-02-02 17:53:52 +03:00
Dmitriy Novozhilov
3a0eee64b8 [Test] Migrate all jvm tests runners for boxInline tests 2021-02-02 17:53:50 +03:00
Dmitriy Novozhilov
8973e3f362 [TD] Update fir directives in boxInline tests 2021-02-02 17:50:07 +03:00
Dmitriy Novozhilov
92e21e76ba [Test] Implement SMAP dump handler 2021-02-02 17:50:07 +03:00
Dmitriy Novozhilov
e3ab3d6be3 [Test] Align lines in TestFile with lines in real testdata file 2021-02-02 17:50:07 +03:00
Dmitriy Novozhilov
60e0831c11 [Test] Introduce two module structure transformers for codegen test 2021-02-02 17:50:07 +03:00
Dmitriy Novozhilov
13a778fd9c [Test] Add ability to freely transform module structure which was parsed from directive
Service ModuleStructureExtractor may break readabilty of test so it
  should be used very carefully

Originally it is created for box inline test where we have different
  runners on same testdata where one runner assumes that all files
  in test in same module and other that they in different ones
2021-02-02 17:50:06 +03:00
Dmitriy Novozhilov
fc83dc17fe [Test] Support USE_OLD_INLINE_CLASSES_MANGLING_SCHEME directive 2021-02-02 17:50:06 +03:00
Dmitriy Novozhilov
3f758a3fa2 [Test] Make BytecodeInliningHandler for new infrastructure 2021-02-02 17:50:06 +03:00
Dmitriy Novozhilov
0768a7089c [TD] Fix friend modules 2021-02-02 17:50:06 +03:00
Dmitriy Novozhilov
5075484c8e [TD] Update directives in kotlinAgainstKotlin testdata 2021-02-02 17:50:05 +03:00
Dmitriy Novozhilov
9ba41c5b88 [Test] Improve error reporting if there are too many values passed to directive 2021-02-02 17:50:05 +03:00
Dmitriy Novozhilov
5c8d555808 [Test] Move KotlinAgainstKotlin tests under BlackBoxCodegen tests 2021-02-02 17:50:05 +03:00
Mikhael Bogdanov
1ea4fa4464 Fix android test with type annotations. Remove obsolete JVM 8 flavors
Remove some new test cause their originals would be executed on JvmTarget6OnJvm8
2021-02-02 14:32:50 +01:00
Mikhael Bogdanov
c13f38f6df Support proper frame maps for enumValues 2021-02-02 14:32:50 +01:00
Mikhael Bogdanov
1a044e5af4 Support proper frame maps for enum valueOf 2021-02-02 14:32:50 +01:00
Mikhael Bogdanov
5b64ceceb3 JVM_IR. Generate additional checkcast for when/try epressions to avoid frame map problems on reification 2021-02-02 14:32:50 +01:00
Mikhael Bogdanov
16928d6e3f Don't remove checkcast for reified values
#KT-35511 Fixed
2021-02-02 14:32:50 +01:00
Mikhail Glukhikh
0b0ba7d987 Don't use warningsAsError in compiler modules if useFIR is ON 2021-02-02 16:29:27 +03:00
Marcin Aman
d953a03807 Specify type explicitly in KotlinCoreProjectEnvironment.createCoreFileManager to allow overriding this method with different implementation 2021-02-02 05:26:04 -08:00
Mikhail Glukhikh
21000f4174 [FIR] Support TypeVariableMarker.isReified 2021-02-02 16:25:08 +03:00
Mikhail Glukhikh
465261e611 FIR: don't create intersection override for duplicating symbols 2021-02-02 16:25:08 +03:00
Dmitry Gridin
b9c33a0c6e [i18n] copy-paste message from RefactoringBundle to fix missing resource in 202
^KT-44675 Fixed
2021-02-02 20:23:04 +07:00
Ivan Gavrilovic
2fce6a4af9 Locate build history when file is outside of root project dir
Support use-cases when the build dir is outside of root project dir.
Many projects set up output dir as <root_project>/../out/<project_name>/build
to be able to clean build dir more easily. This commit adds support
to build history file detection and it tries to find build history
files for artifacts that are:
- under root project dir (a default structure)
- under root project's build dir parent (to support typical custom setup)

Fixes https://youtrack.jetbrains.com/issue/KT-40875

Test: BaseIncrementalCompilationMultiProjectIT
2021-02-02 12:47:07 +03:00
Nicola Corti
5de34b052f Remove unsupported '!' from DIAGNOSTICS directive 2021-02-02 01:30:33 -08:00
Nicola Corti
e2b7aba086 Do not report UNNECESSARY_SAFE_CALL on ErrorType 2021-02-02 12:10:56 +03:00
Roman Artemev
59551eb037 [Plugin API] Provide diagnostic API for IR plugins 2021-02-02 12:05:35 +03:00
Roman Artemev
9fa5feeeea [CLI] Provide MessageCollector based logger for IR from CLI 2021-02-02 12:05:35 +03:00
Roman Artemev
daa65a2fff [KLIB] Handle linkage error
Do not crash compiler with ugly stacktrace in case of misconfiguration.
Report relatively friendly diagnostic message instead
2021-02-02 12:05:35 +03:00
Roman Artemev
bf67308cc2 [KLIB] Use IrMessageLogger in klib linker to report errors 2021-02-02 12:05:35 +03:00
Roman Artemev
6891ad0dfc [IR] Add IrMessageLogger interface for diagnostic reporting from IR 2021-02-02 12:05:35 +03:00
Roman Artemev
bb66b2fd04 Drop redundant compile dependency 2021-02-02 12:05:35 +03:00
Roman Artemev
c5068b7d45 [KLIB] Drop unused logger 2021-02-02 12:05:34 +03:00
Roman Artemev
484b884d04 [KLIB] Make IrModuleDeserializer's printable 2021-02-02 12:05:34 +03:00
Roman Artemev
d6bb1f2d4e [KLIB] Make KotlinLibraryImpl printable 2021-02-02 12:05:34 +03:00
Roman Artemev
24d82c63e0 [JS IR] Commonize CLI error reporting
Use general `AnalysisResult.CompilationErrorException` instead of
custom JsIrCompilationError to indicate about unsuccessful compilation

- Drop JsIrCompilationError
2021-02-02 12:05:34 +03:00
Roman Artemev
ba5193870e [IR] Drop unused language version settings parameters from DependenciesGenerator 2021-02-02 12:05:34 +03:00
Sergey Bogolepov
06498c0efd Support for macos_arm64 target in backend 2021-02-02 15:30:03 +07:00
Dmitriy Novozhilov
f255f93ad9 [Test] Support skip of android codegen tests with new ASSERTION_MODE directive 2021-02-02 07:08:13 +01:00
Alexander Udalov
eff13d24dc Remove unneeded language feature configuration from fir:tree
It causes a verbose warning to be displayed on each build. Inline
classes are enabled by default since Kotlin 1.5, so this configuration
is no longer needed.
2021-02-01 20:25:06 +01:00
Nwokocha wisdom maduabuchi
e47dfcbe64 Update ReadMe.md (#3877) 2021-02-01 21:27:02 +03:00
Igor Yakovlev
18cebe5131 [FIR IDE] Codereview minor refactoring
https://jetbrains.team/p/kt/review/2069/
https://jetbrains.team/p/kt/review/2070/
2021-02-01 21:21:03 +03:00
Igor Yakovlev
e529a7bf9b [FIR IDE] Implement isInheritor for FirLightClassForClassOrObjectSymbol 2021-02-01 21:21:03 +03:00
Igor Yakovlev
56db4bd1ac [FIR IDE] Implement isInheritor for KtFirBasedFakeLightClass 2021-02-01 21:21:02 +03:00
Igor Yakovlev
5d4606daaa [FIR IDE] Remove LightClassProvider 2021-02-01 21:21:02 +03:00
Igor Yakovlev
2812034896 [FIR IDE] Make KtFakeLightClass independent 2021-02-01 21:21:02 +03:00
Igor Yakovlev
c1cdf273a6 [FIR IDE] Fix test data fir parameters highlighting test 2021-02-01 21:21:02 +03:00
Igor Yakovlev
9f282e0ddc [FIR] Do not erase type arguments for unresolved method calls 2021-02-01 21:21:02 +03:00
Igor Yakovlev
659d2c13b4 [FIR IDE] Fix annotation value parameter and ctor resolve 2021-02-01 21:21:01 +03:00
Igor Yakovlev
019635189a [FIR IDE] Fix annotation call reference resolve to ctor 2021-02-01 21:21:01 +03:00
Igor Yakovlev
65b6a95f64 [FIR IDE] Fix structure element non analyzable elements recording for analyzable properties 2021-02-01 21:21:01 +03:00
Alexander Udalov
5480faf5c5 Add tests for issues fixed in JVM IR and other obsolete issues
#KT-6007
 #KT-16445
 #KT-17753
 #KT-22488
 #KT-23881
 #KT-24135
 #KT-26360
 #KT-27427
 #KT-27449
 #KT-27830
 #KT-28042
 #KT-29595
 #KT-30708
 #KT-32793
2021-02-01 18:29:59 +01:00
Anton Yalyshev
3e59adc7f3 Add change-notes for 1.4.30 release 2021-02-01 19:03:47 +03:00
Anton Yalyshev
90f9dd5b33 Revert change-notes for 1.4.30 2021-02-01 18:57:05 +03:00
Mikhael Bogdanov
206b38f0ab Fix compilation against asm 7.0 2021-02-01 16:52:46 +01:00
Anton Yalyshev
78c6e0733c Add change-notes for 1.4.30 2021-02-01 18:51:38 +03:00
Mikhail Glukhikh
1f62fee4f9 Fix typo 2021-02-01 18:33:05 +03:00
Mads Ager
593fb8770b [FIR] Fix lookup order for statics in super chains
The order was reversed and the static in the top-most class
in the inheritance hierarchy would be found instead of the
lowest one.
2021-02-01 18:32:55 +03:00
Dmitry Petrov
4ec369ac5b JVM_IR fix special bridge generation for inline classes 2021-02-01 17:57:58 +03:00
Alexander Udalov
8172ae5d89 Fix codegen test classLiteralWithExpectedType.kt on Android
Similar to changes in d022bb0248, this test started to fail because
`AnnotationTarget.TYPE` is mapped to `ElementType.TYPE_USE` if JVM
target is >= 1.8. In codegen tests on Android, we're running the
emulator of version 19 which is less than 26, where `TYPE_USE` has first
appeared.
2021-02-01 15:54:01 +01:00
pyos
bd3bc13e75 JVM_IR: give loops somewhat more debuggable labels 2021-02-01 15:51:31 +01:00
pyos
ad53fc931e JVM: optimize temporary kotlin.jvm.internal.Refs as well
i.e. remove the condition that there must be an LVT entry. Such
temporary `Ref`s can be created, for example, by the JVM_IR backend
if a lambda inlined at an IR level (e.g. argument to `assert`/`Array`)
is the target of a non-local return from a function inlined at bytecode
level (e.g. `run`):

    IntArray(n) { i ->
        intOrNull?.let { return@IntArray it }
        someInt
    }

->

    val `tmp$0` = IntArray(n)
    for (i in 0 until `tmp$0`.size) {
        var `tmp$1`: Int
        do {
            intOrNull?.let {
                `tmp$1` = it // causes `tmp$1` to become an IntRef
                break
            }
            `tmp$1` = someInt
        } while (false)
        `tmp$0`[i] = `tmp$1`
    }
2021-02-01 15:51:31 +01:00
pyos
0f2ca5d84c JVM_IR: support non-local break/continue in the inliner
Not in the frontend or psi2ir, though, so this not a complete
implementation of KT-1436, but rather a part of it that is currently
useful to make other code compile. In particular, lambdas passed to
array constructors and JVM-style `assert` are inlined as IR returnable
blocks, which are then converted into `do { ... } while (false)` loops,
so non-local returns from them become non-local `break`s.
2021-02-01 15:51:31 +01:00
Ilya Gorbunov
4a17228621 Infer required kotlin-test jvm capability based on used test framework
Except when:
- the Gradle version is less than 6.0, it doesn't read the metadata
published by a newer Gradle by default.
- the requested dependency version is less than 1.5, because it doesn't
have metadata published.

Update integration tests to use kotlin-test common dependency.

KT-40225
2021-02-01 16:50:05 +03:00
Ilya Gorbunov
cbeadba15d Disable metadata publishing for legacy common artifacts
When they are used explicitly in common source sets, they cannot be
resolved in platform ones after that since they only have
common kotlin-api variants in their metadata.

KT-40225
2021-02-01 16:50:05 +03:00
Ilya Gorbunov
573aac7252 Apply common configuration to custom publications in kotlin-test
To do that, extract parts of publishing setup into reusable functions.
This change makes signing and repository configuration applied to all
project publications, not just to the Main one.

Also:
- Get rid of dependencies from non-default variants in the root pom
- Add an empty javadoc jar

KT-40225
2021-02-01 16:50:05 +03:00
Ilya Gorbunov
a16aaa3824 Setup publications with MPP Gradle metadata for kotlin-test library
Move publication configuration from individual platform specific
kotlin-test- modules to the root module.

KT-40225
2021-02-01 16:50:05 +03:00
Vladimir Dolzhenko
913c298be8 Kotlin highlight passes are reworked
#KT-37702 Fixed
2021-02-01 13:18:38 +00:00
Vladimir Dolzhenko
558338f997 Lazy diagnostics API in frontend
Relates to #KT-37702
2021-02-01 13:18:37 +00:00
Pavel Kirpichenkov
8f675fe757 Split combined test into two to avoid flaky behaviour
Prevent simultaneous access to the library directory
2021-02-01 15:09:13 +03:00
eugenpolytechnic
9ad88a5a0d FIR: introduce parameter type is Throwable check 2021-02-01 15:07:21 +03:00
eugenpolytechnic
5c0231b727 FIR: introduce CatchParameterChecker 2021-02-01 15:07:13 +03:00
Alexander Udalov
d8549d6292 Build: fix inaccurate change to the logic of useIRForLibraries 2021-02-01 11:54:36 +01:00
Alexander Udalov
e9436da858 Change logic of applying JVM target from AGP options
Now that the default JVM target is 1.8, we have to add the JVM target
1.6 explicitly if the Android project is configured with source/target
1.6, and not do anything if it's configured with 1.8.

 #KT-31027
2021-02-01 11:54:05 +01:00
Alexander Udalov
adfa8c788c Light classes: use JVM target from the module
Using "JVM_1_8" always resulted in incorrect mapping of Kotlin
annotation targets to Java element types.

The change in AbstractKotlinRenderLogTest is needed because while
CliTraceHolder.module is technically a descriptor leak, it was never
detected by this test accidentally, because of the depth cutoff equal to
10, which started to not be enough after the minor refactoring of
replacing `Delegates.notNull` with `lateinit`.
2021-02-01 11:54:05 +01:00
Alexander Udalov
64e97225b8 Light classes: map annotation targets depending on JVM target
Since the default JVM target (`JvmTarget.DEFAULT`) is now 1.8, the
changed test started to fail. This change fixes it.
2021-02-01 11:54:04 +01:00
Alexander Udalov
d022bb0248 Switch default JVM target to 1.8
#KT-29405 Fixed
2021-02-01 11:54:04 +01:00
Ivan Gavrilovic
509ed64917 KT-43686: Make kapt Gradle task cacheable across machines
Use `@Classpath` for kotlin stdlib input property. This is to
allow cache hits when builds are running on different machines
and path to kotlin stdlib differs.

Test: BuildCacheRelocationIT
2021-02-01 13:28:20 +03:00
Dmitriy Novozhilov
771600077c [Test] Fail if there are changes in generated fir tree files in teamcity build 2021-02-01 10:18:37 +03:00
Dmitriy Novozhilov
297288e984 [Test] Don't generate new files in GeneratorsFileUtil in teamcity mode 2021-02-01 10:18:37 +03:00
Dmitriy Novozhilov
772ca2715c [Test] Don't change testdata in FirIdenticalChecker in teamcity mode 2021-02-01 10:18:37 +03:00
Alexander Gorshenev
6265ac8c19 Re-enabled disabled test 2021-01-30 17:41:54 +03:00
Alexander Gorshenev
16b3fedcd4 Created AbstractKlibBinaryCompatibilityTest and AbstractJsKlibBinaryCompatibilityTest
A common test runner for klib binary compatibility tests
and its js counterpart
2021-01-30 17:41:54 +03:00
Alexander Udalov
e7cf34a2a9 Workaround illegal access problem in daemon for JDK 17-ea
Otherwise Kotlin cannot be used in Gradle since
https://github.com/openjdk/jdk/commit/ed4c4ee7 where JDK internals
started to be encapsulated by default.

For some reason, using

    listOf("--add-opens", "java.base/java.util=ALL-UNNAMED")

doesn't help, so use the more general `--illegal-access=permit`.

 #KT-43704
2021-01-29 21:29:08 +01:00
Alexander Udalov
f08733eb75 CLI: suppress warning on JDK 9+ with illegal access to ResourceBundle
The underlying issue is tracked in IDEA-248785.

 #KT-43704 Fixed
2021-01-29 21:29:08 +01:00
Alexander Udalov
2ef4ca4e6e CLI: do not pass -noverify to java process starting from JDK 13
#KT-44232 Fixed
2021-01-29 21:28:25 +01:00
Alexander Udalov
2bbe3db041 Update copyrights in CLI scripts 2021-01-29 21:27:28 +01:00
Mikhael Bogdanov
9f9c8e3d77 Mute stream api test on Android 2021-01-29 18:22:16 +01:00
Dmitriy Novozhilov
21f022dec2 Add :kotlin-scripting-compiler.test to modules with disabled -Werror flag 2021-01-29 20:01:01 +03:00
Sergey Igushkin
021a63827d Add API version 1.5 to accepted values in MPP language settings 2021-01-29 19:49:45 +03:00
Mikhael Bogdanov
6a29097a8c Remove obsolete dependency for dx 2021-01-29 17:47:37 +01:00
Mikhael Bogdanov
be9ef8f3c8 Remove obsolete DxChecker 2021-01-29 17:47:37 +01:00
Steven Schäfer
482e217b5e JVM IR: Fix inline class mangling for calls to internal functions
...in a different module, e.g., using -Xfriend-paths.
2021-01-29 16:23:15 +01:00
Mikhail Glukhikh
6747084fe2 FIR TEST: perform more accurate check on file identity 2021-01-29 16:57:14 +03:00
Mikhail Glukhikh
338aad98eb FIR: run diagnostic "with stdlib" tests also in light tree mode 2021-01-29 16:55:34 +03:00
Mikhail Glukhikh
7d4eaefd36 FIR: report UNSAFE_CALL on dot when possible 2021-01-29 16:55:26 +03:00
Mikhail Glukhikh
0ee4f1f393 FIR: more exact nullability determination in potential UNSAFE_CALL check 2021-01-29 16:55:09 +03:00
Jinseong Jeon
e72ddbcbfe FIR checker: differentiate UNSAFE_CALL from INAPPLICABLE_CANDIDATE
To do so, inside the root cause of inapplicable candidate errors,
we will record expected/actual type of receiver, if any.
That will help identifying inapplicable calls on nullable receiver.
2021-01-29 16:54:23 +03:00
Mikhail Glukhikh
4b823eca21 Fix test data (FIR_IDENTICAL) 2021-01-29 16:54:17 +03:00
2390 changed files with 51117 additions and 32100 deletions

View File

@@ -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).

View File

@@ -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

View File

@@ -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
}
}

View File

@@ -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"
)
}
}

View File

@@ -81,8 +81,6 @@ extra["intellijReleaseType"] = when {
else -> "releases"
}
extra["versions.androidDxSources"] = "5.0.0_r2"
extra["customDepsOrg"] = "kotlin.build"
repositories {

View File

@@ -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)

View File

@@ -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

View File

@@ -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"]}"

View File

@@ -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()

View File

@@ -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",

View File

@@ -80,14 +80,6 @@ android {
reflect0 {
dimension "box"
}
jvm80 {
dimension "box"
}
reflectjvm80 {
dimension "box"
}
}
}

View File

@@ -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()

View File

@@ -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<>();

View File

@@ -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() {}
}
}

View File

@@ -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);

View File

@@ -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

View File

@@ -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)

View File

@@ -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

View File

@@ -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
}
}
}

View File

@@ -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");
};
}

View File

@@ -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) {

View File

@@ -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)

View File

@@ -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)
}
}
}

View File

@@ -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)

View File

@@ -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)

View File

@@ -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) {

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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:="."}

View File

@@ -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 %*

View File

@@ -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

View File

@@ -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"))

View File

@@ -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
}

View File

@@ -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

View File

@@ -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)

View File

@@ -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

View File

@@ -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)

View File

@@ -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())
}
}

View File

@@ -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)
}
}
}
}

View File

@@ -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

View File

@@ -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
}
}

View File

@@ -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")

View File

@@ -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;
}

View File

@@ -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))
}

View File

@@ -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)

View File

@@ -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 {

View File

@@ -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");
}

View File

@@ -5,7 +5,7 @@
package org.jetbrains.kotlin.config
enum class JvmSamConversions(
enum class JvmClosureGenerationScheme(
val description: String,
val minJvmTarget: JvmTarget
) {

View File

@@ -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 }

View File

@@ -50,4 +50,7 @@ object AnalysisFlags {
@JvmStatic
val libraryToSourceAnalysis by AnalysisFlag.Delegates.Boolean
@JvmStatic
val extendedCompilerChecks by AnalysisFlag.Delegates.Boolean
}

View File

@@ -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) }

View File

@@ -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",

View File

@@ -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)

View File

@@ -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|)
}

View 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|) {
}
}

View 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<!>) {}
}

View File

@@ -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?) {

View File

@@ -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|

View File

@@ -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|
}
}

View File

@@ -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> {

View File

@@ -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|
}

View File

@@ -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
}

View File

@@ -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) {

View File

@@ -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|

View File

@@ -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
}
}

View File

@@ -14,6 +14,5 @@ fun main(x: A?) {
x?.unit()
}
// lambda has a type (() -> Unit?)
foo(lambda)
}

View File

@@ -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) {

View File

@@ -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
}

View File

@@ -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()
}

View File

@@ -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
}
}

View File

@@ -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()
}
}

View File

@@ -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
}
}

View File

@@ -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
}
}

View File

@@ -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
}

View File

@@ -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()
}

View File

@@ -11,5 +11,5 @@ fun test(b: Boolean) {
} else {
a = null
}
a.<!INAPPLICABLE_CANDIDATE{LT}!><!INAPPLICABLE_CANDIDATE{PSI}!>foo<!>()<!>
a<!UNSAFE_CALL!>.<!>foo()
}

View File

@@ -18,5 +18,5 @@ fun test_3() {
x = ""
x.length
x = null
x.<!INAPPLICABLE_CANDIDATE!>length<!>
x<!UNSAFE_CALL!>.<!>length
}

View 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| {
}
}

View File

@@ -0,0 +1,6 @@
// WITH_EXTENDED_CHECKERS
@Suppress("warnings")
public class A {
final fun foo() {}
}

View 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| {
}
}

View File

@@ -0,0 +1,7 @@
// WITH_EXTENDED_CHECKERS
@Suppress("REDUNDANT_VISIBILITY_MODIFIER")
public class A {
@Suppress("REDUNDANT_MODALITY_MODIFIER")
public final fun foo() {}
}

View 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))
}

View File

@@ -0,0 +1,6 @@
fun foo(x: String) {}
@Suppress("INAPPLICABLE_CANDIDATE")
fun bar() {
foo(10)
}

View File

@@ -0,0 +1,3 @@
FILE: singleWarning.kt
@R|kotlin/Suppress|(vararg(String(REDUNDANT_VISIBILITY_MODIFIER))) public final fun foo(): R|kotlin/Unit| {
}

View File

@@ -0,0 +1,4 @@
// WITH_EXTENDED_CHECKERS
@Suppress("REDUNDANT_VISIBILITY_MODIFIER")
public fun foo() {}

View 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|>()
}
}
}

View 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() {}<!>
}

View File

@@ -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()

View File

@@ -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)
}

View File

@@ -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)<!>
}

View File

@@ -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()

View File

@@ -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)<!>
}

View File

@@ -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