Compare commits

..

408 Commits

Author SHA1 Message Date
Sergey Rostov
8e817c3ba0 ScriptTemplatesClassRootsIndex: inc version and minor fixes
Content was changed, so we should force reindex.

Minor changes:
- There is no need to save a string, we can just save nothing
 by using the Unit value (see UnitKey.save and UnitKey.read)
- Unit can be shared between all indexes, so we can extract UnitKey object
- It would be good to extract abstract class FileListIndex:
  - for better readability: separate the logic of the specific index from the common FileListIndex implementation
  - someone can use it also
- mapOf (Unit to null) will create singletonMap itself and more readable
- ScriptTemplatesClassRootsIndex.KEY perhaps better to call NAME
2020-07-08 11:02:01 +03:00
Mikhail Glukhikh
4a988f467a [FIR2IR] Code cleanup: DelegatedMemberGenerator 2020-07-08 10:05:07 +03:00
Juan Chen
d163853c97 [FIR] add support for implementation by delgation
This commit handles "subclass: super-interface by delegate-expression".

During Psi2Fir, for each delegate, we add to the subclass a synthetic
field (which has type super-interface), and an assignment of the
delegate-expression to the synthetic field in the primary constructor,
so that the delegate-expression can be resolved and transformed along
the way.

During Fir2Ir, we look up delegatable members from the super-interface
and generate corresponding functions/properties for the subclass.

TODO: support for generic delegatable members and generic
super-interface.
2020-07-08 09:42:24 +03:00
Natalia Selezneva
1d45dc8d81 Optimize ScriptTemplatesFromDependenciesProvider
No needs to convert file.url to VirtualFile
because index already has getContainingFiles method
Do not iterate through all children of VirtualFile
to avoid VFS events initialisation for those files
there is no guarantee that file is under source root
so is can be not present is vfs at this moment
2020-07-07 23:26:58 +03:00
Vladimir Dolzhenko
45600830d3 Fixed locking granularity in ScriptDefinitionsManager
#KT-34552 Fixed
#KT-39547 Fixed
2020-07-07 19:15:32 +00:00
simon.ogorodnik
77ccb3767c [FIR] Add system property selector for lightTree2fir / psi2fir 2020-07-07 21:47:24 +03:00
simon.ogorodnik
a460b8f2f4 [FIR] Support source directories for lightTree2fir 2020-07-07 21:47:24 +03:00
simon.ogorodnik
6c7a40627f [FIR] Forbid constructors in processFunctionsByName 2020-07-07 21:47:24 +03:00
simon.ogorodnik
6bc654ee49 [FIR] Add full compiler pipeline modularized test
Fixup: allow kotlin package
2020-07-07 21:47:24 +03:00
simon.ogorodnik
b48dfe9b3d Allow dirs as content root in modularized tests 2020-07-07 21:47:24 +03:00
simon.ogorodnik
bf1c3777ab Add IR specific timing measurements to performance manager 2020-07-07 21:47:24 +03:00
simon.ogorodnik
0de70d295a Fix argument names 2020-07-07 21:47:23 +03:00
simon.ogorodnik
b401443dbd Compute GC metrics only during compilation 2020-07-07 21:47:23 +03:00
simon.ogorodnik
6095ec66ed Allow to pass external performance manager to compiler 2020-07-07 21:47:23 +03:00
Alexander Udalov
8c71d8f126 Undeprecate VariableDescriptorWithAccessors.isDelegated
Apparently there's quite a few valid usages of this method outside of
the compiler frontend, where manual suppression is annoying.
2020-07-07 18:09:40 +02:00
Jinseong Jeon
50b2ea7053 FIR: avoid cast exception in Candidate.prepareExpectedType 2020-07-07 16:55:53 +03:00
Nick
a5f34a880c [FIR] Fix computeTypeArguments() & add diagnostic for type args 2020-07-07 15:52:17 +03:00
Stanislav Erokhin
8772fabc4f Fix since-build version for AS 3.6 and AS 4.0 2020-07-07 15:40:02 +03:00
Nikita Bobko
50d2b963cc Revert "202: Fix GradleFacetImportTest#testJDKImport test" for 193 bunch
This fixes test in 193 and 192 bunch
2020-07-07 12:29:19 +00:00
Nikita Bobko
496b8d5bd4 Create 193 bunch for GradleFacetImportTest.kt 2020-07-07 12:29:18 +00:00
Anton Bannykh
0885d608d8 JS IR: normalize the generate file path in the box tests 2020-07-07 13:00:42 +03:00
Ilya Goncharov
bb35509c38 [Gradle, JS] Warning on missed types and typings on genext npm dep
#KT-38331 fixed
2020-07-07 12:10:13 +03:00
Ilya Goncharov
1b3b2e539c [Gradle, JS] Not run separate dukat if there is no d ts files
^KT-38331 fixed
2020-07-07 12:09:58 +03:00
Jinseong Jeon
a18bd1bb75 FIR deserializer: use annotation info from enclosing class for companion object 2020-07-07 11:43:51 +03:00
Jinseong Jeon
81345bcc26 FIR deserializer: load annotations on inner classes 2020-07-07 11:43:51 +03:00
Victor Petukhov
c588bc604d NI: do substitution stub types during updating trace for lambda (these stub types can appear from the builder inference as postponed variables)
^KT-40060 Fixed
2020-07-07 11:17:06 +03:00
Victor Petukhov
eec3a4720c NI: don't collect members if a receiver type is StubType to avoid creating error candidates instead of not crating them at all
^KT-37717 Fixed
2020-07-07 11:17:06 +03:00
Ivan Kylchik
989e4293a3 [FIR] Fix exhaustiveness check in case of sealed subclass
The problem appear because check was performed only on direct children
of sealed class. To fix this, heritage tree is built and used in check

#KT-38989 Fixed
2020-07-07 10:58:06 +03:00
Nick
40cd30f7f6 [FIR] Partial performance fix for the effective visibility checker 2020-07-07 10:24:04 +03:00
Leonid Startsev
80561ec125 Update kx.serialization dependency
so tests won't fail due to
'library was compiled with pre-release flag' error.

Update test data
2020-07-07 01:14:32 +03:00
Natalia Selezneva
74aa3ac79a Minor: replace deprecated method usage 2020-07-06 23:23:46 +03:00
Natalia Selezneva
b3a84ba081 Fix warning in ScriptConfigurationHighlightingTest
In case of exception from dependencies resolver
we do not threat the configurations as up-to-date,
so the reloading process will be started during test
despite updateScriptDependenciesSynchronously called at startup.
This will lead to the warning from checkHighlighting
because if script reports are different we rehighlight the script.
Note that test won't fail.
2020-07-06 23:23:46 +03:00
Natalia Selezneva
6ec13ab38a Scripts: do not throw roots change event in case when roots are empty 2020-07-06 23:23:46 +03:00
Natalia Selezneva
16c5ba0988 Tests: do not throw roots change event in the current thread
This may cause exception during resolve,
because all caches are invalidated after this
and resolve should be restarted
Exception: module descriptor isn't find in its own dependencies
Unmute IdeReplCompletionTestGenerated.testDefinedExtension

^KT-34825 Fixed
2020-07-06 23:23:46 +03:00
Igor Yakovlev
5871628f2b Possibly fix flacky test of light classes for decompiled declarations
Tests:
JavaAgainstKotlinBinariesCheckerTestGenerated.testInferenceReturnType_1_8JavaAgainstKotlinBinariesCheckerTestGenerated.testReturnInnerClasses
2020-07-06 22:28:45 +03:00
Roman Golyshev
637d3430ff KT-39869 Remove redundant performDelayedRefactoringRequests call
- In `ObsoleteExperimentalCoroutinesInspection` it is redundant because
it is performed immediately after the single `bindToFqName` call,
so there is no reason to postpone the refactoring and then immediately
invoke it
- In `ObsoleteKotlinJsPackagesInspection` there are no reason to call
it at all (no refactorings are postponed)
2020-07-06 18:04:02 +00:00
Roman Golyshev
5cf6b860a6 KT-39869 Add inspection for FQN usages of kotlin.browser package
- `kotlin.dom` does not need this because it contains only extensions
- Add test for launching whole project fix; mute it because currently it
does not pass
  - The test fails because in tests `RefJavaManager` tries to create
  `RefJavaFileImpl` for .kt files. It will try to use UAST, but it
  does not work for JS files. In production this is disabled, so no
  problems occur
2020-07-06 18:04:01 +00:00
Roman Golyshev
91fa5d38b3 KT-39869 Fix review suggestions
- Review: https://jetbrains.team/p/kt/review/1349
2020-07-06 18:04:00 +00:00
Roman Golyshev
75de352ce2 KT-39869 Add ObsoleteKotlinJsPackagesInspection inspection
- This inspection allows to migrate from `kotlin.dom|kotlin.browser`
to `kotlinx.dom|kotlinx.browser` packages respectively
- This inspection is available from the import statements, and also
from the `Run migrations` action
- ^KT-39869 Fixed
2020-07-06 18:04:00 +00:00
Roman Golyshev
ec087e8f3d KT-39869 Move base classes to separate file 2020-07-06 18:03:59 +00:00
Roman Golyshev
871bb30dbe KT-39869 Refactor ObsoleteExperimentalCoroutinesInspection.kt
- We need this to reuse the logic for migration inspections
2020-07-06 18:03:58 +00:00
Toshiaki Kameyama
6b5c31e2fc Move statement up: do not apply to @file annotation
#KT-10790 Fixed
2020-07-06 17:50:39 +02:00
Yaroslav Chernyshev
aeed7fe52d KT-36801 Added forgotten changes for 192 platform
#KT-39989 Fixed
2020-07-06 18:07:11 +03:00
Ivan Kylchik
574aa0affe [FIR] Fix synthetic property is not var due to Nullable on parameter
Synthetic property is var when it have setter. The latter is set up
in property when its parameter type is equal to getter return type. In
case of using @Nullable, parameter type of setter is not equal to
return type of getter, because the latter is flexible type. So to fix
this verification should occur using not null types

#KT-39076 Fixed
2020-07-06 17:52:37 +03:00
Pavel Punegov
48c5f48af0 Ignore test in Native, see #KT-38859 2020-07-06 17:33:12 +03:00
Ilya Goncharov
cb3d7349a3 [Gradle, JS] Deprecation of frontend plugin
^KT-40048 fixed
2020-07-06 17:30:31 +03:00
Natalia Selezneva
56afd763dc Minor: add debug log messages 2020-07-06 15:53:28 +03:00
Natalia Selezneva
6c0d91837c Load file attributes for last modified files under try-catch
This should avoid exceptions from initialization of GradleBuildRootsManager.EP

EA-232521 Fixed
2020-07-06 15:52:43 +03:00
Ilya Goncharov
03bc61c80a [Gradle, JS] Add test on public package json inside archives (jar and klib) 2020-07-06 15:23:33 +03:00
Ilya Goncharov
f76a1f0e86 [Gradle, JS] jsJar dependsOn PublicPackageJsonTask
But package.json included into jar only if public npm dependencies exists
2020-07-06 15:23:33 +03:00
Ilya Goncharov
5c968acb13 [Gradle, JS] Simplify creation of public package json task 2020-07-06 15:23:33 +03:00
Ilya Goncharov
a2d5cda716 [Gradle, JS] Output file of public package json as var for changing it 2020-07-06 15:23:33 +03:00
Ilya Goncharov
a4ad3d88c6 [Gradle, JS] Remove duplicate of reporting js compiler statistic 2020-07-06 15:10:16 +03:00
Vladimir Dolzhenko
974dfbc9ab Advance bootstrap to 1.4.20-dev-1680 2020-07-06 12:04:11 +02:00
Vladimir Ilmov
a2040f01bf Body elements resolution in KotlinDebuggerCache added / analyzeWithContentAndGetResult
While we trying to find an inlined SourcePosition, the body should be
resolved KotlinPositionManager.getLambdaOrFunIfInside / InlineUtil.isInlinedArgument
to make shure the lambda is an argument for a call.

 #KT-39309 fixed
 #KT-39435 fixed
2020-07-06 11:33:50 +02:00
Dmitriy Novozhilov
a0f8ada285 [FIR-TEST] Unmute failing diagnostic tests 2020-07-06 12:11:57 +03:00
Igor Yakovlev
4707f4fc3f Change signature does not make doubled refactoring for java usages
Fixed #KT-22170
2020-07-06 11:54:36 +03:00
Dmitry Gridin
7b9fad00a1 Rename KotlinLikeLangLineIndentProvider to KotlinLangLineIndentProvider
Relates to #KT-22211
2020-07-06 14:51:29 +07:00
Dmitry Petrov
b75de60afb Minor: mute failing test 2020-07-06 10:47:10 +03:00
Mikhail Zarechenskiy
d8f701ee61 Add test for obsolete issue
#KT-39588 Obsolete
2020-07-05 18:17:44 +03:00
Vladimir Dolzhenko
03d5fe8d6c Add dispatchAllInvocationEvents to editor actions in perf tests 2020-07-04 23:33:02 +02:00
Vladimir Dolzhenko
a830c69a30 Regenerate TypingIndentationTestBaseGenerated 2020-07-04 22:25:09 +02:00
Vladimir Krivosheev
75b1cf8a23 Explicitly specify id of KotlinNonJvmSourceRootConverterProvider
IDEA 2020.3 uses `id` from extension definition to avoid creating instance of converter without need.
2020-07-04 15:38:15 +02:00
Vyacheslav Karpukhin
6ecd2e57fb Created bunch 203 2020-07-04 02:11:18 +02:00
Vladimir Dolzhenko
357746e344 Do not force FULL analysis for PARTIAL_FOR_COMPLETION for the current open file
Relates to #KT-38687
2020-07-03 22:57:22 +02:00
Vladimir Dolzhenko
51375ed278 PluginStartupListener clean up
Relates to #KT-39968
2020-07-03 22:30:15 +02:00
Vladimir Dolzhenko
0b2e15d20c PluginStartupListener clean up
Relates to #KT-39968
2020-07-03 22:05:43 +02:00
Mikhail Zarechenskiy
01f2b0e26b Fix test data about JsExport
It allows only for top-level declarations, plus JsName is needed to
 avoid error about method redeclaration
2020-07-03 21:23:29 +03:00
Mikhail Zarechenskiy
9a08085146 Fix redundant semicolon inspection before soft keywords
Fixes few tests:
 - RedundantSemicolon.testBetweenSoftModifierKeywordAndDeclaration
 - RedundantSemicolon.testBetweenSoftModifierKeywordAndDeclaration2
 - RedundantSemicolon.testBetweenSoftModifierKeywordAndDeclaration3

 This bug was introduced in 741ebeb7b8
2020-07-03 21:23:29 +03:00
Mikhail Zarechenskiy
a0ecfce7b7 Update test data: add correct error 2020-07-03 21:23:29 +03:00
Nikolay Krasko
87a520fc30 202: Overcome failure in PathManager.getHomePath() because of the wrong dir
Stacktrace:

java.lang.RuntimeException: Could not find installation home path. Please reinstall the software.
  at com.intellij.openapi.application.PathManager.getHomePath(PathManager.java:106)
  at com.intellij.openapi.application.PathManager.getHomePath(PathManager.java:76)
  at com.intellij.openapi.application.PathManager.getPreInstalledPluginsPath(PathManager.java:248)
  at com.intellij.ide.plugins.DescriptorListLoadingContext.<init>(DescriptorListLoadingContext.java:57)
  at com.intellij.ide.plugins.DescriptorListLoadingContext.createSingleDescriptorContext(DescriptorListLoadingContext.java:61)
  at com.intellij.ide.plugins.PluginManagerCore.registerExtensionPointAndExtensions(PluginManagerCore.java:1397)
  at com.intellij.core.CoreApplicationEnvironment.registerExtensionPointAndExtensions(CoreApplicationEnvironment.java:266)
  at org.jetbrains.kotlin.cli.jvm.compiler.CoreApplicationEnvironmentCompatKt.registerExtensionPointAndExtensionsEx(coreApplicationEnvironmentCompat.kt:17)
  at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.registerApplicationExtensionPointsAndExtensionsFrom(KotlinCoreEnvironment.kt:534)
  at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.createApplicationEnvironment(KotlinCoreEnvironment.kt:505)
  at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.getOrCreateApplicationEnvironmentForProduction(KotlinCoreEnvironment.kt:465)
  at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:92)
  at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:52)
  at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:88)
  at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:44)
  at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:98)
  at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:76)
  at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:45)
  at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMainNoExit(CLITool.kt:227)
  at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMainNoExit$default(CLITool.kt:225)
  at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMain(CLITool.kt:214)
  at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler$Companion.main(K2JVMCompiler.kt:262)
  at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.main(K2JVMCompiler.kt)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:498)
  at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:63)
2020-07-03 21:21:23 +03:00
Dmitriy Dolovov
d63728afe5 [Commonizer] Use 'index:Int' instead of Name for addressing type parameters 2020-07-03 22:27:58 +07:00
Mikhail Zarechenskiy
0ee7306d9c Fix coercion to Unit when variable already have other constraints
Don't add `Unit` if variable has an upper constraint T <: A.

 It's impossible to coerce variable T to Unit as constraint system will
 be always contradictory: T := Unit => Unit should be subtype of A

 #KT-39900 Fixed
2020-07-03 17:54:14 +03:00
Dmitry Petrov
026f54f3d8 Fix Kapt3 tests
Nullability annotations are no longer generated on private fields,
so line numbers in generated java sources changed.
2020-07-03 17:51:30 +03:00
Dmitry Petrov
761e47264a JVM_IR: fix property reference generation for inline class primary val 2020-07-03 17:51:30 +03:00
Vladimir Dolzhenko
1450cf5f63 Fix KOTLIN_BUNDLED registration
#KT-39968 Fixed
2020-07-03 14:46:40 +00:00
Dmitry Gridin
d1455d0d22 KotlinOptimizeImportsRefactoringHelper: should remove unused directives by pointer
#KT-39899 Fixed
#EA-209827 Fixed
2020-07-03 14:29:46 +00:00
Dmitry Gridin
62e252ec26 Inline refactoring: should support set/get operator
#KT-17378 Fixed
2020-07-03 21:11:58 +07:00
Toshiaki Kameyama
e31ea0c243 ReplaceWith: suggest to replace for 'get/set' operator functions
#KT-15944 Fixed
2020-07-03 21:10:24 +07:00
Dmitriy Novozhilov
82b6ecfa64 [FIR-TEST] Add test for KT-39075 2020-07-03 17:09:29 +03:00
Dmitriy Novozhilov
59bedaaa55 [FIR] Rename FirElvisCall to FirElvisExpression
FirElvisCall is not a FirCall, so FirElvisExpression is more
  convenient name
2020-07-03 17:09:29 +03:00
Dmitriy Novozhilov
1db2ba51d2 [FIR] Don't pass flow from inplace lambdas throw when and elvis expressions
#KT-39080 Fixed
2020-07-03 17:09:29 +03:00
Dmitriy Novozhilov
1429cba2d4 [FIR] Fix CCE in postponed lambda resolution 2020-07-03 17:09:28 +03:00
Dmitriy Novozhilov
8311c1f0e2 [FIR] Fix projection of Comparable supertype for ILT
#KT-39048 Fixed
2020-07-03 17:09:28 +03:00
Dmitriy Novozhilov
a882a9dff5 [FIR] Create scope for type parameter as scope for intersection of bounds
Before change we've created composite scope for all bounds, which
  is incorrect, because intersection of all bounds may be less than
  all bounds (see test in commit)

#KT-39032 Fixed
2020-07-03 17:09:28 +03:00
Jinseong Jeon
44d0af8597 FIR2IR: handle 'this' as reference to outer object 2020-07-03 12:53:57 +03:00
Ilya Muradyan
1798542db7 Fix and enable embedded tests in scripting-ide-services 2020-07-03 12:21:45 +03:00
Ilya Muradyan
e88bef4275 Fix jar-dependent test in scripting-ide-services 2020-07-03 12:21:45 +03:00
Mikhail Zarechenskiy
d51bb2c053 Add compatibility resolve when variable has "bad" intersection type
#KT-39468 Fixed
2020-07-03 12:18:28 +03:00
Ivan Kylchik
92a51b9794 [FIR] Add illegal underscore check in BaseFirBuilder 2020-07-03 12:06:49 +03:00
Ivan Kylchik
cc4b50fdc1 [FIR] Add illegal underscore diagnostic 2020-07-03 12:06:47 +03:00
Ivan Kylchik
54945b7fbc Extract illegal underscore check function to ParseUtils 2020-07-03 12:06:45 +03:00
Ivan Kylchik
d0f6997e6d [FIR] Fix some of fir spec tests for real-literals
#KT-38336 Fixed
2020-07-03 12:06:44 +03:00
Dmitry Petrov
17c15cfe0a JVM, JVM_IR: update bytecode listing testData for inline classes 2020-07-02 22:39:06 +03:00
Dmitry Petrov
6e0bb0b468 JVM: no nullability annotations for inline class '-impl' methods
Specialized generated methods for inline classes (toString-impl,
hashCode-impl, equals-impl, etc) are inaccessible from Java, and thus
don't require nullability annotations.
2020-07-02 22:39:06 +03:00
Dmitry Petrov
ea042eb6c4 JVM_IR: no nullability annotations for inline class '-impl' methods
Specialized generated methods for inline classes (toString-impl,
hashCode-impl, equals-impl, etc) are inaccessible from Java, and thus
don't require nullability annotations.
2020-07-02 22:39:06 +03:00
Dmitry Petrov
a238d6a890 JVM_IR: no annotations on parameters of 'property$annotations' methods 2020-07-02 22:39:06 +03:00
Dmitry Petrov
8da988b18e JVM_IR: Mangle primary val getter of inline class if required
TODO fix reflection
2020-07-02 22:39:06 +03:00
Dmitry Petrov
62d2581faf JVM_IR: Don't generate annotations on generated inline class members 2020-07-02 22:39:05 +03:00
Dmitry Petrov
dc4b9d3887 JVM_IR: Don't mangle internal constructor-impl for inline classes 2020-07-02 22:39:05 +03:00
Ilya Kirillov
5cfac8fa3f FIR IDE: introduce symbol pointers for restoring symbols in another read action
fix pointer
2020-07-02 22:25:06 +03:00
Ilya Kirillov
f88ebed1a3 FIR IDE: move types to its own package 2020-07-02 22:25:06 +03:00
Ilya Kirillov
5f548fc459 FIR IDE: add creating stdlib symbols by fqName tests 2020-07-02 22:25:06 +03:00
Ilya Kirillov
799a49649c FIR IDE: introduce symbol modality 2020-07-02 22:25:06 +03:00
Ilya Kirillov
75a96f0153 FIR IDE: add info about varargs to parmater symbol 2020-07-02 22:25:05 +03:00
Ilya Kirillov
f10f6c6360 FIR IDE: introduce package symbol 2020-07-02 22:25:05 +03:00
Ilya Kirillov
18d46a86ae FIR IDE: add identity weak map based cache for KtSymbolByFirBuilder 2020-07-02 22:25:05 +03:00
Ilya Kirillov
a26063b3f8 FIR IDE: rename Invalidatable -> ValidityOwner 2020-07-02 22:25:05 +03:00
Ilya Kirillov
226d514788 FIR IDE: rename reference classes to KtFir*Reference for consistency 2020-07-02 22:25:05 +03:00
Ilya Kirillov
66933ea2fe FIR IDE: use withValidityAssertion instead of explicit check in FirAnalysisSession 2020-07-02 22:25:04 +03:00
Ilya Kirillov
8368284817 FIR IDE: introduce KtType 2020-07-02 22:25:04 +03:00
Ilya Kirillov
c44756bbfd FIR IDE: add tests for building kt symbols by PSI 2020-07-02 22:25:04 +03:00
Ilya Kirillov
8a52954bf8 FIR IDE: introduce symbol provider 2020-07-02 22:25:03 +03:00
Ilya Kirillov
20b93507ab FIR IDE: use symbols for reference resolve 2020-07-02 22:25:03 +03:00
Ilya Kirillov
749afbd141 FIR IDE: use symbols for call resolve 2020-07-02 22:25:03 +03:00
Ilya Kirillov
82866176fb FIR IDE: introduce symbol API 2020-07-02 22:25:03 +03:00
Alexander Udalov
ba948cda38 Report warning on characters which can cause problems on Windows
As soon as we fix KT-17438, this warning will be turned into an error.
2020-07-02 21:19:28 +02:00
Alexander Udalov
181965f6e8 IR: inline namedIrModulePhase and namedIrFilePhase phase builders
Construct NamedCompilerPhase directly instead. Only use phase builders
where the code becomes easier to read.
2020-07-02 21:19:28 +02:00
Alexander Udalov
15a969b3ba IR: refactor performByIrFile a little
Take a list of phases instead of the CompositePhase, to make stacktraces
nicer and avoid quadratic time of phase construction.
2020-07-02 21:19:28 +02:00
Alexander Udalov
4475325ffa IR: refactor PhaseBuilders a little
- use named classes to improve stacktraces
- reorder parameters to make the code shorter
- use explicit types to improve IDE resolve in usages
2020-07-02 21:19:27 +02:00
Alexander Udalov
7997d4afd3 IR: do not use AnyNamedPhase where there is Context parameter 2020-07-02 21:19:27 +02:00
Alexander Udalov
ef58f1e72e IR: simplify phaser code a little
- merge NamedCompilerPhase, SameTypeNamedPhaseWrapper,
  AbstractNamedPhaseWrapper and inherit it from SameTypeCompilerPhase
- inline some functions to simplify stacktraces
- reformat and fix inspections
2020-07-02 21:19:27 +02:00
Stanislav Erokhin
74ce26cdc2 Fix 1.4-M2 ChangeLog.md 2020-07-02 22:16:59 +03:00
Vyacheslav Gerasimov
18d71c7907 Build: Encode build number in teamcity build url 2020-07-02 22:05:35 +03:00
Vyacheslav Gerasimov
8e1269cc32 Build: Add hacky workaround for retrying PublishToMavenRepository tasks
It's supposed to help with `Caused by: org.apache.http.NoHttpResponseException: api.bintray.com:443 failed to respond`
2020-07-02 22:05:35 +03:00
Dmitriy Dolovov
3bb234b17c [Commonizer] Clean-up CirTypeSignature usages 2020-07-03 00:22:44 +07:00
Dmitriy Dolovov
ffd0c69698 [Commonizer] Use ClassId instead of FqName for addressing classes and TAs 2020-07-03 00:22:38 +07:00
Ilya Kirillov
57aefbcd57 FIR IDE: migrate to 201 2020-07-02 19:34:37 +03:00
Mads Ager
1124887aa0 [JVM_IR] Fix stepping behavior for assignments to local variables. 2020-07-02 17:29:07 +02:00
Vladimir Dolzhenko
543efffa5c Turn off stability check for PerformanceTypingIndentationTest 2020-07-02 17:13:10 +02:00
Igor Yakovlev
89d5c030dc Improve incremental analisys for nested blocks 2020-07-02 17:52:40 +03:00
Toshiaki Kameyama
efdeb7b449 Introduce "Add '== true'" quick fix for TYPE_MISMATCH
#KT-39930 Fixed
2020-07-02 19:31:43 +07:00
Dmitriy Novozhilov
5bf18c09bb Advance bootstrap to 1.4.20-dev-1530 2020-07-02 15:19:24 +03:00
Natalia Selezneva
a73dac75d4 Optimize KotlinScriptDependenciesClassFinder
Do not call processDirectories for all package prefixes checking inner classes

^KT-39796 Fixed
2020-07-02 15:14:02 +03:00
Mikhail Glukhikh
f46970219f [FIR2IR] Simplify elvis conversion 2020-07-02 15:10:52 +03:00
Mikhail Glukhikh
68b84722c4 [FIR2IR] Simplify generateWhen 2020-07-02 15:10:52 +03:00
Mikhail Glukhikh
24c8eb43a2 [FIR2IR] Don't build stub FirWhen for converting elvis expression 2020-07-02 15:10:52 +03:00
Mikhail Glukhikh
6229d2e215 [FIR2IR] Extract generateWhen & toIrWhenBranch 2020-07-02 15:10:52 +03:00
Mikhail Glukhikh
31765a4abc [FIR2IR] Move visitElvis & visitWhen close to one another 2020-07-02 15:10:52 +03:00
Dmitriy Novozhilov
f4d5070a7b [FIR-TEST] Mute BB test due to KT-39659 2020-07-02 15:10:52 +03:00
Dmitriy Novozhilov
a7ed9c7dc5 [FIR] Add conversion of FirElvisCall to backend IR 2020-07-02 15:10:52 +03:00
Dmitriy Novozhilov
102c9c08d0 [FIR] Resolve elvis call as special synthetic call
Before that commit we desugared `a ?: b` as

when (val elvis = a) {
    null -> b
    else -> elvis
}

It was incorrect, because `a` should be resolved in dependent mode,
  but when it was `elvis` initializer it was resolved in independent
  mode, so we can't infer type for `a` in some complex cases
2020-07-02 15:10:51 +03:00
Dmitriy Novozhilov
b49b3245af [FIR] Add special node for elvis call
#KT-39074
2020-07-02 15:10:51 +03:00
Dmitriy Novozhilov
648953085f [FIR] Replace kotlin/Throwable with java/lang/Throwable in JvmMappedScope
#KT-39044 Fixed
2020-07-02 15:10:51 +03:00
Dmitriy Novozhilov
624b9306f0 [FIR] Resolve LHS of type operator call in independent context
#KT-39046 Fixed
2020-07-02 15:10:51 +03:00
Jinseong Jeon
c9e423bf64 FIR deserializer: fix parameter shift for constructor of inner classes and enums
#KT-39837 Fixed
2020-07-02 13:34:39 +03:00
Georgy Bronnikov
8e24256f95 JVM_IR: avoid descriptors when tracking inline properties
Preparing to use wrapped properties in InlineCodegen.
2020-07-02 12:46:58 +03:00
Georgy Bronnikov
385d522d27 JVM_IR: do not use descriptor in isCompiledToJvmDefault 2020-07-02 12:45:26 +03:00
Vsevolod Tolstopyatov
3270c7e016 Introduce CancellationException
#KT-39126 Fixed
2020-07-02 11:01:28 +03:00
Natalia Selezneva
5ec110c33f *.gradle.kts: catch exceptions during GradleBuildRootManager initialization
^KT-39317 Fixed
2020-07-02 08:48:05 +03:00
Natalia Selezneva
c7c7ffb0e0 *.gradle.kts: get java home from build environment instead of execution settings
Note that getting GradleExecutionSettings may lead to write action
because it link javaHome with existing sdks

^KT-39317
2020-07-02 08:48:05 +03:00
Steven Schäfer
5cdf053c8e Coroutines: Fix RedundantLocalsEliminationMethodTransformer
- Take control flow into account when collecting usage information
- Don't remove stores to local variables
2020-07-02 00:49:28 +02:00
Alexander Gorshenev
3113281e2d Adapted fake override checker to inheritance from friend module internal interfaces 2020-07-01 20:29:48 +03:00
Mikhail Glukhikh
07feb2185b Fix exception in FirExposedVisibilityChecker 2020-07-01 19:30:50 +03:00
Ilmir Usmanov
697c8637ee For all int-like typed variables, use int as field type and coerce
it during spill-unspill.
Coerce int to boolean, otherwise, VerifyError is thrown on android
Completely rewrite SpilledVariableFieldTypesAnalysis... again,
but this time use BasicInterpreter
This way, the analysis both does not use SourceInterpreter and
is in line with the rest on analyses.
2020-07-01 17:26:47 +02:00
Alexander Udalov
e7f33ac051 IR: do not inherit IrFunctionReference from IrFunctionAccessExpression
To avoid the diamond hierarchy and to allow refactoring the IR element
hierarchy from interfaces to classes, improving performance of visitors
and transformers.
2020-07-01 13:03:56 +02:00
Alexander Udalov
d4605f5816 IR: add type parameter to IrMemberAccessExpression and some subclasses
This is needed to get rid of the diamond hierarchy:

                 IrMemberAccessExpression
                 /                       \
                /                         \
IrFunctionAccessExpression     IrCallableReference
                \                      /
                 \                    /
                   IrFunctionReference

In the subsequent commit, IrFunctionReference no longer inherits from
IrFunctionAccessExpression; the more precise type of `val symbol:
IrFunctionSymbol` is now carried via the generic type argument.

This will help to refactor IR element hierarchy from interfaces to
classes, improving performance of visitors and transformers.
2020-07-01 13:03:56 +02:00
Alexander Udalov
d794c9dc4d IR: remove non-supertype usages of abstract impl classes
Work with the corresponding base interfaces instead. This change will
help in moving the IR element hierarchy from interfaces to classes,
should the need arise.

There's a possible change in behavior in
`CallAndReferenceGenerator.applyCallArguments`, which however doesn't
seem to break anything: IrPropertyReferenceImpl can now also be handled
by this method.
2020-07-01 13:03:56 +02:00
Alexander Udalov
ccac23f5b2 IR: make mapOptimized non-inline, rename to transformIfNeeded
This seems to have no effect on performance, however it clearly shows
that this method is a hotspot now with regard to own CPU samples.
Furthermore, it somewhat decreases the bytecode size at call sites and
might actually allow the HotSpot to inline those methods earlier and
hopefully deoptimize less frequently.
2020-07-01 13:03:56 +02:00
Alexander Udalov
6a699c9384 IR: minor, remove accept from some interfaces 2020-07-01 13:03:56 +02:00
Jinseong Jeon
1e3019798a FIR2IR: discard fake overrides for property accessors according to base visibility 2020-07-01 13:59:42 +03:00
Nikita Bobko
6985c5fd2a 202: Fix KotlinJpsBuildTest tests
Test failure was caused by "replace custom source root types to a special
'unknown' type and back on plugin unload/load (IDEA-235292)" in intellij.

We override `getModuleSourceRootPropertiesSerializers` in `KotlinModelSerializerService`
by inheriting from `KotlinCommonJpsModelSerializerExtension`
2020-07-01 11:31:23 +03:00
Nikita Bobko
4e65b2fb9e Refactoring: mark const strings with const keyword 2020-07-01 11:31:23 +03:00
Nikita Bobko
31e45d4f4c 202: Fix some ParameterInfoTestGenerated
Speaking strictly:
* `ParameterInfoTestGenerated$WithLib1.testUseJavaFromLib`
* `ParameterInfoTestGenerated$WithLib2.testUseJavaSAMFromLib`
* `ParameterInfoTestGenerated$WithLib3.testUseJavaSAMFromLib`
2020-07-01 11:31:23 +03:00
Nikita Bobko
cbc57351f5 202: Fix SlicerLeafGroupingTestGenerated tests 2020-07-01 11:31:22 +03:00
Nikolay Krasko
0d71b7ac2c 202: Add fastutil jar to tests dependencies 2020-07-01 11:31:22 +03:00
Nikolay Krasko
ca7169b84f 202: Disable ignored plugins check in compiler environment
Stacktrace:

java.lang.NullPointerException
  	at java.io.Reader.<init>(Reader.java:78)
  	at java.io.InputStreamReader.<init>(InputStreamReader.java:113)
  	at com.intellij.ide.plugins.PluginManagerCore.getBrokenPluginVersions(PluginManagerCore.java:207)
  	at com.intellij.ide.plugins.PluginManagerCore.createLoadingResult(PluginManagerCore.java:825)
  	at com.intellij.ide.plugins.DescriptorListLoadingContext.createSingleDescriptorContext(DescriptorListLoadingContext.java:61)
  	at com.intellij.ide.plugins.PluginManagerCore.registerExtensionPointAndExtensions(PluginManagerCore.java:1397)
  	at com.intellij.core.CoreApplicationEnvironment.registerExtensionPointAndExtensions(CoreApplicationEnvironment.java:266)
  	at org.jetbrains.kotlin.cli.jvm.compiler.CoreApplicationEnvironmentCompatKt.registerExtensionPointAndExtensionsEx(coreApplicationEnvironmentCompat.kt:17)
  	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.registerApplicationExtensionPointsAndExtensionsFrom(KotlinCoreEnvironment.kt:534)
  	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.createApplicationEnvironment(KotlinCoreEnvironment.kt:505)
  	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.getOrCreateApplicationEnvironmentForProduction(KotlinCoreEnvironment.kt:465)
  	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:92)
  	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:52)
  	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:88)
  	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:44)
  	at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:98)
  	at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:76)
  	at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:45)
  	at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMainNoExit(CLITool.kt:227)
  	at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMainNoExit$default(CLITool.kt:225)
  	at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMain(CLITool.kt:214)
  	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler$Companion.main(K2JVMCompiler.kt:262)
  	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.main(K2JVMCompiler.kt)
2020-07-01 11:31:22 +03:00
Nikita Bobko
ef562598ea 202: Fix MultiFileJvmBasicCompletionTestGenerated
It was broken by 4bef803e1b5994e9ea9731acfb5095a94b1b1383 in intellij
2020-07-01 11:31:21 +03:00
Nikita Bobko
3187bb2aa4 202: Fix KotlinMavenImporterTest#testJDKImport test
Test failure was caused by 8e1ab882641db695e3b70085d14a59e1e8e9f579 +
b79ca6e3a855b9d74dba129583d7ed25ecd2f552 in intellij
2020-07-01 11:31:21 +03:00
Nikita Bobko
5c95c48c90 202: Fix GradleFacetImportTest#testJDKImport test
Test failure was caused by 8e1ab882641db695e3b70085d14a59e1e8e9f579 +
b79ca6e3a855b9d74dba129583d7ed25ecd2f552 in intellij
2020-07-01 11:31:21 +03:00
Nikita Bobko
536c4bbab1 202: Fix KotlinEvaluateExpressionTestGenerated.SingleBreakpoint
Now `getTreeEvaluation` returns `CompletableFuture<PsiElement>` not `PsiElement` as it was in 201
2020-07-01 11:31:20 +03:00
Nikita Bobko
046030e301 202: Fix "Module 'foo': No SDK defined" in tests
Fixes several tests in 202:
* NewMultiplatformProjectImportingTest
* KaptImportingTest
* ...

This failure was caused by b79ca6e3a855b9d74dba129583d7ed25ecd2f552 in intellij
2020-07-01 11:31:20 +03:00
Nikita Bobko
8fb82c2cb7 202: Fix missing formatting in nJ2K tests
Formatting in nJ2K tests (actually it still works in IDE) was broken by
dee00ac38946b8a8a5165dffd083e67c85935723 in intellij
2020-07-01 11:31:20 +03:00
Nikita Bobko
264094861d 202: Fix null passed to @NotNull in PomModelImpl
Fixes `AdditionalResolveDescriptorRendererTestGenerated#testAnonymousObjectInClassParameterInitializer`
and others
2020-07-01 11:31:19 +03:00
Vladimir Dolzhenko
853503d75f Force perform FULL analysis to avoid redundant analysis for the current open file
#KT-38687 Fixed
2020-07-01 08:22:58 +00:00
Sergey Rostov
1a82c94979 revert accidentally committed project.xml 2020-07-01 10:36:40 +03:00
Mikhail Zarechenskiy
d9fc71b8c0 Advance bootstrap to 1.4.20-dev-1515 2020-07-01 10:11:13 +03:00
Denis Zharkov
3ce980fd88 Fix incremental compilation for calls to inner classes from supertypes
The problem became actual after 8c2baf0704
2020-07-01 06:55:52 +03:00
Mikhail Zarechenskiy
6b81cc8b77 Update test data as stdlib now isn't pre-release 2020-06-30 22:59:23 +03:00
Mikhail Zarechenskiy
94dcff5bab Advance bootstrap to 1.4.20-dev-1508 2020-06-30 21:48:30 +03:00
Mikhail Zarechenskiy
f37f89a151 Set KotlinCompilerVersion.IS_PRE_RELEASE = false
Since master is 1.4.20 now and branch 1.4.0 is 1.4-RC

 #KT-39860 Fixed
2020-06-30 21:01:45 +03:00
Mikhail Bogdanov
b5b5c8aebc Check target for -Xjvm-default modes
#KT-39925 Fixed
2020-06-30 19:47:06 +02:00
Dmitriy Dolovov
3e42b9d527 [Commonizer] Remove unused property from CirFunction 2020-07-01 00:12:03 +07:00
Nikolay Krasko
21fa2bf98c Switch to 201 platform 2020-06-30 19:53:18 +03:00
Nikolay Krasko
50863b6985 Fix using swing ComboBox and wrong bunching 2020-06-30 19:53:17 +03:00
Nikolay Krasko
2c1b01fcf6 Setup standalone environment in BuiltInsSerializer
Main change is in calling setupIdeaStandaloneExecution()
2020-06-30 19:53:17 +03:00
Nikolay Krasko
3b2e1cfa39 Show TeamCity user for agent builds 2020-06-30 19:53:17 +03:00
Dmitry Gridin
86fe10ba44 AddDefaultConstructorFix: fix testData
#KT-20718
2020-06-30 23:22:08 +07:00
Toshiaki Kameyama
7be5410877 Add a quick fix for NO_CONSTRUCTOR error on 'expect' annotation entry
#KT-20718 Fixed
2020-06-30 23:22:08 +07:00
Mikhail Glukhikh
d846a22e33 [FIR] Introduce & use FirTypeRef.coneType 2020-06-30 18:49:06 +03:00
Toshiaki Kameyama
0392fe75fc Convert to block body: specify non-nullable type when body expression is platform type and overriden method is non-nullable type
#KT-12222 Fixed
2020-06-30 22:47:13 +07:00
Dmitry Petrov
d37b616e1f JVM_IR: Fix enum classes ABI
1. Enum entry fields don't have nullability annotations.

2. Enum class special methods (values, valueOf) are not 'final'
(although they probably should be, javac generates corresponding
methods without ACC_FINAL flag).

3. Enum class special methods don't have nullability annotations.

4. Don't generate synthetic accessor for enum entry class constructor.

KT-37019 KT-37020 KT-37021
2020-06-30 18:24:25 +03:00
Stanislav Erokhin
f753824429 Advance bootstrap version to 1.4.20-dev-1401 2020-06-30 17:56:11 +03:00
Ilmir Usmanov
7536da788c Minor. Update test 2020-06-30 16:54:36 +02:00
Jinseong Jeon
34174d6e7d FIR deserializer: load annotations for property and fields, along with use-site targets 2020-06-30 17:28:22 +03:00
Mikhail Bogdanov
3580c7c28c Write proto flag about compatibility mode
There is no any special aim for this flag now.
  But it could be useful in future in case of compatibility mode deprecation
2020-06-30 14:59:01 +02:00
Vladimir Dolzhenko
f372a0fe6c Force full analysis even if incremental analysis is available but existed is erroneous 2020-06-30 12:53:34 +00:00
Konstantin Tskhovrebov
343e645282 Rename and refactor kmm plugin packages, task names, ids and etc. 2020-06-30 15:28:39 +03:00
Vladimir Dolzhenko
48a9226e1c Fix copy-paste from KTS files
#KT-37517 Fixed
2020-06-30 12:24:31 +00:00
Toshiaki Kameyama
0a230905ae Remove redundant spread operator: don't report if overloaded functions cannot be resolved
#KT-38282 Fixed
2020-06-30 19:16:22 +07:00
Ilya Kirillov
f179b39c70 Wizard: fix project template list size 2020-06-30 15:10:55 +03:00
Aleksei Cherepanov
b9b068ff63 Fix FirMultiModuleResolveTestGenerated tests 2020-06-30 14:16:52 +03:00
Sergey Igushkin
8ba131290a Fixup for 1f5fa5eb7 – adjust error message 2020-06-30 13:14:03 +03:00
Sergey Igushkin
1f5fa5eb7c Add back empty stub implementations of KotlinGradleSubplugin (KT-39809)
* If a KotlinGradleSubplugin implements
 KotlinCompilerPluginSupportPlugin, don't apply it as a legacy plugin

* Add the legacy KotlinGradleSubplugin implementations back so that
 when there's JAR hell with META-INF/services in the old artifacts
 pointing to the classes, loading the plugins with ServiceLoader (legacy
 implementation) from the new artifacts would not fail.

* There's a corner case for plugins not in kotlin-gradle-plugin
 If a newer and older version of such a subplugin is used with an older
 version of the Kotlin Gradle plugin, the latter will find the META-INF
 entries and will try to load the subplugins from the new version. With
 the original fix for KT-39809, this would result in silently ignored
 empty stub implementations.

 Given that the Kotlin Gradle plugin can now check if a subplugin
 supports the new API, it's OK to keep the old entries and make the
 stub implementations throw a build error when called, so that improper
 plugin versions are not ignored and are clearly reported.

 Note that this is only necessary for the subplugins not bundled in the
 kotlin-gradle-plugin module, as those will always be in sync with the
 Kotlin version.

Issue #KT-39809 Fixed
2020-06-30 12:51:51 +03:00
Sergey Igushkin
cb936dd82e Fix internals with symlinked friend paths (KT-35341)
The friend paths converted to canonical paths didn't match absolute
paths in the compiler code in case of symlinked directories.

This fixes a regression.

Issue #KT-35341 Fixed
2020-06-30 12:51:50 +03:00
kvirolainen
5b1d019bb0 Added Incomplete destructuring inspection
#KT-21223 Fixed
2020-06-30 11:47:27 +02:00
Sergey Igushkin
e6bca819d4 Remove kotlin.native.linkFromSources, expose tasks' sources
* Drop the deprecated mode in the Kotlin/Native link
tasks using sources rather than the intermediate
compiled klib.

* Remove the `allSources` and `commonSources`
properties from the KotlinNativeCompilation, use the
tasks' properties instead.
2020-06-30 12:27:14 +03:00
Mads Ager
c3b5b21845 [JVM] Extend stepping tests with <clinit> stepping.
In addition, made the stepping information for constructor calls
consistent across JVM_IR and JVM. For JVM_IR that stepping behavior
is consistent for enum constructor calls in <clinit> for JVM it
is not.
2020-06-30 11:18:29 +02:00
Ilya Kirillov
2693664aa7 FIR IDE: unmute tests after introducing fake element kinds 2020-06-30 11:55:59 +03:00
Ilya Kirillov
9baced20c4 FIR IDE: find FIR element by PSI one only if FIR have a real source
Also, add a check that there is only one element with the same real source
2020-06-30 11:55:58 +03:00
Ilya Kirillov
5acdad29ec FIR: change source of existing type refs in DataClassMembersGenerator to avoid sources clash 2020-06-30 11:55:57 +03:00
Ilya Kirillov
650f2dd713 FIR: consider source of FirSingleExpressionBlock as a fake one 2020-06-30 11:55:56 +03:00
Ilya Kirillov
1c564e1bd6 FIR: add ImplicitTypeRef to the control flow fir element sources 2020-06-30 11:55:56 +03:00
Ilya Kirillov
94967bcd00 FIR: introduce element kind for source elements
It is needed for FIR IDE to determine if FIR element was built by PSI
or it is generated one
2020-06-30 11:55:53 +03:00
Dmitriy Novozhilov
f6e653b242 [FIR] Fix compilation broken in 309050d9 2020-06-30 11:43:46 +03:00
Dmitriy Novozhilov
309050d956 [FIR] Add ExtensionFunctionType attribute
#KT-39034 Fixed
2020-06-30 11:30:19 +03:00
Dmitriy Novozhilov
1d3c0f56a9 [FIR] Save type attributes in substitution 2020-06-30 11:30:19 +03:00
Dmitriy Novozhilov
25fd5cd4ac [FIR] Save type attributes in ConeKotlinType.withNullability 2020-06-30 11:30:19 +03:00
Dmitriy Novozhilov
840d3975cc [FIR] Add computing type attributes for deserialized types 2020-06-30 11:30:19 +03:00
Dmitriy Novozhilov
cfa250957a [FIR] Fix creating type attributes for intersection types 2020-06-30 11:30:18 +03:00
Jinseong Jeon
fab9ee47f9 FIR deserializer: proper annotation loading for value parameter of property setter 2020-06-30 11:01:03 +03:00
Toshiaki Kameyama
9308525d93 Add receiver of kotlin.text.toPattern to standard Kotlin injections
#KT-39231 Fixed
2020-06-30 14:26:37 +07:00
Vyacheslav Karpukhin
787d22c93e Created bunch 203 2020-06-30 03:41:51 +02:00
Egor Zhdan
09a111239e Stabilize ProjectTaskRunner registration order 2020-06-29 23:11:54 +02:00
Vyacheslav Karpukhin
866e5397d9 New ultimate modules 2020-06-29 23:11:54 +02:00
Ilmir Usmanov
ed80b431f0 Restore refined int-type analysis 2020-06-29 21:42:30 +02:00
Alexander Gorshenev
8920e68584 Muted .IncrementalJsKlibCompilerRunnerTestGenerated.ClassHierarchyAffected.testMethodRemoved
until we have full fledged fake override support in klib
2020-06-29 21:58:32 +03:00
Alexander Gorshenev
41a472693a Updated extraHelp test data for the new flags 2020-06-29 21:58:32 +03:00
Alexander Gorshenev
bf419bc243 Compute correct signature for fake override properties with type parameters 2020-06-29 21:58:32 +03:00
Alexander Gorshenev
d90c383287 Fine tuned fake override validator for internals 2020-06-29 21:58:32 +03:00
Alexander Gorshenev
e08b800eb9 Treat internals as publics for fake override construction 2020-06-29 21:58:31 +03:00
Alexander Gorshenev
e61960f333 Fake override construction fallback mode 2020-06-29 21:58:31 +03:00
Alexander Gorshenev
de79e3bec3 Added -Xdisable-fake-override-validator 2020-06-29 21:58:31 +03:00
Ilmir Usmanov
f127a0f593 Add flag to disable new spilled variable type analysis 2020-06-29 20:50:43 +02:00
Mikhail Zarechenskiy
d7df6e1e0c Avoid references to DeprecatedSinceKotlin to fix JPS build 2020-06-29 21:49:01 +03:00
Ilmir Usmanov
28e6028af4 Minor. Add test 2020-06-29 20:13:40 +02:00
Ilmir Usmanov
da12532669 Ignore fake inliner variables in merge operation
since they are not read and just markers.
 #KT-39863 Fixed
2020-06-29 20:13:37 +02:00
Mikhail Zarechenskiy
b0b8d40b71 Update ApiTest.testIrStdlib for JS, an addition to 9be8c5b5 2020-06-29 21:09:19 +03:00
Dmitry Petrov
e4198466b8 JVM_IR: No nullability annotations on static lambda instances 2020-06-29 19:32:03 +03:00
Dmitry Petrov
eefa621c56 JVM_IR KT-37006: InlineOnly property accessors are private in bytecode 2020-06-29 19:08:58 +03:00
Alexander Udalov
b94a4d9fc3 Render more information on inner classes in bytecode listing tests 2020-06-29 17:33:39 +02:00
Vyacheslav Gerasimov
4bb670e667 Build: Use project kotlin-reflect in fir tree generator
To avoid unstable dependency substitution depending on local version
2020-06-29 18:17:09 +03:00
Vyacheslav Gerasimov
1ef68dfffd Build: Fix kotlin-test-js-ir:commonMainSources to copy only sources
Copying previous build result with sources leads to unstable task inputs
2020-06-29 18:17:08 +03:00
Vyacheslav Gerasimov
5198020c29 Build: Fix kotlin-stdlib related errors during jps build import 2020-06-29 18:17:08 +03:00
Vyacheslav Gerasimov
63b7350046 Build: Use sources from kotlin mpp source set in sourcesJar helper 2020-06-29 18:17:08 +03:00
Vyacheslav Gerasimov
77a8cf4e66 Build: Use attributes to resolve test dependencies in jps build mode 2020-06-29 18:17:08 +03:00
Igor Yakovlev
a32f901ab9 Make property initializer modification is OutOfBlock change
Fixed #KT-38762
2020-06-29 18:05:05 +03:00
Mikhail Zarechenskiy
507a718632 Update tests for completion after adding DeprecatedSinceKotlin 2020-06-29 17:41:05 +03:00
Mikhail Zarechenskiy
87014f816c Update ApiTest.testStdlib for JS, an addition to 9be8c5b5 2020-06-29 17:04:42 +03:00
Mikhail Glukhikh
d798071e06 IrConstTransformer: drop unnecessary argument existence check 2020-06-29 16:31:24 +03:00
Jinseong Jeon
c3fc524c0d FIR: handle named arguments in annotations properly 2020-06-29 16:23:03 +03:00
Mikhail Glukhikh
4f36697737 [FIR2IR] Mute 2 BB tests failing due to signature clashing 2020-06-29 16:08:26 +03:00
Mikhail Glukhikh
6cb3687d5d [FIR2IR] Replace 'throw AssertionError()' with error() / assert() {...} 2020-06-29 16:08:15 +03:00
Mikhail Glukhikh
69ec8f2d89 [FIR2IR] Allow to get cached symbols in fake override generator 2020-06-29 16:08:14 +03:00
Mikhail Glukhikh
c4d41f48a3 [IR] Allow Fir2Ir symbols in function factory 2020-06-29 16:08:12 +03:00
Mikhail Glukhikh
a6234eb261 [FIR2IR] Don't compose signatures for private declarations 2020-06-29 16:08:11 +03:00
Mikhail Glukhikh
19d115778b [IR] Allow fast reference path in SymbolTable for wrapped descriptors 2020-06-29 16:08:10 +03:00
Mikhail Glukhikh
90f9b9c1c9 [FIR2IR] Unmute 6 fixed BB tests 2020-06-29 16:08:09 +03:00
Mikhail Glukhikh
2d5e6bb90b [FIR2IR] Introduce lazy properties 2020-06-29 16:08:08 +03:00
Mikhail Glukhikh
efd614194b [FIR2IR] Make Fir2IrBindableSymbol public API 2020-06-29 16:08:06 +03:00
Mikhail Glukhikh
ca5e560f1f [FIR2IR] Introduce lazy constructors 2020-06-29 16:08:05 +03:00
Mikhail Glukhikh
fcabd02fe8 [FIR] Take class expect flag into account in its substitution scope 2020-06-29 16:08:00 +03:00
Mikhail Glukhikh
c1609ed490 [FIR] Make expect class members also expect 2020-06-29 16:07:50 +03:00
Mikhail Glukhikh
2fefa682b7 [FIR2IR] Do not compose signature for local class members 2020-06-29 16:07:49 +03:00
Mikhail Glukhikh
9a0e763761 [FIR2IR] Require classId from parent class for fake overrides 2020-06-29 16:07:48 +03:00
Mikhail Glukhikh
34a2196295 FirClassSubstitutionScope: extract SubstitutedData & reorder functions 2020-06-29 16:07:43 +03:00
Mikhail Glukhikh
bf009a4949 [FIR2IR] Handle delegating constructor call type arguments properly 2020-06-29 16:07:30 +03:00
Mikhail Glukhikh
2cffbadbd5 [FIR2IR] Use overridden symbol when handling delegating constructor call 2020-06-29 16:07:29 +03:00
Mikhail Glukhikh
456508a332 IR SymbolTable: don't allow unbound symbols in declare by signature only 2020-06-29 16:07:27 +03:00
Mikhail Glukhikh
7243d04f58 [FIR2IR] Simplification of property building in lazy class 2020-06-29 16:07:26 +03:00
Mikhail Glukhikh
a8db7b3ba6 [FIR2IR] Simplification of function building in lazy class 2020-06-29 16:07:25 +03:00
Mikhail Glukhikh
f7be373711 Add extra parent checks in Fir2IrLazyClass 2020-06-29 16:07:24 +03:00
Ivan Kylchik
13f7b6a22e Create separate constructor for ir interpreter with only ir builtins
By introducing this constructor, ir interpreter will no longer find ir
exceptions in module and so interpreter is creating faster for fir2ir
goals
2020-06-29 15:27:26 +03:00
Ivan Kylchik
de2b20482a Allow IrConstTransformer to visit and evaluate vararg elements 2020-06-29 15:27:25 +03:00
Ivan Kylchik
6fa03297f9 Allow IrConstTransformer to visit annotations of all declarations 2020-06-29 15:27:25 +03:00
Ivan Kylchik
c87b12ec2f Speed up fir2ir constant evaluation
This fix extract IrConstTransformer object to a common variable and all
files then use it
2020-06-29 15:27:24 +03:00
Mikhail Zarechenskiy
032fdd63d9 Ignore codegen test for Android
There is no such method as java.util.List.stream
2020-06-29 15:26:20 +03:00
Leonid Startsev
6ea0c37e52 Update test data with new package name after 901d8f3e7a 2020-06-29 15:09:30 +03:00
Mikhail Zarechenskiy
6efa7a51c6 Fix priority for "add import" action wrt DeprecatedSinceKotlin 2020-06-29 14:25:09 +03:00
Mikhail Zarechenskiy
beca7fca30 Fix completion order & presentation wrt to DeprecatedSinceKotlin 2020-06-29 14:25:09 +03:00
Mikhail Zarechenskiy
bcaa635a4e Fix parameter info presentation with regard to DeprecatedSinceKotlin 2020-06-29 14:25:09 +03:00
Mikhail Zarechenskiy
9be8c5b527 Update test data about built-ins 2020-06-29 14:25:09 +03:00
Mikhail Zarechenskiy
b7df9ec05a Implement equals/hashCode as this class previously was a data one
Fixes duplicated diagnostics in tests
2020-06-29 14:25:08 +03:00
Mikhail Zarechenskiy
a2da00eb49 Prohibit using DeprecatedSinceKotlin outside kotlin subpackage 2020-06-29 14:25:08 +03:00
Mikhail Zarechenskiy
790433984b Prohibit using DeprecatedSinceKotlin annotation without arguments 2020-06-29 14:25:08 +03:00
Mikhail Zarechenskiy
67100d5ebe Reject values of DeprecatedSince.. that are not parseable as a version 2020-06-29 14:25:07 +03:00
Mikhail Zarechenskiy
5d88058928 Place DeprecatedSinceKotlin annotation under 1.4 version 2020-06-29 14:25:06 +03:00
Mikhail Zarechenskiy
2f55a3fa0d Add various test for DeprecatedSinceKotlin annotation 2020-06-29 14:23:26 +03:00
Mikhail Zarechenskiy
0f2c96c64d Don't perform additional lookups for DeprecatedSinceKotlin annotation
There is no need to check it as `DeprecatedSinceKotlin` can be used
 only along with `Deprecated` annotation
2020-06-29 14:23:22 +03:00
Mikhail Zarechenskiy
158013ef3a Remove message and replaceWith parameters from DeprecatedSinceKotlin 2020-06-29 14:22:33 +03:00
Mikhail Zarechenskiy
60c51476f2 Introduce declaration checker for DeprecatedSinceKotlin annotation
- DeprecatedSinceKotlin annotation should only be applicable when
   there's `@Deprecated` annotation on the same declaration
 - Deprecation level shouldn't be specified in the relevant
   `@Deprecated` annotation
 - Check that warningSince <= errorSince <= hiddenSince
2020-06-29 14:22:32 +03:00
Alexander Udalov
0aaf29c045 Introduce DeprecatedSinceKotlin annotation
This annotation will be used in the standard library to prevent the new
compiler from reporting deprecation diagnostics in case an older API
version is used (where the declaration was not deprecated yet).

 #KT-23575 Fixed
2020-06-29 14:22:29 +03:00
Dmitriy Dolovov
b2022144e6 [Commonizer] Fast-pass for library fragments absent for some targets
^KT-39897
2020-06-29 16:40:59 +07:00
Dmitriy Novozhilov
ee22488ab2 [FIR] Cleanup FIR modules. Part 8 (types package) 2020-06-29 12:19:06 +03:00
Dmitriy Novozhilov
2c3fe8b8ec [FIR] Cleanup FIR modules. Part 7 (scopes package) 2020-06-29 12:19:06 +03:00
Dmitriy Novozhilov
c6124f6d56 [FIR] Cleanup FIR modules. Part 6 (transformers package) 2020-06-29 12:19:05 +03:00
Dmitriy Novozhilov
e817f919c2 [FIR] Cleanup FIR modules. Part 5 (body.resolve package) 2020-06-29 12:19:05 +03:00
Dmitriy Novozhilov
285b6d28af [FIR] Cleanup FIR modules. Part 4 (providers and resolve packages) 2020-06-29 12:19:05 +03:00
Dmitriy Novozhilov
1d90302848 [FIR] Cleanup FIR modules. Part 3 (inference package) 2020-06-29 12:19:05 +03:00
Dmitriy Novozhilov
1766c22f6f [FIR] Cleanup FIR modules. Part 2 (dfa package) 2020-06-29 12:19:04 +03:00
Dmitriy Novozhilov
604c68b3a0 [FIR] Cleanup FIR modules. Part 1 (calls package) 2020-06-29 12:19:04 +03:00
Dmitriy Novozhilov
1ac0e8449b [FIR] Move FirJavaTypeRef to fir.jvm module 2020-06-29 12:19:04 +03:00
Dmitriy Novozhilov
fd1de9b298 [FIR] Fix typo in FirCloneableSymbolProvider 2020-06-29 12:19:03 +03:00
Dmitriy Novozhilov
57b9baac53 [FIR] Get rid of FirSession.inferenceContext
Leave only FirSession.typeContext
2020-06-29 12:19:03 +03:00
Dmitriy Novozhilov
43bb60addb [FIR] Remove workaround for KT-39659 2020-06-29 12:19:03 +03:00
Dmitriy Novozhilov
7834284bec [FIR] Support deserialization of value parameter annotations
There are still some problems, see KT-39837
2020-06-29 12:19:03 +03:00
Dmitriy Novozhilov
2b2f9b3386 [FIR] Remove delegate specific methods from abstract inference session 2020-06-29 12:19:02 +03:00
Dmitriy Novozhilov
9c6ed2ea02 [FIR] Complete delegate calls in default inference session 2020-06-29 12:19:02 +03:00
Dmitriy Novozhilov
dbbb999952 [FIR] Support builder (coroutine) inference
#KT-37431 Fixed
2020-06-29 12:19:02 +03:00
Dmitriy Novozhilov
6a9504f26a [FIR-TEST] Add coroutines diagnostic tests from old FE to FIR test suite 2020-06-29 12:19:02 +03:00
Dmitriy Novozhilov
d0affc6c6a [FIR] Rename ResolverParts.kt to ResolutionStages.kt 2020-06-29 12:19:01 +03:00
Dmitriy Novozhilov
de1b5cd056 [FIR] Add extracting @Exact and @NoInfer attributes from annotations
(cherry picked from commit e4c8c14e3e)
2020-06-29 12:19:01 +03:00
Dmitriy Novozhilov
7ab3dd04a0 [FIR] Add attributes for @Exact and @NoInfer
(cherry picked from commit e43932f147)
2020-06-29 12:19:01 +03:00
Dmitriy Novozhilov
ac51e5dbd1 [FIR] Add workaround for KT-19306 2020-06-29 12:19:00 +03:00
Dmitriy Novozhilov
3f5db6b86e [FIR] Add ConeAttributes to ConeKotlinType
(cherry picked from commit f76befa84e)
2020-06-29 12:19:00 +03:00
Dmitriy Novozhilov
e76f3f93f6 [FIR] Move ArrayMap to cones module
(cherry picked from commit 407d1365bd)
2020-06-29 12:19:00 +03:00
Abduqodiri Qurbonzoda
d3fb9cc5f3 Deprecate with error mixed Int/FP contains operator for ranges KT-22423 2020-06-29 12:18:19 +03:00
Vladimir Dolzhenko
ab20b3e083 Add InterruptedException handler to CancellableSimpleLock
#EA-220650 Fixed
2020-06-29 08:47:53 +00:00
Vladimir Dolzhenko
a9444c386d Use actual import list on PlainTextPaste
#EA-225256 Fixed
2020-06-29 08:47:52 +00:00
Dmitry Gridin
30f98e6730 Inline refactoring: shouldn't lose return type information
#KT-26705 Fixed
2020-06-29 07:55:21 +00:00
Dmitry Gridin
c3b726f10a Inline refactoring: should add explicit type argument for parameters
#KT-17402 Fixed
2020-06-29 07:55:20 +00:00
Dmitry Gridin
45234c9784 Inline refactoring: fix case with introduction of variable to return
#KT-39818 Fixed
2020-06-29 07:55:20 +00:00
Andrey Uskov
f4e9acb233 Escape arguments when Gradle plugin launches out of process compilation
#KT-39755 Fixed
2020-06-28 11:38:04 +03:00
Yunir Salimzyanov
90dae320c3 Specify full name of parametrized flaky test to synchronize it on TeamCity
KTI-239
2020-06-27 13:29:18 +03:00
Yunir Salimzyanov
b795e50e61 Add logic to synchronize muted tests on teamcity with database flaky tests
KTI-239
2020-06-27 13:29:18 +03:00
Yunir Salimzyanov
a382bef144 Extract classes and related functions of muteWithDatabase to separate module 2020-06-27 13:29:18 +03:00
Yunir Salimzyanov
4474077963 Create separate module for muting tests logic 2020-06-27 13:29:17 +03:00
Georgy Bronnikov
5e115c48b3 Unmute FIR test 2020-06-27 00:25:34 +03:00
Shagen Ogandzhanian
8a393ec041 Update dukat dependency to 0.5.4 2020-06-26 21:05:21 +02:00
Leonid Startsev
901d8f3e7a Rename several core entities as a part of kx.serialization abi change 2020-06-26 20:31:23 +03:00
Leonid Startsev
5208bbcd21 Support new ContextSerializer signature 2020-06-26 20:31:22 +03:00
Toshiaki Kameyama
7ea1700b78 Convert lambda to reference: support generic function call
#KT-14578 Fixed
#KT-14395 Fixed
2020-06-26 20:30:39 +03:00
Dmitry Petrov
2137a4b1e5 JVM, JVM_IR: no nullability annotations on private and synthetic methods
NB it looks like it doesn't cover all cases, e.g., some synthetic
methods generated for suspend functions.
2020-06-26 18:51:35 +03:00
Georgy Bronnikov
5684e694b5 JVM_IR: handle diamond inheritance for Java fields 2020-06-26 18:46:41 +03:00
Anton Bannykh
da79f93c61 JS IR: per-module .js generation support 2020-06-26 17:55:33 +03:00
Anton Bannykh
deb5dc1057 Don't merge files into a single module 2020-06-26 17:55:33 +03:00
Anton Bannykh
5239ab477c Lowerings apply to a list of modules 2020-06-26 17:55:33 +03:00
Anton Bannykh
9a1d9814de Simpify phase building 2020-06-26 17:55:33 +03:00
Anton Bannykh
2e68526b44 Merge ES6 pipeline 2020-06-26 17:55:32 +03:00
Anton Bannykh
a1c9ee1013 Mute failing ES6 phases 2020-06-26 17:55:32 +03:00
Alexey Trilis
955087868a KT-39843 Update project wizard templates after replacing kotlin.browser with kotlinx.browser
#KT-39843 Fixed
2020-06-26 17:54:02 +03:00
Denis Zharkov
66e53305bf FIR: Leave only one composite-like scope implementation 2020-06-26 16:52:10 +03:00
Denis Zharkov
09bb755088 FIR: Pass scope to FirSpecificTypeResolverTransformer as data 2020-06-26 16:52:10 +03:00
Denis Zharkov
cea38771f1 FIR: Unbound TypeResolver from IterableScope 2020-06-26 16:52:10 +03:00
Denis Zharkov
b607cecc2b FIR: Clear JavaTypeParameterStack
- Remove unused method
- Rename method to make it findable through "Find usages"
2020-06-26 16:52:10 +03:00
Denis Zharkov
f3e4e9b162 FIR: Make qualifier have only one static scope
It's more correct as that's how it works in FE 1.0
2020-06-26 16:52:10 +03:00
Denis Zharkov
a017109d7d FIR: Use static scope for importing from non-object classes 2020-06-26 16:52:10 +03:00
Denis Zharkov
396c6377f8 FIR: Do not check statics in MemberScopeTowerLevel
Type scopes should not contain them anymore
2020-06-26 16:52:10 +03:00
Denis Zharkov
9668a60151 FIR: Explicitlty separate static and member scopes
For Java, they have rather different semantics considering "overrides"
and obtaining functions/properties from supertypes

See the Java statics implementation
2020-06-26 16:52:10 +03:00
Denis Zharkov
e058c578a8 FIR: Minor. Make method private 2020-06-26 16:52:10 +03:00
Denis Zharkov
24d7d208a0 FIR: Extract Java class rendering in tests 2020-06-26 16:52:10 +03:00
Denis Zharkov
9b5b882dcb Add "*.jar binary" to .gitattributes 2020-06-26 16:52:10 +03:00
Ilya Goncharov
be2d6b99f6 [Gradle, JS] Add test on changing of default value for generating externals 2020-06-26 16:26:13 +03:00
Ilya Goncharov
4bfcb4b041 [Gradle, JS] Use common projectName fun 2020-06-26 16:26:13 +03:00
Ilya Goncharov
89c1af4feb [Gradle, JS] Add tests on changing generating externals for npm deps 2020-06-26 16:26:13 +03:00
Ilya Goncharov
891071e074 [Gradle, JS] Add assertSingleFileExists 2020-06-26 16:26:13 +03:00
Ilya Goncharov
405412f6c1 [Gradle, JS] Use generateExternalsIntegrated instead of full build 2020-06-26 16:26:13 +03:00
Ilya Goncharov
f584fb1576 [Gradle, JS] Add test on integrated dukat task 2020-06-26 16:26:13 +03:00
Ilya Goncharov
1a9f236a60 [Gradle, JS] Add tests on Separate Dukat integration 2020-06-26 16:26:12 +03:00
Ilya Goncharov
007970ded8 [Gradle, JS] Add independent peer npm dependency to test
^KT-39842 fixed
2020-06-26 16:20:45 +03:00
Ilya Goncharov
bd05b447c0 [Gradle, JS] Ignore peer dependencies in yarn resolution
^KT-39842 fixed
2020-06-26 16:20:35 +03:00
Dmitry Petrov
9468670980 Minor: update testData with nullability annotations 2020-06-26 15:17:23 +03:00
Dmitry Petrov
64e47265e1 JVM, JVM_IR: no nullability annotations on lateinit backing fields 2020-06-26 15:08:23 +03:00
Toshiaki Kameyama
e822e871f5 KT-39532 Support intention to convert reference to lambda and vice versa for adapted references (#3495)
* Convert lambda to reference: support a function which has default parameters/unit return type/suspendability

#KT-39532 Fixed
2020-06-26 14:21:17 +03:00
Mikhail Zarechenskiy
a87b25d10e Don't silently ignore argument mismatch for provide delegate
#KT-39816 Fixed
2020-06-26 14:03:49 +03:00
Mikhail Zarechenskiy
ea5fef76d1 Fix ambiguity on reference inside blocks of special functions
#KT-37058 Fixed
2020-06-26 14:03:49 +03:00
Mikhail Zarechenskiy
c2c139ef4f Fix adaptation for references with default values after varargs
After vararg argument it's possible to pass values only by name, so
 here we modulate this behavior

 #KT-37721 Fixed
2020-06-26 14:03:48 +03:00
Mikhail Zarechenskiy
c5a2ab2512 Callable reference adaptation should have dependency on API version 1.4
#KT-38069 Fixed
2020-06-26 14:03:47 +03:00
Mikhail Zarechenskiy
bc40669598 Prohibit functional interface constructor references
#KT-36706 Fixed
2020-06-26 14:03:47 +03:00
Ilya Gorbunov
e3050cd997 Minor tweaks in js api dump run configuration
- parallel build
- clean test results before running tests again
2020-06-26 13:53:49 +03:00
Ilya Gorbunov
94ab50a21a Fixup stdlib-js api dump
Some strange effect related to loading types from kotlin.reflect.
2020-06-26 13:52:05 +03:00
Ilya Kirillov
366a75e222 Wizard: update versions of used libraries for 1.4-M3
#KT-39503 fixed
#KT-39503 fixed
2020-06-26 12:19:35 +03:00
Ilya Kirillov
35d5936829 Wizard: add info about used Kotlin version to project test importing failure 2020-06-26 12:19:34 +03:00
Dmitriy Novozhilov
7ea17f0d31 Revert "[FIR] Move ArrayMap to cones module"
This reverts commit 407d1365
2020-06-26 11:47:20 +03:00
Dmitriy Novozhilov
0b29a3e5c1 Revert "[FIR] Add ConeAttributes to ConeKotlinType"
This reverts commit f76befa8
2020-06-26 11:47:08 +03:00
Dmitriy Novozhilov
76550d3c5d Revert "[FIR] Add attributes for @Exact and @NoInfer"
This reverts commit e43932f1
2020-06-26 11:46:59 +03:00
Dmitriy Novozhilov
c0634217e1 Revert "[FIR] Add extracting @Exact and @NoInfer attributes from annotations"
This reverts commit e4c8c14e
2020-06-26 11:46:50 +03:00
Pavel Kirpichenkov
59e63f549b Add completion highlighting tests for heavy Kotlin files
#KT-37219 In Progress
2020-06-26 11:13:07 +03:00
Pavel Kirpichenkov
5c70f973a5 Force resolution of file annotations before element analysis
^KT-37219 In Progress
2020-06-26 11:13:07 +03:00
Dmitriy Novozhilov
e4c8c14e3e [FIR] Add extracting @Exact and @NoInfer attributes from annotations 2020-06-26 10:54:51 +03:00
Dmitriy Novozhilov
e43932f147 [FIR] Add attributes for @Exact and @NoInfer 2020-06-26 10:54:51 +03:00
Dmitriy Novozhilov
f76befa84e [FIR] Add ConeAttributes to ConeKotlinType 2020-06-26 10:54:51 +03:00
Dmitriy Novozhilov
407d1365bd [FIR] Move ArrayMap to cones module 2020-06-26 10:54:50 +03:00
Matts966
36102504a1 Update ReadMe.md 2020-06-26 09:41:57 +02:00
Matts966
20ed42dd38 Update deprecated doc about mac build environment requirements 2020-06-26 09:41:57 +02:00
Toshiaki Kameyama
2fd3af73eb Convert reference to lambda: fix it works correctly when referenced function has default argument
#KT-17222 Fixed
#KT-24138 Fixed
#KT-39532
2020-06-26 10:20:29 +03:00
Mikhail Zarechenskiy
bc34f7f7f5 Add test for obsolete issue
#KT-26345 Obsolete
2020-06-26 07:45:25 +03:00
Abduqodiri Qurbonzoda
a04f70fb36 Fix min/maxByOrNull function samples 2020-06-26 07:16:01 +03:00
Mikhail Zarechenskiy
684ca5029f Add tests for obsolete issues
#KT-37734 Obsolete
 #KT-39824 Obsolete
2020-06-26 06:24:59 +03:00
shiraji
9844607d0f Make string literals clickable
#KT-35732 Fixed
#KT-32403 Fixed
2020-06-25 22:40:39 +02:00
Igor Yakovlev
f06e116bf7 Improved equals for light decompiled declarations 2020-06-25 23:19:54 +03:00
Igor Yakovlev
27c139926c LightClass improved isInheritor check for cases when resolve is failed
Fixed #KT-37210
2020-06-25 23:17:09 +03:00
Guillaume Darmont
e72a06bdf4 Add specific highlight for Enum class
#KT-39844 Fixed
2020-06-25 21:53:19 +02:00
Dmitry Petrov
3f266aafb4 JVM: no nullability annotations on private and synthetic fields 2020-06-25 22:31:12 +03:00
Victor Petukhov
cbd8b58d5c Commit trace for callable reference's LHS with reserved syntax like foo?::bar?::bar to avoid the lack of diagnostics reporting
^KT-35075 Fixed
2020-06-25 20:44:58 +03:00
Ilmir Usmanov
1ee8e615fc Reuse value is ISTORE if expected type is the same, otherwise, create
new value
2020-06-25 18:51:15 +02:00
Ilmir Usmanov
c21820c615 Revert "Revert "Fix merging two reference values""
This reverts commit 1cccceabb9.
2020-06-25 18:51:13 +02:00
Ilmir Usmanov
a6f14c206b Revert "Revert "Revert "Revert "Completely rewrite reifiedIntTypeAnalysis, making it more streamline""""
This reverts commit 447308dcfc.
2020-06-25 18:51:11 +02:00
Kristoffer Andersen
b95d3e711e [JVM IR] KT-36985: $default respects @Deprecated
$default dispatch methods gains @Deprecated if the original function
with default arguments has it.
2020-06-25 18:43:45 +03:00
Ilya Gorbunov
034623f82a Fix top level import quick fix test for JS
There's no longer any JS-only top level function that is not imported
by default, so I used a common non-imported top level function.
2020-06-25 18:36:04 +03:00
Ilya Gorbunov
448e0ceae1 Drop quickfix tests that relied on removed native annotation 2020-06-25 18:36:04 +03:00
Ilya Gorbunov
8dfcebf542 Expose KTypeProjection.STAR constant in a field
#KT-30083
2020-06-25 18:25:24 +03:00
Ilya Gorbunov
53cbcfac5a Validate arguments of KTypeProjection constructor
#KT-34596 Fixed
2020-06-25 18:25:24 +03:00
Ilya Gorbunov
d41e8ed4ad Annotate KTypeProjection factory methods with JvmStatic
#KT-30084 Fixed
2020-06-25 18:25:24 +03:00
Ilya Chernikov
e8659d4b37 Fix initializer error arizing on scripting annotation creation
also fixes tests in main-kts
2020-06-25 17:21:38 +02:00
Vladimir Dolzhenko
3585f80c67 Fix 201 compilation
Relates to #KT-17926
2020-06-25 17:15:13 +02:00
Toshiaki Kameyama
12cd3785b0 Move statement: move parameters/arguments with a comment correctly
#KT-34705 Fixed
#KT-34707 Fixed
#KT-34587 Fixed
2020-06-25 15:45:25 +02:00
Raluca Sauciuc
9c8904f165 Restore KotlinExplicitMovementProvider in as40 2020-06-25 15:06:27 +02:00
2043 changed files with 33745 additions and 18503 deletions

13
.bunch
View File

@@ -1,7 +1,8 @@
193
201
202_201
192
as36_192
as40
as41_201
202
203_202
193
192_193
as36_192_193
as40_193
as41

1
.gitattributes vendored
View File

@@ -3,5 +3,6 @@
* text=auto
* eol=lf
*.png binary
*.jar binary
compiler/cli/bin/* eol=lf
compiler/cli/bin/*.bat eol=crlf

View File

@@ -13,21 +13,6 @@
</option>
</JavaCodeStyleSettings>
<JetCodeStyleSettings>
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
<value>
<package name="java.util" alias="false" withSubpackages="false" />
<package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" />
</value>
</option>
<option name="PACKAGES_IMPORT_LAYOUT">
<value>
<package name="" alias="false" withSubpackages="true" />
<package name="java" alias="false" withSubpackages="true" />
<package name="javax" alias="false" withSubpackages="true" />
<package name="kotlin" alias="false" withSubpackages="true" />
<package name="" alias="true" withSubpackages="true" />
</value>
</option>
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
</JetCodeStyleSettings>
<MarkdownNavigatorCodeStyleSettings>

View File

@@ -4,12 +4,13 @@
<option name="executionName" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="--tests &quot;org.jetbrains.kotlin.js.test.ApiTest&quot; -Poverwrite.output=true" />
<option name="scriptParameters" value="--tests &quot;org.jetbrains.kotlin.js.test.ApiTest&quot; -Poverwrite.output=true --parallel" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value=":js:js.tests:cleanTest" />
<option value=":js:js.tests:test" />
</list>
</option>

View File

@@ -100,6 +100,8 @@
- [`KT-38668`](https://youtrack.jetbrains.com/issue/KT-38668) Project with module dependency in KN, build fails with Kotlin 1.3.71 and associated libs but passes with 1.3.61.
- [`KT-38857`](https://youtrack.jetbrains.com/issue/KT-38857) Class versions V1_5 or less must use F_NEW frames.
- [`KT-39113`](https://youtrack.jetbrains.com/issue/KT-39113) "AssertionError: Uninitialized value on stack" with EXACTLY_ONCE contract in non-inline function and lambda destructuring
- [`KT-28483`](https://youtrack.jetbrains.com/issue/KT-28483) Override of generic-return-typed function with inline class should lead to a boxing
- [`KT-37963`](https://youtrack.jetbrains.com/issue/KT-37963) ClassCastException: Value of inline class represented as 'java.lang.Object' is not boxed properly on return from lambda
### Docs & Examples
@@ -325,6 +327,7 @@
- [`KT-38579`](https://youtrack.jetbrains.com/issue/KT-38579) New Project wizard 1.4+: multiplatform mobile application: build fails on lint task: Configuration with name 'compileClasspath' not found
- [`KT-38929`](https://youtrack.jetbrains.com/issue/KT-38929) New project wizard: update libraries in project template according to kotlin IDE plugin version
- [`KT-38417`](https://youtrack.jetbrains.com/issue/KT-38417) Enable new project wizard by-default
- [`KT-38158`](https://youtrack.jetbrains.com/issue/KT-38158) java.lang.NullPointerException when try to create new project via standard wizard on Mac os
### JS. Tools
@@ -377,6 +380,7 @@
- [`KT-16529`](https://youtrack.jetbrains.com/issue/KT-16529) Names of KProperty's type parameters are inconsistent with ReadOnlyProperty/ReadWriteProperty
- [`KT-36356`](https://youtrack.jetbrains.com/issue/KT-36356) Specify which element Iterable.distinctBy(selector) retains
- [`KT-38060`](https://youtrack.jetbrains.com/issue/KT-38060) runningFold and runningReduce instead of scanReduce
- [`KT-38566`](https://youtrack.jetbrains.com/issue/KT-38566) Kotlin/JS IR: kx.serialization & ktor+JsonFeature: SerializationException: Can't locate argument-less serializer for class
### Reflection

View File

@@ -41,7 +41,12 @@ For local development, if you're not working on bytecode generation or the stand
You also can use [Gradle properties](https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties) to setup `JDK_*` variables.
> Note: The JDK 6 for MacOS is not available on Oracle's site. You can [download it here](https://support.apple.com/kb/DL1572).
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
```
On Windows you might need to add long paths setting to the repo:

View File

@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.incremental.storage
import com.intellij.util.io.DataExternalizer
import com.intellij.util.io.KeyDescriptor
import com.intellij.util.io.JpsPersistentHashMap
import com.intellij.util.io.PersistentHashMap
import java.io.File
@@ -28,10 +28,10 @@ class NonCachingLazyStorage<K, V>(
private val valueExternalizer: DataExternalizer<V>
) : LazyStorage<K, V> {
@Volatile
private var storage: JpsPersistentHashMap<K, V>? = null
private var storage: PersistentHashMap<K, V>? = null
@Synchronized
private fun getStorageIfExists(): JpsPersistentHashMap<K, V>? {
private fun getStorageIfExists(): PersistentHashMap<K, V>? {
if (storage != null) return storage
if (storageFile.exists()) {
@@ -43,7 +43,7 @@ class NonCachingLazyStorage<K, V>(
}
@Synchronized
private fun getStorageOrCreateNew(): JpsPersistentHashMap<K, V> {
private fun getStorageOrCreateNew(): PersistentHashMap<K, V> {
if (storage == null) {
storage = createMap()
}
@@ -69,7 +69,7 @@ class NonCachingLazyStorage<K, V>(
}
override fun append(key: K, value: V) {
getStorageOrCreateNew().appendDataWithoutCache(key, value)
getStorageOrCreateNew().appendData(key) { dataOutput -> valueExternalizer.save(dataOutput, value) }
}
@Synchronized
@@ -79,7 +79,7 @@ class NonCachingLazyStorage<K, V>(
} catch (ignored: Throwable) {
}
JpsPersistentHashMap.deleteFilesStartingWith(storageFile)
PersistentHashMap.deleteFilesStartingWith(storageFile)
storage = null
}
@@ -101,6 +101,6 @@ class NonCachingLazyStorage<K, V>(
storage?.close()
}
private fun createMap(): JpsPersistentHashMap<K, V> =
JpsPersistentHashMap(storageFile, keyDescriptor, valueExternalizer)
private fun createMap(): PersistentHashMap<K, V> =
PersistentHashMap(storageFile, keyDescriptor, valueExternalizer)
}

View File

@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.incremental.storage
import com.intellij.util.io.DataExternalizer
import com.intellij.util.io.KeyDescriptor
import com.intellij.util.io.PersistentHashMap
import com.intellij.util.io.JpsPersistentHashMap
import java.io.File
@@ -28,10 +28,10 @@ class NonCachingLazyStorage<K, V>(
private val valueExternalizer: DataExternalizer<V>
) : LazyStorage<K, V> {
@Volatile
private var storage: PersistentHashMap<K, V>? = null
private var storage: JpsPersistentHashMap<K, V>? = null
@Synchronized
private fun getStorageIfExists(): PersistentHashMap<K, V>? {
private fun getStorageIfExists(): JpsPersistentHashMap<K, V>? {
if (storage != null) return storage
if (storageFile.exists()) {
@@ -43,7 +43,7 @@ class NonCachingLazyStorage<K, V>(
}
@Synchronized
private fun getStorageOrCreateNew(): PersistentHashMap<K, V> {
private fun getStorageOrCreateNew(): JpsPersistentHashMap<K, V> {
if (storage == null) {
storage = createMap()
}
@@ -69,7 +69,7 @@ class NonCachingLazyStorage<K, V>(
}
override fun append(key: K, value: V) {
getStorageOrCreateNew().appendData(key) { dataOutput -> valueExternalizer.save(dataOutput, value) }
getStorageOrCreateNew().appendDataWithoutCache(key, value)
}
@Synchronized
@@ -79,7 +79,7 @@ class NonCachingLazyStorage<K, V>(
} catch (ignored: Throwable) {
}
PersistentHashMap.deleteFilesStartingWith(storageFile)
JpsPersistentHashMap.deleteFilesStartingWith(storageFile)
storage = null
}
@@ -101,6 +101,6 @@ class NonCachingLazyStorage<K, V>(
storage?.close()
}
private fun createMap(): PersistentHashMap<K, V> =
PersistentHashMap(storageFile, keyDescriptor, valueExternalizer)
private fun createMap(): JpsPersistentHashMap<K, V> =
JpsPersistentHashMap(storageFile, keyDescriptor, valueExternalizer)
}

View File

@@ -152,6 +152,7 @@ rootProject.apply {
from(rootProject.file("gradle/jps.gradle.kts"))
from(rootProject.file("gradle/checkArtifacts.gradle.kts"))
from(rootProject.file("gradle/checkCacheability.gradle.kts"))
from(rootProject.file("gradle/retryPublishing.gradle.kts"))
}
IdeVersionConfigurator.setCurrentIde(project)
@@ -365,6 +366,15 @@ allprojects {
}
}
configurations.maybeCreate("embeddedElements").apply {
extendsFrom(configurations["embedded"])
isCanBeConsumed = true
isCanBeResolved = false
attributes {
attribute(Usage.USAGE_ATTRIBUTE, objects.named("embedded-java-runtime"))
}
}
jvmTarget = defaultJvmTarget
javaHome = defaultJavaHome
@@ -513,6 +523,10 @@ val dist = tasks.register("dist") {
dependsOn(":kotlin-compiler:dist")
}
val syncMutedTests = tasks.register("syncMutedTests") {
dependsOn(":compiler:tests-mutes:run")
}
val copyCompilerToIdeaPlugin by task<Copy> {
dependsOn(dist)
into(ideaPluginDir)
@@ -637,6 +651,7 @@ tasks {
dependsOn(":kotlin-scripting-jsr223-test:embeddableTest")
dependsOn(":kotlin-main-kts-test:test")
dependsOn(":kotlin-scripting-ide-services-test:test")
dependsOn(":kotlin-scripting-ide-services-test:embeddableTest")
dependsOn(":kotlin-scripting-js-test:test")
}
@@ -1061,4 +1076,4 @@ if (disableVerificationTasks) {
}
}
}
}
}

View File

@@ -96,6 +96,7 @@ repositories {
dependencies {
implementation(kotlin("stdlib", embeddedKotlinVersion))
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:${project.bootstrapKotlinVersion}")
implementation("org.jetbrains.kotlin:kotlin-build-gradle-plugin:0.0.17")
implementation("com.gradle.publish:plugin-publish-plugin:0.11.0")

View File

@@ -27,6 +27,7 @@ import org.gradle.api.tasks.javadoc.Javadoc
import org.gradle.jvm.tasks.Jar
import org.gradle.api.artifacts.dsl.DependencyHandler
import org.gradle.kotlin.dsl.*
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetContainer
import plugins.KotlinBuildPublishingPlugin
@@ -129,10 +130,16 @@ fun Project.sourcesJar(body: Jar.() -> Unit = {}): TaskProvider<Jar> {
}
val sourcesJar = getOrCreateTask<Jar>("sourcesJar") {
fun Project.mainJavaPluginSourceSet() = findJavaPluginConvention()?.sourceSets?.findByName("main")
fun Project.mainKotlinSourceSet() =
(extensions.findByName("kotlin") as? KotlinSourceSetContainer)?.sourceSets?.findByName("main")
fun Project.sources() = mainJavaPluginSourceSet()?.allSource ?: mainKotlinSourceSet()?.kotlin
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
archiveClassifier.set("sources")
from(project.mainSourceSet.allSource)
from(project.sources())
project.configurations.findByName("embedded")?.let { embedded ->
from(provider {
@@ -141,10 +148,7 @@ fun Project.sourcesJar(body: Jar.() -> Unit = {}): TaskProvider<Jar> {
.map { it.id.componentIdentifier }
.filterIsInstance<ProjectComponentIdentifier>()
.mapNotNull {
project(it.projectPath)
.findJavaPluginConvention()
?.mainSourceSet
?.allSource
project(it.projectPath).sources()
}
})
}

View File

@@ -90,12 +90,18 @@ public abstract class AnnotationCodegen {
private final KotlinTypeMapper typeMapper;
private final ModuleDescriptor module;
private final GenerationState state;
private final boolean skipNullabilityAnnotations;
private AnnotationCodegen(@NotNull InnerClassConsumer innerClassConsumer, @NotNull GenerationState state) {
this(innerClassConsumer, state, false);
}
private AnnotationCodegen(@NotNull InnerClassConsumer innerClassConsumer, @NotNull GenerationState state, boolean skipNullabilityAnnotations) {
this.innerClassConsumer = innerClassConsumer;
this.typeMapper = state.getTypeMapper();
this.module = state.getModule();
this.state = state;
this.skipNullabilityAnnotations = skipNullabilityAnnotations;
}
/**
@@ -196,9 +202,7 @@ public abstract class AnnotationCodegen {
return;
}
if (returnType != null && !AsmUtil.isPrimitive(returnType) &&
!(descriptor instanceof PropertyDescriptor && ((PropertyDescriptor) descriptor).isDelegated())
) {
if (returnType != null && !AsmUtil.isPrimitive(returnType) && !skipNullabilityAnnotations) {
generateNullabilityAnnotation(descriptor.getReturnType(), annotationDescriptorsAlreadyPresent);
}
}
@@ -624,7 +628,16 @@ public abstract class AnnotationCodegen {
@NotNull InnerClassConsumer innerClassConsumer,
@NotNull GenerationState state
) {
return new AnnotationCodegen(innerClassConsumer, state) {
return forMethod(mv, innerClassConsumer, state, false);
}
public static AnnotationCodegen forMethod(
@NotNull MethodVisitor mv,
@NotNull InnerClassConsumer innerClassConsumer,
@NotNull GenerationState state,
boolean skipNullabilityAnnotations
) {
return new AnnotationCodegen(innerClassConsumer, state, skipNullabilityAnnotations) {
@NotNull
@Override
AnnotationVisitor visitAnnotation(String descr, boolean visible) {
@@ -644,7 +657,16 @@ public abstract class AnnotationCodegen {
@NotNull InnerClassConsumer innerClassConsumer,
@NotNull GenerationState state
) {
return new AnnotationCodegen(innerClassConsumer, state) {
return forField(fv, innerClassConsumer, state, false);
}
public static AnnotationCodegen forField(
@NotNull FieldVisitor fv,
@NotNull InnerClassConsumer innerClassConsumer,
@NotNull GenerationState state,
boolean skipNullabilityAnnotations
) {
return new AnnotationCodegen(innerClassConsumer, state, skipNullabilityAnnotations) {
@NotNull
@Override
AnnotationVisitor visitAnnotation(String descr, boolean visible) {
@@ -663,9 +685,10 @@ public abstract class AnnotationCodegen {
int parameter,
@NotNull MethodVisitor mv,
@NotNull InnerClassConsumer innerClassConsumer,
@NotNull GenerationState state
@NotNull GenerationState state,
boolean skipNullabilityAnnotations
) {
return new AnnotationCodegen(innerClassConsumer, state) {
return new AnnotationCodegen(innerClassConsumer, state, skipNullabilityAnnotations) {
@NotNull
@Override
AnnotationVisitor visitAnnotation(String descr, boolean visible) {

View File

@@ -153,18 +153,18 @@ class DefaultParameterValueSubstitutor(val state: GenerationState) {
signature.genericsSignature,
FunctionCodegen.getThrownExceptions(functionDescriptor, typeMapper)
)
val skipNullabilityAnnotations = flags and Opcodes.ACC_PRIVATE != 0 || flags and Opcodes.ACC_SYNTHETIC != 0
AnnotationCodegen.forMethod(mv, memberCodegen, state).genAnnotations(
functionDescriptor,
signature.returnType,
functionDescriptor.returnType
)
AnnotationCodegen.forMethod(mv, memberCodegen, state, skipNullabilityAnnotations)
.genAnnotations(functionDescriptor, signature.returnType, functionDescriptor.returnType)
if (state.classBuilderMode == ClassBuilderMode.KAPT3) {
mv.visitAnnotation(ANNOTATION_TYPE_DESCRIPTOR_FOR_JVM_OVERLOADS_GENERATED_METHODS, false)
}
FunctionCodegen.generateParameterAnnotations(functionDescriptor, mv, signature, remainingParameters, memberCodegen, state)
FunctionCodegen.generateParameterAnnotations(
functionDescriptor, mv, signature, remainingParameters, memberCodegen, state, skipNullabilityAnnotations
)
if (!state.classBuilderMode.generateBodies) {
FunctionCodegen.generateLocalVariablesForParameters(

View File

@@ -33,10 +33,7 @@ import org.jetbrains.kotlin.load.java.JvmAbi;
import org.jetbrains.kotlin.load.java.SpecialBuiltinMembers;
import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor;
import org.jetbrains.kotlin.psi.*;
import org.jetbrains.kotlin.resolve.BindingContext;
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils;
import org.jetbrains.kotlin.resolve.DescriptorUtils;
import org.jetbrains.kotlin.resolve.InlineClassesUtilsKt;
import org.jetbrains.kotlin.resolve.*;
import org.jetbrains.kotlin.resolve.annotations.AnnotationUtilKt;
import org.jetbrains.kotlin.resolve.calls.util.UnderscoreUtilKt;
import org.jetbrains.kotlin.resolve.constants.ArrayValue;
@@ -205,12 +202,13 @@ public class FunctionCodegen {
MethodVisitor mv =
strategy.wrapMethodVisitor(
newMethod(origin,
flags,
asmMethod.getName(),
asmMethod.getDescriptor(),
strategy.skipGenericSignature() ? null : jvmSignature.getGenericsSignature(),
getThrownExceptions(functionDescriptor, typeMapper)
newMethod(
origin,
flags,
asmMethod.getName(),
asmMethod.getDescriptor(),
strategy.skipGenericSignature() ? null : jvmSignature.getGenericsSignature(),
getThrownExceptions(functionDescriptor, typeMapper)
),
flags, asmMethod.getName(),
asmMethod.getDescriptor()
@@ -218,10 +216,14 @@ public class FunctionCodegen {
recordMethodForFunctionIfAppropriate(functionDescriptor, asmMethod);
generateMethodAnnotationsIfRequired(functionDescriptor, asmMethod, jvmSignature, mv, isCompatibilityStubInDefaultImpls
? Collections.singletonList(Deprecated.class)
: Collections.emptyList());
boolean skipNullabilityAnnotations =
(flags & ACC_PRIVATE) != 0 || (flags & ACC_SYNTHETIC) != 0 ||
InlineClassDescriptorResolver.isSpecializedEqualsMethod(functionDescriptor);
generateMethodAnnotationsIfRequired(
functionDescriptor, asmMethod, jvmSignature, mv,
isCompatibilityStubInDefaultImpls ? Collections.singletonList(Deprecated.class) : Collections.emptyList(),
skipNullabilityAnnotations
);
GenerateJava8ParameterNamesKt.generateParameterNames(functionDescriptor, mv, jvmSignature, state, (flags & ACC_SYNTHETIC) != 0);
if (contextKind != OwnerKind.ERASED_INLINE_CLASS) {
@@ -283,7 +285,8 @@ public class FunctionCodegen {
@NotNull Method asmMethod,
@NotNull JvmMethodGenericSignature jvmSignature,
@NotNull MethodVisitor mv,
@NotNull List<Class<?>> additionalNoArgAnnotations
@NotNull List<Class<?>> additionalNoArgAnnotations,
boolean skipNullabilityAnnotations
) {
FunctionDescriptor annotationsOwner;
if (shouldHideConstructorDueToInlineClassTypeValueParameters(functionDescriptor)) {
@@ -298,10 +301,14 @@ public class FunctionCodegen {
annotationsOwner = functionDescriptor;
}
AnnotationCodegen.forMethod(mv, memberCodegen, state)
AnnotationCodegen.forMethod(mv, memberCodegen, state, skipNullabilityAnnotations)
.genAnnotations(annotationsOwner, asmMethod.getReturnType(), functionDescriptor.getReturnType(), null, additionalNoArgAnnotations);
generateParameterAnnotations(annotationsOwner, mv, jvmSignature, memberCodegen, state);
generateParameterAnnotations(
annotationsOwner, mv, jvmSignature,
annotationsOwner.getValueParameters(),
memberCodegen, state, skipNullabilityAnnotations
);
}
@NotNull
@@ -495,25 +502,14 @@ public class FunctionCodegen {
return descriptor != null && !InlineUtil.isInlineOrContainingInline(descriptor);
}
public static void generateParameterAnnotations(
@NotNull FunctionDescriptor functionDescriptor,
@NotNull MethodVisitor mv,
@NotNull JvmMethodSignature jvmSignature,
@NotNull MemberCodegen<?> memberCodegen,
@NotNull GenerationState state
) {
generateParameterAnnotations(
functionDescriptor, mv, jvmSignature, functionDescriptor.getValueParameters(), memberCodegen, state
);
}
public static void generateParameterAnnotations(
@NotNull FunctionDescriptor functionDescriptor,
@NotNull MethodVisitor mv,
@NotNull JvmMethodSignature jvmSignature,
@NotNull List<ValueParameterDescriptor> valueParameters,
@NotNull MemberCodegen<?> memberCodegen,
@NotNull GenerationState state
@NotNull GenerationState state,
boolean skipNullabilityAnnotations
) {
if (isAccessor(functionDescriptor)) return;
@@ -536,14 +532,18 @@ public class FunctionCodegen {
? iterator.next()
: kind == JvmMethodParameterKind.RECEIVER
? JvmCodegenUtil.getDirectMember(functionDescriptor).getExtensionReceiverParameter()
: isDefaultImpl && kind == JvmMethodParameterKind.THIS ? JvmCodegenUtil.getDirectMember(functionDescriptor)
.getDispatchReceiverParameter() : null;
: kind == JvmMethodParameterKind.THIS && isDefaultImpl
? JvmCodegenUtil.getDirectMember(functionDescriptor).getDispatchReceiverParameter()
: null;
if (annotated != null) {
//noinspection ConstantConditions
int parameterIndex = i - syntheticParameterCount;
AnnotationCodegen.forParameter(parameterIndex, mv, memberCodegen, state)
.genAnnotations(annotated, parameterSignature.getAsmType(), annotated.getReturnType(), functionDescriptor, Collections.emptyList());
AnnotationCodegen
.forParameter(parameterIndex, mv, memberCodegen, state, skipNullabilityAnnotations)
.genAnnotations(
annotated, parameterSignature.getAsmType(), annotated.getReturnType(), functionDescriptor,
Collections.emptyList()
);
}
}
}

View File

@@ -16,7 +16,6 @@ import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper;
import org.jetbrains.kotlin.descriptors.ClassDescriptor;
import org.jetbrains.kotlin.descriptors.FunctionDescriptor;
import org.jetbrains.kotlin.descriptors.PropertyDescriptor;
import org.jetbrains.kotlin.lexer.KtTokens;
import org.jetbrains.kotlin.psi.KtClassOrObject;
import org.jetbrains.kotlin.resolve.BindingContext;
import org.jetbrains.kotlin.resolve.InlineClassesUtilsKt;
@@ -46,6 +45,7 @@ public class FunctionsFromAnyGeneratorImpl extends FunctionsFromAnyGenerator {
private final GenerationState generationState;
private final KotlinTypeMapper typeMapper;
private final JvmKotlinType underlyingType;
private final boolean isInErasedInlineClass;
public FunctionsFromAnyGeneratorImpl(
@NotNull KtClassOrObject declaration,
@@ -67,23 +67,27 @@ public class FunctionsFromAnyGeneratorImpl extends FunctionsFromAnyGenerator {
typeMapper.mapType(descriptor),
InlineClassesUtilsKt.substitutedUnderlyingType(descriptor.getDefaultType())
);
this.isInErasedInlineClass = fieldOwnerContext.getContextKind() == OwnerKind.ERASED_INLINE_CLASS;
}
@Override
protected void generateToStringMethod(
@NotNull FunctionDescriptor function, @NotNull List<? extends PropertyDescriptor> properties
@NotNull FunctionDescriptor function,
@NotNull List<? extends PropertyDescriptor> properties
) {
MethodContext context = fieldOwnerContext.intoFunction(function);
JvmDeclarationOrigin methodOrigin = JvmDeclarationOriginKt.OtherOrigin(function);
String toStringMethodName = mapFunctionName(function);
MethodVisitor mv = v.newMethod(methodOrigin, getAccess(), toStringMethodName, getToStringDesc(), null, null);
if (fieldOwnerContext.getContextKind() != OwnerKind.ERASED_INLINE_CLASS && classDescriptor.isInline()) {
if (!isInErasedInlineClass && classDescriptor.isInline()) {
FunctionCodegen.generateMethodInsideInlineClassWrapper(methodOrigin, function, classDescriptor, mv, typeMapper);
return;
}
visitEndForAnnotationVisitor(mv.visitAnnotation(Type.getDescriptor(NotNull.class), false));
if (!isInErasedInlineClass) {
visitEndForAnnotationVisitor(mv.visitAnnotation(Type.getDescriptor(NotNull.class), false));
}
if (!generationState.getClassBuilderMode().generateBodies) {
FunctionCodegen.endVisit(mv, toStringMethodName, getDeclaration());
@@ -144,7 +148,7 @@ public class FunctionsFromAnyGeneratorImpl extends FunctionsFromAnyGenerator {
String hashCodeMethodName = mapFunctionName(function);
MethodVisitor mv = v.newMethod(methodOrigin, getAccess(), hashCodeMethodName, getHashCodeDesc(), null, null);
if (fieldOwnerContext.getContextKind() != OwnerKind.ERASED_INLINE_CLASS && classDescriptor.isInline()) {
if (!isInErasedInlineClass && classDescriptor.isInline()) {
FunctionCodegen.generateMethodInsideInlineClassWrapper(methodOrigin, function, classDescriptor, mv, typeMapper);
return;
}
@@ -213,15 +217,14 @@ public class FunctionsFromAnyGeneratorImpl extends FunctionsFromAnyGenerator {
String equalsMethodName = mapFunctionName(function);
MethodVisitor mv = v.newMethod(methodOrigin, getAccess(), equalsMethodName, getEqualsDesc(), null, null);
boolean isErasedInlineClassKind = fieldOwnerContext.getContextKind() == OwnerKind.ERASED_INLINE_CLASS;
if (!isErasedInlineClassKind && classDescriptor.isInline()) {
if (!isInErasedInlineClass && classDescriptor.isInline()) {
FunctionCodegen.generateMethodInsideInlineClassWrapper(methodOrigin, function, classDescriptor, mv, typeMapper);
return;
}
visitEndForAnnotationVisitor(
mv.visitParameterAnnotation(isErasedInlineClassKind ? 1 : 0, Type.getDescriptor(Nullable.class), false)
);
if (!isInErasedInlineClass) {
visitEndForAnnotationVisitor(mv.visitParameterAnnotation(0, Type.getDescriptor(Nullable.class), false));
}
if (!generationState.getClassBuilderMode().generateBodies) {
FunctionCodegen.endVisit(mv, equalsMethodName, getDeclaration());

View File

@@ -210,7 +210,6 @@ public class PropertyCodegen {
if (kind == OwnerKind.DEFAULT_IMPLS && isDefaultAccessor) return false;
// Delegated or extension properties can only be referenced via accessors
//noinspection deprecation
if (descriptor.isDelegated() || descriptor.getExtensionReceiverParameter() != null) return true;
// Companion object properties should have accessors for non-private properties because these properties can be referenced
@@ -337,11 +336,8 @@ public class PropertyCodegen {
return;
}
@SuppressWarnings("deprecation")
boolean isDelegate = descriptor.isDelegated();
Object defaultValue;
if (isDelegate) {
if (descriptor.isDelegated()) {
defaultValue = null;
}
else if (Boolean.TRUE.equals(bindingContext.get(BindingContext.BACKING_FIELD_REQUIRED, descriptor))) {
@@ -357,7 +353,7 @@ public class PropertyCodegen {
return;
}
generateBackingField(descriptor, isDelegate, defaultValue, isBackingFieldOwner);
generateBackingField(descriptor, descriptor.isDelegated(), defaultValue, isBackingFieldOwner);
}
// Annotations on properties are stored in bytecode on an empty synthetic method. This way they're still
@@ -438,7 +434,13 @@ public class PropertyCodegen {
);
if (annotatedField != null) {
AnnotationCodegen.forField(fv, memberCodegen, state)
// Don't emit nullability annotations for backing field if:
// - backing field is invisible from Java (private or synthetic);
// - property is lateinit (since corresponding field is actually nullable).
boolean skipNullabilityAnnotations =
(modifiers & ACC_PRIVATE) != 0 || (modifiers & ACC_SYNTHETIC) != 0 ||
propertyDescriptor.isLateInit();
AnnotationCodegen.forField(fv, memberCodegen, state, skipNullabilityAnnotations)
.genAnnotations(annotatedField, type, propertyDescriptor.getType());
}
}
@@ -516,9 +518,7 @@ public class PropertyCodegen {
FunctionGenerationStrategy strategy;
if (accessor == null || !accessor.hasBody()) {
@SuppressWarnings("deprecation")
boolean isDelegated = descriptor.getCorrespondingProperty().isDelegated();
if (isDelegated) {
if (descriptor.getCorrespondingProperty().isDelegated()) {
strategy = new DelegatedPropertyAccessorStrategy(state, descriptor);
}
else {

View File

@@ -19,6 +19,7 @@ import org.jetbrains.kotlin.codegen.context.MethodContext
import org.jetbrains.kotlin.codegen.serialization.JvmSerializationBindings.METHOD_FOR_FUNCTION
import org.jetbrains.kotlin.codegen.serialization.JvmSerializerExtension
import org.jetbrains.kotlin.codegen.state.GenerationState
import org.jetbrains.kotlin.config.JVMConfigurationKeys
import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.config.isReleaseCoroutines
import org.jetbrains.kotlin.descriptors.*
@@ -512,7 +513,8 @@ class CoroutineCodegenForLambda private constructor(
containingClassInternalName = v.thisName,
isForNamedFunction = false,
languageVersionSettings = languageVersionSettings,
disableTailCallOptimizationForFunctionReturningUnit = false
disableTailCallOptimizationForFunctionReturningUnit = false,
useOldSpilledVarTypeAnalysis = state.configuration.getBoolean(JVMConfigurationKeys.USE_OLD_SPILLED_VAR_TYPE_ANALYSIS)
)
val maybeWithForInline = if (forInline)
SuspendForInlineCopyingMethodVisitor(stateMachineBuilder, access, name, desc, functionCodegen::newMethod)

View File

@@ -5,14 +5,10 @@
package org.jetbrains.kotlin.codegen.coroutines
import org.jetbrains.kotlin.codegen.AsmUtil
import org.jetbrains.kotlin.codegen.ClassBuilder
import org.jetbrains.kotlin.codegen.StackValue
import org.jetbrains.kotlin.codegen.TransformationMethodVisitor
import org.jetbrains.kotlin.codegen.*
import org.jetbrains.kotlin.codegen.inline.*
import org.jetbrains.kotlin.codegen.optimization.common.*
import org.jetbrains.kotlin.codegen.optimization.fixStack.FixStackMethodTransformer
import org.jetbrains.kotlin.codegen.linkWithLabel
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.config.isReleaseCoroutines
import org.jetbrains.kotlin.resolve.jvm.AsmTypes
@@ -65,7 +61,9 @@ class CoroutineTransformerMethodVisitor(
// May differ from containingClassInternalName in case of DefaultImpls
private val internalNameForDispatchReceiver: String? = null,
// JVM_IR backend generates $completion, while old backend does not
private val putContinuationParameterToLvt: Boolean = true
private val putContinuationParameterToLvt: Boolean = true,
// New SourceInterpreter-less analyser can be somewhat unstable, disable it
private val useOldSpilledVarTypeAnalysis: Boolean = false
) : TransformationMethodVisitor(delegate, access, name, desc, signature, exceptions) {
private val classBuilderForCoroutineState: ClassBuilder by lazy(obtainClassBuilderForCoroutineState)
@@ -594,7 +592,10 @@ class CoroutineTransformerMethodVisitor(
private fun spillVariables(suspensionPoints: List<SuspensionPoint>, methodNode: MethodNode): List<List<SpilledVariableDescriptor>> {
val instructions = methodNode.instructions
val frames = performRefinedTypeAnalysis(methodNode, containingClassInternalName)
val frames =
if (useOldSpilledVarTypeAnalysis) performRefinedTypeAnalysis(methodNode, containingClassInternalName)
else performSpilledVariableFieldTypesAnalysis(methodNode, containingClassInternalName)
fun AbstractInsnNode.index() = instructions.indexOf(this)
// We postpone these actions because they change instruction indices that we use when obtaining frames
@@ -642,11 +643,11 @@ class CoroutineTransformerMethodVisitor(
.map { Pair(it, frame.getLocal(it)) }
.filter { (index, value) ->
(index == 0 && needDispatchReceiver && isForNamedFunction) ||
(value != StrictBasicValue.UNINITIALIZED_VALUE && livenessFrame.isAlive(index))
(value.type != null && livenessFrame.isAlive(index))
}
for ((index, basicValue) in variablesToSpill) {
if (basicValue === StrictBasicValue.NULL_VALUE) {
if (basicValue == StrictBasicValue.NULL_VALUE) {
postponedActions.add {
with(instructions) {
insert(suspension.tryCatchBlockEndLabelAfterSuspensionCall, withInstructionAdapter {
@@ -658,7 +659,7 @@ class CoroutineTransformerMethodVisitor(
continue
}
val type = basicValue.type
val type = basicValue.type!!
val normalizedType = type.normalize()
val indexBySort = varsCountByType[normalizedType]?.plus(1) ?: 0

View File

@@ -1,11 +1,10 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.codegen.coroutines
import org.jetbrains.kotlin.codegen.inline.nodeText
import org.jetbrains.kotlin.codegen.optimization.boxing.isUnitInstance
import org.jetbrains.kotlin.codegen.optimization.common.MethodAnalyzer
import org.jetbrains.kotlin.codegen.optimization.common.asSequence
@@ -13,169 +12,136 @@ import org.jetbrains.kotlin.codegen.optimization.common.removeAll
import org.jetbrains.kotlin.codegen.optimization.fixStack.top
import org.jetbrains.kotlin.codegen.optimization.transformer.MethodTransformer
import org.jetbrains.kotlin.resolve.jvm.AsmTypes
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
import org.jetbrains.org.objectweb.asm.Opcodes
import org.jetbrains.org.objectweb.asm.Type
import org.jetbrains.org.objectweb.asm.tree.*
import org.jetbrains.org.objectweb.asm.tree.AbstractInsnNode
import org.jetbrains.org.objectweb.asm.tree.LabelNode
import org.jetbrains.org.objectweb.asm.tree.MethodNode
import org.jetbrains.org.objectweb.asm.tree.VarInsnNode
import org.jetbrains.org.objectweb.asm.tree.analysis.BasicInterpreter
import org.jetbrains.org.objectweb.asm.tree.analysis.BasicValue
import org.jetbrains.org.objectweb.asm.tree.analysis.Frame
import java.util.*
private class PossibleSpilledValue(val source: AbstractInsnNode, type: Type?) : BasicValue(type) {
val usages = mutableSetOf<AbstractInsnNode>()
override fun toString(): String = when {
source.opcode == Opcodes.ALOAD -> "" + (source as VarInsnNode).`var`
source.isUnitInstance() -> "U"
else -> error("unreachable")
}
override fun equals(other: Any?): Boolean =
other is PossibleSpilledValue && source == other.source
override fun hashCode(): Int = super.hashCode() xor source.hashCode()
}
private object NonSpillableValue : BasicValue(AsmTypes.OBJECT_TYPE) {
override fun equals(other: Any?): Boolean = other is NonSpillableValue
override fun toString(): String = "N"
}
private object ConstructedValue : BasicValue(AsmTypes.OBJECT_TYPE) {
override fun equals(other: Any?): Boolean = other is ConstructedValue
override fun toString(): String = "C"
}
fun BasicValue?.nonspillable(): BasicValue? = if (this?.type?.sort == Type.OBJECT) NonSpillableValue else this
private class RedundantSpillingInterpreter : BasicInterpreter(Opcodes.API_VERSION) {
val possibleSpilledValues = mutableSetOf<PossibleSpilledValue>()
override fun newOperation(insn: AbstractInsnNode): BasicValue? {
if (insn.opcode == Opcodes.NEW) return ConstructedValue
val basicValue = super.newOperation(insn)
return if (insn.isUnitInstance())
// Unit instances come from inlining suspend functions returning Unit.
// They can be spilled before they are eventually popped.
// Track them.
PossibleSpilledValue(insn, basicValue.type).also { possibleSpilledValues += it }
else basicValue.nonspillable()
}
override fun copyOperation(insn: AbstractInsnNode, value: BasicValue?): BasicValue? =
when (value) {
is ConstructedValue -> value
is PossibleSpilledValue -> {
value.usages += insn
if (insn.opcode == Opcodes.ALOAD || insn.opcode == Opcodes.ASTORE) value
else value.nonspillable()
}
else -> value?.nonspillable()
}
override fun naryOperation(insn: AbstractInsnNode, values: MutableList<out BasicValue?>): BasicValue? {
for (value in values.filterIsInstance<PossibleSpilledValue>()) {
value.usages += insn
}
return super.naryOperation(insn, values)?.nonspillable()
}
override fun merge(v: BasicValue?, w: BasicValue?): BasicValue? =
if (v is PossibleSpilledValue && w is PossibleSpilledValue && v.source == w.source) v
else v?.nonspillable()
}
// Inliner emits a lot of locals during inlining.
// Remove all of them since these locals are
// 1) going to be spilled into continuation object
// 2) breaking tail-call elimination
/**
* This pass removes unused Unit values. These typically occur as a result of inlining and could end up spilling
* into the continuation object or break tail-call elimination.
*
* Concretely, we remove "GETSTATIC kotlin/Unit.INSTANCE" instructions if they are unused, or all uses are either
* POP instructions, or ASTORE instructions to locals which are never read and are not named local variables.
*
* This pass does not touch [suspensionPoints], as later passes rely on the bytecode patterns around suspension points.
*/
internal class RedundantLocalsEliminationMethodTransformer(private val suspensionPoints: List<SuspensionPoint>) : MethodTransformer() {
override fun transform(internalClassName: String, methodNode: MethodNode) {
val interpreter = RedundantSpillingInterpreter()
val frames = MethodAnalyzer<BasicValue>(internalClassName, methodNode, interpreter).analyze()
val interpreter = UnitSourceInterpreter(methodNode.localVariables?.mapTo(mutableSetOf()) { it.index } ?: setOf())
val frames = interpreter.run(internalClassName, methodNode)
// Mark all unused instructions for deletion (except for labels which may be used in debug information)
val toDelete = mutableSetOf<AbstractInsnNode>()
for (spilledValue in interpreter.possibleSpilledValues.filter { it.usages.isNotEmpty() }) {
@Suppress("UNCHECKED_CAST")
val aloads = spilledValue.usages.filter { it.opcode == Opcodes.ALOAD } as List<VarInsnNode>
if (aloads.isEmpty()) continue
val slot = aloads.first().`var`
if (aloads.any { it.`var` != slot }) continue
for (aload in aloads) {
methodNode.instructions.set(aload, spilledValue.source.clone())
}
toDelete.addAll(spilledValue.usages.filter { it.opcode == Opcodes.ASTORE })
toDelete.add(spilledValue.source)
methodNode.instructions.asSequence().zip(frames.asSequence()).mapNotNullTo(toDelete) { (insn, frame) ->
insn.takeIf { frame == null && insn !is LabelNode }
}
for (pop in methodNode.instructions.asSequence().filter { it.opcode == Opcodes.POP }) {
val value = (frames[methodNode.instructions.indexOf(pop)]?.top() as? PossibleSpilledValue) ?: continue
if (value.usages.isEmpty() && value.source !in suspensionPoints) {
toDelete.add(pop)
toDelete.add(value.source)
}
}
// Remove unreachable instructions to simplify further analyses
for (index in frames.indices) {
if (frames[index] == null) {
val insn = methodNode.instructions[index]
if (insn !is LabelNode) {
toDelete.add(insn)
}
// Mark all spillable "GETSTATIC kotlin/Unit.INSTANCE" instructions for deletion
for ((unit, uses) in interpreter.unitUsageInformation) {
if (unit !in interpreter.unspillableUnitValues && unit !in suspensionPoints) {
toDelete += unit
toDelete += uses
}
}
methodNode.instructions.removeAll(toDelete)
}
private fun AbstractInsnNode.clone() = when (this) {
is FieldInsnNode -> FieldInsnNode(opcode, owner, name, desc)
is VarInsnNode -> VarInsnNode(opcode, `var`)
is InsnNode -> InsnNode(opcode)
is TypeInsnNode -> TypeInsnNode(opcode, desc)
else -> error("clone of $this is not implemented yet")
}
}
// Handy debugging routing
@Suppress("unused")
fun MethodNode.nodeTextWithFrames(frames: Array<*>): String {
var insns = nodeText.split("\n")
val first = insns.indexOfLast { it.trim().startsWith("@") } + 1
var last = insns.indexOfFirst { it.trim().startsWith("LOCALVARIABLE") }
if (last < 0) last = insns.size
val prefix = insns.subList(0, first).joinToString(separator = "\n")
val postfix = insns.subList(last, insns.size).joinToString(separator = "\n")
insns = insns.subList(first, last)
if (insns.any { it.contains("TABLESWITCH") }) {
var insideTableSwitch = false
var buffer = ""
val res = arrayListOf<String>()
for (insn in insns) {
if (insn.contains("TABLESWITCH")) {
insideTableSwitch = true
}
if (insideTableSwitch) {
buffer += insn
if (insn.contains("default")) {
insideTableSwitch = false
res += buffer
buffer = ""
continue
}
} else {
res += insn
// A version of SourceValue which inherits from BasicValue and is only used for Unit values.
private class UnitValue(val insns: Set<AbstractInsnNode>) : BasicValue(AsmTypes.OBJECT_TYPE) {
constructor(insn: AbstractInsnNode) : this(Collections.singleton(insn))
override fun equals(other: Any?): Boolean = other is UnitValue && insns == other.insns
override fun hashCode() = Objects.hash(insns)
override fun toString() = "U"
}
// A specialized SourceInterpreter which only keeps track of the use sites for Unit values which are exclusively used as
// arguments to POP and unused ASTORE instructions.
private class UnitSourceInterpreter(private val localVariables: Set<Int>) : BasicInterpreter(Opcodes.API_VERSION) {
// All unit values with visible use-sites.
val unspillableUnitValues = mutableSetOf<AbstractInsnNode>()
// Map from unit values to ASTORE/POP use-sites.
val unitUsageInformation = mutableMapOf<AbstractInsnNode, MutableSet<AbstractInsnNode>>()
private fun markUnspillable(value: BasicValue?) =
value?.safeAs<UnitValue>()?.let { unspillableUnitValues += it.insns }
private fun collectUnitUsage(use: AbstractInsnNode, value: UnitValue) {
for (def in value.insns) {
if (def !in unspillableUnitValues) {
unitUsageInformation.getOrPut(def) { mutableSetOf() } += use
}
}
insns = res
}
return prefix + "\n" + insns.withIndex().joinToString(separator = "\n") { (index, insn) ->
if (index >= frames.size) "N/A\t$insn" else "${frames[index]}\t$insn"
} + "\n" + postfix
fun run(internalClassName: String, methodNode: MethodNode): Array<Frame<BasicValue>?> {
val frames = MethodAnalyzer<BasicValue>(internalClassName, methodNode, this).analyze()
// The ASM analyzer does not visit POP instructions, so we do so here.
for ((insn, frame) in methodNode.instructions.asSequence().zip(frames.asSequence())) {
if (frame != null && insn.opcode == Opcodes.POP) {
val value = frame.top()
value.safeAs<UnitValue>()?.let { collectUnitUsage(insn, it) }
}
}
return frames
}
override fun newOperation(insn: AbstractInsnNode?): BasicValue =
if (insn?.isUnitInstance() == true) UnitValue(insn) else super.newOperation(insn)
override fun copyOperation(insn: AbstractInsnNode, value: BasicValue?): BasicValue? {
if (value is UnitValue) {
if (insn is VarInsnNode && insn.opcode == Opcodes.ASTORE && insn.`var` !in localVariables) {
collectUnitUsage(insn, value)
// We track the stored value in case it is subsequently read.
return value
}
unspillableUnitValues += value.insns
}
return super.copyOperation(insn, value)
}
override fun unaryOperation(insn: AbstractInsnNode, value: BasicValue?): BasicValue? {
markUnspillable(value)
return super.unaryOperation(insn, value)
}
override fun binaryOperation(insn: AbstractInsnNode, value1: BasicValue?, value2: BasicValue?): BasicValue? {
markUnspillable(value1)
markUnspillable(value2)
return super.binaryOperation(insn, value1, value2)
}
override fun ternaryOperation(insn: AbstractInsnNode, value1: BasicValue?, value2: BasicValue?, value3: BasicValue?): BasicValue? {
markUnspillable(value1)
markUnspillable(value2)
markUnspillable(value3)
return super.ternaryOperation(insn, value1, value2, value3)
}
override fun naryOperation(insn: AbstractInsnNode, values: List<BasicValue>?): BasicValue? {
values?.forEach(this::markUnspillable)
return super.naryOperation(insn, values)
}
override fun merge(value1: BasicValue?, value2: BasicValue?): BasicValue? =
if (value1 is UnitValue && value2 is UnitValue) {
UnitValue(value1.insns.union(value2.insns))
} else {
// Mark unit values as unspillable if we merge them with non-unit values here.
// This is conservative since the value could turn out to be unused.
markUnspillable(value1)
markUnspillable(value2)
super.merge(value1, value2)
}
}

View File

@@ -0,0 +1,160 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.codegen.coroutines
import org.jetbrains.kotlin.codegen.StackValue
import org.jetbrains.kotlin.codegen.optimization.common.MethodAnalyzer
import org.jetbrains.kotlin.codegen.optimization.common.OptimizationBasicInterpreter
import org.jetbrains.org.objectweb.asm.Label
import org.jetbrains.org.objectweb.asm.Opcodes
import org.jetbrains.org.objectweb.asm.Type
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
import org.jetbrains.org.objectweb.asm.tree.*
import org.jetbrains.org.objectweb.asm.tree.analysis.BasicValue
import org.jetbrains.org.objectweb.asm.tree.analysis.Frame
// BasicValue interpreter from ASM does not distinct 'int' types from other int-like types like 'byte' or 'boolean',
// neither do HotSpot and JVM spec.
// But it seems like Dalvik does not follow it, and spilling boolean value into an 'int' field fails with VerifyError on Android 4,
// so this function calculates refined frames' markup.
// Note that type of some values is only possible to determine by their usages (e.g. ICONST_1, BALOAD both may push boolean or byte on stack)
// In this case, coerce the type of the value.
internal class IloadedValue(val insns: Set<VarInsnNode>) : BasicValue(Type.INT_TYPE)
private class IntLikeCoerceInterpreter : OptimizationBasicInterpreter() {
val needsToBeCoerced = mutableMapOf<VarInsnNode, Type>()
private fun coerce(value: IloadedValue, type: Type) {
for (insn in value.insns) {
needsToBeCoerced[insn] = type
}
}
override fun copyOperation(insn: AbstractInsnNode, value: BasicValue?): BasicValue? =
when {
insn.opcode == Opcodes.ILOAD -> IloadedValue(setOf(insn as VarInsnNode))
value == null -> null
else -> BasicValue(value.type)
}
override fun binaryOperation(insn: AbstractInsnNode, v: BasicValue, w: BasicValue): BasicValue? {
if (insn.opcode == Opcodes.PUTFIELD) {
val expectedType = Type.getType((insn as FieldInsnNode).desc)
if (w is IloadedValue && expectedType.isIntLike()) {
coerce(w, expectedType)
}
}
return super.binaryOperation(insn, v, w)
}
override fun unaryOperation(insn: AbstractInsnNode, value: BasicValue?): BasicValue? {
if (insn.opcode == Opcodes.PUTSTATIC) {
val expectedType = Type.getType((insn as FieldInsnNode).desc)
if (value is IloadedValue && expectedType.isIntLike()) {
coerce(value, expectedType)
}
}
return super.unaryOperation(insn, value)
}
override fun naryOperation(insn: AbstractInsnNode, values: MutableList<out BasicValue?>): BasicValue? {
fun checkTypes(argTypes: Array<Type>, withReceiver: Boolean) {
val offset = if (withReceiver) 1 else 0
for ((index, argType) in argTypes.withIndex()) {
val value = values[index + offset] ?: continue
if (argType.isIntLike() && value is IloadedValue) {
coerce(value, argType)
}
}
}
when (insn.opcode) {
Opcodes.INVOKEDYNAMIC -> {
checkTypes(Type.getArgumentTypes((insn as InvokeDynamicInsnNode).desc), false)
}
Opcodes.INVOKESTATIC -> {
checkTypes(Type.getArgumentTypes((insn as MethodInsnNode).desc), false)
}
Opcodes.INVOKEVIRTUAL, Opcodes.INVOKEINTERFACE, Opcodes.INVOKESPECIAL -> {
checkTypes(Type.getArgumentTypes((insn as MethodInsnNode).desc), true)
}
}
return super.naryOperation(insn, values)
}
override fun ternaryOperation(insn: AbstractInsnNode, arrayref: BasicValue?, index: BasicValue?, value: BasicValue?): BasicValue? {
when (insn.opcode) {
Opcodes.BASTORE -> {
if (value is IloadedValue) {
val type = if (arrayref?.type?.descriptor == "[Z") Type.BOOLEAN_TYPE else Type.BYTE_TYPE
coerce(value, type)
}
}
Opcodes.CASTORE -> {
if (value is IloadedValue) {
coerce(value, Type.CHAR_TYPE)
}
}
Opcodes.SASTORE -> {
if (value is IloadedValue) {
coerce(value, Type.SHORT_TYPE)
}
}
}
return super.ternaryOperation(insn, arrayref, index, value)
}
override fun merge(v: BasicValue, w: BasicValue): BasicValue =
when {
v is IloadedValue && w is IloadedValue && v.type == w.type -> {
val insns = v.insns + w.insns
insns.find { it in needsToBeCoerced }?.let {
val type = needsToBeCoerced[it]!!
coerce(v, type)
coerce(w, type)
}
IloadedValue(insns)
}
v.type == w.type -> {
if (w is IloadedValue) w else v
}
else -> super.merge(v, w)
}
}
internal fun performSpilledVariableFieldTypesAnalysis(
methodNode: MethodNode,
thisName: String
): Array<out Frame<BasicValue>?> {
val interpreter = IntLikeCoerceInterpreter()
MethodAnalyzer(thisName, methodNode, interpreter).analyze()
for ((insn, type) in interpreter.needsToBeCoerced) {
methodNode.instructions.insert(insn, withInstructionAdapter { coerceInt(type, this) })
}
return MethodAnalyzer(thisName, methodNode, OptimizationBasicInterpreter()).analyze()
}
private fun coerceInt(to: Type, v: InstructionAdapter) {
if (to == Type.BOOLEAN_TYPE) {
with(v) {
val zeroLabel = Label()
val resLabel = Label()
ifeq(zeroLabel)
iconst(1)
goTo(resLabel)
mark(zeroLabel)
iconst(0)
mark(resLabel)
}
} else {
StackValue.coerce(Type.INT_TYPE, to, v)
}
}
private fun Type.isIntLike(): Boolean = when (sort) {
Type.BOOLEAN, Type.BYTE, Type.CHAR, Type.SHORT -> true
else -> false
}

View File

@@ -12,6 +12,7 @@ import org.jetbrains.kotlin.codegen.inline.addFakeContinuationConstructorCallMar
import org.jetbrains.kotlin.codegen.inline.coroutines.FOR_INLINE_SUFFIX
import org.jetbrains.kotlin.codegen.inline.preprocessSuspendMarkers
import org.jetbrains.kotlin.codegen.state.GenerationState
import org.jetbrains.kotlin.config.JVMConfigurationKeys
import org.jetbrains.kotlin.config.JVMConstructorCallNormalizationMode
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.config.languageVersionSettings
@@ -95,7 +96,8 @@ class SuspendFunctionGenerationStrategy(
languageVersionSettings = languageVersionSettings,
disableTailCallOptimizationForFunctionReturningUnit = originalSuspendDescriptor.returnType?.isUnit() == true &&
originalSuspendDescriptor.overriddenDescriptors.isNotEmpty() &&
!originalSuspendDescriptor.allOverriddenFunctionsReturnUnit()
!originalSuspendDescriptor.allOverriddenFunctionsReturnUnit(),
useOldSpilledVarTypeAnalysis = state.configuration.getBoolean(JVMConfigurationKeys.USE_OLD_SPILLED_VAR_TYPE_ANALYSIS)
)
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/

View File

@@ -128,7 +128,7 @@ fun createFreeFakeLocalPropertyDescriptor(descriptor: LocalVariableDescriptor, t
val property = PropertyDescriptorImpl.create(
descriptor.containingDeclaration, descriptor.annotations, Modality.FINAL, descriptor.visibility, descriptor.isVar,
descriptor.name, CallableMemberDescriptor.Kind.DECLARATION, descriptor.source, false, descriptor.isConst,
false, false, false, @Suppress("DEPRECATION") descriptor.isDelegated
false, false, false, descriptor.isDelegated
)
property.setType(
descriptor.type, descriptor.typeParameters,

View File

@@ -15,7 +15,10 @@ import org.jetbrains.kotlin.codegen.inline.coroutines.FOR_INLINE_SUFFIX
import org.jetbrains.kotlin.codegen.intrinsics.IntrinsicArrayConstructors
import org.jetbrains.kotlin.codegen.state.GenerationState
import org.jetbrains.kotlin.codegen.state.KotlinTypeMapper
import org.jetbrains.kotlin.config.CommonConfigurationKeys
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.incremental.components.Position
import org.jetbrains.kotlin.incremental.components.ScopeKind
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.renderer.DescriptorRenderer
@@ -87,12 +90,9 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
isSameModule = sourceCompiler.isCallInsideSameModuleAsDeclared(functionDescriptor)
if (functionDescriptor !is FictitiousArrayConstructor) {
val functionOrAccessorName = jvmSignature.asmMethod.name
//track changes for property accessor and @JvmName inline functions/property accessors
if (functionOrAccessorName != functionDescriptor.name.asString()) {
val scope = getMemberScope(functionDescriptor)
//Fake lookup to track track changes for property accessors and @JvmName functions/property accessors
scope?.getContributedFunctions(Name.identifier(functionOrAccessorName), sourceCompiler.lookupLocation)
if (jvmSignature.asmMethod.name != functionDescriptor.name.asString()) {
trackLookup(functionDescriptor)
}
}
}
@@ -500,19 +500,24 @@ abstract class InlineCodegen<out T : BaseExpressionCodegen>(
return true
}
private fun trackLookup(functionOrAccessor: FunctionDescriptor) {
val functionOrAccessorName = jvmSignature.asmMethod.name
val lookupTracker = state.configuration.get(CommonConfigurationKeys.LOOKUP_TRACKER) ?: return
val location = sourceCompiler.lookupLocation.location ?: return
val position = if (lookupTracker.requiresPosition) location.position else Position.NO_POSITION
val classOrPackageFragment = functionOrAccessor.containingDeclaration
lookupTracker.record(
location.filePath,
position,
DescriptorUtils.getFqName(classOrPackageFragment).asString(),
ScopeKind.CLASSIFIER,
functionOrAccessorName
)
}
companion object {
private fun getMemberScope(functionOrAccessor: FunctionDescriptor): MemberScope? {
val callableMemberDescriptor = JvmCodegenUtil.getDirectMember(functionOrAccessor)
val classOrPackageFragment = callableMemberDescriptor.containingDeclaration
return when (classOrPackageFragment) {
is ClassDescriptor -> classOrPackageFragment.unsubstitutedMemberScope
is PackageFragmentDescriptor -> classOrPackageFragment.getMemberScope()
else -> null
}
}
internal fun createInlineMethodNode(
functionDescriptor: FunctionDescriptor,
methodOwner: Type,

View File

@@ -12,6 +12,7 @@ import org.jetbrains.kotlin.codegen.coroutines.*
import org.jetbrains.kotlin.codegen.inline.*
import org.jetbrains.kotlin.codegen.optimization.common.asSequence
import org.jetbrains.kotlin.codegen.optimization.transformer.MethodTransformer
import org.jetbrains.kotlin.config.JVMConfigurationKeys
import org.jetbrains.kotlin.config.isReleaseCoroutines
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
@@ -95,7 +96,8 @@ class CoroutineTransformer(
shouldPreserveClassInitialization = state.constructorCallNormalizationMode.shouldPreserveClassInitialization,
containingClassInternalName = classBuilder.thisName,
isForNamedFunction = false,
disableTailCallOptimizationForFunctionReturningUnit = false
disableTailCallOptimizationForFunctionReturningUnit = false,
useOldSpilledVarTypeAnalysis = state.configuration.getBoolean(JVMConfigurationKeys.USE_OLD_SPILLED_VAR_TYPE_ANALYSIS)
)
if (generateForInline)
@@ -131,7 +133,8 @@ class CoroutineTransformer(
needDispatchReceiver = true,
internalNameForDispatchReceiver = classBuilder.thisName,
disableTailCallOptimizationForFunctionReturningUnit = disableTailCallOptimization,
putContinuationParameterToLvt = !state.isIrBackend
putContinuationParameterToLvt = !state.isIrBackend,
useOldSpilledVarTypeAnalysis = state.configuration.getBoolean(JVMConfigurationKeys.USE_OLD_SPILLED_VAR_TYPE_ANALYSIS)
)
if (generateForInline)

View File

@@ -242,6 +242,17 @@ class CapturedVarsOptimizationMethodTransformer : MethodTransformer() {
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.
private fun InsnList.removeOrReplaceByNop(insn: AbstractInsnNode) {
if (insn.previous is LineNumberNode && insn.next is LabelNode && insn.next.next is LineNumberNode) {
set(insn, InsnNode(Opcodes.NOP))
} else {
remove(insn)
}
}
private fun rewriteRefValue(capturedVar: CapturedVarDescriptor) {
methodNode.instructions.run {
val localVar = capturedVar.localVar!!
@@ -259,9 +270,10 @@ class CapturedVarsOptimizationMethodTransformer : MethodTransformer() {
remove(capturedVar.newInsn)
remove(capturedVar.initCallInsn!!)
capturedVar.stackInsns.forEach { remove(it) }
capturedVar.aloadInsns.forEach { remove(it) }
capturedVar.astoreInsns.forEach { remove(it) }
capturedVar.stackInsns.forEach { removeOrReplaceByNop(it) }
capturedVar.aloadInsns.forEach { removeOrReplaceByNop(it) }
capturedVar.astoreInsns.forEach { removeOrReplaceByNop(it) }
capturedVar.getFieldInsns.forEach { set(it, VarInsnNode(loadOpcode, capturedVar.localVarIndex)) }
capturedVar.putFieldInsns.forEach { set(it, VarInsnNode(storeOpcode, capturedVar.localVarIndex)) }
@@ -273,6 +285,7 @@ class CapturedVarsOptimizationMethodTransformer : MethodTransformer() {
}
}
}
}
}

View File

@@ -74,7 +74,6 @@ fun ExpressionCodegen.createRangeValueForExpression(rangeExpression: KtExpressio
}
}
@Suppress("DEPRECATION")
fun isLocalVarReference(rangeExpression: KtExpression, bindingContext: BindingContext): Boolean {
if (rangeExpression !is KtSimpleNameExpression) return false
val resultingDescriptor = rangeExpression.getResolvedCall(bindingContext)?.resultingDescriptor ?: return false

View File

@@ -94,7 +94,13 @@ class JvmSerializerExtension @JvmOverloads constructor(
writeVersionRequirementForJvmDefaultIfNeeded(descriptor, proto, versionRequirementTable)
if (jvmDefaultMode.forAllMethodsWithBody && isInterface(descriptor)) {
proto.setExtension(JvmProtoBuf.jvmClassFlags, JvmFlags.getClassFlags(true))
proto.setExtension(
JvmProtoBuf.jvmClassFlags,
JvmFlags.getClassFlags(
jvmDefaultMode.forAllMethodsWithBody,
JvmDefaultMode.ALL_COMPATIBILITY == jvmDefaultMode
)
)
}
}

View File

@@ -23,7 +23,9 @@ import org.jetbrains.kotlin.codegen.signature.BothSignatureWriter
import org.jetbrains.kotlin.codegen.signature.JvmSignatureWriter
import org.jetbrains.kotlin.config.*
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.impl.*
import org.jetbrains.kotlin.descriptors.impl.LocalVariableAccessorDescriptor
import org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor
import org.jetbrains.kotlin.descriptors.impl.TypeAliasConstructorDescriptor
import org.jetbrains.kotlin.fileClasses.JvmFileClassUtil
import org.jetbrains.kotlin.load.java.BuiltinMethodsWithSpecialGenericSignature
import org.jetbrains.kotlin.load.java.JvmAbi
@@ -1208,7 +1210,7 @@ class KotlinTypeMapper @JvmOverloads constructor(
return StackValue.sharedTypeForType(mapType(receiverParameter.type))
}
if (descriptor is LocalVariableDescriptor && @Suppress("DEPRECATION") descriptor.isDelegated) {
if (descriptor is LocalVariableDescriptor && descriptor.isDelegated) {
return null
}

View File

@@ -51,7 +51,7 @@ class BuiltInsSerializer(dependOnOldBuiltIns: Boolean) : MetadataSerializer(Buil
put(CommonConfigurationKeys.MODULE_NAME, "module for built-ins serialization")
}
val environment = KotlinCoreEnvironment.createForTests(rootDisposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES)
val environment = KotlinCoreEnvironment.createForProduction(rootDisposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES)
serialize(environment)

View File

@@ -340,6 +340,12 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
)
var explicitApi: String by FreezableVar(ExplicitApiMode.DISABLED.state)
@Argument(
value = "-Xdeserialize-fake-overrides",
description = "Fallback to deserializing fake overrides"
)
var deserializeFakeOverrides: Boolean by FreezableVar(false)
open fun configureAnalysisFlags(collector: MessageCollector): MutableMap<AnalysisFlag<*>, Any> {
return HashMap<AnalysisFlag<*>, Any>().apply {
put(AnalysisFlags.skipMetadataVersionCheck, skipMetadataVersionCheck)

View File

@@ -135,6 +135,9 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
)
var irModuleName: String? by NullableStringFreezableVar(null)
@Argument(value = "-Xir-per-module", description = "Splits generated .js per-module")
var irPerModule: Boolean by FreezableVar(false)
@Argument(
value = "-Xinclude",
valueDescription = "<path>",
@@ -169,6 +172,9 @@ class K2JSCompilerArguments : CommonCompilerArguments() {
@Argument(value = "-Xenable-js-scripting", description = "Enable experimental support of .kts files using K/JS (with -Xir only)")
var enableJsScripting: Boolean by FreezableVar(false)
@Argument(value = "-Xdisable-fake-override-validator", description = "Disable IR fake override validator")
var disableFakeOverrideValidator: Boolean by FreezableVar(false)
override fun checkIrSupport(languageVersionSettings: LanguageVersionSettings, collector: MessageCollector) {
if (!isIrBackendEnabled()) return

View File

@@ -369,6 +369,12 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
)
var repeatCompileModules: String? by NullableStringFreezableVar(null)
@Argument(
value = "-Xuse-old-spilled-var-type-analysis",
description = "Use old, SourceInterpreter-based analysis for fields, used for spilled variables in coroutines"
)
var useOldSpilledVarTypeAnalysis: Boolean by FreezableVar(false)
override fun configureAnalysisFlags(collector: MessageCollector): MutableMap<AnalysisFlag<*>, Any> {
val result = super.configureAnalysisFlags(collector)
result[JvmAnalysisFlags.strictMetadataVersionSemantics] = strictMetadataVersionSemantics

View File

@@ -229,14 +229,19 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
mainArguments = mainCallArguments,
generateFullJs = !arguments.irDce,
generateDceJs = arguments.irDce,
dceDriven = arguments.irDceDriven
dceDriven = arguments.irDceDriven,
multiModule = arguments.irPerModule,
relativeRequirePath = true
)
} catch (e: JsIrCompilationError) {
return COMPILATION_ERROR
}
val jsCode = if (arguments.irDce && !arguments.irDceDriven) compiledModule.dceJsCode!! else compiledModule.jsCode!!
outputFile.writeText(jsCode)
outputFile.writeText(jsCode.mainModule)
jsCode.dependencies.forEach { (name, content) ->
outputFile.resolveSibling("$name.js").writeText(content)
}
if (arguments.generateDts) {
val dtsFile = outputFile.withReplacedExtensionOrNull(outputFile.extension, "d.ts")!!
dtsFile.writeText(compiledModule.tsDefinitions ?: error("No ts definitions"))
@@ -322,6 +327,7 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
}
configuration.put(JSConfigurationKeys.PRINT_REACHABILITY_INFO, arguments.irDcePrintReachabilityInfo)
configuration.put(JSConfigurationKeys.DISABLE_FAKE_OVERRIDE_VALIDATOR, arguments.disableFakeOverrideValidator)
}
override fun executableScriptFileName(): String {

View File

@@ -45,7 +45,7 @@ abstract class CLICompiler<A : CommonCompilerArguments> : CLITool<A>() {
protected abstract val performanceManager: CommonCompilerPerformanceManager
protected open fun createPerformanceManager(arguments: A): CommonCompilerPerformanceManager = performanceManager
protected open fun createPerformanceManager(arguments: A, services: Services): CommonCompilerPerformanceManager = performanceManager
// Used in CompilerRunnerUtil#invokeExecMethod, in Eclipse plugin (KotlinCLICompiler) and in kotlin-gradle-plugin (GradleCompilerRunner)
fun execAndOutputXml(errStream: PrintStream, services: Services, vararg args: String): ExitCode {
@@ -58,7 +58,7 @@ abstract class CLICompiler<A : CommonCompilerArguments> : CLITool<A>() {
}
public override fun execImpl(messageCollector: MessageCollector, services: Services, arguments: A): ExitCode {
val performanceManager = createPerformanceManager(arguments)
val performanceManager = createPerformanceManager(arguments, services)
if (arguments.reportPerf || arguments.dumpPerf != null) {
performanceManager.enableCollectingPerformanceStatistics()
}

View File

@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.cli.common
import org.jetbrains.kotlin.util.PerformanceCounter
import java.io.File
import java.lang.management.GarbageCollectorMXBean
import java.lang.management.ManagementFactory
import java.util.concurrent.TimeUnit
@@ -18,13 +19,21 @@ abstract class CommonCompilerPerformanceManager(private val presentableName: Str
private var analysisStart: Long = 0
private var generationStart: Long = 0
private var startGCData = mutableMapOf<String, GCData>()
private var irTranslationStart: Long = 0
private var irGenerationStart: Long = 0
fun getMeasurementResults(): List<PerformanceMeasurement> = measurements
fun enableCollectingPerformanceStatistics() {
isEnabled = true
PerformanceCounter.setTimeCounterEnabled(true)
ManagementFactory.getGarbageCollectorMXBeans().associateTo(startGCData) { it.name to GCData(it) }
}
private fun deltaTime(start: Long): Long = PerformanceCounter.currentTime() - start
open fun notifyCompilerInitialized() {
if (!isEnabled) return
recordInitializationTime()
@@ -50,9 +59,39 @@ abstract class CommonCompilerPerformanceManager(private val presentableName: Str
generationStart = PerformanceCounter.currentTime()
}
open fun notifyGenerationFinished(lines: Int, files: Int, additionalDescription: String) {
open fun notifyGenerationFinished(files: Int, lines: Int, additionalDescription: String) {
val time = PerformanceCounter.currentTime() - generationStart
measurements += CodeGenerationMeasurement(lines, files, TimeUnit.NANOSECONDS.toMillis(time), additionalDescription)
measurements += CodeGenerationMeasurement(files, lines, TimeUnit.NANOSECONDS.toMillis(time), additionalDescription)
}
open fun notifyIRTranslationStarted() {
irTranslationStart = PerformanceCounter.currentTime()
}
open fun notifyIRTranslationFinished(files: Int, lines: Int, additionalDescription: String?) {
val time = deltaTime(irTranslationStart)
measurements += IRMeasurement(
files,
lines,
TimeUnit.NANOSECONDS.toMillis(time),
additionalDescription,
IRMeasurement.Kind.Translation
)
}
open fun notifyIRGenerationStarted() {
irGenerationStart = PerformanceCounter.currentTime()
}
open fun notifyIRGenerationFinished(files: Int, lines: Int, additionalDescription: String) {
val time = deltaTime(irGenerationStart)
measurements += IRMeasurement(
files,
lines,
TimeUnit.NANOSECONDS.toMillis(time),
additionalDescription,
IRMeasurement.Kind.Generation
)
}
fun dumpPerformanceReport(destination: File) {
@@ -63,7 +102,14 @@ abstract class CommonCompilerPerformanceManager(private val presentableName: Str
if (!isEnabled) return
ManagementFactory.getGarbageCollectorMXBeans().forEach {
measurements += GarbageCollectionMeasurement(it.name, it.collectionTime)
val startCounts = startGCData[it.name]
val startCollectionTime = startCounts?.collectionTime ?: 0
val startCollectionCount = startCounts?.collectionCount ?: 0
measurements += GarbageCollectionMeasurement(
it.name,
it.collectionTime - startCollectionTime,
it.collectionCount - startCollectionCount
)
}
}
@@ -89,4 +135,8 @@ abstract class CommonCompilerPerformanceManager(private val presentableName: Str
}.toByteArray()
open fun notifyRepeat(total: Int, number: Int) {}
private data class GCData(val name: String, val collectionTime: Long, val collectionCount: Long) {
constructor(bean: GarbageCollectorMXBean) : this(bean.name, bean.collectionTime, bean.collectionCount)
}
}

View File

@@ -26,6 +26,7 @@ fun <A : CommonCompilerArguments> CompilerConfiguration.setupCommonArguments(
put(CommonConfigurationKeys.EXPECT_ACTUAL_LINKER, arguments.expectActualLinker)
putIfNotNull(CLIConfigurationKeys.INTELLIJ_PLUGIN_ROOT, arguments.intellijPluginRoot)
put(CommonConfigurationKeys.REPORT_OUTPUT_FILES, arguments.reportOutputFiles)
put(CommonConfigurationKeys.DESERIALIZE_FAKE_OVERRIDES, arguments.deserializeFakeOverrides)
val metadataVersionString = arguments.metadataVersion
if (metadataVersionString != null) {

View File

@@ -20,13 +20,13 @@ class CompilerInitializationMeasurement(private val milliseconds: Long) : Perfor
}
class CodeAnalysisMeasurement(private val files: Int, val lines: Int, private val milliseconds: Long, private val description: String?) :
class CodeAnalysisMeasurement(val files: Int, val lines: Int, val milliseconds: Long, private val description: String?) :
PerformanceMeasurement {
private val speed: Double = lines.toDouble() * 1000 / milliseconds
val lps: Double = lines.toDouble() * 1000 / milliseconds
override fun render(): String =
"ANALYZE: $files files ($lines lines) ${description ?: ""}in $milliseconds ms - ${"%.3f".format(speed)} loc/s"
"ANALYZE: $files files ($lines lines) ${description ?: ""}in $milliseconds ms - ${"%.3f".format(lps)} loc/s"
}
@@ -40,11 +40,23 @@ class CodeGenerationMeasurement(private val files: Int, val lines: Int, private
}
class GarbageCollectionMeasurement(private val garbageCollectionKind: String, private val milliseconds: Long) : PerformanceMeasurement {
override fun render(): String = "GC time for $garbageCollectionKind is $milliseconds ms"
class GarbageCollectionMeasurement(val garbageCollectionKind: String, val milliseconds: Long, val count: Long) : PerformanceMeasurement {
override fun render(): String = "GC time for $garbageCollectionKind is $milliseconds ms, $count collections"
}
class PerformanceCounterMeasurement(private val counterReport: String) : PerformanceMeasurement {
override fun render(): String = counterReport
}
class IRMeasurement(val files: Int, val lines: Int, val milliseconds: Long, private val description: String?, val kind: Kind) :
PerformanceMeasurement {
val lps: Double = lines.toDouble() * 1000 / milliseconds
override fun render(): String =
"IR: $kind $files files ($lines lines) ${description ?: ""}in $milliseconds ms - ${"%.3f".format(lps)} loc/s"
enum class Kind {
Generation, Translation
}
}

View File

@@ -267,7 +267,9 @@ class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
override val performanceManager: CommonCompilerPerformanceManager
get() = error("Unsupported")
override fun createPerformanceManager(arguments: K2JVMCompilerArguments): CommonCompilerPerformanceManager {
override fun createPerformanceManager(arguments: K2JVMCompilerArguments, services: Services): CommonCompilerPerformanceManager {
val externalManager = services[CommonCompilerPerformanceManager::class.java]
if (externalManager != null) return externalManager
val argument = arguments.profileCompilerCommand ?: return K2JVMCompilerPerformanceManager()
return ProfilingCompilerPerformanceManager.create(argument)
}

View File

@@ -4,147 +4,52 @@
*/
package org.jetbrains.kotlin.cli.jvm.compiler;
import com.intellij.DynamicBundle;
import com.intellij.codeInsight.ContainerProvider;
import com.intellij.codeInsight.JavaContainerProvider;
import com.intellij.codeInsight.folding.JavaCodeFoldingSettings;
import com.intellij.codeInsight.folding.impl.JavaCodeFoldingSettingsBase;
import com.intellij.codeInsight.folding.impl.JavaFoldingBuilderBase;
import com.intellij.codeInsight.runner.JavaMainMethodProvider;
import com.intellij.core.CoreApplicationEnvironment;
import com.intellij.core.CoreJavaDirectoryService;
import com.intellij.core.CorePsiPackageImplementationHelper;
import com.intellij.ide.highlighter.ArchiveFileType;
import com.intellij.ide.highlighter.JavaClassFileType;
import com.intellij.ide.highlighter.JavaFileType;
import com.intellij.lang.LanguageASTFactory;
import com.intellij.core.JavaCoreApplicationEnvironment;
import com.intellij.lang.MetaLanguage;
import com.intellij.lang.folding.LanguageFolding;
import com.intellij.lang.java.JavaLanguage;
import com.intellij.lang.java.JavaParserDefinition;
import com.intellij.navigation.ItemPresentationProviders;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.extensions.ExtensionsArea;
import com.intellij.openapi.fileTypes.FileTypeExtensionPoint;
import com.intellij.openapi.fileTypes.PlainTextFileType;
import com.intellij.openapi.fileTypes.PlainTextLanguage;
import com.intellij.openapi.fileTypes.PlainTextParserDefinition;
import com.intellij.openapi.projectRoots.JavaVersionService;
import com.intellij.openapi.vfs.VirtualFileSystem;
import com.intellij.psi.*;
import com.intellij.psi.FileContextProvider;
import com.intellij.psi.augment.PsiAugmentProvider;
import com.intellij.psi.augment.TypeAnnotationModifier;
import com.intellij.psi.compiled.ClassFileDecompilers;
import com.intellij.psi.impl.LanguageConstantExpressionEvaluator;
import com.intellij.psi.impl.PsiExpressionEvaluator;
import com.intellij.psi.impl.PsiSubstitutorFactoryImpl;
import com.intellij.psi.impl.compiled.ClassFileStubBuilder;
import com.intellij.psi.impl.file.PsiPackageImplementationHelper;
import com.intellij.psi.impl.search.MethodSuperSearcher;
import com.intellij.psi.impl.source.tree.JavaASTFactory;
import com.intellij.psi.impl.source.tree.PlainTextASTFactory;
import com.intellij.psi.meta.MetaDataContributor;
import com.intellij.psi.presentation.java.*;
import com.intellij.psi.search.searches.SuperMethodsSearch;
import com.intellij.psi.stubs.BinaryFileStubBuilders;
import com.intellij.util.QueryExecutor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.cli.jvm.modules.CoreJrtFileSystem;
/**
* adapted from com.intellij.core.JavaCoreApplicationEnvironment
* TODO: initiate removal original from com.intellij.core since it seems that there are no usages left
*/
public class KotlinCoreApplicationEnvironment extends CoreApplicationEnvironment {
public class KotlinCoreApplicationEnvironment extends JavaCoreApplicationEnvironment {
public static KotlinCoreApplicationEnvironment create(@NotNull Disposable parentDisposable, boolean unitTestMode) {
KotlinCoreApplicationEnvironment environment = new KotlinCoreApplicationEnvironment(parentDisposable, unitTestMode);
registerExtensionPoints();
return environment;
}
public static KotlinCoreApplicationEnvironment create(@NotNull Disposable parentDisposable, boolean unitTestMode) {
return new KotlinCoreApplicationEnvironment(parentDisposable, unitTestMode);
}
private KotlinCoreApplicationEnvironment(@NotNull Disposable parentDisposable, boolean unitTestMode) {
super(parentDisposable, unitTestMode);
}
private KotlinCoreApplicationEnvironment(@NotNull Disposable parentDisposable, boolean unitTestMode) {
super(parentDisposable, unitTestMode);
private static void registerExtensionPoints() {
registerApplicationExtensionPoint(DynamicBundle.LanguageBundleEP.EP_NAME, DynamicBundle.LanguageBundleEP.class);
registerApplicationExtensionPoint(FileContextProvider.EP_NAME, FileContextProvider.class);
registerExtensionPoints();
registerApplicationExtensionPoint(MetaDataContributor.EP_NAME, MetaDataContributor.class);
registerApplicationExtensionPoint(PsiAugmentProvider.EP_NAME, PsiAugmentProvider.class);
registerApplicationExtensionPoint(JavaMainMethodProvider.EP_NAME, JavaMainMethodProvider.class);
registerExtensions();
}
registerApplicationExtensionPoint(ContainerProvider.EP_NAME, ContainerProvider.class);
registerApplicationExtensionPoint(ClassFileDecompilers.EP_NAME, ClassFileDecompilers.Decompiler.class);
private void registerExtensionPoints() {
ExtensionsArea area = Extensions.getRootArea();
registerApplicationExtensionPoint(MetaLanguage.EP_NAME, MetaLanguage.class);
CoreApplicationEnvironment.registerExtensionPoint(area, BinaryFileStubBuilders.EP_NAME, FileTypeExtensionPoint.class);
CoreApplicationEnvironment.registerExtensionPoint(area, FileContextProvider.EP_NAME, FileContextProvider.class);
IdeaExtensionPoints.INSTANCE.registerVersionSpecificAppExtensionPoints(Extensions.getRootArea());
}
CoreApplicationEnvironment.registerExtensionPoint(area, MetaDataContributor.EP_NAME, MetaDataContributor.class);
CoreApplicationEnvironment.registerExtensionPoint(area, PsiAugmentProvider.EP_NAME, PsiAugmentProvider.class);
CoreApplicationEnvironment.registerExtensionPoint(area, JavaMainMethodProvider.EP_NAME, JavaMainMethodProvider.class);
CoreApplicationEnvironment.registerExtensionPoint(area, ContainerProvider.EP_NAME, ContainerProvider.class);
CoreApplicationEnvironment.registerExtensionPoint(area, ClassFileDecompilers.EP_NAME, ClassFileDecompilers.Decompiler.class);
CoreApplicationEnvironment.registerExtensionPoint(area, TypeAnnotationModifier.EP_NAME, TypeAnnotationModifier.class);
CoreApplicationEnvironment.registerExtensionPoint(area, MetaLanguage.EP_NAME, MetaLanguage.class);
IdeaExtensionPoints.INSTANCE.registerVersionSpecificAppExtensionPoints(area);
}
private void registerExtensions() {
registerFileType(JavaClassFileType.INSTANCE, "class");
registerFileType(JavaFileType.INSTANCE, "java");
registerFileType(ArchiveFileType.INSTANCE, "jar;zip");
registerFileType(PlainTextFileType.INSTANCE, "txt;sh;bat;cmd;policy;log;cgi;MF;jad;jam;htaccess");
addExplicitExtension(LanguageASTFactory.INSTANCE, PlainTextLanguage.INSTANCE, new PlainTextASTFactory());
registerParserDefinition(new PlainTextParserDefinition());
addExplicitExtension(FileTypeFileViewProviders.INSTANCE, JavaClassFileType.INSTANCE, new ClassFileViewProviderFactory());
addExplicitExtension(BinaryFileStubBuilders.INSTANCE, JavaClassFileType.INSTANCE, new ClassFileStubBuilder());
addExplicitExtension(LanguageASTFactory.INSTANCE, JavaLanguage.INSTANCE, new JavaASTFactory());
registerParserDefinition(new JavaParserDefinition());
addExplicitExtension(LanguageConstantExpressionEvaluator.INSTANCE, JavaLanguage.INSTANCE, new PsiExpressionEvaluator());
addExtension(ContainerProvider.EP_NAME, new JavaContainerProvider());
myApplication.registerService(PsiPackageImplementationHelper.class, new CorePsiPackageImplementationHelper());
myApplication.registerService(PsiSubstitutorFactory.class, new PsiSubstitutorFactoryImpl());
myApplication.registerService(JavaDirectoryService.class, createJavaDirectoryService());
myApplication.registerService(JavaVersionService.class, new JavaVersionService());
addExplicitExtension(ItemPresentationProviders.INSTANCE, PsiPackage.class, new PackagePresentationProvider());
addExplicitExtension(ItemPresentationProviders.INSTANCE, PsiClass.class, new ClassPresentationProvider());
addExplicitExtension(ItemPresentationProviders.INSTANCE, PsiMethod.class, new MethodPresentationProvider());
addExplicitExtension(ItemPresentationProviders.INSTANCE, PsiField.class, new FieldPresentationProvider());
addExplicitExtension(ItemPresentationProviders.INSTANCE, PsiLocalVariable.class, new VariablePresentationProvider());
addExplicitExtension(ItemPresentationProviders.INSTANCE, PsiParameter.class, new VariablePresentationProvider());
registerApplicationService(JavaCodeFoldingSettings.class, new JavaCodeFoldingSettingsBase());
addExplicitExtension(LanguageFolding.INSTANCE, JavaLanguage.INSTANCE, new JavaFoldingBuilderBase() {
@Override
protected boolean shouldShowExplicitLambdaType(@NotNull PsiAnonymousClass anonymousClass, @NotNull PsiNewExpression expression) {
return false;
}
@Override
protected boolean isBelowRightMargin(@NotNull PsiFile file, int lineLength) {
return false;
}
});
registerApplicationExtensionPoint(SuperMethodsSearch.EP_NAME, QueryExecutor.class);
addExtension(SuperMethodsSearch.EP_NAME, new MethodSuperSearcher());
}
// overridden in upsource
protected CoreJavaDirectoryService createJavaDirectoryService() {
return new CoreJavaDirectoryService();
}
@Nullable
@Override
protected VirtualFileSystem createJrtFileSystem() {
return new CoreJrtFileSystem();
}
@Nullable
@Override
protected VirtualFileSystem createJrtFileSystem() {
return new CoreJrtFileSystem();
}
}

View File

@@ -0,0 +1,150 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.cli.jvm.compiler;
import com.intellij.codeInsight.ContainerProvider;
import com.intellij.codeInsight.JavaContainerProvider;
import com.intellij.codeInsight.folding.JavaCodeFoldingSettings;
import com.intellij.codeInsight.folding.impl.JavaCodeFoldingSettingsBase;
import com.intellij.codeInsight.folding.impl.JavaFoldingBuilderBase;
import com.intellij.codeInsight.runner.JavaMainMethodProvider;
import com.intellij.core.CoreApplicationEnvironment;
import com.intellij.core.CoreJavaDirectoryService;
import com.intellij.core.CorePsiPackageImplementationHelper;
import com.intellij.ide.highlighter.ArchiveFileType;
import com.intellij.ide.highlighter.JavaClassFileType;
import com.intellij.ide.highlighter.JavaFileType;
import com.intellij.lang.LanguageASTFactory;
import com.intellij.lang.MetaLanguage;
import com.intellij.lang.folding.LanguageFolding;
import com.intellij.lang.java.JavaLanguage;
import com.intellij.lang.java.JavaParserDefinition;
import com.intellij.navigation.ItemPresentationProviders;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.extensions.ExtensionsArea;
import com.intellij.openapi.fileTypes.FileTypeExtensionPoint;
import com.intellij.openapi.fileTypes.PlainTextFileType;
import com.intellij.openapi.fileTypes.PlainTextLanguage;
import com.intellij.openapi.fileTypes.PlainTextParserDefinition;
import com.intellij.openapi.projectRoots.JavaVersionService;
import com.intellij.openapi.vfs.VirtualFileSystem;
import com.intellij.psi.*;
import com.intellij.psi.augment.PsiAugmentProvider;
import com.intellij.psi.augment.TypeAnnotationModifier;
import com.intellij.psi.compiled.ClassFileDecompilers;
import com.intellij.psi.impl.LanguageConstantExpressionEvaluator;
import com.intellij.psi.impl.PsiExpressionEvaluator;
import com.intellij.psi.impl.PsiSubstitutorFactoryImpl;
import com.intellij.psi.impl.compiled.ClassFileStubBuilder;
import com.intellij.psi.impl.file.PsiPackageImplementationHelper;
import com.intellij.psi.impl.search.MethodSuperSearcher;
import com.intellij.psi.impl.source.tree.JavaASTFactory;
import com.intellij.psi.impl.source.tree.PlainTextASTFactory;
import com.intellij.psi.meta.MetaDataContributor;
import com.intellij.psi.presentation.java.*;
import com.intellij.psi.search.searches.SuperMethodsSearch;
import com.intellij.psi.stubs.BinaryFileStubBuilders;
import com.intellij.util.QueryExecutor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.cli.jvm.modules.CoreJrtFileSystem;
/**
* adapted from com.intellij.core.JavaCoreApplicationEnvironment
* TODO: initiate removal original from com.intellij.core since it seems that there are no usages left
*/
public class KotlinCoreApplicationEnvironment extends CoreApplicationEnvironment {
public static KotlinCoreApplicationEnvironment create(@NotNull Disposable parentDisposable, boolean unitTestMode) {
return new KotlinCoreApplicationEnvironment(parentDisposable, unitTestMode);
}
private KotlinCoreApplicationEnvironment(@NotNull Disposable parentDisposable, boolean unitTestMode) {
super(parentDisposable, unitTestMode);
registerExtensionPoints();
registerExtensions();
}
private void registerExtensionPoints() {
ExtensionsArea area = Extensions.getRootArea();
CoreApplicationEnvironment.registerExtensionPoint(area, BinaryFileStubBuilders.EP_NAME, FileTypeExtensionPoint.class);
CoreApplicationEnvironment.registerExtensionPoint(area, FileContextProvider.EP_NAME, FileContextProvider.class);
CoreApplicationEnvironment.registerExtensionPoint(area, MetaDataContributor.EP_NAME, MetaDataContributor.class);
CoreApplicationEnvironment.registerExtensionPoint(area, PsiAugmentProvider.EP_NAME, PsiAugmentProvider.class);
CoreApplicationEnvironment.registerExtensionPoint(area, JavaMainMethodProvider.EP_NAME, JavaMainMethodProvider.class);
CoreApplicationEnvironment.registerExtensionPoint(area, ContainerProvider.EP_NAME, ContainerProvider.class);
CoreApplicationEnvironment.registerExtensionPoint(area, ClassFileDecompilers.EP_NAME, ClassFileDecompilers.Decompiler.class);
CoreApplicationEnvironment.registerExtensionPoint(area, TypeAnnotationModifier.EP_NAME, TypeAnnotationModifier.class);
CoreApplicationEnvironment.registerExtensionPoint(area, MetaLanguage.EP_NAME, MetaLanguage.class);
IdeaExtensionPoints.INSTANCE.registerVersionSpecificAppExtensionPoints(area);
}
private void registerExtensions() {
registerFileType(JavaClassFileType.INSTANCE, "class");
registerFileType(JavaFileType.INSTANCE, "java");
registerFileType(ArchiveFileType.INSTANCE, "jar;zip");
registerFileType(PlainTextFileType.INSTANCE, "txt;sh;bat;cmd;policy;log;cgi;MF;jad;jam;htaccess");
addExplicitExtension(LanguageASTFactory.INSTANCE, PlainTextLanguage.INSTANCE, new PlainTextASTFactory());
registerParserDefinition(new PlainTextParserDefinition());
addExplicitExtension(FileTypeFileViewProviders.INSTANCE, JavaClassFileType.INSTANCE, new ClassFileViewProviderFactory());
addExplicitExtension(BinaryFileStubBuilders.INSTANCE, JavaClassFileType.INSTANCE, new ClassFileStubBuilder());
addExplicitExtension(LanguageASTFactory.INSTANCE, JavaLanguage.INSTANCE, new JavaASTFactory());
registerParserDefinition(new JavaParserDefinition());
addExplicitExtension(LanguageConstantExpressionEvaluator.INSTANCE, JavaLanguage.INSTANCE, new PsiExpressionEvaluator());
addExtension(ContainerProvider.EP_NAME, new JavaContainerProvider());
myApplication.registerService(PsiPackageImplementationHelper.class, new CorePsiPackageImplementationHelper());
myApplication.registerService(PsiSubstitutorFactory.class, new PsiSubstitutorFactoryImpl());
myApplication.registerService(JavaDirectoryService.class, createJavaDirectoryService());
myApplication.registerService(JavaVersionService.class, new JavaVersionService());
addExplicitExtension(ItemPresentationProviders.INSTANCE, PsiPackage.class, new PackagePresentationProvider());
addExplicitExtension(ItemPresentationProviders.INSTANCE, PsiClass.class, new ClassPresentationProvider());
addExplicitExtension(ItemPresentationProviders.INSTANCE, PsiMethod.class, new MethodPresentationProvider());
addExplicitExtension(ItemPresentationProviders.INSTANCE, PsiField.class, new FieldPresentationProvider());
addExplicitExtension(ItemPresentationProviders.INSTANCE, PsiLocalVariable.class, new VariablePresentationProvider());
addExplicitExtension(ItemPresentationProviders.INSTANCE, PsiParameter.class, new VariablePresentationProvider());
registerApplicationService(JavaCodeFoldingSettings.class, new JavaCodeFoldingSettingsBase());
addExplicitExtension(LanguageFolding.INSTANCE, JavaLanguage.INSTANCE, new JavaFoldingBuilderBase() {
@Override
protected boolean shouldShowExplicitLambdaType(@NotNull PsiAnonymousClass anonymousClass, @NotNull PsiNewExpression expression) {
return false;
}
@Override
protected boolean isBelowRightMargin(@NotNull PsiFile file, int lineLength) {
return false;
}
});
registerApplicationExtensionPoint(SuperMethodsSearch.EP_NAME, QueryExecutor.class);
addExtension(SuperMethodsSearch.EP_NAME, new MethodSuperSearcher());
}
// overridden in upsource
protected CoreJavaDirectoryService createJavaDirectoryService() {
return new CoreJavaDirectoryService();
}
@Nullable
@Override
protected VirtualFileSystem createJrtFileSystem() {
return new CoreJrtFileSystem();
}
}

View File

@@ -1,55 +0,0 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.cli.jvm.compiler;
import com.intellij.DynamicBundle;
import com.intellij.codeInsight.ContainerProvider;
import com.intellij.codeInsight.runner.JavaMainMethodProvider;
import com.intellij.core.JavaCoreApplicationEnvironment;
import com.intellij.lang.MetaLanguage;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.vfs.VirtualFileSystem;
import com.intellij.psi.FileContextProvider;
import com.intellij.psi.augment.PsiAugmentProvider;
import com.intellij.psi.compiled.ClassFileDecompilers;
import com.intellij.psi.meta.MetaDataContributor;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.cli.jvm.modules.CoreJrtFileSystem;
public class KotlinCoreApplicationEnvironment extends JavaCoreApplicationEnvironment {
public static KotlinCoreApplicationEnvironment create(@NotNull Disposable parentDisposable, boolean unitTestMode) {
KotlinCoreApplicationEnvironment environment = new KotlinCoreApplicationEnvironment(parentDisposable, unitTestMode);
registerExtensionPoints();
return environment;
}
private KotlinCoreApplicationEnvironment(@NotNull Disposable parentDisposable, boolean unitTestMode) {
super(parentDisposable, unitTestMode);
}
private static void registerExtensionPoints() {
registerApplicationExtensionPoint(DynamicBundle.LanguageBundleEP.EP_NAME, DynamicBundle.LanguageBundleEP.class);
registerApplicationExtensionPoint(FileContextProvider.EP_NAME, FileContextProvider.class);
registerApplicationExtensionPoint(MetaDataContributor.EP_NAME, MetaDataContributor.class);
registerApplicationExtensionPoint(PsiAugmentProvider.EP_NAME, PsiAugmentProvider.class);
registerApplicationExtensionPoint(JavaMainMethodProvider.EP_NAME, JavaMainMethodProvider.class);
registerApplicationExtensionPoint(ContainerProvider.EP_NAME, ContainerProvider.class);
registerApplicationExtensionPoint(ClassFileDecompilers.EP_NAME, ClassFileDecompilers.Decompiler.class);
registerApplicationExtensionPoint(MetaLanguage.EP_NAME, MetaLanguage.class);
IdeaExtensionPoints.INSTANCE.registerVersionSpecificAppExtensionPoints(Extensions.getRootArea());
}
@Nullable
@Override
protected VirtualFileSystem createJrtFileSystem() {
return new CoreJrtFileSystem();
}
}

View File

@@ -374,6 +374,7 @@ object KotlinToJVMBytecodeCompiler {
performanceManager?.notifyGenerationStarted()
val signaturer = IdSignatureDescriptor(JvmManglerDesc())
performanceManager?.notifyIRTranslationStarted()
val (moduleFragment, symbolTable, sourceManager, components) =
Fir2IrConverter.createModuleFragment(
session, resolveTransformer.scopeSession, firFiles,
@@ -381,6 +382,9 @@ object KotlinToJVMBytecodeCompiler {
generatorExtensions = JvmGeneratorExtensions(),
mangler = FirJvmKotlinMangler(session)
)
performanceManager?.notifyIRTranslationFinished(ktFiles.size, codeLines, debugTargetDescription)
val dummyBindingContext = NoScopeRecordCliBindingTrace().bindingContext
val codegenFactory = JvmIrCodegenFactory(moduleConfiguration.get(CLIConfigurationKeys.PHASE_CONFIG) ?: PhaseConfig(jvmPhases))
@@ -402,7 +406,7 @@ object KotlinToJVMBytecodeCompiler {
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()
performanceManager?.notifyIRGenerationStarted()
generationState.beforeCompile()
codegenFactory.generateModuleInFrontendIRMode(
generationState, moduleFragment, symbolTable, sourceManager
@@ -431,6 +435,7 @@ object KotlinToJVMBytecodeCompiler {
generationState.extraJvmDiagnosticsTrace.bindingContext, environment.messageCollector
)
performanceManager?.notifyIRGenerationFinished(ktFiles.size, codeLines, additionalDescription = debugTargetDescription)
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()
outputs[module] = generationState
}

View File

@@ -22,6 +22,7 @@ import com.intellij.psi.*
class MockExternalAnnotationsManager : ExternalAnnotationsManager() {
override fun chooseAnnotationsPlace(element: PsiElement): AnnotationPlace = AnnotationPlace.NOWHERE
override fun chooseAnnotationsPlaceNoUi(element: PsiElement): AnnotationPlace = AnnotationPlace.NOWHERE
override fun isExternalAnnotationWritable(listOwner: PsiModifierListOwner, annotationFQN: String): Boolean = false
override fun isExternalAnnotation(annotation: PsiAnnotation): Boolean = false

View File

@@ -22,7 +22,6 @@ import com.intellij.psi.*
class MockExternalAnnotationsManager : ExternalAnnotationsManager() {
override fun chooseAnnotationsPlace(element: PsiElement): AnnotationPlace = AnnotationPlace.NOWHERE
override fun chooseAnnotationsPlaceNoUi(element: PsiElement): AnnotationPlace = AnnotationPlace.NOWHERE
override fun isExternalAnnotationWritable(listOwner: PsiModifierListOwner, annotationFQN: String): Boolean = false
override fun isExternalAnnotation(annotation: PsiAnnotation): Boolean = false

View File

@@ -6,4 +6,10 @@
package org.jetbrains.kotlin.cli.jvm.compiler
fun setupIdeaStandaloneExecution() {
System.getProperties().setProperty("idea.plugins.compatible.build", "201.6668.13")
System.getProperties().setProperty("project.structure.add.tools.jar.to.new.jdk", "false")
System.getProperties().setProperty("psi.track.invalidation", "true")
System.getProperties().setProperty("psi.incremental.reparse.depth.limit", "1000")
System.getProperties().setProperty("ide.hide.excluded.files", "false")
System.getProperties().setProperty("ast.loading.filter", "false")
}

View File

@@ -0,0 +1,9 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.cli.jvm.compiler
fun setupIdeaStandaloneExecution() {
}

View File

@@ -12,4 +12,6 @@ fun setupIdeaStandaloneExecution() {
System.getProperties().setProperty("psi.incremental.reparse.depth.limit", "1000")
System.getProperties().setProperty("ide.hide.excluded.files", "false")
System.getProperties().setProperty("ast.loading.filter", "false")
System.getProperties().setProperty("idea.ignore.disabled.plugins", "true")
System.getProperties().setProperty("idea.home.path", System.getProperty("java.io.tmpdir"))
}

View File

@@ -8,9 +8,11 @@ package org.jetbrains.kotlin.cli.jvm.compiler
import com.intellij.core.CoreApplicationEnvironment
import com.intellij.openapi.extensions.ExtensionsArea
import java.io.File
import java.nio.file.FileSystems
// FIX ME WHEN BUNCH 193 REMOVED
fun registerExtensionPointAndExtensionsEx(pluginFile: File, fileName: String, area: ExtensionsArea) {
val pluginRoot = FileSystems.getDefault().getPath(pluginFile.path)
@Suppress("MissingRecentApi")
CoreApplicationEnvironment.registerExtensionPointAndExtensions(pluginFile, fileName, area)
CoreApplicationEnvironment.registerExtensionPointAndExtensions(pluginRoot, fileName, area)
}

View File

@@ -8,11 +8,9 @@ package org.jetbrains.kotlin.cli.jvm.compiler
import com.intellij.core.CoreApplicationEnvironment
import com.intellij.openapi.extensions.ExtensionsArea
import java.io.File
import java.nio.file.FileSystems
// FIX ME WHEN BUNCH 193 REMOVED
fun registerExtensionPointAndExtensionsEx(pluginFile: File, fileName: String, area: ExtensionsArea) {
val pluginRoot = FileSystems.getDefault().getPath(pluginFile.path)
@Suppress("MissingRecentApi")
CoreApplicationEnvironment.registerExtensionPointAndExtensions(pluginRoot, fileName, area)
CoreApplicationEnvironment.registerExtensionPointAndExtensions(pluginFile, fileName, area)
}

View File

@@ -38,6 +38,17 @@ fun CompilerConfiguration.setupJvmSpecificArguments(arguments: K2JVMCompilerArgu
}
}
val jvmTarget = get(JVMConfigurationKeys.JVM_TARGET) ?: JvmTarget.DEFAULT
if (jvmTarget.bytecodeVersion < JvmTarget.JVM_1_8.bytecodeVersion) {
val jvmDefaultMode = languageVersionSettings.getFlag(JvmAnalysisFlags.jvmDefaultMode)
if (jvmDefaultMode.forAllMethodsWithBody) {
messageCollector.report(
ERROR,
"'-Xjvm-default=${jvmDefaultMode.description}' is only supported since JVM target 1.8. Recompile with '-jvm-target 1.8'"
)
}
}
addAll(JVMConfigurationKeys.ADDITIONAL_JAVA_MODULES, arguments.additionalJavaModules?.asList())
}
@@ -198,6 +209,7 @@ fun CompilerConfiguration.configureAdvancedJvmOptions(arguments: K2JVMCompilerAr
put(CLIConfigurationKeys.ALLOW_KOTLIN_PACKAGE, arguments.allowKotlinPackage)
put(JVMConfigurationKeys.USE_SINGLE_MODULE, arguments.singleModule)
put(JVMConfigurationKeys.USE_OLD_SPILLED_VAR_TYPE_ANALYSIS, arguments.useOldSpilledVarTypeAnalysis)
arguments.declarationsOutputPath?.let { put(JVMConfigurationKeys.DECLARATIONS_JSON_PATH, it) }
}

View File

@@ -19,7 +19,7 @@ public class KotlinCompilerVersion {
// Binaries produced by this compiler with that language version (or any future language version) are going to be marked
// as "pre-release" and will not be loaded by release versions of the compiler.
// Change this value before and after every major release
private static final boolean IS_PRE_RELEASE = true;
private static final boolean IS_PRE_RELEASE = false;
public static final String TEST_IS_PRE_RELEASE_SYSTEM_PROPERTY = "kotlin.test.is.pre.release";

View File

@@ -122,4 +122,7 @@ public class JVMConfigurationKeys {
public static final CompilerConfigurationKey<Boolean> NO_KOTLIN_NOTHING_VALUE_EXCEPTION =
CompilerConfigurationKey.create("Do not use KotlinNothingValueException available since 1.4");
public static final CompilerConfigurationKey<Boolean> USE_OLD_SPILLED_VAR_TYPE_ANALYSIS =
CompilerConfigurationKey.create("Use old, SourceInterpreter-based analysis for fields, used for spilled variables in coroutines");
}

View File

@@ -47,6 +47,9 @@ object CommonConfigurationKeys {
@JvmField
val EXPECT_ACTUAL_LINKER = CompilerConfigurationKey.create<Boolean>("Experimental expext/actual linker")
@JvmField
val DESERIALIZE_FAKE_OVERRIDES = CompilerConfigurationKey.create<Boolean>("Deserialize fake overrides")
}
var CompilerConfiguration.languageVersionSettings: LanguageVersionSettings

View File

@@ -208,10 +208,10 @@ public final class Byte : R|kotlin/Number|, R|kotlin/Comparable<kotlin/Byte>|, R
public final const val MIN_VALUE: R|kotlin/Byte| = Byte(-128)
public get(): R|kotlin/Byte|
@R|kotlin/SinceKotlin|(version = String(1.3)) public final const val SIZE_BITS: R|kotlin/Int| = Int(8)
@PROPERTY:R|kotlin/SinceKotlin|(version = String(1.3)) public final const val SIZE_BITS: R|kotlin/Int| = Int(8)
public get(): R|kotlin/Int|
@R|kotlin/SinceKotlin|(version = String(1.3)) public final const val SIZE_BYTES: R|kotlin/Int| = Int(1)
@PROPERTY:R|kotlin/SinceKotlin|(version = String(1.3)) public final const val SIZE_BYTES: R|kotlin/Int| = Int(1)
public get(): R|kotlin/Int|
private constructor(): R|kotlin/Byte.Companion|
@@ -279,7 +279,7 @@ public final class Char : R|kotlin/Comparable<kotlin/Char>|, R|java/io/Serializa
public final const val MAX_SURROGATE: R|kotlin/Char| = Char(57343)
public get(): R|kotlin/Char|
@R|kotlin/SinceKotlin|(version = String(1.3)) public final const val MAX_VALUE: R|kotlin/Char| = Char(65535)
@PROPERTY:R|kotlin/SinceKotlin|(version = String(1.3)) public final const val MAX_VALUE: R|kotlin/Char| = Char(65535)
public get(): R|kotlin/Char|
public final const val MIN_HIGH_SURROGATE: R|kotlin/Char| = Char(55296)
@@ -291,13 +291,13 @@ public final class Char : R|kotlin/Comparable<kotlin/Char>|, R|java/io/Serializa
public final const val MIN_SURROGATE: R|kotlin/Char| = Char(55296)
public get(): R|kotlin/Char|
@R|kotlin/SinceKotlin|(version = String(1.3)) public final const val MIN_VALUE: R|kotlin/Char| = Char(0)
@PROPERTY:R|kotlin/SinceKotlin|(version = String(1.3)) public final const val MIN_VALUE: R|kotlin/Char| = Char(0)
public get(): R|kotlin/Char|
@R|kotlin/SinceKotlin|(version = String(1.3)) public final const val SIZE_BITS: R|kotlin/Int| = Int(16)
@PROPERTY:R|kotlin/SinceKotlin|(version = String(1.3)) public final const val SIZE_BITS: R|kotlin/Int| = Int(16)
public get(): R|kotlin/Int|
@R|kotlin/SinceKotlin|(version = String(1.3)) public final const val SIZE_BYTES: R|kotlin/Int| = Int(2)
@PROPERTY:R|kotlin/SinceKotlin|(version = String(1.3)) public final const val SIZE_BYTES: R|kotlin/Int| = Int(2)
public get(): R|kotlin/Int|
private constructor(): R|kotlin/Char.Companion|
@@ -358,6 +358,20 @@ public abstract interface Comparable<in T> : R|kotlin/Any| {
}
@R|kotlin/annotation/Target|() @R|kotlin/annotation/MustBeDocumented|() @R|kotlin/SinceKotlin|(version = String(1.4)) public final annotation class DeprecatedSinceKotlin : R|kotlin/Annotation| {
public final val errorSince: R|kotlin/String|
public get(): R|kotlin/String|
public final val hiddenSince: R|kotlin/String|
public get(): R|kotlin/String|
public final val warningSince: R|kotlin/String|
public get(): R|kotlin/String|
public constructor(warningSince: R|kotlin/String| = STUB, errorSince: R|kotlin/String| = STUB, hiddenSince: R|kotlin/String| = STUB): R|kotlin/DeprecatedSinceKotlin|
}
public final enum class DeprecationLevel : R|kotlin/Enum<kotlin/DeprecationLevel>| {
private constructor(): R|kotlin/DeprecationLevel|
@@ -485,10 +499,10 @@ public final class Double : R|kotlin/Number|, R|kotlin/Comparable<kotlin/Double>
public final const val POSITIVE_INFINITY: R|kotlin/Double| = Double(Infinity)
public get(): R|kotlin/Double|
@R|kotlin/SinceKotlin|(version = String(1.4)) public final const val SIZE_BITS: R|kotlin/Int| = Int(64)
@PROPERTY:R|kotlin/SinceKotlin|(version = String(1.4)) public final const val SIZE_BITS: R|kotlin/Int| = Int(64)
public get(): R|kotlin/Int|
@R|kotlin/SinceKotlin|(version = String(1.4)) public final const val SIZE_BYTES: R|kotlin/Int| = Int(8)
@PROPERTY:R|kotlin/SinceKotlin|(version = String(1.4)) public final const val SIZE_BYTES: R|kotlin/Int| = Int(8)
public get(): R|kotlin/Int|
private constructor(): R|kotlin/Double.Companion|
@@ -664,10 +678,10 @@ public final class Float : R|kotlin/Number|, R|kotlin/Comparable<kotlin/Float>|,
public final const val POSITIVE_INFINITY: R|kotlin/Float| = Float(Infinity)
public get(): R|kotlin/Float|
@R|kotlin/SinceKotlin|(version = String(1.4)) public final const val SIZE_BITS: R|kotlin/Int| = Int(32)
@PROPERTY:R|kotlin/SinceKotlin|(version = String(1.4)) public final const val SIZE_BITS: R|kotlin/Int| = Int(32)
public get(): R|kotlin/Int|
@R|kotlin/SinceKotlin|(version = String(1.4)) public final const val SIZE_BYTES: R|kotlin/Int| = Int(4)
@PROPERTY:R|kotlin/SinceKotlin|(version = String(1.4)) public final const val SIZE_BYTES: R|kotlin/Int| = Int(4)
public get(): R|kotlin/Int|
private constructor(): R|kotlin/Float.Companion|
@@ -823,10 +837,10 @@ public final class Int : R|kotlin/Number|, R|kotlin/Comparable<kotlin/Int>|, R|j
public final const val MIN_VALUE: R|kotlin/Int| = Int(-2147483648)
public get(): R|kotlin/Int|
@R|kotlin/SinceKotlin|(version = String(1.3)) public final const val SIZE_BITS: R|kotlin/Int| = Int(32)
@PROPERTY:R|kotlin/SinceKotlin|(version = String(1.3)) public final const val SIZE_BITS: R|kotlin/Int| = Int(32)
public get(): R|kotlin/Int|
@R|kotlin/SinceKotlin|(version = String(1.3)) public final const val SIZE_BYTES: R|kotlin/Int| = Int(4)
@PROPERTY:R|kotlin/SinceKotlin|(version = String(1.3)) public final const val SIZE_BYTES: R|kotlin/Int| = Int(4)
public get(): R|kotlin/Int|
private constructor(): R|kotlin/Int.Companion|
@@ -979,10 +993,10 @@ public final class Long : R|kotlin/Number|, R|kotlin/Comparable<kotlin/Long>|, R
public final const val MIN_VALUE: R|kotlin/Long| = Long(-9223372036854775808)
public get(): R|kotlin/Long|
@R|kotlin/SinceKotlin|(version = String(1.3)) public final const val SIZE_BITS: R|kotlin/Int| = Int(64)
@PROPERTY:R|kotlin/SinceKotlin|(version = String(1.3)) public final const val SIZE_BITS: R|kotlin/Int| = Int(64)
public get(): R|kotlin/Int|
@R|kotlin/SinceKotlin|(version = String(1.3)) public final const val SIZE_BYTES: R|kotlin/Int| = Int(8)
@PROPERTY:R|kotlin/SinceKotlin|(version = String(1.3)) public final const val SIZE_BYTES: R|kotlin/Int| = Int(8)
public get(): R|kotlin/Int|
private constructor(): R|kotlin/Long.Companion|
@@ -1169,10 +1183,10 @@ public final class Short : R|kotlin/Number|, R|kotlin/Comparable<kotlin/Short>|,
public final const val MIN_VALUE: R|kotlin/Short| = Short(-32768)
public get(): R|kotlin/Short|
@R|kotlin/SinceKotlin|(version = String(1.3)) public final const val SIZE_BITS: R|kotlin/Int| = Int(16)
@PROPERTY:R|kotlin/SinceKotlin|(version = String(1.3)) public final const val SIZE_BITS: R|kotlin/Int| = Int(16)
public get(): R|kotlin/Int|
@R|kotlin/SinceKotlin|(version = String(1.3)) public final const val SIZE_BYTES: R|kotlin/Int| = Int(2)
@PROPERTY:R|kotlin/SinceKotlin|(version = String(1.3)) public final const val SIZE_BYTES: R|kotlin/Int| = Int(2)
public get(): R|kotlin/Int|
private constructor(): R|kotlin/Short.Companion|

View File

@@ -7,7 +7,7 @@ public final class Class : R|kotlin/Any| {
public constructor(): R|test/Class|
public final companion object Companion : R|kotlin/Any| {
public final var property: R|kotlin/Int|
@FIELD:R|test/Anno|() public final var property: R|kotlin/Int|
public get(): R|kotlin/Int|
public set(value: R|kotlin/Int|): R|kotlin/Unit|

View File

@@ -4,7 +4,7 @@ public final annotation class Anno : R|kotlin/Annotation| {
}
public final class Class : R|kotlin/Any| {
public final val x: R|kotlin/Int|
@PROPERTY:R|test/Anno|() public final val x: R|kotlin/Int|
public get(): R|kotlin/Int|
public constructor(): R|test/Class|

View File

@@ -9,7 +9,7 @@ public final annotation class Anno : R|kotlin/Annotation| {
public final class Class : R|kotlin/Any| {
@R|test/Anno|(t = R|java/lang/annotation/ElementType.METHOD|()) public final fun foo(): R|kotlin/Unit|
public final var bar: R|kotlin/Int|
@FIELD:R|test/Anno|(t = R|java/lang/annotation/ElementType.FIELD|()) public final var bar: R|kotlin/Int|
public get(): R|kotlin/Int|
public set(value: R|kotlin/Int|): R|kotlin/Unit|

View File

@@ -7,10 +7,10 @@ public sealed class Sealed : R|kotlin/Any| {
public final val z: R|test/Z|
public get(): R|test/Z|
@R|test/Ann|() private constructor(z: R|test/Z|): R|test/Sealed|
@R|test/Ann|() private constructor(@R|test/Ann|() z: R|test/Z|): R|test/Sealed|
public final class Derived : R|test/Sealed| {
public constructor(z: R|test/Z|): R|test/Sealed.Derived|
@R|test/Ann|() public constructor(z: R|test/Z|): R|test/Sealed.Derived|
}
@@ -20,11 +20,11 @@ public final class Test : R|kotlin/Any| {
public final val z: R|test/Z|
public get(): R|test/Z|
@R|test/Ann|() public constructor(z: R|test/Z|, a: R|kotlin/Int|): R|test/Test|
@R|test/Ann|() public constructor(z: R|test/Z|, @R|test/Ann|() a: R|kotlin/Int|): R|test/Test|
@R|test/Ann|() private constructor(z: R|test/Z|, s: R|kotlin/String|): R|test/Test|
@R|test/Ann|() private constructor(z: R|test/Z|, @R|test/Ann|() s: R|kotlin/String|): R|test/Test|
@R|test/Ann|() public constructor(z: R|test/Z|): R|test/Test|
@R|test/Ann|() public constructor(@R|test/Ann|() z: R|test/Z|): R|test/Test|
}

View File

@@ -4,7 +4,7 @@ public final annotation class Anno : R|kotlin/Annotation| {
}
public final class Class : R|kotlin/Any| {
public final var property: R|kotlin/Int|
@FIELD:R|test/Anno|() public final var property: R|kotlin/Int|
public get(): R|kotlin/Int|
public set(value: R|kotlin/Int|): R|kotlin/Unit|

View File

@@ -12,6 +12,6 @@ public final class Class : R|kotlin/Any| {
public final val x: R|kotlin/Int|
public get(): R|kotlin/Int|
public constructor(x: R|kotlin/Int|, y: R|kotlin/String|): R|test/Class|
public constructor(@R|test/A|() x: R|kotlin/Int|, @R|test/B|() y: R|kotlin/String|): R|test/Class|
}

View File

@@ -15,7 +15,7 @@ public final enum class E : R|kotlin/Enum<test/E>| {
public final val y: R|kotlin/Int|
public get(): R|kotlin/Int|
private constructor(x: R|kotlin/String|, y: R|kotlin/Int|): R|test/E|
private constructor(@R|test/A|() x: R|kotlin/String|, @R|test/B|() y: R|kotlin/Int|): R|test/E|
public final static fun values(): R|kotlin/Array<test/E>| {
}

View File

@@ -1,4 +1,4 @@
public final fun R|kotlin/Int|.foo(x: R|kotlin/Int|): R|kotlin/Unit|
public final fun R|kotlin/Int|.foo(@R|test/A|() x: R|kotlin/Int|): R|kotlin/Unit|
public final annotation class A : R|kotlin/Annotation| {
public constructor(): R|test/A|

View File

@@ -4,7 +4,7 @@ public final annotation class Anno : R|kotlin/Annotation| {
}
public final class Class : R|kotlin/Any| {
public final fun R|kotlin/String|.foo(x: R|kotlin/Int|): R|kotlin/Int|
public final fun R|kotlin/String|.foo(@R|test/Anno|() x: R|kotlin/Int|): R|kotlin/Int|
public constructor(): R|test/Class|

View File

@@ -6,7 +6,7 @@ public final annotation class A : R|kotlin/Annotation| {
public final class Class : R|kotlin/Any| {
public final var R|kotlin/Int|.foo: R|kotlin/Int|
public get(): R|kotlin/Int|
public set(value: R|kotlin/Int|): R|kotlin/Unit|
public set(@R|test/A|() value: R|kotlin/Int|): R|kotlin/Unit|
public constructor(): R|test/Class|

View File

@@ -4,7 +4,7 @@ public final annotation class Anno : R|kotlin/Annotation| {
}
public final class Class : R|kotlin/Any| {
public final fun foo(x: R|kotlin/String|): R|kotlin/Unit|
public final fun foo(@R|test/Anno|() x: R|kotlin/String|): R|kotlin/Unit|
public constructor(): R|test/Class|

View File

@@ -4,6 +4,6 @@ public final annotation class Anno : R|kotlin/Annotation| {
}
public abstract interface Trait : R|kotlin/Any| {
public open fun foo(x: R|kotlin/String|): R|kotlin/Int|
public open fun foo(@R|test/Anno|() x: R|kotlin/String|): R|kotlin/Int|
}

View File

@@ -13,7 +13,7 @@ public final class Outer : R|kotlin/Any| {
public final val y: R|kotlin/String|
public get(): R|kotlin/String|
public constructor(y: R|kotlin/String|): R|test/Outer.Inner|
public constructor(@R|test/A|(s = String(inner)) y: R|kotlin/String|): R|test/Outer.Inner|
}
@@ -21,7 +21,7 @@ public final class Outer : R|kotlin/Any| {
public final val x: R|kotlin/String|
public get(): R|kotlin/String|
public constructor(x: R|kotlin/String|): R|test/Outer.Nested|
public constructor(@R|test/A|(s = String(nested)) x: R|kotlin/String|): R|test/Outer.Nested|
}

View File

@@ -1,6 +1,6 @@
public final fun bar(x: R|kotlin/Int|): R|kotlin/Unit|
public final fun bar(@R|test/A|() @R|test/B|() @R|test/C|() @R|test/D|() x: R|kotlin/Int|): R|kotlin/Unit|
public final fun foo(x: R|kotlin/Int|, y: R|kotlin/Double|, z: R|kotlin/String|): R|kotlin/Unit|
public final fun foo(@R|test/A|() @R|test/B|() x: R|kotlin/Int|, @R|test/A|() @R|test/C|() y: R|kotlin/Double|, @R|test/B|() @R|test/C|() @R|test/D|() z: R|kotlin/String|): R|kotlin/Unit|
public final annotation class A : R|kotlin/Annotation| {
public constructor(): R|test/A|

View File

@@ -6,7 +6,7 @@ public final annotation class A : R|kotlin/Annotation| {
public final class Class : R|kotlin/Any| {
public final var foo: R|kotlin/Int|
public get(): R|kotlin/Int|
public set(value: R|kotlin/Int|): R|kotlin/Unit|
public set(@R|test/A|() value: R|kotlin/Int|): R|kotlin/Unit|
public constructor(): R|test/Class|

View File

@@ -1,4 +1,4 @@
public final fun foo(x: R|kotlin/Int|): R|kotlin/Unit|
public final fun foo(@R|test/Anno|() x: R|kotlin/Int|): R|kotlin/Unit|
public final annotation class Anno : R|kotlin/Annotation| {
public constructor(): R|test/Anno|

View File

@@ -4,7 +4,7 @@ public final annotation class Anno : R|kotlin/Annotation| {
}
public final class Class : R|kotlin/Any| {
public final val property: R|kotlin/Int|
@PROPERTY:R|test/Anno|() public final val property: R|kotlin/Int|
public get(): R|kotlin/Int|
public constructor(): R|test/Class|

View File

@@ -7,7 +7,7 @@ public final class Class : R|kotlin/Any| {
public constructor(): R|test/Class|
public final companion object Companion : R|kotlin/Any| {
public final val property: R|kotlin/Int|
@PROPERTY:R|test/Anno|() public final val property: R|kotlin/Int|
public get(): R|kotlin/Int|
private constructor(): R|test/Class.Companion|

View File

@@ -1,11 +1,11 @@
public final class Class : R|kotlin/Any| {
public final val R|kotlin/Double|.extension: R|kotlin/Int|
@PROPERTY:R|test/DoubleAnno|() public final val R|kotlin/Double|.extension: R|kotlin/Int|
public get(): R|kotlin/Int|
public final val R|kotlin/Int|.extension: R|kotlin/Int|
@PROPERTY:R|test/IntAnno|() public final val R|kotlin/Int|.extension: R|kotlin/Int|
public get(): R|kotlin/Int|
public final val R|kotlin/String|.extension: R|kotlin/String|
@PROPERTY:R|test/StringAnno|() public final val R|kotlin/String|.extension: R|kotlin/String|
public get(): R|kotlin/String|
public constructor(): R|test/Class|

View File

@@ -5,7 +5,7 @@ public final annotation class Anno : R|kotlin/Annotation| {
public abstract interface Trait : R|kotlin/Any| {
public final companion object Companion : R|kotlin/Any| {
public final val property: R|kotlin/Int|
@PROPERTY:R|test/Anno|() public final val property: R|kotlin/Int|
public get(): R|kotlin/Int|
private constructor(): R|test/Trait.Companion|

View File

@@ -4,7 +4,7 @@ public final annotation class Anno : R|kotlin/Annotation| {
}
public final class Class : R|kotlin/Any| {
public final val property: R|kotlin/String|
@PROPERTY_DELEGATE_FIELD:R|test/Anno|() public final val property: R|kotlin/String|
public get(): R|kotlin/String|
public constructor(): R|test/Class|

View File

@@ -4,7 +4,7 @@ public final annotation class Anno : R|kotlin/Annotation| {
}
public final class Class : R|kotlin/Any| {
public final var property: R|kotlin/Int|
@FIELD:R|test/Anno|() public final var property: R|kotlin/Int|
public get(): R|kotlin/Int|
public set(value: R|kotlin/Int|): R|kotlin/Unit|

View File

@@ -1,5 +1,5 @@
public final class A : R|kotlin/Any| {
public final fun R|kotlin/String|.myLength(q: R|kotlin/String|): R|kotlin/Int|
public final fun R|kotlin/String|.myLength(@R|test/Ann|() q: R|kotlin/String|): R|kotlin/Int|
public final val R|kotlin/String|.myLength2: R|kotlin/Int|
public get(): R|kotlin/Int|

View File

@@ -0,0 +1,13 @@
// ISSUE: KT-39032
interface A {
fun foo()
}
interface B : A {
override fun foo()
}
fun <E> bar(e: E) where E : A, E : B {
e.foo()
}

View File

@@ -0,0 +1,12 @@
FILE: uselessMultipleBounds.kt
public abstract interface A : R|kotlin/Any| {
public abstract fun foo(): R|kotlin/Unit|
}
public abstract interface B : R|A| {
public abstract override fun foo(): R|kotlin/Unit|
}
public final fun <E : R|A|, R|B|> bar(e: R|E|): R|kotlin/Unit| {
R|<local>/e|.R|/B.foo|()
}

View File

@@ -61,14 +61,14 @@ digraph inplaceLambdaInControlFlowExpressions_kt {
23 [label="Postponed enter to lambda"];
subgraph cluster_9 {
color=blue
33 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
32 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
subgraph cluster_10 {
color=blue
34 [label="Enter block"];
35 [label="Function call: R|/materialize|<R|kotlin/String|>()"];
36 [label="Exit block"];
33 [label="Enter block"];
34 [label="Function call: R|/materialize|<R|kotlin/String|>()"];
35 [label="Exit block"];
}
37 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
36 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
24 [label="Postponed exit from lambda"];
25 [label="Function call: R|kotlin/run|<R|kotlin/String|>(...)"];
@@ -77,11 +77,10 @@ digraph inplaceLambdaInControlFlowExpressions_kt {
27 [label="Exit when branch result"];
28 [label="Exit when"];
}
29 [label="Call arguments union" style="filled" fillcolor=yellow];
30 [label="Variable declaration: lval x: R|kotlin/String|"];
31 [label="Exit block"];
29 [label="Variable declaration: lval x: R|kotlin/String|"];
30 [label="Exit block"];
}
32 [label="Exit function test_1" style="filled" fillcolor=red];
31 [label="Exit function test_1" style="filled" fillcolor=red];
}
8 -> {9};
9 -> {10};
@@ -98,7 +97,7 @@ digraph inplaceLambdaInControlFlowExpressions_kt {
20 -> {28};
21 -> {22};
22 -> {23};
23 -> {33};
23 -> {32};
23 -> {24} [color=red];
24 -> {25};
25 -> {26};
@@ -107,78 +106,77 @@ digraph inplaceLambdaInControlFlowExpressions_kt {
28 -> {29};
29 -> {30};
30 -> {31};
31 -> {32};
32 -> {33};
33 -> {34};
34 -> {35};
35 -> {36};
36 -> {37};
37 -> {29} [color=red];
37 -> {24} [color=green];
36 -> {24} [color=green];
subgraph cluster_11 {
color=red
38 [label="Enter function test_2" style="filled" fillcolor=red];
37 [label="Enter function test_2" style="filled" fillcolor=red];
subgraph cluster_12 {
color=blue
39 [label="Enter block"];
38 [label="Enter block"];
subgraph cluster_13 {
color=blue
40 [label="Try expression enter"];
39 [label="Try expression enter"];
subgraph cluster_14 {
color=blue
41 [label="Try main block enter"];
40 [label="Try main block enter"];
subgraph cluster_15 {
color=blue
42 [label="Enter block"];
43 [label="Postponed enter to lambda"];
41 [label="Enter block"];
42 [label="Postponed enter to lambda"];
subgraph cluster_16 {
color=blue
58 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
57 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
subgraph cluster_17 {
color=blue
59 [label="Enter block"];
60 [label="Function call: R|/materialize|<R|kotlin/String|>()"];
61 [label="Exit block"];
58 [label="Enter block"];
59 [label="Function call: R|/materialize|<R|kotlin/String|>()"];
60 [label="Exit block"];
}
62 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
61 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
44 [label="Postponed exit from lambda"];
45 [label="Function call: R|kotlin/run|<R|kotlin/String|>(...)"];
46 [label="Exit block"];
43 [label="Postponed exit from lambda"];
44 [label="Function call: R|kotlin/run|<R|kotlin/String|>(...)"];
45 [label="Exit block"];
}
47 [label="Try main block exit"];
46 [label="Try main block exit"];
}
subgraph cluster_18 {
color=blue
48 [label="Catch enter"];
47 [label="Catch enter"];
subgraph cluster_19 {
color=blue
49 [label="Enter block"];
50 [label="Const: String()"];
51 [label="Exit block"];
48 [label="Enter block"];
49 [label="Const: String()"];
50 [label="Exit block"];
}
52 [label="Catch exit"];
51 [label="Catch exit"];
}
53 [label="Try expression exit"];
52 [label="Try expression exit"];
}
54 [label="Call arguments union" style="filled" fillcolor=yellow];
55 [label="Variable declaration: lval x: R|kotlin/String|"];
56 [label="Exit block"];
53 [label="Call arguments union" style="filled" fillcolor=yellow];
54 [label="Variable declaration: lval x: R|kotlin/String|"];
55 [label="Exit block"];
}
57 [label="Exit function test_2" style="filled" fillcolor=red];
56 [label="Exit function test_2" style="filled" fillcolor=red];
}
37 -> {38};
38 -> {39};
39 -> {40};
40 -> {41};
41 -> {57 48 42};
42 -> {43};
43 -> {58};
43 -> {44} [color=red];
40 -> {56 47 41};
41 -> {42};
42 -> {57};
42 -> {43} [color=red];
43 -> {44};
44 -> {45};
45 -> {46};
46 -> {47};
47 -> {53};
48 -> {57 49};
46 -> {52};
47 -> {56 48};
48 -> {49};
49 -> {50};
50 -> {51};
51 -> {52};
@@ -186,56 +184,55 @@ digraph inplaceLambdaInControlFlowExpressions_kt {
53 -> {54};
54 -> {55};
55 -> {56};
56 -> {57};
57 -> {58};
58 -> {59};
59 -> {60};
60 -> {61};
61 -> {62};
62 -> {54} [color=red];
62 -> {44} [color=green];
61 -> {53} [color=red];
61 -> {43} [color=green];
subgraph cluster_20 {
color=red
63 [label="Enter function test_3" style="filled" fillcolor=red];
62 [label="Enter function test_3" style="filled" fillcolor=red];
subgraph cluster_21 {
color=blue
64 [label="Enter block"];
65 [label="Postponed enter to lambda"];
63 [label="Enter block"];
64 [label="Postponed enter to lambda"];
subgraph cluster_22 {
color=blue
73 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
72 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
subgraph cluster_23 {
color=blue
74 [label="Enter block"];
75 [label="Function call: R|/materialize|<R|kotlin/String?|>()"];
76 [label="Exit block"];
73 [label="Enter block"];
74 [label="Function call: R|/materialize|<R|kotlin/String?|>()"];
75 [label="Exit block"];
}
77 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
76 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
66 [label="Postponed exit from lambda"];
67 [label="Function call: R|kotlin/run|<R|kotlin/String?|>(...)"];
68 [label="Check not null: R|kotlin/run|<R|kotlin/String?|>(...)!!"];
69 [label="Call arguments union" style="filled" fillcolor=yellow];
70 [label="Variable declaration: lval x: R|kotlin/String|"];
71 [label="Exit block"];
65 [label="Postponed exit from lambda"];
66 [label="Function call: R|kotlin/run|<R|kotlin/String?|>(...)"];
67 [label="Check not null: R|kotlin/run|<R|kotlin/String?|>(...)!!"];
68 [label="Call arguments union" style="filled" fillcolor=yellow];
69 [label="Variable declaration: lval x: R|kotlin/String|"];
70 [label="Exit block"];
}
72 [label="Exit function test_3" style="filled" fillcolor=red];
71 [label="Exit function test_3" style="filled" fillcolor=red];
}
62 -> {63};
63 -> {64};
64 -> {65};
65 -> {73};
65 -> {66} [color=red];
64 -> {72};
64 -> {65} [color=red];
65 -> {66};
66 -> {67};
67 -> {68};
68 -> {69};
69 -> {70};
70 -> {71};
71 -> {72};
72 -> {73};
73 -> {74};
74 -> {75};
75 -> {76};
76 -> {77};
77 -> {69} [color=red];
77 -> {66} [color=green];
76 -> {68} [color=red];
76 -> {65} [color=green];
}

View File

@@ -13,8 +13,11 @@ 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|
}
public final val b: R|B| = R|<local>/b|

View File

@@ -24,15 +24,7 @@ FILE: delegateWithLambda.kt
}
public final val x: R|kotlin/String|by R|/lazy|<R|kotlin/String|>(<L> = lazy@fun <anonymous>(): R|kotlin/String| {
lval y: R|kotlin/String| = when (lval <elvis>: R|kotlin/String?| = (R|/getAny|() as? R|kotlin/String|)) {
==($subj$, Null(null)) -> {
String()
}
else -> {
R|<local>/<elvis>|
}
}
lval y: R|kotlin/String| = (R|/getAny|() as? R|kotlin/String|) ?: String()
^ R|<local>/y|
}
)

View File

@@ -0,0 +1,8 @@
class A<in T, out K>
class B
fun test() {
val a1 = A<<!PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT!>in Int<!>, <!PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT!>out B<!>>()
val a2 = A<Int, B>()
val a3 = A<<!PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT!>*<!>, <!PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT!>*<!>>()
}

View File

@@ -0,0 +1,18 @@
FILE: projectionsOnNonClassTypeArguments.kt
public final class A<in T, out K> : R|kotlin/Any| {
public constructor<in T, out K>(): R|A<T, K>| {
super<R|kotlin/Any|>()
}
}
public final class B : R|kotlin/Any| {
public constructor(): R|B| {
super<R|kotlin/Any|>()
}
}
public final fun test(): R|kotlin/Unit| {
lval a1: R|A<kotlin/Int, B>| = R|/A.A|<in R|kotlin/Int|, out R|B|>()
lval a2: R|A<kotlin/Int, B>| = R|/A.A|<R|kotlin/Int|, R|B|>()
lval a3: R|A<kotlin/Any?, kotlin/Any?>| = R|/A.A|<*, *>()
}

View File

@@ -0,0 +1,54 @@
sealed class A
sealed class B : A()
class C : A()
sealed class D : B()
sealed class E : B()
fun test_1(e: A) {
val a = when (e) {
is C -> 1
is D -> 2
is E -> 3
}.plus(0)
val b = when (e) {
is B -> 1
is C -> 2
}.plus(0)
val c = when (e) {
is B -> 1
is C -> 2
is E -> 3
is D -> 4
}.plus(0)
val d = when (e) {
is E -> 1
is A -> 2
}.plus(0)
}
fun test_2(e: A) {
val a = when (e) {
is D -> 1
is E -> 2
}.<!UNRESOLVED_REFERENCE!>plus<!>(0)
val b = when (e) {
is B -> 1
is D -> 2
is E -> 3
}.<!UNRESOLVED_REFERENCE!>plus<!>(0)
val c = when (e) {
is B -> 1
is D -> 2
}.<!UNRESOLVED_REFERENCE!>plus<!>(0)
val d = when (e) {
is C -> 1
}.<!UNRESOLVED_REFERENCE!>plus<!>(0)
}

View File

@@ -0,0 +1,116 @@
FILE: exhaustiveness_sealedSubClass.kt
public sealed class A : R|kotlin/Any| {
private constructor(): R|A| {
super<R|kotlin/Any|>()
}
}
public sealed class B : R|A| {
private constructor(): R|B| {
super<R|A|>()
}
}
public final class C : R|A| {
public constructor(): R|C| {
super<R|A|>()
}
}
public sealed class D : R|B| {
private constructor(): R|D| {
super<R|B|>()
}
}
public sealed class E : R|B| {
private constructor(): R|E| {
super<R|B|>()
}
}
public final fun test_1(e: R|A|): R|kotlin/Unit| {
lval a: R|kotlin/Int| = when (R|<local>/e|) {
($subj$ is R|C|) -> {
Int(1)
}
($subj$ is R|D|) -> {
Int(2)
}
($subj$ is R|E|) -> {
Int(3)
}
}
.R|kotlin/Int.plus|(Int(0))
lval b: R|kotlin/Int| = when (R|<local>/e|) {
($subj$ is R|B|) -> {
Int(1)
}
($subj$ is R|C|) -> {
Int(2)
}
}
.R|kotlin/Int.plus|(Int(0))
lval c: R|kotlin/Int| = when (R|<local>/e|) {
($subj$ is R|B|) -> {
Int(1)
}
($subj$ is R|C|) -> {
Int(2)
}
($subj$ is R|E|) -> {
Int(3)
}
($subj$ is R|D|) -> {
Int(4)
}
}
.R|kotlin/Int.plus|(Int(0))
lval d: R|kotlin/Int| = when (R|<local>/e|) {
($subj$ is R|E|) -> {
Int(1)
}
($subj$ is R|A|) -> {
Int(2)
}
}
.R|kotlin/Int.plus|(Int(0))
}
public final fun test_2(e: R|A|): R|kotlin/Unit| {
lval a: <ERROR TYPE REF: Unresolved name: plus> = when (R|<local>/e|) {
($subj$ is R|D|) -> {
Int(1)
}
($subj$ is R|E|) -> {
Int(2)
}
}
.<Unresolved name: plus>#(Int(0))
lval b: <ERROR TYPE REF: Unresolved name: plus> = when (R|<local>/e|) {
($subj$ is R|B|) -> {
Int(1)
}
($subj$ is R|D|) -> {
Int(2)
}
($subj$ is R|E|) -> {
Int(3)
}
}
.<Unresolved name: plus>#(Int(0))
lval c: <ERROR TYPE REF: Unresolved name: plus> = when (R|<local>/e|) {
($subj$ is R|B|) -> {
Int(1)
}
($subj$ is R|D|) -> {
Int(2)
}
}
.<Unresolved name: plus>#(Int(0))
lval d: <ERROR TYPE REF: Unresolved name: plus> = when (R|<local>/e|) {
($subj$ is R|C|) -> {
Int(1)
}
}
.<Unresolved name: plus>#(Int(0))
}

View File

@@ -16,27 +16,11 @@ FILE: test.kt
}
public final fun test1(x: R|AnotherClass?|): R|kotlin/Unit| {
lval bar: R|kotlin/CharSequence| = when (lval <elvis>: R|kotlin/CharSequence?| = R|<local>/x|?.{ $subj$.R|/AnotherClass.bar| }) {
==($subj$, Null(null)) -> {
^test1 Unit
}
else -> {
R|<local>/<elvis>|
}
}
lval bar: R|kotlin/CharSequence| = R|<local>/x|?.{ $subj$.R|/AnotherClass.bar| } ?: ^test1 Unit
R|<local>/x|.R|/AnotherClass.bar|
}
public final fun test2(x: R|SomeClass?|): R|kotlin/Unit| {
lval bar: R|kotlin/CharSequence| = when (lval <elvis>: R|kotlin/CharSequence?| = R|<local>/x|?.{ $subj$.R|/SomeClass.bar| }) {
==($subj$, Null(null)) -> {
^test2 Unit
}
else -> {
R|<local>/<elvis>|
}
}
lval bar: R|kotlin/CharSequence| = R|<local>/x|?.{ $subj$.R|/SomeClass.bar| } ?: ^test2 Unit
R|<local>/x|.R|/SomeClass.bar|
}
public final fun test3(x: R|AnotherClass?|): R|kotlin/Unit| {
@@ -58,62 +42,22 @@ FILE: test.kt
}
public final fun test5(x: R|AnotherClass?|): R|kotlin/Unit| {
lval bar: R|kotlin/String| = when (lval <elvis>: R|kotlin/String?| = (R|<local>/x|?.{ $subj$.R|/AnotherClass.bar| } as? R|kotlin/String|)) {
==($subj$, Null(null)) -> {
^test5 Unit
}
else -> {
R|<local>/<elvis>|
}
}
lval bar: R|kotlin/String| = (R|<local>/x|?.{ $subj$.R|/AnotherClass.bar| } as? R|kotlin/String|) ?: ^test5 Unit
R|<local>/x|.R|/AnotherClass.foo|
}
public final fun test6(x: R|SomeClass?|): R|kotlin/Unit| {
lval bar: R|kotlin/String| = when (lval <elvis>: R|kotlin/String?| = (R|<local>/x|?.{ $subj$.R|/SomeClass.bar| } as? R|kotlin/String|)) {
==($subj$, Null(null)) -> {
^test6 Unit
}
else -> {
R|<local>/<elvis>|
}
}
lval bar: R|kotlin/String| = (R|<local>/x|?.{ $subj$.R|/SomeClass.bar| } as? R|kotlin/String|) ?: ^test6 Unit
R|<local>/x|.R|/SomeClass.foo|
}
public final fun test7(x: R|AnotherClass?|): R|kotlin/Unit| {
lval baz: R|kotlin/Boolean| = when (lval <elvis>: R|kotlin/Boolean?| = (R|<local>/x|?.{ $subj$.R|/AnotherClass.baz|() } as? R|kotlin/Boolean|)) {
==($subj$, Null(null)) -> {
^test7 Unit
}
else -> {
R|<local>/<elvis>|
}
}
lval baz: R|kotlin/Boolean| = (R|<local>/x|?.{ $subj$.R|/AnotherClass.baz|() } as? R|kotlin/Boolean|) ?: ^test7 Unit
R|<local>/x|.R|/AnotherClass.foo|
}
public final fun test8(x: R|AnotherClass?|): R|kotlin/Unit| {
lval bar: R|kotlin/CharSequence| = when (lval <elvis>: R|kotlin/CharSequence?| = R|<local>/x|?.{ $subj$.R|/AnotherClass.bar| }) {
==($subj$, Null(null)) -> {
^test8 Unit
}
else -> {
R|<local>/<elvis>|
}
}
lval bar: R|kotlin/CharSequence| = R|<local>/x|?.{ $subj$.R|/AnotherClass.bar| } ?: ^test8 Unit
R|<local>/x|.R|/AnotherClass.foo|
}
public final fun test9(x: R|AnotherClass?|): R|kotlin/Unit| {
lval baz: R|kotlin/Any| = when (lval <elvis>: R|kotlin/Any?| = R|<local>/x|?.{ $subj$.R|/AnotherClass.baz|() }) {
==($subj$, Null(null)) -> {
^test9 Unit
}
else -> {
R|<local>/<elvis>|
}
}
lval baz: R|kotlin/Any| = R|<local>/x|?.{ $subj$.R|/AnotherClass.baz|() } ?: ^test9 Unit
R|<local>/x|.R|/AnotherClass.foo|
}

View File

@@ -0,0 +1,19 @@
// ISSUE: KT-39075
class A {
fun unit() {}
}
fun foo(x: () -> Unit) {}
fun main(x: A?) {
val lambda = l@{
if (x?.hashCode() == 0) return@l
x?.unit()
}
// lambda has a type (() -> Unit?)
foo(lambda)
}

View File

@@ -0,0 +1,25 @@
FILE: coercionToUnitWithEarlyReturn.kt
public final class A : R|kotlin/Any| {
public constructor(): R|A| {
super<R|kotlin/Any|>()
}
public final fun unit(): R|kotlin/Unit| {
}
}
public final fun foo(x: R|() -> kotlin/Unit|): R|kotlin/Unit| {
}
public final fun main(x: R|A?|): R|kotlin/Unit| {
lval lambda: R|() -> kotlin/Unit| = l@fun <anonymous>(): R|kotlin/Unit| {
when () {
==(R|<local>/x|?.{ $subj$.R|kotlin/Any.hashCode|() }, Int(0)) -> {
^@l Unit
}
}
^ R|<local>/x|?.{ $subj$.R|/A.unit|() }
}
R|/foo|(R|<local>/lambda|)
}

View File

@@ -0,0 +1,14 @@
// ISSUE: KT-39048
// FILE: JavaClass.java
public class JavaClass<T extends Comparable<? super T>> {
public JavaClass(T from) {}
}
// FILE: main.kt
class K<T : Comparable<T>>(t: T)
fun main() {
K(0)
JavaClass(0)
}

View File

@@ -0,0 +1,11 @@
FILE: main.kt
public final class K<T : R|kotlin/Comparable<T>|> : R|kotlin/Any| {
public constructor<T : R|kotlin/Comparable<T>|>(t: R|T|): R|K<T>| {
super<R|kotlin/Any|>()
}
}
public final fun main(): R|kotlin/Unit| {
R|/K.K|<R|kotlin/Int|>(Int(0))
R|/JavaClass.JavaClass|<R|ft<ILT: 0, ILT: 0?>!|>(Int(0))
}

View File

@@ -0,0 +1,18 @@
// ISSUE: KT-39012
interface A
fun <T> foo(f: (MutableList<T>) -> Unit): List<T>? = TODO()
fun <T> listOf(): List<T> = TODO()
fun bar1(w: List<CharSequence>): List<CharSequence>? {
return foo { container ->
container.add("")
} ?: w
}
fun bar2(): List<CharSequence>? {
return foo { container ->
container.add("")
} ?: listOf()
}

View File

@@ -0,0 +1,21 @@
FILE: lambdaInElvis.kt
public abstract interface A : R|kotlin/Any| {
}
public final fun <T> foo(f: R|(kotlin/collections/MutableList<T>) -> kotlin/Unit|): R|kotlin/collections/List<T>?| {
^foo R|kotlin/TODO|()
}
public final fun <T> listOf(): R|kotlin/collections/List<T>| {
^listOf R|kotlin/TODO|()
}
public final fun bar1(w: R|kotlin/collections/List<kotlin/CharSequence>|): R|kotlin/collections/List<kotlin/CharSequence>?| {
^bar1 R|/foo|<R|kotlin/CharSequence|>(<L> = foo@fun <anonymous>(container: R|kotlin/collections/MutableList<kotlin/CharSequence>|): R|kotlin/Unit| {
^ R|<local>/container|.R|FakeOverride<kotlin/collections/MutableList.add: R|kotlin/Boolean|>|(String())
}
) ?: R|<local>/w|
}
public final fun bar2(): R|kotlin/collections/List<kotlin/CharSequence>?| {
^bar2 R|/foo|<R|kotlin/CharSequence|>(<L> = foo@fun <anonymous>(container: R|kotlin/collections/MutableList<kotlin/CharSequence>|): R|kotlin/Unit| {
^ R|<local>/container|.R|FakeOverride<kotlin/collections/MutableList.add: R|kotlin/Boolean|>|(String())
}
) ?: R|/listOf|<R|kotlin/CharSequence|>()
}

View File

@@ -0,0 +1,19 @@
// ISSUE: KT-39034
interface A
fun test_0(a: A, f: A.() -> Unit) {
a.f()
}
fun test_1(a: A, ys: List<A.() -> Unit>) {
for (y in ys) {
a.y()
}
}
fun test_2(a: A, vararg zs: A.() -> Unit) {
for (z in zs) {
a.z()
}
}

View File

@@ -0,0 +1,22 @@
FILE: nestedExtensionFunctionType.kt
public abstract interface A : R|kotlin/Any| {
}
public final fun test_0(a: R|A|, f: R|A.() -> kotlin/Unit|): R|kotlin/Unit| {
R|<local>/f|.R|FakeOverride<kotlin/Function1.invoke: R|kotlin/Unit|>|(R|<local>/a|)
}
public final fun test_1(a: R|A|, ys: R|kotlin/collections/List<kotlin/Function1<A, kotlin/Unit>>|): R|kotlin/Unit| {
lval <iterator>: R|kotlin/collections/Iterator<kotlin/Function1<A, kotlin/Unit>>| = R|<local>/ys|.R|FakeOverride<kotlin/collections/List.iterator: R|kotlin/collections/Iterator<kotlin/Function1<A, kotlin/Unit>>|>|()
while(R|<local>/<iterator>|.R|kotlin/collections/Iterator.hasNext|()) {
lval y: R|(A) -> kotlin/Unit| = R|<local>/<iterator>|.R|FakeOverride<kotlin/collections/Iterator.next: R|(A) -> kotlin/Unit|>|()
R|<local>/y|.R|FakeOverride<kotlin/Function1.invoke: R|kotlin/Unit|>|(R|<local>/a|)
}
}
public final fun test_2(a: R|A|, vararg zs: @R|kotlin/ExtensionFunctionType|() R|kotlin/Array<out kotlin/Function1<A, kotlin/Unit>>|): R|kotlin/Unit| {
lval <iterator>: R|kotlin/collections/Iterator<kotlin/Function1<A, kotlin/Unit>>| = R|<local>/zs|.R|FakeOverride<kotlin/Array.iterator: R|kotlin/collections/Iterator<kotlin/Function1<A, kotlin/Unit>>|>|()
while(R|<local>/<iterator>|.R|kotlin/collections/Iterator.hasNext|()) {
lval z: R|(A) -> kotlin/Unit| = R|<local>/<iterator>|.R|FakeOverride<kotlin/collections/Iterator.next: R|(A) -> kotlin/Unit|>|()
R|<local>/z|.R|FakeOverride<kotlin/Function1.invoke: R|kotlin/Unit|>|(R|<local>/a|)
}
}

View File

@@ -1,12 +1,4 @@
FILE: invokeInWhenSubjectVariableInitializer.kt
public final fun test(func: R|() -> kotlin/String?|): R|kotlin/Unit| {
lval x: R|kotlin/String| = when (lval <elvis>: R|kotlin/String?| = R|<local>/func|.R|FakeOverride<kotlin/Function0.invoke: R|kotlin/String?|>|()) {
==($subj$, Null(null)) -> {
String()
}
else -> {
R|<local>/<elvis>|
}
}
lval x: R|kotlin/String| = R|<local>/func|.R|FakeOverride<kotlin/Function0.invoke: R|kotlin/String?|>|() ?: String()
}

View File

@@ -0,0 +1,17 @@
// ISSUE: KT-39046
fun foo(b: B<Int, Int>) {}
fun test_1(b: B<String, Number>) {
foo(b.myMap {
it.k.length // implicits
} as B<Int, Int>)
}
fun test_2(s: String) {
val func = { s.length } as B<Int, Int>
}
class B<out K, V>(val k: K, val v: V)
fun <X, R, V> B<X, V>.myMap(transform: (B<X, V>) -> R): B<R, V> = TODO()

View File

@@ -0,0 +1,30 @@
FILE: lambdaInLhsOfTypeOperatorCall.kt
public final fun foo(b: R|B<kotlin/Int, kotlin/Int>|): R|kotlin/Unit| {
}
public final fun test_1(b: R|B<kotlin/String, kotlin/Number>|): R|kotlin/Unit| {
R|/foo|((R|<local>/b|.R|/myMap|<R|kotlin/String|, R|kotlin/Int|, R|kotlin/Number|>(<L> = myMap@fun <anonymous>(it: R|B<kotlin/String, kotlin/Number>|): R|kotlin/Int| {
^ R|<local>/it|.R|FakeOverride</B.k: R|kotlin/String|>|.R|kotlin/String.length|
}
) as R|B<kotlin/Int, kotlin/Int>|))
}
public final fun test_2(s: R|kotlin/String|): R|kotlin/Unit| {
lval func: R|B<kotlin/Int, kotlin/Int>| = (fun <anonymous>(): R|kotlin/Int| {
^ R|<local>/s|.R|kotlin/String.length|
}
as R|B<kotlin/Int, kotlin/Int>|)
}
public final class B<out K, V> : R|kotlin/Any| {
public constructor<out K, V>(k: R|K|, v: R|V|): R|B<K, V>| {
super<R|kotlin/Any|>()
}
public final val k: R|K| = R|<local>/k|
public get(): R|K|
public final val v: R|V| = R|<local>/v|
public get(): R|V|
}
public final fun <X, R, V> R|B<X, V>|.myMap(transform: R|(B<X, V>) -> R|): R|B<R, V>| {
^myMap R|kotlin/TODO|()
}

Some files were not shown because too many files have changed in this diff Show More