Compare commits

...

435 Commits

Author SHA1 Message Date
Alexander Udalov
adfe706504 Add release notes for 1.0.2-1
(cherry picked from commit 1ebcd193a2)
2016-06-23 17:38:38 +03:00
Nikolay Krasko
f6c1ff038c Remove stopping JobSchedule executor. It now fails on shutdown attempt. 2016-06-10 13:47:36 +03:00
Nikolay Krasko
0747a6f1d0 plugin.xml: Add dependency on java module
This restricts usage of plugin to IDEA and Android Studio
2016-06-08 18:21:47 +03:00
Yan Zhulanow
c3bd24349c Fix EA-80764. Do not try to get the resource manager for the disposed module 2016-06-07 18:31:04 +03:00
Yan Zhulanow
8be1335a54 Fix EA-82394. PsiType.getClassName() can return null. Return "<anonymous type>" in that case. 2016-06-07 18:31:02 +03:00
Yan Zhulanow
cf033d0f20 Fix EA-82166. NPE. loadModel() can return null, and it's a bad idea to call methods on a null pointer. 2016-06-07 18:31:01 +03:00
Yan Zhulanow
98b28996b0 Fix EA-82449. Do not run Lint diagnostics if the project is already disposed 2016-06-07 18:31:00 +03:00
Yan Zhulanow
c6e328aa0f KT-12387 Fix Performance problem with Lint in IDE
Call checkCanceled() before running Lint diagnostics (UastScanner)
2016-06-07 18:30:59 +03:00
Yan Zhulanow
61e8e01608 Fix #KT-12047 (Kotlin Lint: "Missing @JavascriptInterface on methods" does not report anything) 2016-06-07 18:30:58 +03:00
Yan Zhulanow
c3d01ec9ed Fix #KT-12015 (Kotlin Lint False Positive for Bundle.getInt()).
Android firstly checks API version against the function call receiver type, so we should do the same to be consistent.
2016-06-07 18:28:42 +03:00
Alexey Tsvetkov
723df5fdc3 Shade in kotlin-build-common-test 2016-06-07 14:17:25 +03:00
Alexey Tsvetkov
ddbf7906e1 Shade in kotlin-android-extensions 2016-06-07 14:17:20 +03:00
Alexey Tsvetkov
ad811531bd Shade in kotlin-compiler-embeddable
Now kotlin gradle plugin is compatible with android gradle plugin 2.2

     #KT-12478 fixed
     #KT-12431 fixed
     #KT-12406 fixed
2016-06-07 14:17:16 +03:00
Alexey Tsvetkov
a54c04ab04 Set idea.io.use.nio2=true every build on windows
Otherwise (setting property once in static block) gradle daemon might clear system properties

     #KT-11770 fixed
2016-06-07 14:16:46 +03:00
Nikolay Krasko
e44f5ce624 More write action requirement remove
Workaround for exception: Refactorings should not be started inside write action because they start progress inside and any read action from the progress task would cause the deadlock
2016-05-24 17:49:45 +03:00
Nikolay Krasko
bb470f3e58 Don't request write action for ChangeParameterTypeFix because it's based on refactoring
Workaround for exception: Refactorings should not be started inside write action because they start progress inside and any read action from the progress task would cause the deadlock
2016-05-24 17:49:45 +03:00
Nikolay Krasko
f16f364ea4 Don't request write action for RemoveUnusedFunctionParameterFix because it's based on refactoring (KT-12440)
Workaround for exception: Refactorings should not be started inside write action because they start progress inside and any read action from the progress task would cause the deadlock

 #KT-12440 Fixed
2016-05-24 17:49:44 +03:00
Nikolay Krasko
384c651dee Don't request write action for ReplaceExplicitFunctionLiteralParamWithItIntention because it's based on refactoring (KT-12436)
Workaround for exception: Refactorings should not be started inside write action because they start progress inside and any read action from the progress task would cause the deadlock

 #KT-12436 Fixed
2016-05-24 17:49:43 +03:00
Nikolay Krasko
edeaff2023 Restore packing plugin-api module output to plugin 2016-05-20 20:08:33 +03:00
Nikolay Krasko
4a646faac8 Check there's no direct usages of asm (org.objectweb.asm) library in project
Such usages should be replaced with asm from idea (org.jetbrains.org.objectweb.asm)
2016-05-20 16:06:29 +03:00
Nikolay Krasko
95d4efdbd7 Don't use reference to asm directly. Use asm from Idea instead. 2016-05-20 16:06:28 +03:00
Nikolay Krasko
6251e8c461 Remove unused import 2016-05-18 13:53:28 +03:00
Nikolay Krasko
923f9fb7c2 Remove unused method that causes compatibility problem in update AS plugin 2016-05-17 21:42:58 +03:00
Alexey Sedunov
9998841a60 Rename: Do not use Change Signature for parameter renaming
(cherry picked from commit 797465a)
2016-05-16 13:22:30 +03:00
Alexander Udalov
e5fd456075 Add empty source jars to kotlin-build-common Maven artifacts
Maven Central requires all artifacts to have sources and javadocs
2016-05-12 23:28:33 +03:00
Ilya Gorbunov
ddadef7331 Add tests for deserialization of collections persisted with kotlin 1.0
(cherry picked from commit 15dcd3d)
2016-05-12 21:22:09 +03:00
Ilya Gorbunov
4ff79ae2bc Fix serialVersionUID for EmptyList after introducing RandomAccess interface. #KT-10794
(cherry picked from commit 6a07d5f)
2016-05-12 21:22:01 +03:00
Dmitry Jemerov
62d16d88c7 specify precise path for module source root so that Java descriptors are found correctly 2016-05-12 18:48:29 +02:00
Dmitry Jemerov
05c62b0459 workaround for KT-9407: don't use qualified name in Pattern class link
#KT-12129 Fixed
(cherry picked from commit be8c953)
2016-05-12 17:54:47 +02:00
Dmitry Jemerov
c451a47a63 specify github revision number in build parameters
(cherry picked from commit 11c0b30)
2016-05-12 16:58:25 +02:00
Nikolay Krasko
9f634e4fab No more patched jflex 1.4.3 in idea repository. Download artifact from maven.
02c7c658e8
2016-05-12 12:27:37 +03:00
Nikolay Krasko
99cd039edc Make downloading idea sources optional 2016-05-12 12:27:34 +03:00
Alexey Tsvetkov
7521b762fe Minor: fix downloading sdk in test 2016-05-12 00:26:50 +03:00
Alexey Tsvetkov
5fa0eecdee Avoid cache corruption on compile error
#KT-11874 fixed
2016-05-12 00:26:49 +03:00
Alexey Tsvetkov
6ccb123d58 Fix Application leak in AbstractAnnotationProcessorBoxTest 2016-05-11 23:55:55 +03:00
Alexey Tsvetkov
6e746d85c5 Increase daemon test memory limit again
It is still more strict than it was before (before each test build could grow < 2500 kb, now < 300 kb on average of 10 runs)
2016-05-11 23:55:52 +03:00
Yan Zhulanow
8755dec1b1 Fix EA-81689 2016-05-11 21:35:29 +03:00
Alexander Udalov
b0eb7a8484 Remove empty 1.0.3 and 1.1 sections 2016-05-11 20:50:00 +03:00
Alexander Udalov
d310564f8c Update ChangeLog for 1.0.2 2016-05-11 11:26:14 +03:00
Alexey Andreev
037b0a2b7b KT-11996 Fix issue with referencing outer class in case of inner class constructors and members/properties. Fix issue with referencing outer classes from secondary constructors. Remove unnecessary tests. 2016-05-10 17:53:35 +03:00
Alexey Andreev
3c80d0f86f KT-11823 Generate proper argument for closure constructor for this as a free variable. Give some explanation for function that generates closure arguments as well as a clear name. Give explanation to some code in UsageTracker.isSingletonReceiver, augmented by a test case. 2016-05-10 17:43:05 +03:00
Nikolay Krasko
fde3e8f374 Remove write action from refactoring start (KT-11486)
#KT-11486 Fixed
2016-05-10 16:18:45 +03:00
Valentin Kipyatkov
beeb92d864 Fixed dialog with suggestion to process external code shown even when there is nothing to process
(cherry picked from commit 7b1bf4c)
2016-05-10 15:02:47 +03:00
Alexey Tsvetkov
73ad5eb472 Refactoring: rename ClassBuilderMode entry LIGHT_CLASSES_WITH_METADATA->KAPT 2016-05-05 20:48:26 +03:00
Alexey Tsvetkov
1bdb55b3fc Fix collecting source retention annotations
#KT-12187 fixed
2016-05-05 20:48:26 +03:00
Alexey Andreev
b39bd00309 JS/RTTI: minor refactoring of expandInCalls 2016-05-05 17:27:23 +03:00
Alexey Andreev
7625ea7ca1 JS/RTTI: if it's known that T <: X & Y, where T is non-reified type variable, for each a is T check that a is X && a is Y 2016-05-05 17:27:22 +03:00
Alexey Andreev
994cbe7468 JS/RTTI: in expressions like a as T when inferred type for a is S, where S <: T, don't generate type checking 2016-05-05 17:27:22 +03:00
Alexey Andreev
da8b5d1678 JS/RTTI. Fix runtime checking against kotlin.CharSequence 2016-05-05 17:27:21 +03:00
Alexey Andreev
df71ce42e5 JS/RTTI: fix withInlineTurnedOff test 2016-05-05 17:27:20 +03:00
Alexey Andreev
31f1027491 JS/RTTI: fix compiler crashing when translating expressions like (continue as T) 2016-05-05 17:27:19 +03:00
Zalim Bashorov
a43734b663 JS/RTTI. Fix build and tests 2016-05-05 17:27:18 +03:00
Alexey Tsvetkov
f65acea46a JS/RTTI. Fix run-time type checking against Comparable 2016-05-05 17:27:17 +03:00
Alexey Tsvetkov
78b89f67fb JS/RTTI. Fix RegExpMatch 2016-05-05 17:27:15 +03:00
Alexey Tsvetkov
e6de277729 JS/RTTI: removed Kotlin.orNull(Kotlin.isAny) optimization 2016-05-05 17:27:14 +03:00
Alexey Tsvetkov
9cb9397747 JS/RTTI: added another cast to reified test 2016-05-05 17:27:13 +03:00
Alexey Tsvetkov
d60566984f JS/RTTI: Added cast to Array test 2016-05-05 17:27:12 +03:00
Alexey Tsvetkov
cae827ace1 JS/RTTI: simplify cast to Any test 2016-05-05 17:27:11 +03:00
Alexey Tsvetkov
ece8d847a7 JS/RTTI: fixed cast to generic type parameter with upper bound different than Any 2016-05-05 17:27:10 +03:00
Alexey Tsvetkov
8bc8a1a1e9 JS/RTTI: (minor) fixed typo 2016-05-05 17:27:10 +03:00
Alexey Tsvetkov
c02d8ba872 JS/RTTI: (minor) escape code fragments in comments 2016-05-05 17:27:08 +03:00
Alexey Tsvetkov
944f812cdf JS/RTTI: fix nullability check 2016-05-05 17:27:08 +03:00
Alexey Tsvetkov
eb4bd5290b JS/RTTI: use Array.isArray to check array instance 2016-05-05 17:27:07 +03:00
Alexey Tsvetkov
19a2f6ad1d JS/RTTI: use typeof f === 'function' to check function instance 2016-05-05 17:27:06 +03:00
Alexey Tsvetkov
c8f332fdcb JS/RTTI: cast to generic type parameter as to Any 2016-05-05 17:27:05 +03:00
Alexey Tsvetkov
d09c26ac44 JS/RTTI: fix cast to Any 2016-05-05 17:27:04 +03:00
Alexey Tsvetkov
d0f0d3c9dc JS/RTTI: support safe casts 2016-05-05 17:27:04 +03:00
Alexey Tsvetkov
8c4a24f42e JS/RTTI: support unsafe casts
#KT-2670 fixed
2016-05-05 17:27:03 +03:00
Alexey Tsvetkov
42a58ae6a8 JS/RTTI: made cast test generated 2016-05-05 17:27:02 +03:00
Alexey Tsvetkov
f2a3ed4ac6 JS/RTTI: test that reified is-check works when inline turned off 2016-05-05 17:27:01 +03:00
Alexey Tsvetkov
fa78bbfded JS/RTTI: fixed double testing for null for reified 2016-05-05 17:27:00 +03:00
Alexey Tsvetkov
41096ea6b8 JS/RTTI: avoid possible side-effect for is-check on nullable type
#KT-7038 fixed
2016-05-05 17:27:00 +03:00
Alexey Tsvetkov
f355d4b4e0 JS/RTTI: use generation for rtti test 2016-05-05 17:26:59 +03:00
Alexey Tsvetkov
c577450a87 JS/RTTI: fixed is-check on nullable reified parameters
#KT-7016 fixed
    #KT-8012 fixed
2016-05-05 17:26:58 +03:00
Mikhael Bogdanov
abfaf29fff 'bytecodeText' test for synthetic accessor generic signature converted to 'writeSignature' test
(cherry picked from commit cd6b709)
2016-05-04 17:20:01 +03:00
Mikhael Bogdanov
e4e975db7d Fix for KT-12127: Undeclared type variable on delegated property backing field
#KT-12127 Fixed
(cherry picked from commit ee7bbbf)
2016-05-04 17:19:58 +03:00
Nikolay Krasko
1adefff577 Do not request write action for MoveDeclarationToSeparateFileIntention (EA-81511)
There's nothing but delegation to move refactoring. This started to fail in br146 because of this commit:
334772b7a8
2016-05-04 14:56:47 +03:00
Alexey Tsvetkov
d262b0e602 Add class stubs dir to stub generation task classpath 2016-04-29 19:25:09 +03:00
Alexey Tsvetkov
32fff210fb Serialize error type to proto when generating stubs 2016-04-29 19:25:09 +03:00
Alexey Tsvetkov
3033341fa4 Refactoring: rename javaAptSourceDir->hackAnnotationDir 2016-04-29 19:25:09 +03:00
Alexey Tsvetkov
4e68be6132 Refactoring: rename AnnotatedElementDescriptor->AnnotatedElement 2016-04-29 19:25:09 +03:00
Alexey Tsvetkov
7d1d8985b2 Exclude compiled files when compiling incrementally 2016-04-29 19:25:08 +03:00
Alexey Tsvetkov
719465d58c Report compiled classes when generating kapt stubs 2016-04-29 19:25:08 +03:00
Alexey Tsvetkov
965698eeb5 Include metadata in light classes for kapt 2016-04-29 19:25:08 +03:00
Alexey Tsvetkov
503a96c469 Fix incremental compilation with kapt generating stubs
Changes:
* map incremental property to compile kotlin after java task
* when generating stubs compile kotlin task should not remove or copy classfiles
2016-04-29 19:25:08 +03:00
Alexey Tsvetkov
7e88a2eb13 Add kapt incremental tests 2016-04-29 19:25:08 +03:00
Alexey Tsvetkov
0e8710c6c2 Update kapt annotations file incrementally 2016-04-29 19:25:08 +03:00
Alexey Tsvetkov
cc4ed6603f Serialize KotlinAnnotationProvider 2016-04-29 19:25:08 +03:00
Alexey Tsvetkov
7a96ab04bd Minor: extract constant 2016-04-29 19:25:07 +03:00
Alexey Tsvetkov
2059cebc01 Refactoring: make AnnotatedElementDescriptor hierarchy sealed 2016-04-29 19:25:07 +03:00
Alexey Tsvetkov
8dae11b358 Pass reader as param 2016-04-29 19:25:07 +03:00
Alexey Tsvetkov
8d8b92af59 Make fun local since it's bound to outer function semantics 2016-04-29 19:25:07 +03:00
Alexey Tsvetkov
ba1e5c39ba Read annotations during construction of KotlinAnnotationsProvider
The rationale is to access kotlinClassesInternal and annotatedKotlinElementsInternal
in any order
2016-04-29 19:25:07 +03:00
Alexey Tsvetkov
66a2d20dc1 Minor: add const 2016-04-29 19:25:07 +03:00
Alexey Tsvetkov
e14c092140 Pass reader in constructor to KotlinAnnotationProvider 2016-04-29 19:25:07 +03:00
Alexey Tsvetkov
a622dcaedd Make annotation collector tests more thorough 2016-04-29 19:25:06 +03:00
Alexey Tsvetkov
b504057ffe Refactoring: move kapt tests to separate class 2016-04-29 19:25:06 +03:00
Alexey Tsvetkov
01b77f357f Prevent compile tasks from running when nothing changes
#KT-10932 fixed
2016-04-29 19:25:06 +03:00
Alexey Tsvetkov
58e3e01013 Minor: use more recent version of gradle in test 2016-04-29 19:25:06 +03:00
Alexey Tsvetkov
a0eeb63196 Minor: do not print output in assertion message 2016-04-29 19:25:06 +03:00
Alexey Tsvetkov
16f8d9805b Refactoring: extract properties for gradle task's properties access in plugin 2016-04-29 19:25:06 +03:00
Zalim Bashorov
89eda710ab Fix NoSuchMethodError when try to access in test to internal member from production for gradle projects imported into IDEA 16 or higher
#KT-11993 Fixed
(cherry picked from commit ed0fa2c)
2016-04-29 18:26:32 +03:00
Alexander Udalov
ffaebc3415 Update ChangeLog for 1.0.2 2016-04-29 15:44:06 +03:00
Mikhail Glukhikh
6d3389df38 Correct handling of empty super type list while adding an entry #KT-12011 Fixed
(cherry picked from commit 918f843)
2016-04-29 09:23:54 +03:00
Alexey Sedunov
92fd99622b Change Signature: Do not use local declaration as a context for a type code fragment
(cherry picked from commit e6ab2f1)
2016-04-27 18:25:44 +03:00
Alexander Udalov
c40c04bdce Perform version override earlier and only on teamcity 2016-04-26 22:06:06 +03:00
Mikhail Zarechenskiy
862d5a13d0 Move part of code that related to 'Optimize imports' action to ide-common module 2016-04-26 20:50:37 +03:00
Mikhail Zarechenskiy
96626e693d Get rid of guava's collections and dependency on Idea's settings from util function
This commit prepares 'prepareOptimizedImports' function to
move to the ide-common module to reuse it in the Eclipse plugin
2016-04-26 20:50:30 +03:00
Nikolay Krasko
a72dc1887a Add write action for shorten references in finish template after building call (KT-12056)
Write action was removed in idea 146

 #KT-12056 Fixed
2016-04-26 20:14:33 +03:00
Nikolay Krasko
40f9d7680c Add write action for shortening references in templates (KT-11418)
Write action was removed in idea 146.

#KT-11418 Fixed
2016-04-26 20:05:27 +03:00
Nikolay Krasko
2c0bf5a12d Revert write actions in utility code (EA-81892)
Revert commits:
ab0fe0a900
97a97614b5
2016-04-26 20:04:57 +03:00
Zalim Bashorov
61295a6003 Minor: fix tests
(cherry picked from commit 3048c29)
2016-04-26 19:12:17 +03:00
Alexey Sedunov
316e8ae504 Change Signature: Fix context element for type code fragments to avoid bogus "Type can not be resolved" warnings
#KT-11862 Fixed
(cherry picked from commit dc9ab21)
2016-04-26 18:08:09 +03:00
Alexey Andreev
b6d132751b KT-11100 Fix generation of name of FakeCallableDescriptorForObject that is presumably used to express invoke operator on (companion) objects 2016-04-26 17:07:32 +03:00
Alexey Sedunov
0c05245f2f Spring Support: Replace accessor name with property name when processing usages in Kotlin files
#KT-11880 Fixed
(cherry picked from commit 12987de)
2016-04-26 16:24:44 +03:00
Zalim Bashorov
37ecd149b2 Add Unit to compiled part of Kotlin JS stdlib and don't show "Kotlin not configured" for Kotlin JS projects
#KT-11556 Fixed

(cherry picked from commit 658eac2)
2016-04-25 18:04:01 +03:00
Alexander Udalov
ea915cd538 Update ChangeLog for 1.0.2 2016-04-22 21:23:31 +03:00
Yan Zhulanow
54b7c4a09e Lint: Fix KT-12009: IAE at JavaContext.getLocation()
(cherry picked from commit d478b90)
2016-04-22 19:50:50 +03:00
Yan Zhulanow
75e8aa23eb Lint: run inspections only for Kotlin
(cherry picked from commit 9ea7a4f)
2016-04-22 19:50:47 +03:00
Yan Zhulanow
91c7fe40ce Lint: Remove AssertDetector (unrelated to Kotlin)
(cherry picked from commit 04ed20c)
2016-04-22 19:50:45 +03:00
Yan Zhulanow
8223ed5b6e Minor: Fix Uast blinking tests
(cherry picked from commit cbe21ab)
2016-04-22 19:50:43 +03:00
Yan Zhulanow
36ccbf6b83 Fix EA-81689
(cherry picked from commit 16b8311)
2016-04-22 19:50:41 +03:00
Yan Zhulanow
7eeaecc4a7 Minor: fix sparam -> setparam
(cherry picked from commit 4298559)
2016-04-22 19:50:38 +03:00
Alexey Andreev
0d4e3ed0f6 KT-6201 KT-6203 KT-6326 KT-6777 Add test cases to prove that issues are no longer reproducible
(cherry picked from commit 0869eb7)
2016-04-22 10:18:10 +03:00
Yan Zhulanow
096c77ee9e Minor: Fix compilation problem 2016-04-22 04:16:53 +03:00
Yan Zhulanow
5a6ab876be Lint: Review changes
(cherry picked from commit 33f9a0c)
2016-04-21 20:12:11 +03:00
Yan Zhulanow
5110ac2666 Lint: Fix KT-11922: ClassCastException: org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl cannot be cast to org.jetbrains.kotlin.descriptors.ClassDescriptor
(cherry picked from commit d7faef6)
2016-04-21 20:11:16 +03:00
Yan Zhulanow
1ffd998207 Lint: Fix KT-11919 ("Missing Parcelable CREATOR field" rule is not accurate)
(cherry picked from commit a2b1eb7)
2016-04-21 20:11:12 +03:00
Yan Zhulanow
5be10b34c2 Lint: Fix KT-11939 (@SuppressLint("PrivateResource") doesn't work)
(cherry picked from commit 33434a3)
2016-04-21 20:11:09 +03:00
Yan Zhulanow
c17fd0b0d0 Lint: Fix KT-11924 (False positive on beginTransaction() should be completed with a commit() call)
(cherry picked from commit 574aa5d)
2016-04-21 20:11:05 +03:00
Yan Zhulanow
0eadae9535 Lint, Uast: Fix Java function descriptor calculation KT-11923
(cherry picked from commit 5008c6d)
2016-04-21 20:10:35 +03:00
Yan Zhulanow
f7ee7eabdc Lint: Fix EA-81466
(cherry picked from commit aa06cd8)
2016-04-21 20:10:32 +03:00
Yan Zhulanow
cd8e30f1f5 Lint: Fix EA-81613, EA-81468
(cherry picked from commit 64dbba8)
2016-04-21 20:10:29 +03:00
Alexey Sedunov
1dd1f15b95 Minor: Fix test data 2016-04-21 18:24:54 +03:00
Alexey Sedunov
ac0a9c476c Find Usages: Start read action for derived class search
#KT-11845 Fixed
(cherry picked from commit df07554)
2016-04-21 17:01:50 +03:00
Alexey Sedunov
7f412a47a0 Find Usages: Fixed searching of Java usages for @JvmStatic properties and @JvmStatic @JvmOverloads functions
#KT-11736 Fixed
(cherry picked from commit 021c88e)
2016-04-21 17:00:59 +03:00
Nikolay Krasko
65f9aef779 Write Action: Add write action for template finish processor (KT-11418) 2016-04-21 15:03:33 +03:00
Nikolay Krasko
32a037df22 Write Action: Wrap import insertion with write action 2016-04-21 15:03:32 +03:00
Nikolay Krasko
bda218c50b Write Action: Add write action for deleting qualifier in shortenReferences
Problem revealed after template listners are executed without write action
5c2c946265
2016-04-21 15:03:29 +03:00
Nikolay Krasko
e0eece53c4 Update until version for new idea build numbering 2016-04-21 15:01:53 +03:00
Alexey Andreev
6b2435e0b7 KT-11030 Remove tests for diagnostics for local classes in JS backend 2016-04-21 10:46:09 +03:00
Alexey Andreev
8407757a7c KT-11030 Initialization order of enum entries in JS now conforms to JVM backend 2016-04-21 10:46:09 +03:00
Alexey Andreev
53e6fde7f1 KT-11030 Minor code improvements 2016-04-21 10:46:08 +03:00
Alexey Andreev
1b29496b9d KT-11028 Add test for the issue 2016-04-21 10:46:08 +03:00
Alexey Andreev
c3941599e9 KT-11030 Fix referencing wrong field generated for captured variable when this captured variable referenced both from constructor and non-constructor method. Avoid duplicate generation of call to delegated constructor. 2016-04-21 10:46:07 +03:00
Alexey Andreev
58f5628165 KT-11611 Prevent duplicate generation of default values of secondary constructor parameters 2016-04-21 10:46:07 +03:00
Alexey Andreev
1c1001cd82 KT-11030 When constructor of object expression calls super constructor, place this call at object creation instead of object's constructor. This allows to capture outer this reference properly in certain cases. JVM backend uses the same approach 2016-04-21 10:46:07 +03:00
Alexey Andreev
7338cb0d0b KT-11030 Refactor translation of class to support secondary constructors of local classes 2016-04-21 10:46:06 +03:00
Alexey Andreev
ded40b5529 KT-11030 Simplify code and refactor generation of object expressions 2016-04-21 10:46:06 +03:00
Alexey Andreev
2771a91dfb KT-11030 Refactoring code to properly implement secondary constructors in local classes 2016-04-21 10:46:05 +03:00
Alexey Andreev
277965f940 KT-11030 Fix translation of secondary constructors of inner classes 2016-04-21 10:46:05 +03:00
Alexey Andreev
d80c049c13 KT-11030 Fix subclassing of local class by local class 2016-04-21 10:46:04 +03:00
Alexey Andreev
15e70e3c21 KT-11030 When local function is declared inside constructor, capture this into this function 2016-04-21 10:46:04 +03:00
Alexey Andreev
c4ba543578 KT-11030 Make copy method of local data classes to copy captured variables 2016-04-21 10:46:03 +03:00
Alexey Andreev
57978ad42a KT-11030 Fix capturing of local variables via by expression, i.e. object : ClassName by v where v is local variable 2016-04-21 10:46:03 +03:00
Alexey Andreev
6bdbf23bdb KT-11030 Repair support of enums. Minor refactoring of ClassTranslator 2016-04-21 10:46:03 +03:00
Alexey Andreev
534817b7a6 KT-11030 Don't capture companion objects into closure 2016-04-21 10:46:02 +03:00
Alexey Andreev
6360c51ac2 KT-11030 Fix translation of FQN of native companion objects 2016-04-21 10:46:02 +03:00
Alexey Andreev
61ca6bfb8f KT-11030 Copy static properties of object's class to instance of object (think about moving local functions to member methods in objects) 2016-04-21 10:46:01 +03:00
Alexey Andreev
a3f25fc823 KT-11030 Avoid name clash between member fields and fields that store closure of local classes 2016-04-21 10:46:01 +03:00
Alexey Andreev
d6ae45ff67 KT-11030 Unify concept of objects and companion objects. Fix order of initialization of nested objects. 2016-04-21 10:46:01 +03:00
Alexey Andreev
3c919b17b3 KT-11030 Implements closures in classes. Represent local object literals as classes 2016-04-21 10:46:00 +03:00
Alexey Andreev
b244590c52 KT-11030 Implements local classes that don't have closure 2016-04-21 10:46:00 +03:00
Alexey Andreev
a5be0ceaec KT-11030 Disable error reporting of local classes in JS backend 2016-04-21 10:45:59 +03:00
Alexey Andreev
3cb37a7257 KT-11030 Borrow test for local classes from JVM backend 2016-04-21 10:45:59 +03:00
Alexey Tsvetkov
3786c23249 Minor: slightly increase memory limit for gradle daemon test 2016-04-20 13:45:27 +03:00
Ilya Chernikov
bf0cd8919a Fix mistakenly removed import 2016-04-20 10:03:47 +02:00
Alexander Udalov
acf51ab6e8 Do not consider error results successful in '::' LHS resolution
Fixes EA-81649
2016-04-19 19:43:24 +03:00
Alexander Udalov
78dd3488f8 Extract '::' type-checking code to DoubleColonExpressionResolver 2016-04-19 19:43:17 +03:00
Yan Zhulanow
ce747884c1 Fix "No error on increment or augmented assignment when 'get' is an operator but 'set' is not" #KT-11300
(cherry picked from commit 9b1402d)
2016-04-19 19:25:44 +03:00
Yan Zhulanow
f53529fad2 Android Extensions: Do not upcast ViewStub to View (KT-10321)
(cherry picked from commit 371e80b)
2016-04-19 18:49:43 +03:00
Yan Zhulanow
c4ea34a084 Android Extensions: handle layout file rename
(cherry picked from commit 6e14c11)
2016-04-19 18:49:35 +03:00
Yan Zhulanow
86fc06d24f Android Extensions: regenerate properties when layout is renamed/deleted/added (KT-11944)
(cherry picked from commit 47b3394)
2016-04-19 18:48:52 +03:00
Yan Zhulanow
8d3d54af1e Android Extensions: support identifiers with packages (KT-10841)
(cherry picked from commit 9e33b7d)
2016-04-19 18:48:45 +03:00
Alexey Tsvetkov
133bf20698 Make Kotlin2JsGradlePluginIT test compatible with gradle 2.x 2016-04-18 22:14:06 +03:00
Alexey Tsvetkov
8fa610a463 Make gradle daemon thread leak test more thorough
Former test made the following assertion:
for any of 3 sequent builds on the same gradle daemon
the difference in used memory between build start and finish
should not exceed 2500 kb.

Current test makes the following assertion:
the difference of used memory after first and last
of 10 sequent builds on the same daemon should not exceed 200 kb.
2016-04-18 22:14:03 +03:00
Alexey Tsvetkov
64c1a16b36 Remove ThreadTracker from gradle plugin
ThreadTracker was introduced to detect memory leaks
when using gradle daemon. However, it makes
quite strong assumption about build lifecycle:
there should not be any builds started after
kotlin plugin is configured that are alive when
buildFinished callback is called.

This assumption can be broken by some gradle configurations
namely our android tests and gradle 2.13-rc.

Since we already have daemon memory leak test (KotlinGradlePluginIT#testKotlinOnlyDaemonMemory),
after some discussion it was decided to remove ThreadTracker
2016-04-18 22:13:59 +03:00
Mikhail Zarechenskiy
e0aee0acc2 Create artifact with 'formatter' module output to share it with Eclipse plugin 2016-04-18 21:43:40 +03:00
Mikhail Zarechenskiy
6649588dff Split KotlinBlock on two clases to share independent logic about
formatting  between Idea and Eclipse

 Also make 'formatter' module depend on fewer dependencies
2016-04-18 21:43:40 +03:00
Mikhail Zarechenskiy
e1fca178e9 Move files related to formatting to module 'formatter' as is 2016-04-18 21:43:40 +03:00
Mikhail Zarechenskiy
7ba8f1f74d Create 'formatter' module
Purpose of this module is to extract common code  about formatting and reuse it in Eclipse
2016-04-18 21:43:40 +03:00
Mikhail Zarechenskiy
21cfff6ab3 J2K KotlinBlock: convert and prettify
Also get rid of ContainerUtil
2016-04-18 21:43:40 +03:00
Mikhail Zarechenskiy
4fa49ed28e J2K KotlinBlock: rename 2016-04-18 21:43:40 +03:00
Alexey Sedunov
8ef8af8675 Light Classes: Replace accessor with property name when renaming KtProperty/KtParameter through its light methods
#KT-11880 Fixed
(cherry picked from commit 8bab59f)
2016-04-18 18:00:19 +03:00
Alexey Sedunov
700c6cd2d7 Spring Support: Allow injection of SpEL into string literals with escape sequences
#KT-11904 Fixed
(cherry picked from commit 20c6fce)
2016-04-18 18:00:18 +03:00
Ilya Chernikov
41102693a5 Fix KT-10507 - "missing extension point" with parallel compilation 2016-04-18 15:11:49 +02:00
Natalia Ukhorskaya
97e2c67a18 Debugger: 'Step Over' unexpectedly resume if condition of 'while' loop contains inline function call
#KT-11932 Fixed
2016-04-15 18:13:48 +03:00
Alexey Andreev
4a20e1db83 KT-11875 Moves code that uncovers the following JS function:
```
function foo (closureParam, closureParam2, ...) {
    return function() {
        // function body
    }
}
```

from FunctionContext to FunctionInlineMutator. The old code causes bug when calling this function like this: `foo(this, ...)`, since first `closureParam` is replaced with `this`. Later, FunctionInlineMutator can't make difference between original `this` inside *function body* and former `closureParam` reference that became `this` after replacement. So, let FunctionInlineMutator replace `this` in *function body* and then substitute closure parameters.

KT-11875 Fixed
(cherry picked from commit 8ad3398)
2016-04-15 17:37:39 +03:00
Natalia Ukhorskaya
c30e7f4307 Minor: clarify exception messages during Evaluate Expression 2016-04-15 16:00:52 +03:00
Natalia Ukhorskaya
8fb1e2e08f Fix EA-72969 - assert: ExtractFunctionForDebuggerUtilKt$getFunctionForExtractedFragment$.invoke : ERROR_TYPES
Context element for codeFragment can be a KtFile (not  only KtExpression) ex. in case when file was changed after debugger starts and there is no expression at line with breakpoint
2016-04-15 16:00:46 +03:00
Natalia Ukhorskaya
0618e8e223 Fix EA-80854 - IOOBE: KotlinLineBreakpointType.getLambdaByOrdinal.
This could happen when breakpoint in lambda was set but than the code changed and there is no lambdas at this line anymore
2016-04-15 16:00:39 +03:00
Natalia Ukhorskaya
a4f2da6606 Debugger, minor: do not throw NPE when receiverTypes are null in completion 2016-04-15 16:00:32 +03:00
Natalia Ukhorskaya
198536dc0a Debugger: cannot evaluate expression with raw types
#KT-11831 Fixed
2016-04-15 16:00:22 +03:00
Natalia Ukhorskaya
80c8e3b731 Debugger: do not insert ambiguous imports inside codeFragments
#KT-11927 Fixed
2016-04-15 16:00:15 +03:00
Natalia Ukhorskaya
3d3f3ef859 Debugger: fix breakpoints inside generic crossinline argument body
#KT-11848 Fixed
2016-04-15 16:00:08 +03:00
Natalia Ukhorskaya
fadde6f8d5 Debugger: write line number for catch clause declaration 2016-04-15 16:00:01 +03:00
Natalia Ukhorskaya
2d6ed6b001 Debugger: fix breakpoints inside inline functions in libraries sources 2016-04-15 15:59:52 +03:00
Natalia Ukhorskaya
6d09caeb8f Debugger: remove unnecessary whitespaces in presentation of line breakpoint variants 2016-04-15 15:59:43 +03:00
Natalia Ukhorskaya
6e0ea9ae9f Get correct target platform for codeFragments 2016-04-15 15:59:34 +03:00
Natalia Ukhorskaya
653ba5bceb Debugger: correct scope for runtime type calculation 2016-04-15 15:59:23 +03:00
Ilya Gorbunov
d24c96fc6f Performance: move the state out of multifile class parts to avoid synchronization.
(cherry picked from commit a2db8f9)
2016-04-15 14:08:52 +03:00
Dmitry Petrov
3f3d6b3320 KT-11645 properly handle private property getter name mangling in reflection
(cherry picked from commit 583733b)
2016-04-15 14:08:52 +03:00
Dmitry Petrov
c37c5d2087 KT-11645 generate backing field for 'private const val' in part implementation class
(cherry picked from commit 511a7e0)
2016-04-15 14:08:52 +03:00
Alexander Udalov
7b398e9e78 Update ChangeLog for 1.0.2 2016-04-15 11:55:34 +03:00
Alexander Udalov
5101c98d18 Exclude InlineOnly from kotlin-test
It's already present in kotlin-stdlib and that causes
com.android.dex.DexException

 #KT-11505 Fixed
2016-04-15 11:55:14 +03:00
Alexey Sedunov
d2f765370f Find Usages: Drop obsolete assertion
#KT-11895 Fixed
(cherry picked from commit 3bd172a)
2016-04-14 20:45:07 +03:00
Natalia Ukhorskaya
76e72380a7 J2K: do not invoke visitChildrenRecursively in Action.update
#KT-11160 Fixed
2016-04-14 18:51:31 +03:00
Natalia Ukhorskaya
30bfdeccbf J2K: do not generate super call to abstract property 2016-04-14 18:51:25 +03:00
Natalia Ukhorskaya
5731945e76 J2K: Insert !! for expression only if NotNull expected (not for Default nullability) 2016-04-14 18:51:19 +03:00
Natalia Ukhorskaya
2ce436bb36 J2K: Get nullability from variable initializer when converting call
#KT-11534 In Progress
2016-04-14 18:51:13 +03:00
Natalia Ukhorskaya
a26fbcd5d4 J2K: Remove unnecessary casts of non-nullable expression to nullable type after conversion
#KT-11543 Fixed
2016-04-14 18:51:06 +03:00
Natalia Ukhorskaya
157079fdc3 Add regression test: parameter from lambda is removed 2016-04-14 18:51:00 +03:00
Natalia Ukhorskaya
9e5ab273f8 J2K, minor: fix testData 2016-04-14 18:50:53 +03:00
Natalia Ukhorskaya
1fdf01b8a9 J2K: convert scratch files correctly
#KT-10604 Fixed
2016-04-14 18:50:43 +03:00
Yan Zhulanow
84692927bc Lint: support both IJ 15 and Android Studio 2.0 (different Android plugins)
Dirty hack :(
(cherry picked from commit 8304c85)
2016-04-14 17:22:47 +03:00
Denis Zharkov
bff3fc7d24 Fix infinite loop in CanBeValInspection
Obviously there should be 'return' instead of 'continue'
Otherwise the loop will not end

 #KT-11891 Fixed
2016-04-14 14:03:17 +03:00
Zalim Bashorov
e8e6862154 Minor: fix testdata 2016-04-14 13:52:41 +03:00
Zalim Bashorov
298ea58539 IC: take into account added and removed classes when calculate affected names
(cherry picked from commit 51c6abd)
2016-04-13 20:26:40 +03:00
Dmitry Petrov
11a382f5d5 EA-81358: use volatile store / volatile load to guarantee publication of deferred clinit results 2016-04-13 16:20:30 +03:00
Kirill Rakhman
5dd25e2896 Let Implement Quickfix: Launch "Implement Members" dialog after applying #KT-11836 Fixed
(cherry picked from commit 56fd2d2)
2016-04-13 12:53:39 +03:00
Alexey Sedunov
0427d20ebf Light Classes: Skip irrelevant overloads when looking for light parameter
#KT-11868 Fixed
(cherry picked from commit 9bf395a)
2016-04-13 12:34:35 +03:00
Nikolay Krasko
d160f63dad Note about EAP-repository configuration added to changelog 2016-04-13 12:37:25 +04:00
Alexander Udalov
9c06c9b6ad Increase PermGen space for 1.0.2 2016-04-13 09:52:45 +03:00
Nikolay Krasko
9b5787c829 Configuration for EAP versions 2016-04-13 08:44:13 +03:00
Nikolay Krasko
df65bb1476 Add eap version to maven versions combobox if working with eap plugin 2016-04-13 00:19:14 +03:00
Nikolay Krasko
e58a2d5a9e Use correct version detection for developer versions
#KT-11213 Fixed
2016-04-13 00:19:14 +03:00
Alexander Udalov
541d87c6c0 Update ChangeLog with issues fixed since 1.0.2-eap-15 2016-04-12 21:22:42 +03:00
Alexander Udalov
c805765b79 Fix memory leak in StdlibTest 2016-04-12 20:08:03 +03:00
Alexander Udalov
1360974e11 Fix deadlock in StaticScopeForKotlinEnum
Also fix possible deadlock in ReflectionTypes

 #KT-11869 Fixed
2016-04-12 20:07:59 +03:00
Alexander Udalov
cd52a5cb09 Do not fail on unknown -X flags
For better compatibility if we add experimental stuff in 1.0.X compilers
2016-04-12 20:07:57 +03:00
Alexander Udalov
039c2911ec Update cli-parser 1.1.1 -> 1.1.2 2016-04-12 20:07:55 +03:00
Alexander Udalov
f4f62f27c1 Cleanup CandidateResolver 2016-04-12 20:06:58 +03:00
Alexander Udalov
42ff05d2fd Fix type of member references without explicit class on LHS
Type of '::foo' for a function foo in a class A should be KFunction0<Unit>, not
KFunction1<A, Unit>. Continue to report an error in this case, to be maybe
supported in the future
2016-04-12 20:05:34 +03:00
Alexander Udalov
225fdbfac6 Assert that callable references cannot have expression on LHS 2016-04-12 20:04:45 +03:00
Michael Bogdanov
c640bc3f14 Write proper start label for parameters of inline function default implementation
(cherry picked from commit be999ca)
2016-04-12 16:44:55 +03:00
Michael Bogdanov
393b1c6b24 Write proper start label for inlined constructor parameters (start label was shifted by additional captured parameters injection)
(cherry picked from commit c52c0e2)
2016-04-12 16:44:48 +03:00
Mikhail Glukhikh
f1a7ccb3a9 Message corrected for warning "some modifier is redundant because another is present"
Cherry pick from commit 1b2deb8 (master) fixes KT-11819
Same case for  KT-11239
ChangeLog
2016-04-11 18:27:04 +03:00
Yan Zhulanow
52bc09ca7e Minor: Fix compilation on 1.0.2 2016-04-11 17:58:24 +03:00
Yan Zhulanow
61e1f68735 Uast, Lint: Update and fix tests
(cherry picked from commit 053418f)
2016-04-11 17:58:23 +03:00
Yan Zhulanow
6253676195 Uast: Add Uast visitor extensions instead of additional checkers
(cherry picked from commit 6cd5ae2)
2016-04-11 16:27:32 +03:00
Yan Zhulanow
f4e4893cb8 Other code review changes
(cherry picked from commit 1f5309a)
2016-04-11 16:27:31 +03:00
Yan Zhulanow
6dc94ef89f Lint: Make lint run normally on both older and newer versions of IDEA (IdeaAndroidProject was replaced by AndroidGradleModel)
(cherry picked from commit 5588e1a)
2016-04-11 16:27:30 +03:00
Yan Zhulanow
a1edf43b48 Change semantics of getObjectKeyword() function
(cherry picked from commit f493b14)
2016-04-11 16:27:29 +03:00
Yan Zhulanow
b64c8cb829 Uast: Rewrite visitor
(cherry picked from commit a369528)
2016-04-11 16:27:28 +03:00
Yan Zhulanow
8002f8e28d Code review changes
(cherry picked from commit e314b51)
2016-04-11 16:27:27 +03:00
Yan Zhulanow
1454e85cab Minor: rename NoTraverse to LeafUElement
(cherry picked from commit 5cd3feb)
2016-04-11 16:27:27 +03:00
Yan Zhulanow
5124f69b0d Code review changes
(cherry picked from commit d6b6739)
2016-04-11 16:27:26 +03:00
Yan Zhulanow
ca6a19b1ac Rename UastHandler to UastCallback
(cherry picked from commit ee47402)
2016-04-11 16:27:25 +03:00
Yan Zhulanow
95076bd68c Uast: Update tests, make the tests a bit more readable (provide toString() methods for Uast kinds)
(cherry picked from commit 5bb8322)
2016-04-11 16:27:24 +03:00
Yan Zhulanow
eafe7848d4 Minor: remove @author comments
(cherry picked from commit ed00ab1)
2016-04-11 16:27:24 +03:00
Yan Zhulanow
118014ddb9 Lint: Add Kotlin Lint tests
(cherry picked from commit f9f4fb2)
2016-04-11 16:27:23 +03:00
Yan Zhulanow
439866b5f7 Download full copy of the Android SDK (needed to run the all Android Lint tests)
(cherry picked from commit cf2ce0f)
2016-04-11 16:27:22 +03:00
Yan Zhulanow
79800e721c Lint: fix some more detectors
(cherry picked from commit 19392fb)
2016-04-11 16:27:21 +03:00
Yan Zhulanow
064b95da81 Lint: Remove lint suppress quickfix (does not work currently with Kotlin)
(cherry picked from commit 936fbb2)
2016-04-11 16:27:21 +03:00
Yan Zhulanow
b71d5c7d6c Uast, Minor: Group binary operators
(cherry picked from commit bc7f0bc)
2016-04-11 16:27:20 +03:00
Yan Zhulanow
e8f4d89351 Uast, Minor: UAnnotated is now always an UElement
(cherry picked from commit c05fa79)
2016-04-11 16:27:19 +03:00
Yan Zhulanow
2d2659dcfe Uast: support 'override' modifier in Java and Kotlin
(cherry picked from commit 7ff1899)
2016-04-11 16:27:18 +03:00
Yan Zhulanow
812deadcd3 Kotlin Uast, Minor: support PsiElementBacked in KotlinUType
(cherry picked from commit 33e13e3)
2016-04-11 16:27:16 +03:00
Yan Zhulanow
9b915d656a Kotlin Uast: support class literal expressions.
Ability to get type of class of class literal expressions.
(cherry picked from commit 4e3683c)
2016-04-11 16:27:15 +03:00
Yan Zhulanow
bab722cf68 Uast: support new elements in UastVisitor
(cherry picked from commit 525f8a2)
2016-04-11 16:27:14 +03:00
Yan Zhulanow
533794b440 Lint: fix Lint additional checkers with the custom handlers
(cherry picked from commit 7297671)
2016-04-11 16:27:14 +03:00
Yan Zhulanow
06cafe0d13 Lint: resolve via the accessor descriptor in PropertyAsCAllAndroidUastAdditionalChecker
(cherry picked from commit 178095d)
2016-04-11 16:27:13 +03:00
Yan Zhulanow
9bc815745a Uast: support internal class names in Java and method signatures in Java and Kotlin
(cherry picked from commit 516ddc2)
2016-04-11 16:27:12 +03:00
Yan Zhulanow
6b6fd50331 Lint: Remove IntellijApiDetector
(cherry picked from commit f4edc50)
2016-04-11 16:27:11 +03:00
Yan Zhulanow
ee53f34465 Java Uast: Support try-with-resources
(cherry picked from commit 3680cbe)
2016-04-11 16:27:11 +03:00
Yan Zhulanow
d16a7264f4 Java Uast: Support static imports
(cherry picked from commit c5653cf)
2016-04-11 16:27:10 +03:00
Yan Zhulanow
820d8cb9c2 Uast: support beforeVisit() and afterVisit() in visitor
(cherry picked from commit 6e10bf0)
2016-04-11 16:27:09 +03:00
Yan Zhulanow
8e10298618 Lint: Support visitResourceReference() in Uast
(cherry picked from commit 799c00e)
2016-04-11 16:27:08 +03:00
Yan Zhulanow
e65497b67c Uast: Rename JavaPsiElemenStub -> JavaDumbUElement, KotlinPsiElementStub -> KotlinDumbUElement.
Use it everywhere in `nameElement`
(cherry picked from commit 9ee221e)
2016-04-11 16:27:08 +03:00
Yan Zhulanow
088f9c2edf Support equals() on UElements (comparation by psi)
(cherry picked from commit 35434de)
2016-04-11 16:27:07 +03:00
Yan Zhulanow
6823c358bf Uast Java, Kotlin: Support all binary operators in Uast
(cherry picked from commit d68e35c)
2016-04-11 16:27:06 +03:00
Yan Zhulanow
edc0459af1 Uast: Support all basic Java types needed for Lint
(cherry picked from commit de8b967)
2016-04-11 16:27:05 +03:00
Yan Zhulanow
9c71780d36 Kotlin Uast: Support object literals
(cherry picked from commit 0525e41)
2016-04-11 16:27:05 +03:00
Yan Zhulanow
ee481be188 Uast: Ability to get the default class type from UClass
(cherry picked from commit 9557439)
2016-04-11 16:27:04 +03:00
Yan Zhulanow
fc8d972ac8 Kotlin Uast, Refactoring: Extract toSource() function
(cherry picked from commit 68bf8de)
2016-04-11 16:27:03 +03:00
Yan Zhulanow
2ec3d94dc0 Uast, Minor: make lateinit mutable propertiy setters internal
(cherry picked from commit 68b2204)
2016-04-11 16:27:02 +03:00
Yan Zhulanow
0490e3ba58 Lint: Remove diagnostics unrelated to uast.
All these diagnostics are already present in the Android plugin, so there's no need in them here.
(cherry picked from commit 76dcb22)
2016-04-11 16:27:02 +03:00
Yan Zhulanow
9d34f91e50 Uast: Allow to search for a static members (in Kotlin static members are located inside the companion objects).
Companion objects support.
(cherry picked from commit 8928281)
2016-04-11 16:27:01 +03:00
Yan Zhulanow
043db50c44 Uast: Support Kotlin anonymous initializers
(cherry picked from commit 4c4705c)
2016-04-11 16:27:00 +03:00
Yan Zhulanow
4f07a94fb7 Java Uast, Minor: Convert Java Uast properties with backing field to properties with getter (optimization)
(cherry picked from commit 06f8c4e)
2016-04-11 16:26:59 +03:00
Yan Zhulanow
e310a58251 Lint: Implement Kotlin Java synthetic property calls as Java method calls via the additional checker
(cherry picked from commit 610871f)
2016-04-11 16:26:58 +03:00
Yan Zhulanow
1ca9d358b1 Replace UastConverter with UastLanguagePlugin, allow additional checkers
(cherry picked from commit b0ef275)
2016-04-11 16:26:58 +03:00
Yan Zhulanow
2a1db9efb3 Lint: Rename all Lint inspections to KLint to provide unique short names
(cherry picked from commit bf10ba6)
2016-04-11 16:26:57 +03:00
Yan Zhulanow
ecbf20151b Kotlin Uast: Support type parameters on functions
(cherry picked from commit dbdbdbd)
2016-04-11 16:26:56 +03:00
Yan Zhulanow
5a14678a8f Lint, Minor: Group lint-related modules
(cherry picked from commit 5f73145)
2016-04-11 16:26:55 +03:00
Yan Zhulanow
ac6cab266f Lint: Rewrite Lint diagnostics using Uast.
(cherry picked from commit 995b4e8)
2016-04-11 16:26:54 +03:00
Yan Zhulanow
4d4012853c Lint: copy diagnostics from IDEA (br143)
(cherry picked from commit fd7161b)
2016-04-11 16:26:53 +03:00
Yan Zhulanow
33a83ebf4a Kotlin Uast: Initial implementation
(cherry picked from commit 0b310a4)
2016-04-11 16:26:52 +03:00
Yan Zhulanow
603fdff499 Java Uast: Initial implementation
(cherry picked from commit eb326e2)
2016-04-11 16:26:51 +03:00
Yan Zhulanow
4b4ed61783 Uast: Unified AST (Kotlin, Java) interfaces set.
Goal: support Android Lint diagnostics in Kotlin by switching Lint scanners from the Java Lombok AST to the abstract AST (uast) with Java and Kotlin PsiElement-backed implementations.
(cherry picked from commit 7f4c6c2)
2016-04-11 16:26:51 +03:00
Alexander Udalov
6527c25b3e Minor, remove paragraph symbols from comments
This character seems to cause problems on some build agents
2016-04-11 16:12:23 +03:00
Alexey Sedunov
c5e5a50908 Spring Support: Support @Transactional annotation in "Make annotated declaration open" inspection
(cherry picked from commit 905ca21)
2016-04-10 19:16:31 +03:00
Alexey Sedunov
4178a2f999 Spring Support: Support Find Usages/Rename (on both declarations and
references) of Kotlin declarations referenced in the XML config
 #KT-11719 Fixed
 #KT-11652 Fixed
(cherry picked from commit 119cf0f)
2016-04-10 19:16:26 +03:00
Alexey Sedunov
b8ab3bc503 Minor: Extract SpringTestFixtureExtension.loadConfigByMainFilePath() function
(cherry picked from commit a553f67)
2016-04-10 12:51:57 +03:00
Alexey Sedunov
eda798fa8a Spring Support: Fix renaming of Spring bean declarations via SpEL references
#KT-11720 Fixed
 #KT-11725 Fixed
(cherry picked from commit afecb09)
2016-04-10 12:51:53 +03:00
Alexey Sedunov
a815927234 Minor: Remove /*rename*/ marker in Rename tests
(cherry picked from commit 5203f62)
2016-04-10 12:51:48 +03:00
Alexey Sedunov
15dae23695 Light Classes: Navigate to KtFile from light class containing file
#KT-11689 Fixed
(cherry picked from commit b890564)
2016-04-10 12:51:43 +03:00
Alexey Sedunov
077acfe2b4 Spring Support: Fixed computation of values in Java annotations referred by Kotlin annotation entries
#KT-11702 Fixed
(cherry picked from commit eeac739)
2016-04-10 12:51:39 +03:00
Alexey Sedunov
9da010c163 Misc: Extract kotlin-ultimate project
(cherry picked from commit a818d47)
2016-04-10 12:51:34 +03:00
Alexey Sedunov
72bdbdb838 Misc: Extract properties "dependencies" and "generators" from update_dependencies.xml
(cherry picked from commit 1a4a740)
2016-04-10 12:51:27 +03:00
Alexey Sedunov
6fa75444fd Spring Support: "Generate @Autowired Dependency..." action
#KT-11408 Fixed
(cherry picked from commit 843e2bc)
2016-04-10 12:51:23 +03:00
Alexey Sedunov
934eaa61fa Spring Support: "Generate Dependency..." actions
#KT-11407 Fixed
(cherry picked from commit 233f2b4)
2016-04-10 12:51:18 +03:00
Alexey Sedunov
bbd15ac27c Minor: Generify KtClassOrObject.addDeclarationXXX()
(cherry picked from commit 4ed1c3d)
2016-04-10 12:51:13 +03:00
Alexey Sedunov
60e3f31c2b [RESTORED] Misc: Fetch Spring libraries to dependencies directory
(cherry picked from commit 81298e5)
2016-04-10 12:51:08 +03:00
Alexey Sedunov
90f5cd9057 [RESTORED] Spring Support: Inspection for Spring configuration
(cherry picked from commit 9aeca98)
2016-04-10 12:51:02 +03:00
Alexey Sedunov
f954fa26f5 [RESTORED] Spring Support: SpEL injections
#KT-11406 Fixed
(cherry picked from commit 236654a)
2016-04-10 12:50:57 +03:00
Alexey Sedunov
287ba05618 [RESTORED] Spring Support: Show Spring line markers for Kotlin classes
#KT-3741 Fixed
(cherry picked from commit a89dbfc)
2016-04-10 12:50:51 +03:00
Alexey Sedunov
a633a7b797 [RESTORED] Light Classes: Constant expression evaluator for light annotation arguments
(cherry picked from commit 962b312)
2016-04-10 12:50:46 +03:00
Alexey Sedunov
8c935188b3 [RESTORED] Spring Support: Implement Spring-specific references
(cherry picked from commit f2e2220)
2016-04-10 12:50:39 +03:00
Alexey Sedunov
4f0379728a [RESTORED] Spring Support: Inspection for final Spring-annotated classes/functions
#KT-11098 Fixed
(cherry picked from commit 196b484)
2016-04-10 01:42:29 +03:00
Alexey Sedunov
be000176aa [RESTORED] Spring Support: Test framework
(cherry picked from commit e4a64e7)
2016-04-10 01:42:13 +03:00
Alexey Sedunov
a79ca8620f [RESTORED] Misc: Configure dependency on Spring support and related plugins: J2EE, JSP, persistence, database tools, CSS
(cherry picked from commit b5ac464)
2016-04-10 01:40:14 +03:00
Alexey Sedunov
690d0cd5d9 [RESTORED] Misc: Configure IDEA Ultimate dependencies
(cherry picked from commit a30b414)
2016-04-10 01:39:28 +03:00
Kirill Rakhman
346b47e00a Fix let implement quickfix label for object expressions
Fixes #KT-11782
(cherry picked from commit da5c963)
2016-04-08 15:14:03 +03:00
Michael Bogdanov
63b33eebb0 Write proper start label for loop parameter
(cherry picked from commit a6044c8)
2016-04-08 14:36:26 +03:00
Valentin Kipyatkov
7dafdef7a1 Fixed StackOverflow in CanBeValInspection.kt
(cherry picked from commit a9fe999)
2016-04-07 20:21:54 +03:00
Alexander Udalov
bc6286bb9c Compute return type for property getters more safely
Do not call `isError()` on property's type right after creation of
PropertyGetterDescriptor because the property has no getter yet (it's created
but not yet stored to the property, that happens a bit later), and `isError()`
leads to computation of the delegate type, which for delegated properties
performs some complex resolution (see `VariableTypeResolver#process`) which
relies on the fact that the property already has a getter.

Since the purpose of the original change (883e2e4d) was to support a quick fix
which would add the type to a property in an expression like "val x get() =
...", check the type (or initializer) presence in the PSI instead, this is
safer and is still suitable for the quick fix.

Also fix arguments to "wrong getter type" diagnostic: previously something
useless like "expected Int, actual Int" was reported

 #KT-11809 Fixed
2016-04-07 15:42:29 +03:00
Alexey Andreev
f966647e14 KT-7819 Add test to ensure that lambda capturing this literal can be inlined 2016-04-06 16:18:53 +03:00
Alexey Andreev
3e8ccc567b KT-7819 Implement non-local returns 2016-04-06 16:18:52 +03:00
Alexey Andreev
b1023bfeb1 KT-7819 Borrow tests for non-local returns from JVM backend 2016-04-06 16:18:52 +03:00
Pavel V. Talanov
449f270aea IDELightClassGenerationSupport#getContextForClassOrObject: do not rely on resolution facade being unchanged
ResolutionFacade should only recompute its underlying structures in case of psi change (which is ok) or some exception, but relying on it being unchanged has led to numerous exceptions in backend when building light classes (EA-70985, EA-80756)
Changing this code may not be the solution but it can possibly move failures to other parts of the system, where they can be easier diagnosed
2016-04-06 16:09:56 +03:00
Dmitry Jemerov
00f63a0dab no KtUsefulTestCase in 1.0.2 branch 2016-04-05 21:00:44 +02:00
Dmitry Jemerov
8e8542e984 don't parse lines starting with @ as KDoc tags if they're inside a Markdown code fence
#KT-11789 Fixed
(cherry picked from commit 01b0cfb)
2016-04-05 19:50:26 +02:00
Dmitry Petrov
f94c470607 KT-11777: no parts for '<root>'
(cherry picked from commit 9f34d06)
2016-04-05 17:27:36 +03:00
Pavel V. Talanov
180d8dfb02 KT-11765 Analyze code in anonymous initializer of inteface
#KT-11765 Fixed
2016-04-05 15:06:59 +03:00
Natalia Ukhorskaya
9848f65d4c Configure Kotlin: do not show notification when apply directive contains double quotes 2016-04-05 14:59:44 +03:00
Natalia Ukhorskaya
cfb8e27a51 Configure kotlin: fix NPE for Idea 145 of higher
#KT-11772 Fixed
2016-04-05 14:59:32 +03:00
Alexey Andreev
a686816728 Generalize pattern that matches JS module declaration to accept unicode characters
(cherry picked from commit eb44819)
2016-04-05 14:49:21 +03:00
Alexey Andreev
305b93d79c Speed-up looking up modules in JS files. This reduces the time needed for JS backend tests to pass
(cherry picked from commit 951ec82)
2016-04-05 14:49:20 +03:00
Alexey Andreev
8c723b4251 Rename JsAstUtils.fqn to fqnWithoutSideEffects. Move PropertyTranslator to appropriate package 2016-04-05 14:49:20 +03:00
Alexey Andreev
82e3126f39 Refactor JS optimizer to use RecursiveJsVisitor where possible and introduce more self-descriptive names in TemporaryAssignmentElimination. Add TODOs and comments for code pieces with non-obvious meaning. 2016-04-05 14:49:20 +03:00
Alexey Andreev
8f2711147f Invert MetadataProperties.withoutSideEffects to sideEffects 2016-04-05 14:49:19 +03:00
Alexey Andreev
621687c75d Add more hints about property access that is provable has no side effect. Refactor namer 2016-04-05 14:49:19 +03:00
Alexey Andreev
9316cca89a Don't relocate temporary variable which receives property access, unless it's provable that this property don't have side effects 2016-04-05 14:49:19 +03:00
Alexey Andreev
2209b38307 Rewrite temporary variable elimination 2016-04-05 14:49:18 +03:00
Alexey Andreev
70aec3914d Prohibit from eliminating non-local temporary variables 2016-04-05 14:49:18 +03:00
Alexey Andreev
0f6f4496a3 Adds test infrastructure for JS optimizer. Adds simple tests 2016-04-05 14:49:17 +03:00
Alexey Andreev
7eccbb0f0d Some cleanup in JS optimizer 2016-04-05 14:49:17 +03:00
Alexey Andreev
735b50aa95 Prevent JS optimizer from inserting duplicate variable declarations 2016-04-05 14:49:17 +03:00
Alexey Andreev
b548e38773 Prevent temporary variable from substituting to branches of ternary conditional expression, since it can sometimes violate evaluation order 2016-04-05 14:49:16 +03:00
Alexey Andreev
e287af71d3 Implement reduction of if statement to ternary conditional expression 2016-04-05 14:49:16 +03:00
Alexey Andreev
3a1cde2fe7 Implement dead code elimination in JS AST. Repeat optimizations until it's not possible to optimize anything 2016-04-05 14:49:16 +03:00
Alexey Andreev
3dc09ad788 Make JS optimizations respect nested functions 2016-04-05 14:49:15 +03:00
Alexey Andreev
18bda4646f Remove optimizations performed during JS inlining. Implement several optimizations as a separate pass 2016-04-05 14:49:15 +03:00
Dmitry Petrov
53c97ecb22 Do not generate postponed initialization method for part class as synchronized.
(cherry picked from commit fe7f7ce)
2016-04-05 14:01:10 +03:00
Michael Bogdanov
ce43732715 Fix for KT-11762: "VerifyError: Bad local variable type" caused by explicit loop variable type
#KT-11762 Fixed
(cherry picked from commit dec53c8)
2016-04-05 13:37:55 +03:00
Zalim Bashorov
85c7882833 Don't use invalid entries (including disposed libraries) when crete module infos to avoid exceptions in the future (see #EA-81326)
(cherry picked from commit f2237f6)
2016-04-05 13:11:18 +03:00
Zalim Bashorov
420559a7d2 Check that library isn't already disposed before use to avoid exceptions like in #EA-79154
(cherry picked from commit 88da3fe)
2016-04-05 13:11:10 +03:00
Zalim Bashorov
057848d7a9 Generate stubs only for files from jar
#EA-78399 fixed
(cherry picked from commit 7dad183)
2016-04-05 13:11:02 +03:00
Kirill Rakhman
081a2cc7cd Fix handling of nullable types in LetImplementInterfaceFix #KT-11404
(cherry picked from commit f9bef68)
2016-04-05 12:40:44 +03:00
Stanislav Erokhin
30e447648c Minor. Remove failed tests for KT-8116. 2016-04-04 23:24:51 +03:00
Stanislav Erokhin
aa8c12e814 Minor. Mute testdata. 2016-04-04 23:24:51 +03:00
Stanislav Erokhin
2ac27c8bdf Minor. Fix testdata. 2016-04-04 23:24:50 +03:00
Alexander Udalov
8418313b39 ChangeLog: add some missing issues fixed in 1.0.1 2016-04-04 21:44:45 +03:00
Alexander Udalov
ec03bfc64a ChangeLog for 1.0.2 2016-04-04 21:44:43 +03:00
Pavel V. Talanov
6ff8c4a051 Typecheck call arguments if callee is resolved to variable
#KT-11579 Fixed
2016-04-04 21:12:40 +03:00
Pavel V. Talanov
8649762b2a KtLightClassForFacade is no longer valid if some of the files have changed their name
#KT-11580 Fixed
2016-04-04 21:11:12 +03:00
Stanislav Erokhin
5a70f32250 KT-11733 Cannot infer type parameter in SAM with nullability annotations
#KT-11733 Fixed
2016-04-04 15:30:46 +03:00
Nikolay Krasko
8608127c23 Fix too frequent check for compiler modification 2016-04-04 15:29:58 +03:00
Natalia Ukhorskaya
8600540b9d Minor: fix test on java 6 2016-04-04 15:28:16 +03:00
Natalia Ukhorskaya
79de5b962f Avoid 1s delay in completion in debugger fields if session is not stopped on a breakpoint 2016-04-04 15:28:05 +03:00
Mikhail Glukhikh
fc602179db KT-11404 (let type implement interface): indirect inheritance with generics fixed
(cherry picked from commit b55610b)
2016-04-04 15:15:22 +03:00
Mikhail Glukhikh
97e753bb30 KT-11404: additional test to cover indirect inheritance
(cherry picked from commit 640ae60)
2016-04-04 14:04:17 +03:00
Kirill Rakhman
70349e4f78 Implement quick-fix "let type implement interface" #KT-11404 Fixed
(cherry picked from commit 1e6f507)
2016-04-04 14:04:06 +03:00
Kirill Rakhman
3c9fdda679 cleanup KtClassOrObject and KtClass
(cherry picked from commit 2198a8c)
2016-04-04 14:03:55 +03:00
Mikhail Glukhikh
f7dc3d4ce8 Simplify comparison fix introduced #KT-10509 Fixed
(cherry picked from commit 214e1d3)
2016-04-04 14:03:42 +03:00
hedgehog
de54a61594 #KT-10797 Fixed
(cherry picked from commit 02d4376)
2016-04-04 12:30:11 +02:00
Yaroslav Ulanovych
8b764ad8c9 Fix #KT-11675 Fixed - Add Smart Enter processor for 'init'
(cherry picked from commit 242a44e)
2016-04-04 12:13:14 +02:00
Natalia Ukhorskaya
6354600db1 Minor: count lambdaOrdinal in tests from 1 instead of 0 2016-04-04 12:36:04 +03:00
Natalia Ukhorskaya
812e9716be Debugger: Smart Step Into inside lambda suggests methods from outer context
#KT-10148 Fixed
2016-04-04 12:35:53 +03:00
Natalia Ukhorskaya
c5c2eedddb Do not highlight completion variants from nullable receiver with grey in Evaluate Expression Dialog
#KT-11578 Fixed
2016-04-04 12:35:42 +03:00
Natalia Ukhorskaya
aed6c9367d Smart step into skips methods from subclasses
#KT-11705 Fixed
2016-04-04 12:35:30 +03:00
Natalia Ukhorskaya
52123a976d Configure Kotlin action fails for Idea 145 or higher
#KT-11593 Fixed
2016-04-04 12:35:20 +03:00
Natalia Ukhorskaya
9bf6b40eb9 Minor: rearrange test data 2016-04-04 12:35:07 +03:00
Natalia Ukhorskaya
c8dffd6fcb Debugger: do not insert array in imports 2016-04-04 12:34:47 +03:00
Natalia Ukhorskaya
158ddb010b Debugger: remove useless casts from expressions converted from java 2016-04-04 12:34:20 +03:00
Natalia Ukhorskaya
728faf4df0 Debugger: Convert java expression to kotlin when open EE dialog from Variables View
#KT-6805 Fixed
2016-04-04 12:34:08 +03:00
Michael Bogdanov
7e13a314a1 Fix for KT-11677: Generic type signatures for local classes in inlined lambdas are not written properly
#KT-11677 Fixed
(cherry picked from commit e0adfd4)
2016-04-04 12:13:34 +03:00
Michael Bogdanov
c87a6b6c92 Support test directives in inline tests
(cherry picked from commit f5166b7)
2016-04-04 12:13:28 +03:00
Michael Bogdanov
126dad7d3f Added test for obsolete KT-11631: Couldn't inline method call
#KT-11631 Obsolete
(cherry picked from commit d319811)
2016-04-04 12:13:22 +03:00
Ilya Gorbunov
bd1b4cf629 Change String.subSequence parameter names to match those of CharSequence.subSequence. 2016-04-01 21:48:39 +03:00
Sergey Mashkov
898056429d KT-11261 Implement MavenArchetypesProvider extension point 2016-04-01 20:48:03 +03:00
Ilya Gorbunov
fd12c661f7 Binary compatibility validator: filter out empty facades *after* members are flattened from non-public part superclasses.
Use stable member sort order for members flattened from non-public superclasses, rewrite test to make order matter.
(cherry picked from commit 6ba98f7)
2016-04-01 18:04:51 +03:00
Alexander Udalov
cf788372d3 Reorder and prettify existing ChangeLog entries for 1.0.2 2016-04-01 17:49:11 +03:00
Alexander Udalov
c14ac2f48c Configure Kotlin in project: list only modules with Kotlin files
This was initially done in d07d34af but reverted in 8f2dd2c8, possibly due to
incorrect rebase

 #KT-10831 Fixed
2016-04-01 14:15:42 +03:00
Dmitry Petrov
bf0e8daff3 binary compat validator: update testData for changes related to new facade generation
(cherry picked from commit 1d87595)
2016-04-01 10:14:35 +03:00
Dmitry Petrov
5c329e7487 KT-11410: generate light classes from multifile class parts in binaries
if explicitly requested by fqName
(cherry picked from commit 92ddbb2)
2016-04-01 10:14:32 +03:00
Dmitry Petrov
3e2765e357 KT-11410: write multifile class code generation scheme to extra field (xi) in kotlin.Metadata.
(cherry picked from commit 4c4141e)
2016-04-01 10:14:29 +03:00
Dmitry Petrov
ddf9568cf8 KT-11410: Build stdlib with new part/facade inheritance scheme.
(cherry picked from commit d30ab50)
2016-04-01 10:14:26 +03:00
Dmitry Petrov
d3b96efdbf KT-11410: Class hierarchy for parts/facade of multi-file class.
Preserve static initialization semantics for parts by introducing a special "clinit trigger" class.
Insert "static initialization trigger" call to every method of a part class, remove this call on inline.
Always mangle names for private functions in multifile class parts to avoid resolution clashes on inheritance.

NB in codegen tests initializers for all non-const vals are wrapped in 'run { ... }',
so that the initializer is not a constant expression, and some static initialization code should be generated.
(cherry picked from commit db58ebc)
2016-04-01 10:14:23 +03:00
Dmitry Petrov
2ce79db5ca KT-11410: Add Xmultifile-parts-inherit CLI option.
(cherry picked from commit 0ccaf43)
2016-04-01 10:14:20 +03:00
Dmitry Petrov
852e236896 KOTLIN_CONFIGURATION_FLAGS directive for passing compiler configuration parameters to tests.
So far, only boolean flags are supported.
(cherry picked from commit 095cbea)
2016-04-01 10:14:17 +03:00
Ilya Gorbunov
667f7ddc72 Optimize snapshot operations to return special collection implementations when result is empty or has single element.
#KT-9990 Fixed

(cherry picked from commit f35dc47b4e)
2016-04-01 01:38:14 +03:00
Sergey Mashkov
13d4be6f74 KT-11261 Implement MavenArchetypesProvider extension point 2016-03-31 23:09:51 +02:00
Sergey Mashkov
a78a7eb6fb KT-2917 maven archetype for kotlin projects 2016-03-31 23:09:26 +02:00
Pavel V. Talanov
a39aeb5288 ExceptionTracker: do not increment counter on ReenteringLazyValueComputationException
ReenteringLazyValueComputationException is in fact correct behaviour which does not indicate a problem we should try to recover from
This led to an obscure bug when resolve sessions were invalidated multiple times during light class construction (see KT-11635)
 #KT-11635 Fixed
2016-03-31 19:53:37 +03:00
Pavel V. Talanov
bc2a563b61 KT-11721 Wrong "Typechecker has run into recursive problem" on calling kotlin get function as synthetic property
#KT-11721 Fixed
2016-03-31 19:53:35 +03:00
Ilya Gorbunov
bd44cd9a3c Minor: commit missing file (related to Remove implementations of intrinsic array creation functions) 2016-03-31 19:46:37 +03:00
Alexey Tsvetkov
cbb36d8f3d Load kotlin.incremental from local.properties file too 2016-03-31 19:42:24 +03:00
Mikhail Glukhikh
3e832fcf34 Build fix: evaluationErrors.repl
(cherry picked from commit 60511f0)
2016-03-31 19:31:16 +03:00
Mikhail Glukhikh
8517bfff23 Refactoring: DeclarationsChecker checkClassOrObjectMembers / checkFunction
(cherry picked from commit 56ef98e)
2016-03-31 19:31:02 +03:00
Mikhail Glukhikh
ff567b4a21 KT-11666: Implicit nothing is allowed for overridden function / properties
(cherry picked from commit 8c131f4)
2016-03-31 19:30:48 +03:00
Mikhail Glukhikh
369d64b489 Implicit nothing / intersection types are now checked also for member functions #KT-11666 Fixed
(cherry picked from commit 4c03aaa)
2016-03-31 19:30:34 +03:00
Ilya Gorbunov
276daa6d83 Make Map.plus accept Map out-projected by key type as either operand (receiver or parameter).
#KT-11301 Fixed
(cherry picked from commit d5d19f5)
2016-03-31 17:58:50 +03:00
Ilya Gorbunov
96ebda5548 Remove implementations of intrinsic array creation functions (arrayOf, primitiveArrayOf)
#KT-11485 Fixed
(cherry picked from commit 0332217)
2016-03-31 17:58:43 +03:00
Ilya Gorbunov
7433683011 Minor: Make internal monitorEnter/monitorExit functions private to remove them from the public API
#KT-11485
(cherry picked from commit 9caa17d)
2016-03-31 17:58:37 +03:00
Ilya Gorbunov
9342de43d2 Introduce RandomAccess to JS.
Make EmptyList support RandomAccess.
#KT-10794
(cherry picked from commit ab68b49)
2016-03-31 17:58:30 +03:00
Pavel V. Talanov
ac1f19d6ef Improve message clarity for WRONG_NUMBER_OF_TYPE_ARGUMENTS diagnostics
#KT-9887 Fixed
2016-03-31 16:06:25 +03:00
Alexey Tsvetkov
2f1a1c570d Build non-incrementally when input class-file is changed 2016-03-31 15:08:52 +03:00
Denis Zharkov
a2e194dd18 Fix SAM adapters substitution
Approximate sourceFunction types if it's needed

 #KT-11696 Fixed
2016-03-31 14:54:28 +03:00
Denis Zharkov
01a083efbf Add additional visibility check for synthetic extensions
Use extension receiver as dispatch one, because it is effectively dispatch
(after some desugaring)
2016-03-31 14:54:28 +03:00
Denis Zharkov
89b99b7952 Minor. Adjust JS test to protected visibility changes 2016-03-31 14:54:28 +03:00
Denis Zharkov
a3d83ce268 Adjust J2K to latest protected visibility fixes 2016-03-31 14:54:28 +03:00
Denis Zharkov
6d3f06cd09 Prohibit protected constructor calls that are not super-calls in subtypes
#KT-11649 Fixed
2016-03-31 14:54:28 +03:00
Denis Zharkov
2bd7132f3e Minor. Covariantly override ClassDescriptor.original 2016-03-31 14:54:28 +03:00
Denis Zharkov
91146aa07a Do not check receiver for protected constructor calls
Checks for protected constructors should be performed manually,
because they are rather complex
2016-03-31 14:54:28 +03:00
Denis Zharkov
26dd9bd035 Respect receiver-dependent visibility when selecting smart-cast type 2016-03-31 14:54:28 +03:00
Denis Zharkov
9107e18f8d Make PositioningStrategy.mark public
Because it's used with receivers of types different from call site ones.
2016-03-31 14:54:28 +03:00
Denis Zharkov
04fd2dd0c8 Refine isVisible for protected visibility
#KT-7437 Fixed
 #KT-7971 Fixed
 #KT-7051 Fixed
 #KT-6125 Fixed
 #KT-6186 Fixed
2016-03-31 14:54:28 +03:00
Denis Zharkov
07f6da5919 Clarify Visibility.isVisible contract for null as receiverValue
See comment
2016-03-31 14:54:28 +03:00
Pavel V. Talanov
7ba05d71e6 KtLightModifierList* is created only for light classes build for sources
This is a hacky solution to avoid calling lightMemberOrigin.originalElement inside
Moreover it needs to resolve descriptor for sources inside computeAnnotations and it is used only for kotlin sources so this will have to do for now
2016-03-30 21:44:12 +03:00
Pavel V. Talanov
045eddab71 KT-11678 Support navigation from Java source to Kotlin binaries
Introduce LightMemberOriginForCompiledElement which holds logic for finding corresponding decompiled declaration
ByJvmSignatureIndexer stores the required information while building decompiled text

Some are unsolved in this commit:
   - constructors
   - @Jvm* and other unregular generated members
   - annotation methods

 #KT-11678 Fixed
2016-03-30 21:44:11 +03:00
Pavel V. Talanov
0ef2e036a3 LightElements: avoid computation of LightMemberOrigin.originalElement on common api calls 2016-03-30 21:44:10 +03:00
Pavel V. Talanov
06fe23f773 Refactor light elements
KtLightElement#delegate -> clsDelegate, KtLightElement#origin -> kotlinOrigin and make them properties
KtLightClassForDecompiledDeclaration stores KtClsFile
KtLightField stores LightMemberOrigin
2016-03-30 21:44:09 +03:00
Pavel V. Talanov
a16510b2fe Refactor: Make LightMemberOrigin an interface, extract one implementation 2016-03-30 21:44:08 +03:00
Pavel V. Talanov
4edb43000d Improve AbstractReferenceResolveTest 2016-03-30 21:44:08 +03:00
Pavel V. Talanov
5983635cfa Refactor: abstract over decompiled text indexing
Move navigation-related code from KtDecompiledFile
2016-03-30 21:44:07 +03:00
Pavel V. Talanov
bac921f661 Drop non-generated NavigateToDecompiledLibraryTest
It relies on internal data structure
2016-03-30 21:44:06 +03:00
Pavel V. Talanov
3960112397 Generate navigateToDecompiledLibraryTest from the same test data as navigateToLibrarySourceTest
Change test data format
2016-03-30 21:44:05 +03:00
Pavel V. Talanov
0999aab6fb Generate tests for resolving references to kotlin binaries from java in IDE 2016-03-30 21:44:04 +03:00
Alexander Udalov
fa142c273e Fix multiple resource leaks by closing InputStream instances
The main fix is in BuiltInsPackageFragment, the rest is the improvement of
other usages of getResourceAsStream

 #KT-11433 Fixed
2016-03-30 21:42:37 +03:00
Alexander Udalov
ee3a4eefdf Fix double quotes in diagnostic messages
For diagnostics without any parameters, the given text is simply rendered as a
String, so no symbols should be escaped.

For diagnostics with parameters, the format in java.text.MessageFormat is used,
so one single quote is erased and two single quotes become one single quote in
the rendered text.
2016-03-30 21:42:36 +03:00
Mikhail Glukhikh
64c5164201 Fix of getCorrespondingLoop for complex loop / try-finally trees #KT-8246 Fixed
(cherry picked from commit b7e8f71)
2016-03-30 20:45:49 +03:00
Alexander Udalov
97bee57321 Enable bootstrap and force version increment in 1.0.2 2016-03-30 19:05:05 +03:00
Alexander Udalov
0710b5b459 Rename Changelog.md -> ChangeLog.md 2016-03-30 18:29:46 +03:00
2150 changed files with 86407 additions and 6510 deletions

8
.gitignore vendored
View File

@@ -13,3 +13,11 @@ workspace.xml
*.versionsBackup
/idea/testData/debugger/tinyApp/classes*
/jps-plugin/testData/kannotator
ultimate/.DS_Store
ultimate/.idea/shelf
ultimate/dependencies
ultimate/ideaSDK
ultimate/out
ultimate/tmp
ultimate/workspace.xml
ultimate/*.versionsBackup

9
.idea/artifacts/KotlinFormatter.xml generated Normal file
View File

@@ -0,0 +1,9 @@
<component name="ArtifactManager">
<artifact type="jar" name="KotlinFormatter">
<output-path>$PROJECT_DIR$/out/artifacts/internal</output-path>
<root id="archive" name="kotlin-formatter.jar">
<element id="module-output" name="formatter" />
<element id="dir-copy" path="$PROJECT_DIR$/idea/formatter" />
</root>
</artifact>
</component>

View File

@@ -11,7 +11,7 @@
<element id="directory" name="META-INF">
<element id="dir-copy" path="$PROJECT_DIR$/jps-plugin/src/META-INF" />
</element>
<element id="extracted-dir" path="$PROJECT_DIR$/dependencies/cli-parser-1.1.1.jar" path-in-jar="/" />
<element id="extracted-dir" path="$PROJECT_DIR$/dependencies/cli-parser-1.1.2.jar" path-in-jar="/" />
<element id="module-output" name="cli-common" />
<element id="module-output" name="idea-jps-common" />
<element id="module-output" name="jps-plugin" />

View File

@@ -47,6 +47,9 @@
<element id="module-output" name="idea-repl" />
<element id="module-output" name="idea-live-templates" />
<element id="module-output" name="resolution" />
<element id="module-output" name="plugin-api" />
<element id="module-output" name="idea-ultimate" />
<element id="module-output" name="formatter" />
</element>
<element id="library" level="project" name="javax.inject" />
<element id="directory" name="jps">
@@ -59,6 +62,16 @@
<element id="archive" name="kotlin-android-extensions-compiler-plugin.jar">
<element id="module-output" name="android-extensions-compiler" />
</element>
<element id="archive" name="android-lint.jar">
<element id="module-output" name="uast-kotlin" />
<element id="module-output" name="lint-idea" />
<element id="module-output" name="uast-java" />
<element id="module-output" name="uast-common" />
<element id="module-output" name="lint-checks" />
<element id="library" level="project" name="guava" />
<element id="module-output" name="lint-api" />
<element id="module-output" name="uast-android" />
</element>
</element>
<element id="directory" name="kotlinc">
<element id="dir-copy" path="$PROJECT_DIR$/dist/kotlinc" />

View File

@@ -1,11 +1,11 @@
<component name="libraryTable">
<library name="cli-parser">
<CLASSES>
<root url="jar://$PROJECT_DIR$/dependencies/cli-parser-1.1.1.jar!/" />
<root url="jar://$PROJECT_DIR$/dependencies/cli-parser-1.1.2.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$PROJECT_DIR$/dependencies/cli-parser-1.1.1-sources.jar!/" />
<root url="jar://$PROJECT_DIR$/dependencies/cli-parser-1.1.2-sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@@ -11,7 +11,6 @@
<SOURCES>
<root url="jar://$PROJECT_DIR$/dependencies/guava-17.0-sources.jar!/" />
<root url="jar://$PROJECT_DIR$/dependencies/asm5-src.zip!/" />
<root url="jar://$PROJECT_DIR$/dependencies/cli-parser-1.1.1-sources.jar!/" />
<root url="jar://$PROJECT_DIR$/ideaSDK/sources/sources.jar!/" />
</SOURCES>
<jarDirectory url="file://$PROJECT_DIR$/ideaSDK/lib" recursive="false" />

9
.idea/modules.xml generated
View File

@@ -3,6 +3,7 @@
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/Kotlin.iml" filepath="$PROJECT_DIR$/Kotlin.iml" />
<module fileurl="file://$PROJECT_DIR$/plugins/lint/android-annotations/android-annotations.iml" filepath="$PROJECT_DIR$/plugins/lint/android-annotations/android-annotations.iml" />
<module fileurl="file://$PROJECT_DIR$/plugins/android-extensions/android-extensions-compiler/android-extensions-compiler.iml" filepath="$PROJECT_DIR$/plugins/android-extensions/android-extensions-compiler/android-extensions-compiler.iml" group="plugins/android-extensions" />
<module fileurl="file://$PROJECT_DIR$/plugins/android-extensions/android-extensions-idea/android-extensions-idea.iml" filepath="$PROJECT_DIR$/plugins/android-extensions/android-extensions-idea/android-extensions-idea.iml" group="plugins/android-extensions" />
<module fileurl="file://$PROJECT_DIR$/plugins/android-extensions/android-extensions-jps/android-extensions-jps.iml" filepath="$PROJECT_DIR$/plugins/android-extensions/android-extensions-jps/android-extensions-jps.iml" group="plugins/android-extensions" />
@@ -31,6 +32,7 @@
<module fileurl="file://$PROJECT_DIR$/core/descriptors.runtime/descriptors.runtime.iml" filepath="$PROJECT_DIR$/core/descriptors.runtime/descriptors.runtime.iml" group="core" />
<module fileurl="file://$PROJECT_DIR$/core/deserialization/deserialization.iml" filepath="$PROJECT_DIR$/core/deserialization/deserialization.iml" group="core" />
<module fileurl="file://$PROJECT_DIR$/eval4j/eval4j.iml" filepath="$PROJECT_DIR$/eval4j/eval4j.iml" group="ide" />
<module fileurl="file://$PROJECT_DIR$/idea/formatter/formatter.iml" filepath="$PROJECT_DIR$/idea/formatter/formatter.iml" group="ide" />
<module fileurl="file://$PROJECT_DIR$/compiler/frontend/frontend.iml" filepath="$PROJECT_DIR$/compiler/frontend/frontend.iml" group="compiler" />
<module fileurl="file://$PROJECT_DIR$/compiler/frontend.java/frontend.java.iml" filepath="$PROJECT_DIR$/compiler/frontend.java/frontend.java.iml" group="compiler/java" />
<module fileurl="file://$PROJECT_DIR$/generators/generators.iml" filepath="$PROJECT_DIR$/generators/generators.iml" group="infrastructure" />
@@ -58,6 +60,9 @@
<module fileurl="file://$PROJECT_DIR$/js/js.translator/js.translator.iml" filepath="$PROJECT_DIR$/js/js.translator/js.translator.iml" group="compiler/js" />
<module fileurl="file://$PROJECT_DIR$/jps-plugin/kannotator-jps-plugin-test/kannotator-jps-plugin-test.iml" filepath="$PROJECT_DIR$/jps-plugin/kannotator-jps-plugin-test/kannotator-jps-plugin-test.iml" group="ide/jps" />
<module fileurl="file://$PROJECT_DIR$/compiler/light-classes/light-classes.iml" filepath="$PROJECT_DIR$/compiler/light-classes/light-classes.iml" group="compiler/java" />
<module fileurl="file://$PROJECT_DIR$/plugins/lint/lint-api/lint-api.iml" filepath="$PROJECT_DIR$/plugins/lint/lint-api/lint-api.iml" group="plugins/lint" />
<module fileurl="file://$PROJECT_DIR$/plugins/lint/lint-checks/lint-checks.iml" filepath="$PROJECT_DIR$/plugins/lint/lint-checks/lint-checks.iml" group="plugins/lint" />
<module fileurl="file://$PROJECT_DIR$/plugins/lint/lint-idea/lint-idea.iml" filepath="$PROJECT_DIR$/plugins/lint/lint-idea/lint-idea.iml" group="plugins/lint" />
<module fileurl="file://$PROJECT_DIR$/compiler/plugin-api/plugin-api.iml" filepath="$PROJECT_DIR$/compiler/plugin-api/plugin-api.iml" group="compiler" />
<module fileurl="file://$PROJECT_DIR$/compiler/preloader/preloader.iml" filepath="$PROJECT_DIR$/compiler/preloader/preloader.iml" group="compiler/cli" />
<module fileurl="file://$PROJECT_DIR$/core/reflection.jvm/reflection.jvm.iml" filepath="$PROJECT_DIR$/core/reflection.jvm/reflection.jvm.iml" group="core" />
@@ -65,6 +70,10 @@
<module fileurl="file://$PROJECT_DIR$/core/runtime.jvm/runtime.jvm.iml" filepath="$PROJECT_DIR$/core/runtime.jvm/runtime.jvm.iml" group="core" />
<module fileurl="file://$PROJECT_DIR$/compiler/serialization/serialization.iml" filepath="$PROJECT_DIR$/compiler/serialization/serialization.iml" group="compiler" />
<module fileurl="file://$PROJECT_DIR$/temp-jdk8/temp-jdk8.iml" filepath="$PROJECT_DIR$/temp-jdk8/temp-jdk8.iml" />
<module fileurl="file://$PROJECT_DIR$/plugins/lint/uast-android/uast-android.iml" filepath="$PROJECT_DIR$/plugins/lint/uast-android/uast-android.iml" group="plugins/lint" />
<module fileurl="file://$PROJECT_DIR$/plugins/uast-common/uast-common.iml" filepath="$PROJECT_DIR$/plugins/uast-common/uast-common.iml" group="plugins/lint" />
<module fileurl="file://$PROJECT_DIR$/plugins/uast-java/uast-java.iml" filepath="$PROJECT_DIR$/plugins/uast-java/uast-java.iml" group="plugins/lint" />
<module fileurl="file://$PROJECT_DIR$/plugins/uast-kotlin/uast-kotlin.iml" filepath="$PROJECT_DIR$/plugins/uast-kotlin/uast-kotlin.iml" group="plugins/lint" />
<module fileurl="file://$PROJECT_DIR$/compiler/util/util.iml" filepath="$PROJECT_DIR$/compiler/util/util.iml" />
<module fileurl="file://$PROJECT_DIR$/core/util.runtime/util.runtime.iml" filepath="$PROJECT_DIR$/core/util.runtime/util.runtime.iml" group="core" />
</modules>

View File

@@ -13,7 +13,7 @@
<option name="MAIN_CLASS_NAME" value="" />
<option name="METHOD_NAME" value="" />
<option name="TEST_OBJECT" value="package" />
<option name="VM_PARAMETERS" value="-ea -XX:+HeapDumpOnOutOfMemoryError -Xmx900m -XX:MaxPermSize=400m -XX:+UseCodeCacheFlushing -XX:ReservedCodeCacheSize=128m" />
<option name="VM_PARAMETERS" value="-ea -XX:+HeapDumpOnOutOfMemoryError -Xmx900m -XX:MaxPermSize=500m -XX:+UseCodeCacheFlushing -XX:ReservedCodeCacheSize=128m" />
<option name="PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" />
<option name="ENV_VARIABLES" />

View File

@@ -2,7 +2,7 @@
<configuration default="false" name="IDEA (No ProcessCanceledException)" type="Application" factoryName="Application" singleton="true">
<extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" />
<option name="MAIN_CLASS_NAME" value="com.intellij.idea.Main" />
<option name="VM_PARAMETERS" value="-Xmx800m -XX:ReservedCodeCacheSize=64m -XX:MaxPermSize=250m -XX:+HeapDumpOnOutOfMemoryError -ea -Didea.is.internal=true -Didea.debug.mode=true -Didea.system.path=../system-idea -Didea.config.path=../config-idea -Dapple.laf.useScreenMenuBar=true -Dapple.awt.graphics.UseQuartz=true -Dsun.io.useCanonCaches=false -Dplugin.path=$PROJECT_DIR$/out/artifacts/Kotlin -Didea.ProcessCanceledException=disabled -Dkotlin.internal.mode.enabled=true -Didea.additional.classpath=../idea-kotlin-runtime/kotlin-runtime.jar,../idea-kotlin-runtime/kotlin-reflect.jar" />
<option name="VM_PARAMETERS" value="-Xmx800m -XX:ReservedCodeCacheSize=64m -XX:MaxPermSize=400m -XX:+HeapDumpOnOutOfMemoryError -ea -Didea.is.internal=true -Didea.debug.mode=true -Didea.system.path=../system-idea -Didea.config.path=../config-idea -Dapple.laf.useScreenMenuBar=true -Dapple.awt.graphics.UseQuartz=true -Dsun.io.useCanonCaches=false -Dplugin.path=$PROJECT_DIR$/out/artifacts/Kotlin -Didea.ProcessCanceledException=disabled -Dkotlin.internal.mode.enabled=true -Didea.additional.classpath=../idea-kotlin-runtime/kotlin-runtime.jar,../idea-kotlin-runtime/kotlin-reflect.jar" />
<option name="PROGRAM_PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$/ideaSDK/bin" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" />

370
ChangeLog.md Normal file
View File

@@ -0,0 +1,370 @@
# CHANGELOG
<!-- Find: ([^\[/])(KT-\d+) -->
<!-- Replace: $1[$2](https://youtrack.jetbrains.com/issue/$2) -->
## 1.0.2-1
- [KT-12159](https://youtrack.jetbrains.com/issue/KT-12159), [KT-12406](https://youtrack.jetbrains.com/issue/KT-12406), [KT-12431](https://youtrack.jetbrains.com/issue/KT-12431), [KT-12478](https://youtrack.jetbrains.com/issue/KT-12478) Support Android Studio 2.2
- [KT-11770](https://youtrack.jetbrains.com/issue/KT-11770) Fix warning "RuntimeException: Could not find installation home path" when using incremental compilation in Gradle
- [KT-12436](https://youtrack.jetbrains.com/issue/KT-12436), [KT-12440](https://youtrack.jetbrains.com/issue/KT-12440) Fix multiple exceptions during refactorings in IDEA 2016.2 EAP
- [KT-12015](https://youtrack.jetbrains.com/issue/KT-12015), [KT-12047](https://youtrack.jetbrains.com/issue/KT-12047), [KT-12387](https://youtrack.jetbrains.com/issue/KT-12387) Fix multiple issues in Kotlin Lint checks
## 1.0.2
### Compiler
#### Analysis & diagnostics
- [KT-7437](https://youtrack.jetbrains.com/issue/KT-7437), [KT-7971](https://youtrack.jetbrains.com/issue/KT-7971), [KT-7051](https://youtrack.jetbrains.com/issue/KT-7051), [KT-6125](https://youtrack.jetbrains.com/issue/KT-6125), [KT-6186](https://youtrack.jetbrains.com/issue/KT-6186), [KT-11649](https://youtrack.jetbrains.com/issue/KT-11649) Implement missing checks for protected visibility
- [KT-11666](https://youtrack.jetbrains.com/issue/KT-11666) Report "Implicit nothing return type" on non-override member functions
- [KT-4328](https://youtrack.jetbrains.com/issue/KT-4328), [KT-11497](https://youtrack.jetbrains.com/issue/KT-11497), [KT-10493](https://youtrack.jetbrains.com/issue/KT-10493), [KT-10820](https://youtrack.jetbrains.com/issue/KT-10820), [KT-11368](https://youtrack.jetbrains.com/issue/KT-11368) Report error if some classes were not found due to missing or conflicting dependencies
- [KT-11280](https://youtrack.jetbrains.com/issue/KT-11280) Do not perform smart casts for values with custom `equals` compared with `==`
- [KT-3856](https://youtrack.jetbrains.com/issue/KT-3856) Fix wrong "inner class inaccessible" diagnostic for extension to outer class
- [KT-3896](https://youtrack.jetbrains.com/issue/KT-3896), [KT-3883](https://youtrack.jetbrains.com/issue/KT-3883), [KT-4986](https://youtrack.jetbrains.com/issue/KT-4986) `do...while (true)` is now considered an infinite loop
- [KT-10445](https://youtrack.jetbrains.com/issue/KT-10445) Prohibit initialization of captured `val` in lambda or in local function
- [KT-10042](https://youtrack.jetbrains.com/issue/KT-10042) Correctly handle local classes and anonymous objects in control flow analysis
- [KT-11043](https://youtrack.jetbrains.com/issue/KT-11043) Prohibit complex expressions with class literals in annotation arguments
- [KT-10992](https://youtrack.jetbrains.com/issue/KT-10992), [KT-11007](https://youtrack.jetbrains.com/issue/KT-11007) Fix multiple problems related to smart casts
- [KT-11490](https://youtrack.jetbrains.com/issue/KT-11490) Prohibit nested intersection types in return position
- [KT-11411](https://youtrack.jetbrains.com/issue/KT-11411) Report "illegal noinline/crossinline" on parameter of subtype of function type
- [KT-3083](https://youtrack.jetbrains.com/issue/KT-3083) Report "conflicting overloads" for functions with parameter of type parameter type
- [KT-7265](https://youtrack.jetbrains.com/issue/KT-7265) Parse anonymous functions in blocks as expressions
- [KT-8246](https://youtrack.jetbrains.com/issue/KT-8246) Handle break/continue for outer loop correctly in case of try/finally in between
- [KT-11300](https://youtrack.jetbrains.com/issue/KT-11300) Report error on increment or augmented assignment when `get` is an operator but `set` is not
- Report warning about unused anonymous functions
- Improve callable reference type in some ambiguous cases
- Improve multiple diagnostic messages: [KT-10761](https://youtrack.jetbrains.com/issue/KT-10761), [KT-9760](https://youtrack.jetbrains.com/issue/KT-9760), [KT-10949](https://youtrack.jetbrains.com/issue/KT-10949), [KT-9887](https://youtrack.jetbrains.com/issue/KT-9887), [KT-9550](https://youtrack.jetbrains.com/issue/KT-9550), [KT-11239](https://youtrack.jetbrains.com/issue/KT-11239), [KT-11819](https://youtrack.jetbrains.com/issue/KT-11819)
- Fix several compiler bugs leading to exceptions: [KT-9820](https://youtrack.jetbrains.com/issue/KT-9820), [KT-11597](https://youtrack.jetbrains.com/issue/KT-11597), [KT-10983](https://youtrack.jetbrains.com/issue/KT-10983), [KT-10972](https://youtrack.jetbrains.com/issue/KT-10972), [KT-11287](https://youtrack.jetbrains.com/issue/KT-11287), [KT-11492](https://youtrack.jetbrains.com/issue/KT-11492), [KT-11765](https://youtrack.jetbrains.com/issue/KT-11765), [KT-11869](https://youtrack.jetbrains.com/issue/KT-11869)
#### JVM code generation
- [KT-8269](https://youtrack.jetbrains.com/issue/KT-8269), [KT-9246](https://youtrack.jetbrains.com/issue/KT-9246), [KT-10143](https://youtrack.jetbrains.com/issue/KT-10143) Fix visibility of protected classes in bytecode
- [KT-11363](https://youtrack.jetbrains.com/issue/KT-11363) Fix potential binary compatibility breakage on using `when` over enums in inline functions
- [KT-11762](https://youtrack.jetbrains.com/issue/KT-11762) Fix VerifyError caused by explicit loop variable type
- [KT-11645](https://youtrack.jetbrains.com/issue/KT-11645) Fix NoSuchFieldError on private const property in multi-file class
- [KT-9670](https://youtrack.jetbrains.com/issue/KT-9670) Optimize Class <-> KClass wrapping/unwrapping when getting values from annotation
- [KT-6842](https://youtrack.jetbrains.com/issue/KT-6842) Optimize unnecessary boxing and interface calls on iterating over ranges
- [KT-11025](https://youtrack.jetbrains.com/issue/KT-11025) Don't inline const val properties in non-annotation contexts
- [KT-5429](https://youtrack.jetbrains.com/issue/KT-5429) Write nullability annotations on extension receiver parameters
- [KT-11347](https://youtrack.jetbrains.com/issue/KT-11347) Preserve source file and line number of call site when inlining certain standard library functions
- [KT-11677](https://youtrack.jetbrains.com/issue/KT-11677) Write correct generic signatures for local classes in inlined lambdas
- [KT-12127](https://youtrack.jetbrains.com/issue/KT-12127) Do not write unnecessary generic signature for property delegate backing field
- Fix multiple issues leading to exceptions or bad bytecode being generated: [KT-11034](https://youtrack.jetbrains.com/issue/KT-11034), [KT-11519](https://youtrack.jetbrains.com/issue/KT-11519), [KT-11117](https://youtrack.jetbrains.com/issue/KT-11117), [KT-11479](https://youtrack.jetbrains.com/issue/KT-11479)
#### Java interoperability
- [KT-3068](https://youtrack.jetbrains.com/issue/KT-3068) Load contravariantly projected collections in Java (`List<? super T>`) as mutable collections in Kotlin (`MutableList<in T>`)
- [KT-11322](https://youtrack.jetbrains.com/issue/KT-11322) Do not lose type nullability information in SAM constructors
- [KT-11721](https://youtrack.jetbrains.com/issue/KT-11721) Fix wrong "Typechecker has run into recursive problem" error on calling Kotlin get function as synthetic Java property
- [KT-10691](https://youtrack.jetbrains.com/issue/KT-10691) Fix wrong "Inherited platform declarations clash" error on inheritance from generic Java class with overloaded methods
#### Command line compiler
- [KT-9546](https://youtrack.jetbrains.com/issue/KT-9546) Flush stdout and stderr before shutdown when executing scripts
- [KT-10605](https://youtrack.jetbrains.com/issue/KT-10605) Disable colored output on certain platforms to prevent crashes
- Report warning instead of error on unknown "-X" flags
- Remove the compiler option "Xmultifile-facades-open"
#### Compiler daemon
- Reduce read disk activity
- Fix compiler daemon JAR cache clearing on IDEA Ultimate
### Standard library
- [KT-11410](https://youtrack.jetbrains.com/issue/KT-11410) Reduce method count of the standard library by ~2k
- [KT-9990](https://youtrack.jetbrains.com/issue/KT-9990) Optimize snapshot operations to return special collection implementations when result is empty or has single element
- [KT-10794](https://youtrack.jetbrains.com/issue/KT-10794) EmptyList now implements RandomAccess
- [KT-10821](https://youtrack.jetbrains.com/issue/KT-10821) Create at most one wrapper sequence for adjacent drop/take operations on sequences
- [KT-11301](https://youtrack.jetbrains.com/issue/KT-11301) Make Map.plus accept Map out-projected by key type as either operand (receiver or parameter)
- [KT-11485](https://youtrack.jetbrains.com/issue/KT-11485) Remove implementations of some internal intrinsic functions
- [KT-11648](https://youtrack.jetbrains.com/issue/KT-11648) Add deprecated extension MutableList.remove to redirect to valid function removeAt
- [KT-11348](https://youtrack.jetbrains.com/issue/KT-11348) kotlin.test: Make inline methods `todo` and `currentStackTrace` `@InlineOnly` not to lose stack trace
- [KT-11745](https://youtrack.jetbrains.com/issue/KT-11745) Rename parameters of `String.subSequence` to match those of `CharSequence.subSequence`
- [KT-10953](https://youtrack.jetbrains.com/issue/KT-10953) Clarify parameter order of lambda function parameter of `*Indexed` functions
- [KT-10198](https://youtrack.jetbrains.com/issue/KT-10198) Improve docs for `binarySearch` functions
- [KT-9786](https://youtrack.jetbrains.com/issue/KT-9786) Improve docs for `trimIndent`/`trimMargin`
### Reflection
- [KT-9952](https://youtrack.jetbrains.com/issue/KT-9952) Improve `toString()` for lambdas and function expressions when kotlin-reflect.jar is available
- [KT-11433](https://youtrack.jetbrains.com/issue/KT-11433) Fix multiple resource leaks by closing InputStream instances
- [KT-8131](https://youtrack.jetbrains.com/issue/KT-8131) Fix exception from calling `KProperty.javaField` on a subclass
- [KT-10690](https://youtrack.jetbrains.com/issue/KT-10690) Support `javaMethod` and `kotlinFunction` for top level functions in a different file
- [KT-11447](https://youtrack.jetbrains.com/issue/KT-11447) Support reflection calls to multifile class members
- [KT-10892](https://youtrack.jetbrains.com/issue/KT-10892) Load annotations of const properties from multifile classes
- [KT-11258](https://youtrack.jetbrains.com/issue/KT-11258) Don't crash on requesting members of Java collection classes
- [KT-11502](https://youtrack.jetbrains.com/issue/KT-11502) Clarify KClass equality
### JS
- [KT-4124](https://youtrack.jetbrains.com/issue/KT-4124) Support nested classes
- [KT-11030](https://youtrack.jetbrains.com/issue/KT-11030) Support local classes
- [KT-7819](https://youtrack.jetbrains.com/issue/KT-7819) Support non-local returns in local lambdas
- [KT-6912](https://youtrack.jetbrains.com/issue/KT-6912) Safe calls (`x?.let { it }`) are now inlined
- [KT-2670](https://youtrack.jetbrains.com/issue/KT-2670) Support unsafe casts (`as`)
- [KT-7016](https://youtrack.jetbrains.com/issue/KT-7016), [KT-8012](https://youtrack.jetbrains.com/issue/KT-8012) Fix `is`-checks for reified type parameters
- [KT-7038](https://youtrack.jetbrains.com/issue/KT-7038) Avoid unwanted side effects on `is`-checks for nullable types
- [KT-10614](https://youtrack.jetbrains.com/issue/KT-10614) Copy array on vararg call with spread operator
- [KT-10785](https://youtrack.jetbrains.com/issue/KT-10785) Correctly translate property names and receiver instances in assignment operations
- [KT-11611](https://youtrack.jetbrains.com/issue/KT-11611) Fix translation of default value of secondary constructor's functional parameter
- [KT-11100](https://youtrack.jetbrains.com/issue/KT-11100) Fix generation of `invoke` on objects and companion objects
- [KT-11823](https://youtrack.jetbrains.com/issue/KT-11823) Fix capturing of outer class' `this` in inner's lambdas
- [KT-11996](https://youtrack.jetbrains.com/issue/KT-11996) Fix translation of a call to a private member of an outer class from an inner class which is a subtype of the outer class
- [KT-10667](https://youtrack.jetbrains.com/issue/KT-10667) Support inheritance from nested built-in types such as Map.Entry
- [KT-7480](https://youtrack.jetbrains.com/issue/KT-7480) Remove declarations of LinkedList, SortedSet, TreeSet, Enumeration
- [KT-3064](https://youtrack.jetbrains.com/issue/KT-3064) Implement `CharSequence.repeat`
### IDE
New features:
- Spring Support
- [KT-11098](https://youtrack.jetbrains.com/issue/KT-11098) Inspection on final classes/functions annotated with Spring `@Configuration`/`@Component`/`@Bean`
- [KT-11405](https://youtrack.jetbrains.com/issue/KT-11405) Navigation and Find Usages for Spring beans referenced in annotation arguments and BeanFactory method calls
- [KT-3741](https://youtrack.jetbrains.com/issue/KT-3741) Show Spring-specific line markers on Kotlin classes
- [KT-11406](https://youtrack.jetbrains.com/issue/KT-11406) Support Spring EL injections inside of Kotlin string literals
- [KT-11604](https://youtrack.jetbrains.com/issue/KT-11604) Support "Configure Spring facet" inspection on Kotlin classes
- [KT-11407](https://youtrack.jetbrains.com/issue/KT-11407) Implement "Generate Spring Dependency..." actions
- [KT-11408](https://youtrack.jetbrains.com/issue/KT-11408) Implement "Generate `@Autowired` Dependency..." action
- [KT-11652](https://youtrack.jetbrains.com/issue/KT-11652) Rename bean attributes mentioned in Spring XML config together with corresponding Kotlin declarations
- Enable precise incremental compilation by default in non-Maven/Gradle projects
- [KT-11612](https://youtrack.jetbrains.com/issue/KT-11612) Highlight named arguments
- [KT-7715](https://youtrack.jetbrains.com/issue/KT-7715) Highlight `var`s that can be replaced by `val`s
- [KT-5208](https://youtrack.jetbrains.com/issue/KT-5208) Intention action to convert string to raw string and back
- [KT-11078](https://youtrack.jetbrains.com/issue/KT-11078) Quick fix to remove `.java` when KClass is expected
- [KT-1494](https://youtrack.jetbrains.com/issue/KT-1494) Inspection to highlight public members with no documentation
- [KT-8473](https://youtrack.jetbrains.com/issue/KT-8473) Intention action to implement interface or abstract class
- [KT-10299](https://youtrack.jetbrains.com/issue/KT-10299) Inspection to warn on array properties in data classes
- [KT-6674](https://youtrack.jetbrains.com/issue/KT-6674) Inspection to warn on protected symbols in effectively final classes
- [KT-11576](https://youtrack.jetbrains.com/issue/KT-11576) Quick fix to suppress "Unused symbol" warning based on annotations on the declaration
- [KT-10063](https://youtrack.jetbrains.com/issue/KT-10063) Quick fix for adding `arrayOf` wrapper for annotation parameters
- [KT-10476](https://youtrack.jetbrains.com/issue/KT-10476) Quick fix for converting primitive types
- [KT-10859](https://youtrack.jetbrains.com/issue/KT-10859) Quick fix to make `var` with private setter final
- [KT-9498](https://youtrack.jetbrains.com/issue/KT-9498) Quick fix to specify property type
- [KT-10509](https://youtrack.jetbrains.com/issue/KT-10509) Quick fix to simplify condition with senseless comparison
- [KT-11404](https://youtrack.jetbrains.com/issue/KT-11404) Quick fix to let type implement missing interface
- [KT-6785](https://youtrack.jetbrains.com/issue/KT-6785), [KT-10013](https://youtrack.jetbrains.com/issue/KT-10013), [KT-9996](https://youtrack.jetbrains.com/issue/KT-9996), [KT-11675](https://youtrack.jetbrains.com/issue/KT-11675) Support Smart Enter for trailing lambda argument, try/catch/finally, property setter, init block
- Add `kotlinClassName()` and `kotlinFunctionName()` macros for use in live templates
- Auto-configure EAP-repository during Kotlin Maven and Gradle project set up
Issues fixed:
- [KT-11678](https://youtrack.jetbrains.com/issue/KT-11678), [KT-4768](https://youtrack.jetbrains.com/issue/KT-4768) Support navigation to Kotlin libraries from Java sources
- [KT-9401](https://youtrack.jetbrains.com/issue/KT-9401) Support Change Signature quick fix for Java -> Kotlin case
- [KT-8592](https://youtrack.jetbrains.com/issue/KT-8592) Fix "Choose sources" for Kotlin files
- [KT-11256](https://youtrack.jetbrains.com/issue/KT-11256) Fix Navigate to declaration for Java constructor with `@NotNull` parameter
- [KT-11018](https://youtrack.jetbrains.com/issue/KT-11018) Fix `var`s shown in Ctrl + Mouse Hover as `val`s
- [KT-5105](https://youtrack.jetbrains.com/issue/KT-5105), [KT-11024](https://youtrack.jetbrains.com/issue/KT-11024) Improve incompatible ABI versions editor strap, show the hint on how to resolve the problem
- [KT-11638](https://youtrack.jetbrains.com/issue/KT-11638) Fixed `hashCode()` implementation in "Generate equals/hashCode" action
- [KT-10971](https://youtrack.jetbrains.com/issue/KT-10971) Pull Members Up: Always insert spaces between keywords
- [KT-11476](https://youtrack.jetbrains.com/issue/KT-11476), [KT-4175](https://youtrack.jetbrains.com/issue/KT-4175), [KT-10965](https://youtrack.jetbrains.com/issue/KT-10965), [KT-11076](https://youtrack.jetbrains.com/issue/KT-11076) Formatter: fix multiple issues regarding space handling
- [KT-9025](https://youtrack.jetbrains.com/issue/KT-9025) Improve "Create Kotlin Java runtime library" dialog usability
- [KT-11481](https://youtrack.jetbrains.com/issue/KT-11481) Fix "Add import" intention not being available for `is` branches in when
- [KT-10619](https://youtrack.jetbrains.com/issue/KT-10619) Fix completion after package name in annotation
- [KT-10621](https://youtrack.jetbrains.com/issue/KT-10621) Do not show non-top level packages after `@` in completion
- [KT-11295](https://youtrack.jetbrains.com/issue/KT-11295) "Convert string to template" intention: fix exception on certain code
- [KT-10750](https://youtrack.jetbrains.com/issue/KT-10750), [KT-11424](https://youtrack.jetbrains.com/issue/KT-11424) "Convert if to when" intention now detects effectively else branches in subsequent code and performs more accurate comment handling
- Configure Kotlin: show only changed files in the notification "Kotlin not configured", restore all changed files in undo action
- [KT-11556](https://youtrack.jetbrains.com/issue/KT-11556) Do not show "Kotlin not configured" for Kotlin JS projects
- [KT-11593](https://youtrack.jetbrains.com/issue/KT-11593) Fix "Configure Kotlin" action for Gradle projects in IDEA 2016
- [KT-11077](https://youtrack.jetbrains.com/issue/KT-11077) Use new built-in definition file format (`.kotlin_builtins` files)
- [KT-5728](https://youtrack.jetbrains.com/issue/KT-5728) Remove closing curly brace in a string template when opening one is deleted
- [KT-10883](https://youtrack.jetbrains.com/issue/KT-10883) "Explicit get or set call" quick fix: do not move caret too far away
- [KT-5717](https://youtrack.jetbrains.com/issue/KT-5717) "Replace 'when' with 'if'": do not lose comments
- [KT-10797](https://youtrack.jetbrains.com/issue/KT-10797) "Replace with operator" intention is not available anymore for non-`operator` functions
- [KT-11529](https://youtrack.jetbrains.com/issue/KT-11529) Highlighting range for unresolved annotation name does not include `@` now
- [KT-11178](https://youtrack.jetbrains.com/issue/KT-11178) Don't show "Change type arguments" fix when there's nothing to change
- [KT-11789](https://youtrack.jetbrains.com/issue/KT-11789) Don't interpret annotations inside Markdown code blocks as KDoc tags
- [KT-11702](https://youtrack.jetbrains.com/issue/KT-11702) Fixed resolution of Kotlin beans with custom name
- [KT-11689](https://youtrack.jetbrains.com/issue/KT-11689) Fixed exception on attempt to navigate to Kotlin file from Spring notification balloon
- [KT-11725](https://youtrack.jetbrains.com/issue/KT-11725) Fixed renaming of injected SpEL references
- [KT-11720](https://youtrack.jetbrains.com/issue/KT-11720) Fixed renaming of Kotlin beans through SpEL references
- [KT-11719](https://youtrack.jetbrains.com/issue/KT-11719) Fixed renaming of Kotlin parameters references in XML files
- [KT-11736](https://youtrack.jetbrains.com/issue/KT-11736) Fixed searching of Java usages for @JvmStatic properties and @JvmStatic @JvmOverloads functions
- [KT-11862](https://youtrack.jetbrains.com/issue/KT-11862) Fixed bogus warnings about unresolved types in the Change Signature dialog
- Fix several issues leading to exceptions: [KT-11579](https://youtrack.jetbrains.com/issue/KT-11579), [KT-11580](https://youtrack.jetbrains.com/issue/KT-11580), [KT-11777](https://youtrack.jetbrains.com/issue/KT-11777), [KT-11868](https://youtrack.jetbrains.com/issue/KT-11868), [KT-11845](https://youtrack.jetbrains.com/issue/KT-11845), [KT-11486](https://youtrack.jetbrains.com/issue/KT-11486)
- Fixed NoSuchFieldException in Kotlin module settings on IDEA Ultimate
#### Debugger
- [KT-11705](https://youtrack.jetbrains.com/issue/KT-11705) "Smart step into" no longer skips methods from subclasses
- Debugger can now distinguish nested inline arguments
- [KT-11326](https://youtrack.jetbrains.com/issue/KT-11326) Support private classes in Evaluate Expression
- [KT-11455](https://youtrack.jetbrains.com/issue/KT-11455) Fix Evaluate Expression behavior for files with errors in sources
- [KT-10670](https://youtrack.jetbrains.com/issue/KT-10670) Fix Evaluate Expression behavior for inline functions with default parameters
- [KT-11380](https://youtrack.jetbrains.com/issue/KT-11380) Evaluate Expression now handles smart casts correctly
- [KT-10148](https://youtrack.jetbrains.com/issue/KT-10148) Do not suggest methods from outer context in "Smart step into"
- Fix Evaluate Expression for expression created for array element
- Complete private members from libraries in Evaluate Expression
- [KT-11578](https://youtrack.jetbrains.com/issue/KT-11578) Evaluate Expression: do not highlight completion variants from nullable receiver with grey
- [KT-6805](https://youtrack.jetbrains.com/issue/KT-6805) Convert Java expression to Kotlin when opening Evaluate Expression from Variables view
- [KT-11927](https://youtrack.jetbrains.com/issue/KT-11927) Fix "ambiguous import" error when invoking Evaluate Expression from Variables view for some field
- [KT-11831](https://youtrack.jetbrains.com/issue/KT-11831) Fix Evaluate Expression for values of raw types
- Show error message when debug info for some local variable is corrupted
- Avoid 1s delay in completion in debugger fields if session is not stopped on a breakpoint
- Avoid cast to runtime type unavailable in current scope
- Fix text with line breaks in popup with line breakpoint variants
- Fix breakpoints inside inline functions in libraries sources
- Allow breakpoints at catch clause declaration
- [KT-11848](https://youtrack.jetbrains.com/issue/KT-11848) Fix breakpoints inside generic crossinline lambda argument body
- [KT-11932](https://youtrack.jetbrains.com/issue/KT-11932) Fix Step Over for `while` loop condition
### Java to Kotlin converter
- Protected members used outside of inheritors are converted as public
- Support conversion for annotation constructor calls
- Place comments from the middle of the call to the end
- Drop line breaks between operator arguments (except `+`, `-`, `&&` and `||`)
- Add non-null assertions on call site for non-null parameters
- Specify type for variables with anonymous type if they have write accesses
- [KT-11587](https://youtrack.jetbrains.com/issue/KT-11587) Fix conversion of static field accesses from other Java class
- [KT-6800](https://youtrack.jetbrains.com/issue/KT-6800) Quote `$` symbols in converted strings
- [KT-11126](https://youtrack.jetbrains.com/issue/KT-11126) Convert annotations in annotations parameters correctly
- [KT-11600](https://youtrack.jetbrains.com/issue/KT-11600) Do not produce unresolved `toArray` calls for Java `Collection#toArray(T[])`
- [KT-11544](https://youtrack.jetbrains.com/issue/KT-11544) Fix conversion of uninitialized non-final field
- [KT-10604](https://youtrack.jetbrains.com/issue/KT-10604) Fix conversion of scratch files
- [KT-11543](https://youtrack.jetbrains.com/issue/KT-11543) Do not produce unnecessary casts of non-nullable expression to nullable type
- [KT-11160](https://youtrack.jetbrains.com/issue/KT-11160) Fix IDE freeze
### Android
- [KT-7729](https://youtrack.jetbrains.com/issue/KT-7729) Add Android Lint checks for Kotlin (from Android Studio 1.5)
- [KT-11487](https://youtrack.jetbrains.com/issue/KT-11487) Fixed sequential build with kapt and stubs enabled when Kotlin source file was modified and no Java source files were modified
- [KT-11264](https://youtrack.jetbrains.com/issue/KT-11264) Action to create new activity in Kotlin
- [KT-11201](https://youtrack.jetbrains.com/issue/KT-11201) Do not ignore items with similar names in kapt
- [KT-11944](https://youtrack.jetbrains.com/issue/KT-11944) Rename Android Extensions imports when the layout file is renamed/deleted/added
- [KT-10321](https://youtrack.jetbrains.com/issue/KT-10321) Do not upcast ViewStub to View
- [KT-10841](https://youtrack.jetbrains.com/issue/KT-10841) Support `@android:id/*` IDs in Android Extensions
### Maven
- [KT-2917](https://youtrack.jetbrains.com/issue/KT-2917), [KT-11261](https://youtrack.jetbrains.com/issue/KT-11261) Maven archetype for new Kotlin projects
### Gradle
- [KT-8487](https://youtrack.jetbrains.com/issue/KT-8487) Experimental support for incremental compilation with project property `kotlin.incremental`
- [KT-11350](https://youtrack.jetbrains.com/issue/KT-11350) Fixed a bug causing Java rebuild when both Java and Kotlin are up-to-date
- [KT-10507](https://youtrack.jetbrains.com/issue/KT-10507) Fix IllegalArgumentException "Missing extension point" on parallel builds
- [KT-10932](https://youtrack.jetbrains.com/issue/KT-10932) Prevent compile tasks from running when nothing changes
- [KT-11993](https://youtrack.jetbrains.com/issue/KT-11993) Fix NoSuchMethodError on access to internal members in production from tests (IDEA 2016+)
## 1.0.1-2
### Compiler
- [KT-11584](https://youtrack.jetbrains.com/issue/KT-11584), [KT-11514](https://youtrack.jetbrains.com/issue/KT-11514) Correct comparison of Long! / Double! with integer constant
- [KT-11590](https://youtrack.jetbrains.com/issue/KT-11590) SAM adapter for inline function corrected
## 1.0.1-1
### Compiler
- [KT-11468](https://youtrack.jetbrains.com/issue/KT-11468) More correct use-site / declaration-site variance combination handling
- [KT-11478](https://youtrack.jetbrains.com/issue/KT-11478) "Couldn't inline method call" internal compiler error fixed
## 1.0.1
### Compiler
Analysis & diagnostics issues fixed:
- [KT-2277](https://youtrack.jetbrains.com/issue/KT-2277) Local function declarations are now checked for overload conflicts
- [KT-3602](https://youtrack.jetbrains.com/issue/KT-3602) Special diagnostic is reported now on nullable for range
- [KT-10775](https://youtrack.jetbrains.com/issue/KT-10775) No compilation exception for empty when
- [KT-10952](https://youtrack.jetbrains.com/issue/KT-10952) False deprecation warnings removed
- [KT-10934](https://youtrack.jetbrains.com/issue/KT-10934) Type inference improved for whens
- [KT-10902](https://youtrack.jetbrains.com/issue/KT-10902) Redeclaration is reported for top-level property vs classifier conflict
- [KT-9985](https://youtrack.jetbrains.com/issue/KT-9985) Correct handling of safe call arguments in generic functions
- [KT-10856](https://youtrack.jetbrains.com/issue/KT-10856) Diagnostic about projected out member is reported correctly on calls with smart cast receiver
- [KT-5190](https://youtrack.jetbrains.com/issue/KT-5190) Calls of Java 8 Stream.collect
- [KT-11109](https://youtrack.jetbrains.com/issue/KT-11109) Warning is reported on Strictfp annotation on a class because it's not supported yet
- [KT-10686](https://youtrack.jetbrains.com/issue/KT-10686) Support generic constructors defined in Java
- [KT-6958](https://youtrack.jetbrains.com/issue/KT-6958) Fixed resolution for overloaded functions with extension lambdas
- [KT-10765](https://youtrack.jetbrains.com/issue/KT-10765) Correct handling of overload conflict between constructor and function in JPS
- [KT-10752](https://youtrack.jetbrains.com/issue/KT-10752) If inferred type for an expression refers to a non-accessible Java class, it's a compiler error to prevent IAE in runtime
- [KT-7415](https://youtrack.jetbrains.com/issue/KT-7415) Approximation of captured types in signatures
- [KT-10913](https://youtrack.jetbrains.com/issue/KT-10913), [KT-10186](https://youtrack.jetbrains.com/issue/KT-10186), [KT-5198](https://youtrack.jetbrains.com/issue/KT-5198) False “unreachable code” fixed for various situations
- Minor: [KT-3680](https://youtrack.jetbrains.com/issue/KT-3680), [KT-9702](https://youtrack.jetbrains.com/issue/KT-9702), [KT-8776](https://youtrack.jetbrains.com/issue/KT-8776), [KT-6745](https://youtrack.jetbrains.com/issue/KT-6745), [KT-10919](https://youtrack.jetbrains.com/issue/KT-10919), [KT-9548](https://youtrack.jetbrains.com/issue/KT-9548)
JVM code generation issues fixed:
- [KT-11153](https://youtrack.jetbrains.com/issue/KT-11153) NoClassDefFoundError is fixed on primitive iterators during boxing optimization
- [KT-7319](https://youtrack.jetbrains.com/issue/KT-7319) Correct parameter names for @JvmOverloads-generated methods
- [KT-10425](https://youtrack.jetbrains.com/issue/KT-10425) Non-const values of member properties are not inlined now
- [KT-11163](https://youtrack.jetbrains.com/issue/KT-11163) Correct calls of custom compareTo on primitives
- [KT-11081](https://youtrack.jetbrains.com/issue/KT-11081) Reified type parameters are correctly stored in anonymous objects
- [KT-11121](https://youtrack.jetbrains.com/issue/KT-11121) Generic properties generation is fixed for interfaces
- [KT-11285](https://youtrack.jetbrains.com/issue/KT-11285), [KT-10958](https://youtrack.jetbrains.com/issue/KT-10958) Special bridge generation refined
- [KT-10313](https://youtrack.jetbrains.com/issue/KT-10313), [KT-11190](https://youtrack.jetbrains.com/issue/KT-11190), [KT-11192](https://youtrack.jetbrains.com/issue/KT-11192), [KT-11130](https://youtrack.jetbrains.com/issue/KT-11130) Diagnostics and bytecode fixed for various operations with Long
- [KT-11203](https://youtrack.jetbrains.com/issue/KT-11203), [KT-11191](https://youtrack.jetbrains.com/issue/KT-11191), [KT-11206](https://youtrack.jetbrains.com/issue/KT-11206), [KT-8505](https://youtrack.jetbrains.com/issue/KT-8505), [KT-11203](https://youtrack.jetbrains.com/issue/KT-11203) Handling of increment / decrement for collection elements with user-defined get / set fixed
- [KT-9739](https://youtrack.jetbrains.com/issue/KT-9739) Backticked names with spaces are generated correctly
JS translator issues fixed:
- [KT-7683](https://youtrack.jetbrains.com/issue/KT-7683), [KT-11027](https://youtrack.jetbrains.com/issue/KT-11027) correct handling of in / !in inside when expressions
### Standard library
- [KT-10579](https://youtrack.jetbrains.com/issue/KT-10579) Improved performance of sum() and average() for arrays
- [KT-10821](https://youtrack.jetbrains.com/issue/KT-10821) Improved performance of drop() / take() for sequences
### Reflection
- [KT-10840](https://youtrack.jetbrains.com/issue/KT-10840) Fix annotations on Java elements in reflection
### IDE
New features:
- Compatibility with IDEA 2016
- Kotlin Education Plugin (for IDEA 2016)
- [KT-9752](https://youtrack.jetbrains.com/issue/KT-9752) More usable file chooser for "Move declaration to another file"
- [KT-9697](https://youtrack.jetbrains.com/issue/KT-9697) Move method to companion object and back
- [KT-7443](https://youtrack.jetbrains.com/issue/KT-7443) Inspection + intention to replace assert (x != null) with "!!" or elvis
General issues fixed:
- [KT-11277](https://youtrack.jetbrains.com/issue/KT-11277) Correct moving of Java classes from project view
- [KT-11256](https://youtrack.jetbrains.com/issue/KT-11256) Navigate Declaration fixed for Java classes with @NotNull parameter in constructor
- [KT-10553](https://youtrack.jetbrains.com/issue/KT-10553) A warning provided when Refactor / Move result is not compilable due to visibility problems
- [KT-11039](https://youtrack.jetbrains.com/issue/KT-11039) Parameter names are now not missing in parameter info and completion for compiled java code used from kotlin
- [KT-10204](https://youtrack.jetbrains.com/issue/KT-10204) Highlight usages in file is working now for function parameter
- [KT-10954](https://youtrack.jetbrains.com/issue/KT-10954) Introduce Parameter (Ctrl+Alt+P) fixed when default value is a simple name reference
- [KT-10776](https://youtrack.jetbrains.com/issue/KT-10776) Intentions: "Convert to lambda expression" works now for empty function body
- [KT-10815](https://youtrack.jetbrains.com/issue/KT-10815) Generate equals() and hashCode() is no more suggested for interfaces
- [KT-10818](https://youtrack.jetbrains.com/issue/KT-10818) "Initialize with constructor parameter" fixed
- [KT-8876](https://youtrack.jetbrains.com/issue/KT-8876) "Convert member to extension" now removes modality modifiers (open / final)
- [KT-10800](https://youtrack.jetbrains.com/issue/KT-10800) Create enum entry now adds comma after a new entry
- [KT-10552](https://youtrack.jetbrains.com/issue/KT-10552) Pull Members Up now takes visibility conflicts into account
- [KT-10978](https://youtrack.jetbrains.com/issue/KT-10978) Partially fixed, completion for JOOQ became ~ 10 times faster
- [KT-10940](https://youtrack.jetbrains.com/issue/KT-10940) Reference search optimized for convention functions
- [KT-9026](https://youtrack.jetbrains.com/issue/KT-9026) Editor no more locks up during scala file viewing
- [KT-11142](https://youtrack.jetbrains.com/issue/KT-11142), [KT-11276](https://youtrack.jetbrains.com/issue/KT-11276) Darkula scheme appearance corrected for Kotlin
- Minor: [KT-10778](https://youtrack.jetbrains.com/issue/KT-10778), [KT-10763](https://youtrack.jetbrains.com/issue/KT-10763), [KT-10908](https://youtrack.jetbrains.com/issue/KT-10908), [KT-10345](https://youtrack.jetbrains.com/issue/KT-10345), [KT-10696](https://youtrack.jetbrains.com/issue/KT-10696), [KT-11041](https://youtrack.jetbrains.com/issue/KT-11041), [KT-9434](https://youtrack.jetbrains.com/issue/KT-9434), [KT-8744](https://youtrack.jetbrains.com/issue/KT-8744), [KT-9738](https://youtrack.jetbrains.com/issue/KT-9738), [KT-10912](https://youtrack.jetbrains.com/issue/KT-10912)
Configuration issues fixed:
- [KT-11213](https://youtrack.jetbrains.com/issue/KT-11213) Kotlin plugin version corrected in build.gradle
- [KT-10918](https://youtrack.jetbrains.com/issue/KT-10918) "Update Kotlin runtime" action does not try to update the runtime coming in from Gradle
- [KT-11072](https://youtrack.jetbrains.com/issue/KT-11072) Libraries in maven, gradle and ide systems are never more detected as runtime libraries
- [KT-10489](https://youtrack.jetbrains.com/issue/KT-10489) Configuration messages are aggregated into one notification
- [KT-10831](https://youtrack.jetbrains.com/issue/KT-10831) Configure Kotlin in Project: "All modules containing Kotlin files" does not list modules not containing Kotlin files
- [KT-10366](https://youtrack.jetbrains.com/issue/KT-10366) Gradle import: no fake "Configure Kotlin" notification on project creating
Debugger issues fixed:
- [KT-10827](https://youtrack.jetbrains.com/issue/KT-10827) Fixed debugger stepping for inline calls
- [KT-10780](https://youtrack.jetbrains.com/issue/KT-10780) Breakpoints in a lazy property work correctly
- [KT-10634](https://youtrack.jetbrains.com/issue/KT-10634) Watches can now use private overloaded functions
- [KT-10611](https://youtrack.jetbrains.com/issue/KT-10611) Line breakpoints now can be created inside lambda in init block
- [KT-10673](https://youtrack.jetbrains.com/issue/KT-10673) Breakpoints inside lambda are no more ignored in presence of crossinline function parameter
- [KT-11318](https://youtrack.jetbrains.com/issue/KT-11318) Stepping inside for each is optimized
- [KT-3873](https://youtrack.jetbrains.com/issue/KT-3873) Editing code while standing on breakpoint is optimized
- [KT-7261](https://youtrack.jetbrains.com/issue/KT-7261), [KT-7266](https://youtrack.jetbrains.com/issue/KT-7266), [KT-10672](https://youtrack.jetbrains.com/issue/KT-10672) Evaluate expression applicability corrected
### Tools
- [KT-7943](https://youtrack.jetbrains.com/issue/KT-7943), [KT-10127](https://youtrack.jetbrains.com/issue/KT-10127) Overhead removed in Kotlin Gradle Plugin
- [KT-11351](https://youtrack.jetbrains.com/issue/KT-11351) Fixed NoSuchMethodError with Gradle 2.12

View File

@@ -1,154 +0,0 @@
# CHANGELOG
<!-- Find: ([^\[/])(KT-\d+) -->
<!-- Replace: $1[$2](https://youtrack.jetbrains.com/issue/$2) -->
## 1.1
## 1.0.2
- Show only changed files in notification "Kotlin not configured"
- Configure Kotlin: restore all changed files in undo action
- Enable precise incremental compilation by default
- Report warning about unused anonymous functions
### JVM
- Remove the compiler option "Xmultifile-facades-open"
### JS
- Safe calls (`x?.let { it }`) are now inlined
### Tools. J2K
- Protected members used outside of inheritors are converted as public
- Support conversion for annotation constructor calls
- Place comments from the middle of the call to the end
- Drop line breaks between operator arguments (except '+', "-", "&&" and "||")
- Add non-null assertions on call site for non-null parameters
- Specify type for variables with anonymous type if they have write accesses
### Tools. Android
- Fixed sequential build with kapt and stubs enabled when Kotlin source file was modified and no Java source files were modified
### IDE
- Debugger can distinguish nested inline arguments
- Add kotlinClassName() and kotlinFunctionName() macros for use in live templates
- Complete private members from libraries in Evaluate Expression dialog
- Show error message when debug info for some local variable is corrupted
- [KT-11638](https://youtrack.jetbrains.com/issue/KT-11638) Fixed hashCode() implementation in "Generate equals/hashCode" action
### Tools.Gradle
- Added project property 'kotlin.incremental'
- Fixed a bug causing Java rebuild when both Java and Kotlin are up-to-date
## 1.0.1-2
### Compiler
- [KT-11584](https://youtrack.jetbrains.com/issue/KT-11584), [KT-11514](https://youtrack.jetbrains.com/issue/KT-11514) Correct comparison of Long! / Double! with integer constant
- [KT-11590](https://youtrack.jetbrains.com/issue/KT-11590) SAM adapter for inline function corrected
## 1.0.1-1
### Compiler
- [KT-11468](https://youtrack.jetbrains.com/issue/KT-11468) More correct use-site / declaration-site variance combination handling
- [KT-11478](https://youtrack.jetbrains.com/issue/KT-11478) "Couldn't inline method call" internal compiler error fixed
## 1.0.1
### Compiler
Analysis & diagnostics issues fixed:
- [KT-2277](https://youtrack.jetbrains.com/issue/KT-2277) Local function declarations are now checked for overload conflicts
- [KT-3602](https://youtrack.jetbrains.com/issue/KT-3602) Special diagnostic is reported now on nullable for range
- [KT-10775](https://youtrack.jetbrains.com/issue/KT-10775) No compilation exception for empty when
- [KT-10952](https://youtrack.jetbrains.com/issue/KT-10952) False deprecation warnings removed
- [KT-10934](https://youtrack.jetbrains.com/issue/KT-10934) Type inference improved for whens
- [KT-10902](https://youtrack.jetbrains.com/issue/KT-10902) Redeclaration is reported for top-level property vs classifier conflict
- [KT-9985](https://youtrack.jetbrains.com/issue/KT-9985) Correct handling of safe call arguments in generic functions
- [KT-10856](https://youtrack.jetbrains.com/issue/KT-10856) Diagnostic about projected out member is reported correctly on calls with smart cast receiver
- [KT-5190](https://youtrack.jetbrains.com/issue/KT-5190) Calls of Java 8 Stream.collect
- [KT-11109](https://youtrack.jetbrains.com/issue/KT-11109) Warning is reported on Strictfp annotation on a class because it's not supported yet
- [KT-10686](https://youtrack.jetbrains.com/issue/KT-10686) Support generic constructors defined in Java
- [KT-6958](https://youtrack.jetbrains.com/issue/KT-6958) Fixed resolution for overloaded functions with extension lambdas
- [KT-10765](https://youtrack.jetbrains.com/issue/KT-10765) Correct handling of overload conflict between constructor and function in JPS
- [KT-10752](https://youtrack.jetbrains.com/issue/KT-10752) If inferred type for an expression refers to a non-accessible Java class, it's a compiler error to prevent IAE in runtime
- [KT-7415](https://youtrack.jetbrains.com/issue/KT-7415) Approximation of captured types in signatures
- [KT-10913](https://youtrack.jetbrains.com/issue/KT-10913), [KT-10186](https://youtrack.jetbrains.com/issue/KT-10186), [KT-5198](https://youtrack.jetbrains.com/issue/KT-5198) False “unreachable code” fixed for various situations
- Minor: [KT-3680](https://youtrack.jetbrains.com/issue/KT-3680), [KT-9702](https://youtrack.jetbrains.com/issue/KT-9702), [KT-8776](https://youtrack.jetbrains.com/issue/KT-8776), [KT-6745](https://youtrack.jetbrains.com/issue/KT-6745), [KT-10919](https://youtrack.jetbrains.com/issue/KT-10919), [KT-9548](https://youtrack.jetbrains.com/issue/KT-9548)
JVM code generation issues fixed:
- [KT-11153](https://youtrack.jetbrains.com/issue/KT-11153) NoClassDefFoundError is fixed on primitive iterators during boxing optimization
- [KT-7319](https://youtrack.jetbrains.com/issue/KT-7319) Correct parameter names for @JvmOverloads-generated methods
- [KT-10425](https://youtrack.jetbrains.com/issue/KT-10425) Non-const values of member properties are not inlined now
- [KT-11163](https://youtrack.jetbrains.com/issue/KT-11163) Correct calls of custom compareTo on primitives
- [KT-11081](https://youtrack.jetbrains.com/issue/KT-11081) Reified type parameters are correctly stored in anonymous objects
- [KT-11121](https://youtrack.jetbrains.com/issue/KT-11121) Generic properties generation is fixed for interfaces
- [KT-11285](https://youtrack.jetbrains.com/issue/KT-11285), [KT-10958](https://youtrack.jetbrains.com/issue/KT-10958) Special bridge generation refined
- [KT-10313](https://youtrack.jetbrains.com/issue/KT-10313), [KT-11190](https://youtrack.jetbrains.com/issue/KT-11190), [KT-11192](https://youtrack.jetbrains.com/issue/KT-11192), [KT-11130](https://youtrack.jetbrains.com/issue/KT-11130) Diagnostics and bytecode fixed for various operations with Long
- [KT-11203](https://youtrack.jetbrains.com/issue/KT-11203), [KT-11191](https://youtrack.jetbrains.com/issue/KT-11191), [KT-11206](https://youtrack.jetbrains.com/issue/KT-11206), [KT-8505](https://youtrack.jetbrains.com/issue/KT-8505), [KT-11203](https://youtrack.jetbrains.com/issue/KT-11203) Handling of increment / decrement for collection elements with user-defined get / set fixed
- [KT-9739](https://youtrack.jetbrains.com/issue/KT-9739) Backticked names with spaces are generated correctly
JS translator issues fixed:
- [KT-7683](https://youtrack.jetbrains.com/issue/KT-7683), [KT-11027](https://youtrack.jetbrains.com/issue/KT-11027) correct handling of in / !in inside when expressions
### Standard library
- [KT-10579](https://youtrack.jetbrains.com/issue/KT-10579) Improved performance of sum() and average() for arrays
- [KT-10821](https://youtrack.jetbrains.com/issue/KT-10821) Improved performance of drop() / take() for sequences
### IDE
New features:
- Compatibility with IDEA 2016
- Kotlin Education Plugin (for IDEA 2016)
- [KT-9752](https://youtrack.jetbrains.com/issue/KT-9752) More usable file chooser for "Move declaration to another file"
- [KT-9697](https://youtrack.jetbrains.com/issue/KT-9697) Move method to companion object and back
General issues fixed:
- [KT-11277](https://youtrack.jetbrains.com/issue/KT-11277) Correct moving of Java classes from project view
- [KT-11256](https://youtrack.jetbrains.com/issue/KT-11256) Navigate Declaration fixed for Java classes with @NotNull parameter in constructor
- [KT-10553](https://youtrack.jetbrains.com/issue/KT-10553) A warning provided when Refactor / Move result is not compilable due to visibility problems
- [KT-11039](https://youtrack.jetbrains.com/issue/KT-11039) Parameter names are now not missing in parameter info and completion for compiled java code used from kotlin
- [KT-10204](https://youtrack.jetbrains.com/issue/KT-10204) Highlight usages in file is working now for function parameter
- [KT-10954](https://youtrack.jetbrains.com/issue/KT-10954) Introduce Parameter (Ctrl+Alt+P) fixed when default value is a simple name reference
- [KT-10776](https://youtrack.jetbrains.com/issue/KT-10776) Intentions: "Convert to lambda expression" works now for empty function body
- [KT-10815](https://youtrack.jetbrains.com/issue/KT-10815) Generate equals() and hashCode() is no more suggested for interfaces
- [KT-10818](https://youtrack.jetbrains.com/issue/KT-10818) "Initialize with constructor parameter" fixed
- [KT-8876](https://youtrack.jetbrains.com/issue/KT-8876) "Convert member to extension" now removes modality modifiers (open / final)
- [KT-10800](https://youtrack.jetbrains.com/issue/KT-10800) Create enum entry now adds comma after a new entry
- [KT-10552](https://youtrack.jetbrains.com/issue/KT-10552) Pull Members Up now takes visibility conflicts into account
- [KT-10978](https://youtrack.jetbrains.com/issue/KT-10978) Partially fixed, completion for JOOQ became ~ 10 times faster
- [KT-10940](https://youtrack.jetbrains.com/issue/KT-10940) Reference search optimized for convention functions
- [KT-9026](https://youtrack.jetbrains.com/issue/KT-9026) Editor no more locks up during scala file viewing
- [KT-11142](https://youtrack.jetbrains.com/issue/KT-11142), [KT-11276](https://youtrack.jetbrains.com/issue/KT-11276) Darkula scheme appearance corrected for Kotlin
- Minor: [KT-10778](https://youtrack.jetbrains.com/issue/KT-10778), [KT-10763](https://youtrack.jetbrains.com/issue/KT-10763), [KT-10908](https://youtrack.jetbrains.com/issue/KT-10908), [KT-10345](https://youtrack.jetbrains.com/issue/KT-10345), [KT-10696](https://youtrack.jetbrains.com/issue/KT-10696), [KT-11041](https://youtrack.jetbrains.com/issue/KT-11041), [KT-9434](https://youtrack.jetbrains.com/issue/KT-9434)
Configuration issues fixed:
- [KT-11213](https://youtrack.jetbrains.com/issue/KT-11213) Kotlin plugin version corrected in build.gradle
- [KT-10918](https://youtrack.jetbrains.com/issue/KT-10918) "Update Kotlin runtime" action does not try to update the runtime coming in from Gradle
- [KT-11072](https://youtrack.jetbrains.com/issue/KT-11072) Libraries in maven, gradle and ide systems are never more detected as runtime libraries
- [KT-10489](https://youtrack.jetbrains.com/issue/KT-10489) Configuration messages are aggregated into one notification
- [KT-10831](https://youtrack.jetbrains.com/issue/KT-10831) Configure Kotlin in Project: "All modules containing Kotlin files" does not list modules not containing Kotlin files
- [KT-10366](https://youtrack.jetbrains.com/issue/KT-10366) Gradle import: no fake "Configure Kotlin" notification on project creating
Debugger issues fixed:
- [KT-10827](https://youtrack.jetbrains.com/issue/KT-10827) Fixed debugger stepping for inline calls
- [KT-10780](https://youtrack.jetbrains.com/issue/KT-10780) Breakpoints in a lazy property work correctly
- [KT-10634](https://youtrack.jetbrains.com/issue/KT-10634) Watches can now use private overloaded functions
- [KT-10611](https://youtrack.jetbrains.com/issue/KT-10611) Line breakpoints now can be created inside lambda in init block
- [KT-10673](https://youtrack.jetbrains.com/issue/KT-10673) Breakpoints inside lambda are no more ignored in presence of crossinline function parameter
- [KT-11318](https://youtrack.jetbrains.com/issue/KT-11318) Stepping inside for each is optimized
- [KT-3873](https://youtrack.jetbrains.com/issue/KT-3873) Editing code while standing on breakpoint is optimized
- [KT-7261](https://youtrack.jetbrains.com/issue/KT-7261), [KT-7266](https://youtrack.jetbrains.com/issue/KT-7266), [KT-10672](https://youtrack.jetbrains.com/issue/KT-10672) Evaluate expression applicability corrected
### Tools
- [KT-7943](https://youtrack.jetbrains.com/issue/KT-7943), [KT-10127](https://youtrack.jetbrains.com/issue/KT-10127) Overhead removed in Kotlin Gradle Plugin
- [KT-11351](https://youtrack.jetbrains.com/issue/KT-11351) Fixed NoSuchMethodError with Gradle 2.12

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,6 +24,8 @@ import com.intellij.util.io.EnumeratorStringDescriptor
import org.jetbrains.annotations.TestOnly
import org.jetbrains.kotlin.build.GeneratedJvmClass
import org.jetbrains.kotlin.config.IncrementalCompilation
import org.jetbrains.kotlin.incremental.ChangeInfo.MembersChanged
import org.jetbrains.kotlin.incremental.ChangeInfo.Removed
import org.jetbrains.kotlin.incremental.storage.*
import org.jetbrains.kotlin.inline.inlineFunctionsJvmNames
import org.jetbrains.kotlin.load.kotlin.ModuleMapping
@@ -32,12 +34,14 @@ import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCache
import org.jetbrains.kotlin.load.kotlin.incremental.components.JvmPackagePartProto
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.resolve.jvm.JvmClassName
import org.jetbrains.kotlin.serialization.Flags
import org.jetbrains.kotlin.serialization.ProtoBuf
import org.jetbrains.kotlin.serialization.deserialization.NameResolver
import org.jetbrains.kotlin.serialization.deserialization.TypeTable
import org.jetbrains.kotlin.serialization.deserialization.supertypes
import org.jetbrains.kotlin.serialization.jvm.BitEncoding
import org.jetbrains.kotlin.serialization.jvm.JvmProtoBufUtil
import org.jetbrains.kotlin.utils.singletonOrEmptyList
import org.jetbrains.org.objectweb.asm.*
import java.io.File
import java.security.MessageDigest
@@ -118,6 +122,11 @@ open class IncrementalCacheImpl<Target>(
}
}
// used in gradle
@Suppress("unused")
fun classesBySources(sources: Iterable<File>): Iterable<JvmClassName> =
sources.flatMap { sourceToClassesMap[it] }
fun getSubtypesOf(className: FqName): Sequence<FqName> =
subtypesMap[className].asSequence()
@@ -207,32 +216,34 @@ open class IncrementalCacheImpl<Target>(
debugLog("$className is changed: $this")
}
fun clearCacheForRemovedClasses(): CompilationResult {
private fun computeChanges(className: JvmClassName, createChangeInfo: (FqName, Collection<String>) -> ChangeInfo): List<ChangeInfo> {
fun <T> T.getNonPrivateNames(nameResolver: NameResolver, vararg members: T.() -> List<MessageLite>): Set<String> =
members.flatMap { this.it().filterNot { it.isPrivate }.names(nameResolver) }.toSet()
fun createChangeInfo(className: JvmClassName): ChangeInfo? {
if (className.internalName == MODULE_MAPPING_FILE_NAME) return null
if (className.internalName == MODULE_MAPPING_FILE_NAME) return emptyList()
val mapValue = protoMap.get(className) ?: return null
val mapValue = protoMap[className] ?: return emptyList()
return when {
mapValue.isPackageFacade -> {
val packageData = JvmProtoBufUtil.readPackageDataFrom(mapValue.bytes, mapValue.strings)
return when {
mapValue.isPackageFacade -> {
val packageData = JvmProtoBufUtil.readPackageDataFrom(mapValue.bytes, mapValue.strings)
val memberNames =
packageData.packageProto.getNonPrivateNames(
packageData.nameResolver,
ProtoBuf.Package::getFunctionList,
ProtoBuf.Package::getPropertyList
)
val memberNames =
packageData.packageProto.getNonPrivateNames(
packageData.nameResolver,
ProtoBuf.Package::getFunctionList,
ProtoBuf.Package::getPropertyList
)
ChangeInfo.Removed(className.packageFqName, memberNames)
}
else -> {
val classData = JvmProtoBufUtil.readClassDataFrom(mapValue.bytes, mapValue.strings)
listOf(createChangeInfo(className.packageFqName, memberNames))
}
else -> {
val classData = JvmProtoBufUtil.readClassDataFrom(mapValue.bytes, mapValue.strings)
val classFqName = className.fqNameForClassNameWithoutDollars
val kind = Flags.CLASS_KIND.get(classData.classProto.flags)
if (kind == ProtoBuf.Class.Kind.COMPANION_OBJECT) {
val memberNames =
classData.classProto.getNonPrivateNames(
classData.nameResolver,
@@ -241,11 +252,19 @@ open class IncrementalCacheImpl<Target>(
ProtoBuf.Class::getPropertyList
) + classData.classProto.enumEntryList.map { classData.nameResolver.getString(it.name) }
ChangeInfo.Removed(className.fqNameForClassNameWithoutDollars, memberNames)
val companionObjectChanged = createChangeInfo(classFqName.parent(), classFqName.shortName().asString().singletonOrEmptyList())
val companionObjectMembersChanged = createChangeInfo(classFqName, memberNames)
listOf(companionObjectMembersChanged, companionObjectChanged)
}
else {
listOf(ChangeInfo.SignatureChanged(classFqName, areSubclassesAffected = true))
}
}
}
}
fun clearCacheForRemovedClasses(): CompilationResult {
val dirtyClasses = dirtyOutputClassesMap
.getDirtyOutputClasses()
.map(JvmClassName::byInternalName)
@@ -253,7 +272,7 @@ open class IncrementalCacheImpl<Target>(
val changes =
if (IncrementalCompilation.isExperimental())
dirtyClasses.mapNotNull { createChangeInfo(it) }.asSequence()
dirtyClasses.flatMap { computeChanges(it, ::Removed) }.asSequence()
else
emptySequence<ChangeInfo>()
@@ -346,9 +365,6 @@ open class IncrementalCacheImpl<Target>(
experimentalMaps.forEach { it.clean() }
}
fun classesBySources(sources: Iterable<File>): Iterable<JvmClassName> =
sources.flatMap { sourceToClassesMap[it] }
private inner class ProtoMap(storageFile: File) : BasicStringMap<ProtoMapValue>(storageFile, ProtoMapValueExternalizer) {
fun process(kotlinClass: LocalFileKotlinClass, isPackage: Boolean): CompilationResult {
@@ -376,7 +392,17 @@ open class IncrementalCacheImpl<Target>(
storage[key] = data
}
if (oldData == null || !checkChangesIsOpenPart) return CompilationResult(protoChanged = true)
if (!checkChangesIsOpenPart) return CompilationResult(protoChanged = true)
if (oldData == null) {
val changes =
if (IncrementalCompilation.isExperimental())
computeChanges(className, ::MembersChanged).asSequence()
else
emptySequence<ChangeInfo>()
return CompilationResult(protoChanged = true, changes = changes)
}
val difference = difference(oldData, data)
val fqName = if (isPackage) className.packageFqName else className.fqNameForClassNameWithoutDollars

View File

@@ -16,9 +16,6 @@
package org.jetbrains.kotlin.incremental.testingUtils
import com.google.common.collect.Sets
import com.google.common.hash.Hashing
import com.google.common.io.Files
import com.google.protobuf.ExtensionRegistry
import com.intellij.openapi.util.io.FileUtil
import org.jetbrains.kotlin.incremental.LocalFileKotlinClass
@@ -36,6 +33,7 @@ import java.io.File
import java.io.PrintWriter
import java.io.StringWriter
import java.util.*
import java.util.zip.CRC32
import kotlin.comparisons.compareBy
// Set this to true if you want to dump all bytecode (test will fail in this case)
@@ -45,7 +43,7 @@ fun assertEqualDirectories(expected: File, actual: File, forgiveExtraFiles: Bool
val pathsInExpected = getAllRelativePaths(expected)
val pathsInActual = getAllRelativePaths(actual)
val commonPaths = Sets.intersection(pathsInExpected, pathsInActual)
val commonPaths = pathsInExpected.intersect(pathsInActual)
val changedPaths = commonPaths
.filter { DUMP_ALL || !Arrays.equals(File(expected, it).readBytes(), File(actual, it).readBytes()) }
.sorted()
@@ -71,7 +69,11 @@ fun assertEqualDirectories(expected: File, actual: File, forgiveExtraFiles: Bool
Assert.assertEquals(expectedString, actualString)
}
private fun File.hash() = Files.hash(this, Hashing.crc32())
private fun File.checksumString(): String {
val crc32 = CRC32()
crc32.update(this.readBytes())
return java.lang.Long.toHexString(crc32.value)
}
private fun getDirectoryString(dir: File, interestingPaths: List<String>): String {
val buf = StringBuilder()
@@ -93,7 +95,7 @@ private fun getDirectoryString(dir: File, interestingPaths: List<String>): Strin
}
}
else {
p.println(child.name, " ", child.hash())
p.println(child.name, " ", child.checksumString())
}
}

View File

@@ -68,7 +68,7 @@
<fileset dir="${basedir}/lib" includes="**/*.jar"/>
<fileset dir="${dependencies.dir}" includes="jansi.jar"/>
<fileset dir="${dependencies.dir}" includes="jline.jar"/>
<fileset dir="${dependencies.dir}" includes="cli-parser-1.1.1.jar"/>
<fileset dir="${dependencies.dir}" includes="cli-parser-1.1.2.jar"/>
<fileset dir="${basedir}/ideaSDK/jps" includes="jps-model.jar"/>
</path>
@@ -512,7 +512,7 @@
<zipfileset src="${idea.sdk}/lib/oromatcher.jar"/>
<zipfileset src="${idea.sdk}/jps/jps-model.jar"/>
<zipfileset src="${dependencies.dir}/jline.jar"/>
<zipfileset src="${dependencies.dir}/cli-parser-1.1.1.jar"/>
<zipfileset src="${dependencies.dir}/cli-parser-1.1.2.jar"/>
<zipfileset src="${protobuf.jar}"/>
<manifest>
@@ -668,25 +668,28 @@
<pathelement path="${bootstrap.reflect}"/>
<pathelement path="${bootstrap.kotlin.test}"/>
<pathelement path="${idea.sdk}/lib/junit-4.12.jar"/>
<pathelement path="${idea.sdk}/lib/guava-17.0.jar"/>
<pathelement path="${kotlin-home}/lib/kotlin-build-common.jar"/>
<pathelement path="${kotlin-home}/lib/kotlin-compiler.jar"/>
<pathelement path="${protobuf.jar}"/>
</classpath>
</javac2>
<jar destfile="${kotlin-home}/lib/kotlin-build-common-test.jar">
<taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpath="dependencies/jarjar.jar"/>
<jarjar jarfile="${kotlin-home}/lib/kotlin-build-common-test.jar">
<fileset dir="${output}/classes/kotlin-build-common-test"/>
<zipfileset file="${kotlin-home}/build.txt" prefix="META-INF"/>
<zipfileset src="${protobuf.jar}"/>
<rule pattern="com.google.**" result="org.jetbrains.kotlin.com.google.@1"/>
<rule pattern="com.intellij.**" result="org.jetbrains.kotlin.com.intellij.@1"/>
<manifest>
<attribute name="Built-By" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Vendor" value="${manifest.impl.vendor}"/>
<attribute name="Implementation-Title" value="${manifest.impl.title.kotlin.build.common}"/>
<attribute name="Implementation-Version" value="${build.number}"/>
</manifest>
</jar>
</jarjar>
</target>
<target name="daemon-client">
@@ -877,7 +880,7 @@
</target>
<target name="stdlib">
<new-kotlinc output="${output}/classes/stdlib" moduleName="kotlin-stdlib" additionalOptions="-Xdump-declarations-to ${output}/declarations/stdlib-declarations.json">
<new-kotlinc output="${output}/classes/stdlib" moduleName="kotlin-stdlib" additionalOptions="-Xmultifile-parts-inherit -Xdump-declarations-to ${output}/declarations/stdlib-declarations.json">
<src>
<include name="libraries/stdlib/src"/>
</src>
@@ -902,7 +905,7 @@
<pack-runtime-jar jar-name="kotlin-test.jar" implementation-title="${manifest.impl.title.kotlin.test}">
<jar-content>
<fileset dir="${output}/classes/kotlin-test" includes="**/*" excludes="kotlin/internal/OnlyInputTypes*,kotlin/internal"/>
<fileset dir="${output}/classes/kotlin-test" includes="**/*" excludes="kotlin/internal/OnlyInputTypes*,kotlin/internal/InlineOnly*,kotlin/internal"/>
</jar-content>
</pack-runtime-jar>
</target>
@@ -926,7 +929,7 @@
</target>
<target name="reflection">
<new-kotlinc output="${output}/classes/reflection" moduleName="kotlin-reflection" additionalOptions="-Xdump-declarations-to ${output}/declarations/reflect-declarations.json">
<new-kotlinc output="${output}/classes/reflection" moduleName="kotlin-reflection">
<src>
<include name="core/reflection.jvm/src"/>
</src>

View File

@@ -279,7 +279,7 @@ public abstract class AnnotationCodegen {
ClassifierDescriptor classifierDescriptor = annotationDescriptor.getType().getConstructor().getDeclarationDescriptor();
assert classifierDescriptor != null : "Annotation descriptor has no class: " + annotationDescriptor;
RetentionPolicy rp = getRetentionPolicy(classifierDescriptor);
if (rp == RetentionPolicy.SOURCE && typeMapper.getClassBuilderMode() != ClassBuilderMode.LIGHT_CLASSES) {
if (rp == RetentionPolicy.SOURCE && typeMapper.getClassBuilderMode() == ClassBuilderMode.FULL) {
return null;
}
@@ -404,6 +404,7 @@ public abstract class AnnotationCodegen {
case FULL:
throw new IllegalStateException("Don't know how to compile annotation value " + value);
case LIGHT_CLASSES:
case KAPT:
return null;
default:
throw new IllegalStateException("Unknown builder mode: " + mode);

View File

@@ -25,4 +25,8 @@ public enum ClassBuilderMode {
* Generating light classes: Only function signatures
*/
LIGHT_CLASSES,
/**
* Function signatures + metadata (to support incremental compilation with kapt)
*/
KAPT;
}

View File

@@ -134,7 +134,7 @@ class DefaultParameterValueSubstitutor(val state: GenerationState) {
annotationCodegen.genAnnotations(it.value, signature.valueParameters[it.index].asmType)
}
if (state.classBuilderMode == ClassBuilderMode.LIGHT_CLASSES) {
if (state.classBuilderMode != ClassBuilderMode.FULL) {
FunctionCodegen.generateLocalVariablesForParameters(mv, signature, null, Label(), Label(), remainingParameters, isStatic)
mv.visitEnd()
return

View File

@@ -627,7 +627,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
// for (e : E in c) {...}
protected final KtForExpression forExpression;
private final Label bodyStart = new Label();
private final Label loopParameterStartLabel = new Label();
private final Label bodyEnd = new Label();
private final List<Runnable> leaveVariableTasks = Lists.newArrayList();
@@ -635,6 +635,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
protected final Type asmElementType;
protected int loopParameterVar;
protected Type loopParameterType;
private AbstractForLoopGenerator(@NotNull KtForExpression forExpression) {
this.forExpression = forExpression;
@@ -658,15 +659,15 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
if (loopParameter != null) {
// E e = tmp<iterator>.next()
final VariableDescriptor parameterDescriptor = bindingContext.get(VALUE_PARAMETER, loopParameter);
@SuppressWarnings("ConstantConditions") final Type asmTypeForParameter = asmType(parameterDescriptor.getType());
loopParameterVar = myFrameMap.enter(parameterDescriptor, asmTypeForParameter);
loopParameterType = asmType(parameterDescriptor.getType());
loopParameterVar = myFrameMap.enter(parameterDescriptor, loopParameterType);
scheduleLeaveVariable(new Runnable() {
@Override
public void run() {
myFrameMap.leave(parameterDescriptor);
v.visitLocalVariable(parameterDescriptor.getName().asString(),
asmTypeForParameter.getDescriptor(), null,
bodyStart, bodyEnd,
loopParameterType.getDescriptor(), null,
loopParameterStartLabel, bodyEnd,
loopParameterVar);
}
});
@@ -676,6 +677,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
assert multiParameter != null;
// E tmp<e> = tmp<iterator>.next()
loopParameterType = asmElementType;
loopParameterVar = createLoopTempVariable(asmElementType);
}
}
@@ -685,9 +687,8 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
public abstract void checkPreCondition(@NotNull Label loopExit);
public void beforeBody() {
v.mark(bodyStart);
assignToLoopParameter();
v.mark(loopParameterStartLabel);
if (forExpression.getLoopParameter() == null) {
KtDestructuringDeclaration multiParameter = forExpression.getDestructuringParameter();
@@ -843,7 +844,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
makeFakeCall(new TransientReceiver(iteratorCall.getResultingDescriptor().getReturnType()));
StackValue value = invokeFunction(fakeCall, nextCall, StackValue.local(iteratorVarIndex, asmTypeForIterator));
//noinspection ConstantConditions
StackValue.local(loopParameterVar, asmType(nextCall.getResultingDescriptor().getReturnType())).store(value, v);
StackValue.local(loopParameterVar, loopParameterType).store(value, v);
}
@Override
@@ -3666,6 +3667,11 @@ The "returned" value of try expression with no finally is either the last expres
Label clauseStart = new Label();
v.mark(clauseStart);
KtExpression catchBody = clause.getCatchBody();
if (catchBody != null) {
markLineNumber(catchBody, false);
}
VariableDescriptor descriptor = bindingContext.get(VALUE_PARAMETER, clause.getCatchParameter());
assert descriptor != null;
Type descriptorType = asmType(descriptor.getType());
@@ -3673,7 +3679,7 @@ The "returned" value of try expression with no finally is either the last expres
int index = lookupLocalIndex(descriptor);
v.store(index, descriptorType);
gen(clause.getCatchBody(), expectedAsmType);
gen(catchBody, expectedAsmType);
if (!isStatement) {
v.store(savedValue, expectedAsmType);

View File

@@ -198,7 +198,7 @@ public class FunctionCodegen {
parentBodyCodegen.addAdditionalTask(new JvmStaticGenerator(functionDescriptor, origin, state, parentBodyCodegen));
}
if (state.getClassBuilderMode() == ClassBuilderMode.LIGHT_CLASSES || isAbstractMethod(functionDescriptor, contextKind)) {
if (state.getClassBuilderMode() != ClassBuilderMode.FULL || isAbstractMethod(functionDescriptor, contextKind)) {
generateLocalVariableTable(
mv,
jvmSignature,
@@ -294,7 +294,7 @@ public class FunctionCodegen {
private void markEnumOrInnerConstructorParameterAsSynthetic(MethodVisitor mv, int i) {
// IDEA's ClsPsi builder fails to annotate synthetic parameters
if (state.getClassBuilderMode() == ClassBuilderMode.LIGHT_CLASSES) return;
if (state.getClassBuilderMode() != ClassBuilderMode.FULL) return;
// This is needed to avoid RuntimeInvisibleParameterAnnotations error in javac:
// see MethodWriter.visitParameterAnnotation()
@@ -374,6 +374,9 @@ public class FunctionCodegen {
if (!KotlinTypeMapper.isAccessor(functionDescriptor)) {
genNotNullAssertionsForParameters(new InstructionAdapter(mv), parentCodegen.state, functionDescriptor, frameMap);
}
parentCodegen.beforeMethodBody(mv);
methodEnd = new Label();
context.setMethodEndLabel(methodEnd);
strategy.generateBody(mv, frameMap, signature, context, parentCodegen);

View File

@@ -158,7 +158,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
if (!ktClass.hasModifier(KtTokens.OPEN_KEYWORD) && !isAbstract) {
// Light-class mode: Do not make enum classes final since PsiClass corresponding to enum is expected to be inheritable from
isFinal = !(ktClass.isEnum() && state.getClassBuilderMode() == ClassBuilderMode.LIGHT_CLASSES);
isFinal = !(ktClass.isEnum() && state.getClassBuilderMode() != ClassBuilderMode.FULL);
}
isStatic = !ktClass.isInner();
}
@@ -169,7 +169,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
int access = 0;
if (state.getClassBuilderMode() == ClassBuilderMode.LIGHT_CLASSES && !DescriptorUtils.isTopLevelDeclaration(descriptor)) {
if (state.getClassBuilderMode() != ClassBuilderMode.FULL && !DescriptorUtils.isTopLevelDeclaration(descriptor)) {
// ClassBuilderMode.LIGHT_CLASSES means we are generating light classes & looking at a nested or inner class
// Light class generation is implemented so that Cls-classes only read bare code of classes,
// without knowing whether these classes are inner or not (see ClassStubBuilder.EMPTY_STRATEGY)
@@ -265,7 +265,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
private void writeEnclosingMethod() {
// Do not emit enclosing method in "light-classes mode" since currently we generate local light classes as if they're top level
if (state.getClassBuilderMode() == ClassBuilderMode.LIGHT_CLASSES) {
if (state.getClassBuilderMode() != ClassBuilderMode.FULL) {
return;
}

View File

@@ -59,6 +59,7 @@ import java.util.*;
import static org.jetbrains.kotlin.codegen.AsmUtil.calculateInnerClassAccessFlags;
import static org.jetbrains.kotlin.codegen.AsmUtil.isPrimitive;
import static org.jetbrains.kotlin.codegen.ClassBuilderModeUtilKt.shouldGenerateMetadata;
import static org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind.SYNTHESIZED;
import static org.jetbrains.kotlin.resolve.BindingContext.VARIABLE;
import static org.jetbrains.kotlin.resolve.DescriptorUtils.*;
@@ -118,7 +119,7 @@ public abstract class MemberCodegen<T extends KtElement/* TODO: & JetDeclaration
generateSyntheticParts();
if (state.getClassBuilderMode() == ClassBuilderMode.FULL) {
if (shouldGenerateMetadata(state.getClassBuilderMode())) {
generateKotlinMetadataAnnotation();
}
@@ -232,7 +233,7 @@ public abstract class MemberCodegen<T extends KtElement/* TODO: & JetDeclaration
}
private static void badDescriptor(ClassDescriptor descriptor, ClassBuilderMode mode) {
if (mode != ClassBuilderMode.LIGHT_CLASSES) {
if (mode == ClassBuilderMode.FULL) {
throw new IllegalStateException("Generating bad descriptor in ClassBuilderMode = " + mode + ": " + descriptor);
}
}
@@ -336,23 +337,32 @@ public abstract class MemberCodegen<T extends KtElement/* TODO: & JetDeclaration
}
@NotNull
protected ExpressionCodegen createOrGetClInitCodegen() {
DeclarationDescriptor descriptor = context.getContextDescriptor();
protected final ExpressionCodegen createOrGetClInitCodegen() {
if (clInit == null) {
MethodVisitor mv = v.newMethod(JvmDeclarationOriginKt.OtherOrigin(descriptor), ACC_STATIC, "<clinit>", "()V", null, null);
SimpleFunctionDescriptorImpl clInit =
SimpleFunctionDescriptorImpl.create(descriptor, Annotations.Companion.getEMPTY(), Name.special("<clinit>"), SYNTHESIZED,
KotlinSourceElementKt.toSourceElement(element));
clInit.initialize(null, null, Collections.<TypeParameterDescriptor>emptyList(),
Collections.<ValueParameterDescriptor>emptyList(),
DescriptorUtilsKt.getModule(descriptor).getBuiltIns().getUnitType(),
null, Visibilities.PRIVATE);
this.clInit = new ExpressionCodegen(mv, new FrameMap(), Type.VOID_TYPE, context.intoFunction(clInit), state, this);
DeclarationDescriptor contextDescriptor = context.getContextDescriptor();
SimpleFunctionDescriptorImpl clInitDescriptor = createClInitFunctionDescriptor(contextDescriptor);
MethodVisitor mv = createClInitMethodVisitor(contextDescriptor);
clInit = new ExpressionCodegen(mv, new FrameMap(), Type.VOID_TYPE, context.intoFunction(clInitDescriptor), state, this);
}
return clInit;
}
@NotNull
protected MethodVisitor createClInitMethodVisitor(@NotNull DeclarationDescriptor contextDescriptor) {
return v.newMethod(JvmDeclarationOriginKt.OtherOrigin(contextDescriptor), ACC_STATIC, "<clinit>", "()V", null, null);
}
@NotNull
protected SimpleFunctionDescriptorImpl createClInitFunctionDescriptor(@NotNull DeclarationDescriptor descriptor) {
SimpleFunctionDescriptorImpl clInit = SimpleFunctionDescriptorImpl.create(descriptor, Annotations.Companion.getEMPTY(),
Name.special("<clinit>"), SYNTHESIZED, KotlinSourceElementKt.toSourceElement(element));
clInit.initialize(null, null, Collections.<TypeParameterDescriptor>emptyList(),
Collections.<ValueParameterDescriptor>emptyList(),
DescriptorUtilsKt.getModule(descriptor).getBuiltIns().getUnitType(),
null, Visibilities.PRIVATE);
return clInit;
}
protected void generateInitializers(@NotNull Function0<ExpressionCodegen> createCodegen) {
NotNullLazyValue<ExpressionCodegen> codegen = LockBasedStorageManager.NO_LOCKS.createLazyValue(createCodegen);
for (KtDeclaration declaration : ((KtDeclarationContainer) element).getDeclarations()) {
@@ -370,6 +380,9 @@ public abstract class MemberCodegen<T extends KtElement/* TODO: & JetDeclaration
}
}
public void beforeMethodBody(@NotNull MethodVisitor mv) {
}
private void initializeProperty(@NotNull ExpressionCodegen codegen, @NotNull KtProperty property) {
PropertyDescriptor propertyDescriptor = (PropertyDescriptor) bindingContext.get(VARIABLE, property);
assert propertyDescriptor != null;
@@ -382,7 +395,7 @@ public abstract class MemberCodegen<T extends KtElement/* TODO: & JetDeclaration
propValue.store(codegen.gen(initializer), codegen.v);
}
private boolean shouldInitializeProperty(@NotNull KtProperty property) {
protected boolean shouldInitializeProperty(@NotNull KtProperty property) {
if (!property.hasDelegateExpressionOrInitializer()) return false;
PropertyDescriptor propertyDescriptor = (PropertyDescriptor) bindingContext.get(VARIABLE, property);
@@ -398,7 +411,7 @@ public abstract class MemberCodegen<T extends KtElement/* TODO: & JetDeclaration
ConstantValue<?> initializerValue = computeInitializerValue(property, propertyDescriptor, initializer);
// we must write constant values for fields in light classes,
// because Java's completion for annotation arguments uses this information
if (initializerValue == null) return state.getClassBuilderMode() != ClassBuilderMode.LIGHT_CLASSES;
if (initializerValue == null) return state.getClassBuilderMode() == ClassBuilderMode.FULL;
//TODO: OPTIMIZATION: don't initialize static final fields
KotlinType jetType = getPropertyOrDelegateType(property, propertyDescriptor);
@@ -482,7 +495,7 @@ public abstract class MemberCodegen<T extends KtElement/* TODO: & JetDeclaration
v.newField(NO_ORIGIN, ACC_PRIVATE | ACC_STATIC | ACC_FINAL | ACC_SYNTHETIC, JvmAbi.DELEGATED_PROPERTIES_ARRAY_NAME,
"[" + K_PROPERTY_TYPE, null, null);
if (state.getClassBuilderMode() == ClassBuilderMode.LIGHT_CLASSES) return;
if (state.getClassBuilderMode() != ClassBuilderMode.FULL) return;
InstructionAdapter iv = createOrGetClInitCodegen().v;
iv.iconst(delegatedProperties.size());

View File

@@ -26,18 +26,21 @@ import org.jetbrains.kotlin.codegen.state.GenerationState
import org.jetbrains.kotlin.config.IncrementalCompilation
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
import org.jetbrains.kotlin.descriptors.Visibilities
import org.jetbrains.kotlin.diagnostics.DiagnosticUtils
import org.jetbrains.kotlin.fileClasses.JvmFileClassUtil
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader.MultifileClassKind.DELEGATING
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader.MultifileClassKind.INHERITING
import org.jetbrains.kotlin.load.kotlin.incremental.IncrementalPackageFragmentProvider
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.MemberComparator
import org.jetbrains.kotlin.resolve.jvm.JvmClassName
import org.jetbrains.kotlin.resolve.jvm.AsmTypes
import org.jetbrains.kotlin.resolve.jvm.diagnostics.MultifileClass
import org.jetbrains.kotlin.resolve.jvm.diagnostics.MultifileClassPart
import org.jetbrains.kotlin.resolve.jvm.diagnostics.OtherOrigin
@@ -50,11 +53,10 @@ import org.jetbrains.kotlin.serialization.deserialization.descriptors.Deserializ
import org.jetbrains.org.objectweb.asm.MethodVisitor
import org.jetbrains.org.objectweb.asm.Opcodes
import org.jetbrains.org.objectweb.asm.Type
import java.util.*
class MultifileClassCodegen(
private val state: GenerationState,
val files: Collection<KtFile>,
private val files: Collection<KtFile>,
private val facadeFqName: FqName,
private val packagePartRegistry: PackagePartRegistry
) {
@@ -71,55 +73,105 @@ class MultifileClassCodegen(
getDeserializedCallables(compiledPackageFragment)
private fun getDeserializedCallables(compiledPackageFragment: PackageFragmentDescriptor) =
compiledPackageFragment.getMemberScope().getContributedDescriptors(DescriptorKindFilter.CALLABLES, MemberScope.ALL_NAME_FILTER).filterIsInstance<DeserializedCallableMemberDescriptor>()
compiledPackageFragment.getMemberScope()
.getContributedDescriptors(DescriptorKindFilter.CALLABLES, MemberScope.ALL_NAME_FILTER)
.filterIsInstance<DeserializedCallableMemberDescriptor>()
private fun KtFile.getFileClassFqName() =
state.fileClassesProvider.getFileClassInfo(this).fileClassFqName
private val shouldGeneratePartHierarchy =
state.inheritMultifileParts // TODO support incremental compilation
private val partInternalNamesSorted = run {
val partInternalNamesSet = hashSetOf<String>()
for (file in files) {
if (file.hasDeclarationsForPartClass()) {
partInternalNamesSet.add(file.getFileClassFqName().toInternalName())
}
}
compiledPackageFragment?.let {
partInternalNamesSet.addAll(it.partsNames)
}
partInternalNamesSet.sorted()
}
private val superClassForInheritedPart = run {
val result = hashMapOf<String, String>()
for (i in 1 ..partInternalNamesSorted.size - 1) {
result[partInternalNamesSorted[i]] = partInternalNamesSorted[i - 1]
}
result
}
private val delegateGenerationTasks = hashMapOf<CallableMemberDescriptor, () -> Unit>()
private fun getSuperClassForPart(partInternalName: String) =
if (shouldGeneratePartHierarchy)
superClassForInheritedPart[partInternalName] ?: J_L_OBJECT
else
J_L_OBJECT
private val classBuilder = ClassBuilderOnDemand {
val originFile = files.firstOrNull()
val actualPackageFragment = packageFragment ?:
compiledPackageFragment ?:
throw AssertionError("No package fragment for multifile facade $facadeFqName; files: $files")
val declarationOrigin = MultifileClass(originFile, actualPackageFragment, facadeFqName)
val classBuilder = state.factory.newVisitor(declarationOrigin, facadeClassType, files)
val filesWithCallables = files.filter { it.declarations.any { it is KtNamedFunction || it is KtProperty } }
val actualPackageFragment = packageFragment
?: compiledPackageFragment
?: throw AssertionError("No package fragment for multifile facade $facadeFqName; files: $files")
val singleSourceFile = if (previouslyCompiledCallables.isNotEmpty()) null else filesWithCallables.singleOrNull()
val declarationOrigin = MultifileClass(originFile, actualPackageFragment)
classBuilder.defineClass(singleSourceFile, Opcodes.V1_6,
FACADE_CLASS_ATTRIBUTES,
facadeClassType.internalName,
null, "java/lang/Object", ArrayUtil.EMPTY_STRING_ARRAY)
if (singleSourceFile != null) {
classBuilder.visitSource(singleSourceFile.name, null)
val singleSourceFile =
if (previouslyCompiledCallables.isEmpty())
files.singleOrNull { it.hasDeclarationsForPartClass() }
else
null
val superClassForFacade =
if (shouldGeneratePartHierarchy)
partInternalNamesSorted.last()
else
J_L_OBJECT
state.factory.newVisitor(declarationOrigin, facadeClassType, files).apply {
defineClass(singleSourceFile, Opcodes.V1_6, FACADE_CLASS_ATTRIBUTES,
facadeClassType.internalName, null, superClassForFacade, ArrayUtil.EMPTY_STRING_ARRAY)
if (singleSourceFile != null) {
visitSource(singleSourceFile.name, null)
}
if (shouldGeneratePartHierarchy) {
newMethod(OtherOrigin(actualPackageFragment), Opcodes.ACC_PRIVATE, "<init>", "()V", null, null).apply {
visitCode()
visitVarInsn(Opcodes.ALOAD, 0)
visitMethodInsn(Opcodes.INVOKESPECIAL, superClassForFacade, "<init>", "()V", false)
visitInsn(Opcodes.RETURN)
visitMaxs(1, 1)
visitEnd()
}
}
}
classBuilder
}
fun generate(errorHandler: CompilationErrorHandler) {
val generateCallableMemberTasks = HashMap<CallableMemberDescriptor, () -> Unit>()
val partFqNames = arrayListOf<FqName>()
assert(delegateGenerationTasks.isEmpty()) { "generate() is called twice for facade class $facadeFqName" }
generateCodeForSourceFiles(errorHandler, generateCallableMemberTasks, partFqNames)
generateCodeForSourceFiles(errorHandler)
generateDelegatesToPreviouslyCompiledParts(generateCallableMemberTasks, partFqNames)
generateDelegatesToPreviouslyCompiledParts()
if (!partFqNames.isEmpty()) {
generateMultifileFacadeClass(generateCallableMemberTasks, partFqNames)
if (!partInternalNamesSorted.isEmpty()) {
generateMultifileFacadeClass()
}
done()
}
private fun generateCodeForSourceFiles(
errorHandler: CompilationErrorHandler,
generateCallableMemberTasks: MutableMap<CallableMemberDescriptor, () -> Unit>,
partFqNames: MutableList<FqName>
) {
private fun generateCodeForSourceFiles(errorHandler: CompilationErrorHandler) {
for (file in files) {
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()
try {
generatePart(file, generateCallableMemberTasks, partFqNames)
generatePart(file)
state.afterIndependentPart()
}
catch (e: ProcessCanceledException) {
@@ -137,87 +189,103 @@ class MultifileClassCodegen(
}
}
private fun generateMultifileFacadeClass(
tasks: Map<CallableMemberDescriptor, () -> Unit>,
partFqNames: List<FqName>
) {
for (member in tasks.keys.sortedWith(MemberComparator.INSTANCE)) {
tasks[member]!!()
private fun generateMultifileFacadeClass() {
for (member in delegateGenerationTasks.keys.sortedWith(MemberComparator.INSTANCE)) {
delegateGenerationTasks[member]!!()
}
writeKotlinMultifileFacadeAnnotationIfNeeded(partFqNames)
writeKotlinMultifileFacadeAnnotationIfNeeded()
}
fun generateClassOrObject(classOrObject: KtClassOrObject, packagePartContext: FieldOwnerContext<PackageFragmentDescriptor>) {
MemberCodegen.genClassOrObject(packagePartContext, classOrObject, state, null)
}
private fun generatePart(
file: KtFile,
generateCallableMemberTasks: MutableMap<CallableMemberDescriptor, () -> Unit>,
partFqNames: MutableList<FqName>
) {
val packageFragment = this.packageFragment ?:
throw AssertionError("File part $file of $facadeFqName: no package fragment")
private fun generatePart(file: KtFile) {
val packageFragment = this.packageFragment
?: throw AssertionError("File part $file of $facadeFqName: no package fragment")
var generatePart = false
val partClassInfo = state.fileClassesProvider.getFileClassInfo(file)
val partType = AsmUtil.asmTypeByFqNameWithoutInnerClasses(partClassInfo.fileClassFqName)
val partContext = state.rootContext.intoMultifileClassPart(packageFragment, facadeClassType, partType, file)
val partClassFqName = file.getFileClassFqName()
val partInitializerClassFqName = FqName(partClassFqName.asString() + "__Init")
val partType = partClassFqName.toAsmType()
val partInitializerType = partInitializerClassFqName.toAsmType()
val partContext = state.rootContext.intoMultifileClassPart(packageFragment, facadeClassType, partType, partInitializerType, file)
generateNonPartClassDeclarations(file, partContext)
if (!state.generateDeclaredClassFilter.shouldGeneratePackagePart(file) || !file.hasDeclarationsForPartClass()) return
val partInternalName = partType.internalName
packagePartRegistry.addPart(partInternalName.substring(partInternalName.lastIndexOf('/') + 1))
val builder = state.factory.newVisitor(MultifileClassPart(file, packageFragment), partType, file)
MultifileClassPartCodegen(
builder, file, packageFragment,
getSuperClassForPart(partInternalName),
shouldGeneratePartHierarchy,
partContext, state
).generate()
addDelegateGenerationTasksForDeclarationsInFile(file, packageFragment, partType)
}
private fun generateNonPartClassDeclarations(file: KtFile, partContext: FieldOwnerContext<PackageFragmentDescriptor>) {
for (declaration in file.declarations) {
when (declaration) {
is KtProperty, is KtNamedFunction -> {
generatePart = true
}
is KtClassOrObject -> if (state.generateDeclaredClassFilter.shouldGenerateClass(declaration)) {
generateClassOrObject(declaration, partContext)
}
is KtScript -> if (state.generateDeclaredClassFilter.shouldGenerateScript(declaration)) {
ScriptCodegen.createScriptCodegen(declaration, state, partContext).generate()
}
}
}
if (!generatePart || !state.generateDeclaredClassFilter.shouldGeneratePackagePart(file)) return
partFqNames.add(partClassInfo.fileClassFqName)
val name = partType.internalName
packagePartRegistry.addPart(name.substring(name.lastIndexOf('/') + 1))
val builder = state.factory.newVisitor(MultifileClassPart(file, packageFragment, facadeFqName), partType, file)
MultifileClassPartCodegen(builder, file, partType, facadeClassType, partContext, state).generate()
val facadeContext = state.rootContext.intoMultifileClass(packageFragment, facadeClassType, partType)
val memberCodegen = createCodegenForPartOfMultifileFacade(facadeContext)
for (declaration in file.declarations) {
if (declaration is KtNamedFunction || declaration is KtProperty) {
val descriptor = state.bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, declaration)
assert(descriptor is CallableMemberDescriptor) { "Expected callable member, was " + descriptor + " for " + declaration.text }
if (!Visibilities.isPrivate((descriptor as CallableMemberDescriptor).visibility)
&& AsmUtil.getVisibilityAccessFlag(descriptor) != Opcodes.ACC_PRIVATE) {
generateCallableMemberTasks.put(descriptor, { memberCodegen.genFunctionOrProperty(declaration) })
}
is KtClassOrObject ->
if (state.generateDeclaredClassFilter.shouldGenerateClass(declaration)) {
generateClassOrObject(declaration, partContext)
}
is KtScript ->
if (state.generateDeclaredClassFilter.shouldGenerateScript(declaration)) {
ScriptCodegen.createScriptCodegen(declaration, state, partContext).generate()
}
}
}
}
private fun generateDelegatesToPreviouslyCompiledParts(
generateCallableMemberTasks: MutableMap<CallableMemberDescriptor, () -> Unit>,
partFqNames: MutableList<FqName>
) {
if (compiledPackageFragment == null) return
private fun addDelegateGenerationTasksForDeclarationsInFile(file: KtFile, packageFragment: PackageFragmentDescriptor, partType: Type) {
val facadeContext = state.rootContext.intoMultifileClass(packageFragment, facadeClassType, partType)
val memberCodegen = createCodegenForDelegatesInMultifileFacade(facadeContext)
for (declaration in file.declarations) {
if (declaration is KtNamedFunction || declaration is KtProperty) {
val descriptor = state.bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, declaration)
if (descriptor !is CallableMemberDescriptor) {
throw AssertionError("Expected callable member, was " + descriptor + " for " + declaration.text)
}
addDelegateGenerationTaskIfNeeded(descriptor, { memberCodegen.genFunctionOrProperty(declaration) })
}
}
}
partFqNames.addAll(compiledPackageFragment.partsNames.map { JvmClassName.byInternalName(it).fqNameForClassNameWithoutDollars })
private fun shouldGenerateInFacade(descriptor: CallableMemberDescriptor): Boolean {
if (Visibilities.isPrivate(descriptor.visibility)) return false
if (AsmUtil.getVisibilityAccessFlag(descriptor) == Opcodes.ACC_PRIVATE) return false
if (state.classBuilderMode != ClassBuilderMode.FULL) return true
if (shouldGeneratePartHierarchy) {
if (descriptor !is PropertyDescriptor || !descriptor.isConst) return false
}
return true
}
private fun addDelegateGenerationTaskIfNeeded(callable: CallableMemberDescriptor, task: () -> Unit) {
if (shouldGenerateInFacade(callable)) {
delegateGenerationTasks[callable] = task
}
}
private fun generateDelegatesToPreviouslyCompiledParts() {
if (compiledPackageFragment == null) return
for (callable in previouslyCompiledCallables) {
val partFqName = JvmFileClassUtil.getPartFqNameForDeserializedCallable(callable)
val partType = AsmUtil.asmTypeByFqNameWithoutInnerClasses(partFqName)
generateCallableMemberTasks[callable] = { generateDelegateToCompiledMember(callable, compiledPackageFragment, partType) }
addDelegateGenerationTaskIfNeeded(callable, { generateDelegateToCompiledMember(callable, compiledPackageFragment, partType) })
}
}
@@ -228,7 +296,7 @@ class MultifileClassCodegen(
) {
val context = state.rootContext.intoMultifileClass(compiledPackageFragment, facadeClassType, partType)
val memberCodegen = createCodegenForPartOfMultifileFacade(context)
val memberCodegen = createCodegenForDelegatesInMultifileFacade(context)
when (member) {
is DeserializedSimpleFunctionDescriptor -> {
@@ -254,20 +322,22 @@ class MultifileClassCodegen(
}
}
private fun writeKotlinMultifileFacadeAnnotationIfNeeded(partFqNames: List<FqName>) {
if (state.classBuilderMode != ClassBuilderMode.FULL) return
private fun writeKotlinMultifileFacadeAnnotationIfNeeded() {
if (!state.classBuilderMode.shouldGenerateMetadata()) return
if (files.any { it.isScript }) return
writeKotlinMetadata(classBuilder, KotlinClassHeader.Kind.MULTIFILE_CLASS) { av ->
val arv = av.visitArray(JvmAnnotationNames.METADATA_DATA_FIELD_NAME)
for (internalName in partFqNames.map(AsmUtil::internalNameByFqNameWithoutInnerClasses).sorted()) {
for (internalName in partInternalNamesSorted) {
arv.visit(null, internalName)
}
arv.visitEnd()
val multifileClassKind = if (shouldGeneratePartHierarchy) INHERITING else DELEGATING
av.visit(JvmAnnotationNames.METADATA_MULTIFILE_CLASS_KIND_FIELD_NAME, multifileClassKind.id)
}
}
private fun createCodegenForPartOfMultifileFacade(facadeContext: FieldOwnerContext<*>): MemberCodegen<KtFile> =
private fun createCodegenForDelegatesInMultifileFacade(facadeContext: FieldOwnerContext<*>): MemberCodegen<KtFile> =
object : MemberCodegen<KtFile>(state, null, facadeContext, null, classBuilder) {
override fun generateDeclaration() = throw UnsupportedOperationException()
override fun generateBody() = throw UnsupportedOperationException()
@@ -282,15 +352,16 @@ class MultifileClassCodegen(
}
companion object {
private val J_L_OBJECT = AsmTypes.OBJECT_TYPE.internalName
private val FACADE_CLASS_ATTRIBUTES = Opcodes.ACC_PUBLIC or Opcodes.ACC_FINAL or Opcodes.ACC_SUPER
private fun getOnlyPackageFragment(packageFqName: FqName, files: Collection<KtFile>, bindingContext: BindingContext): PackageFragmentDescriptor? {
val fragments = SmartList<PackageFragmentDescriptor>()
for (file in files) {
val fragment = bindingContext.get(BindingContext.FILE_TO_PACKAGE_FRAGMENT, file)
assert(fragment != null) { "package fragment is null for " + file + "\n" + file.text }
?: throw AssertionError("package fragment is null for " + file + "\n" + file.text)
assert(packageFqName == fragment!!.fqName) { "expected package fq name: " + packageFqName + ", actual: " + fragment.fqName }
assert(packageFqName == fragment.fqName) { "expected package fq name: " + packageFqName + ", actual: " + fragment.fqName }
if (!fragments.contains(fragment)) {
fragments.add(fragment)
@@ -302,6 +373,15 @@ class MultifileClassCodegen(
return fragments.firstOrNull()
}
private fun KtFile.hasDeclarationsForPartClass() =
declarations.any { it is KtProperty || it is KtFunction }
private fun FqName.toInternalName() =
AsmUtil.internalNameByFqNameWithoutInnerClasses(this)
private fun FqName.toAsmType() =
AsmUtil.asmTypeByFqNameWithoutInnerClasses(this)
private fun getCompiledPackageFragment(facadeFqName: FqName, state: GenerationState):
IncrementalPackageFragmentProvider.IncrementalPackageFragment.IncrementalMultifileClassPackageFragment? {
if (!IncrementalCompilation.isEnabled()) return null

View File

@@ -17,44 +17,112 @@
package org.jetbrains.kotlin.codegen
import com.intellij.util.ArrayUtil
import org.jetbrains.kotlin.codegen.context.FieldOwnerContext
import org.jetbrains.kotlin.codegen.context.MultifileClassPartContext
import org.jetbrains.kotlin.codegen.serialization.JvmSerializerExtension
import org.jetbrains.kotlin.codegen.state.GenerationState
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader.MultifileClassKind.DELEGATING
import org.jetbrains.kotlin.load.kotlin.header.KotlinClassHeader.MultifileClassKind.INHERITING
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.psi.KtNamedFunction
import org.jetbrains.kotlin.psi.KtProperty
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.jvm.diagnostics.MultifileClass
import org.jetbrains.kotlin.resolve.jvm.diagnostics.OtherOrigin
import org.jetbrains.kotlin.serialization.DescriptorSerializer
import org.jetbrains.org.objectweb.asm.MethodVisitor
import org.jetbrains.org.objectweb.asm.Opcodes
import org.jetbrains.org.objectweb.asm.Type
import org.jetbrains.org.objectweb.asm.tree.AbstractInsnNode
import org.jetbrains.org.objectweb.asm.tree.MethodInsnNode
import java.util.*
class MultifileClassPartCodegen(
v: ClassBuilder,
file: KtFile,
private val filePartType: Type,
private val multifileClassType: Type,
partContext: FieldOwnerContext<*>,
private val packageFragment: PackageFragmentDescriptor,
private val superClassInternalName: String,
private val shouldGeneratePartHierarchy: Boolean,
private val partContext: MultifileClassPartContext,
state: GenerationState
) : MemberCodegen<KtFile>(state, null, partContext, file, v) {
private val partType = partContext.filePartType
private val facadeClassType = partContext.multifileClassType
private val staticInitClassType = Type.getObjectType(partType.internalName + STATIC_INIT_CLASS_SUFFIX)
private val partClassAttributes =
if (shouldGeneratePartHierarchy)
OPEN_PART_CLASS_ATTRIBUTES
else
FINAL_PART_CLASS_ATTRIBUTES
private fun ClassBuilder.newSpecialMethod(originDescriptor: DeclarationDescriptor, name: String) =
newMethod(OtherOrigin(originDescriptor), Opcodes.ACC_STATIC, name, "()V", null, null)
private val staticInitClassBuilder = ClassBuilderOnDemand {
state.factory.newVisitor(MultifileClass(file, packageFragment), staticInitClassType, file).apply {
defineClass(file, Opcodes.V1_6, STATE_INITIALIZER_CLASS_ATTRIBUTES,
staticInitClassType.internalName, null, "java/lang/Object", ArrayUtil.EMPTY_STRING_ARRAY)
visitSource(file.name, null)
}
}
private val requiresDeferredStaticInitialization =
shouldGeneratePartHierarchy && file.declarations.any {
it is KtProperty && shouldInitializeProperty(it)
}
override fun generate() {
if (state.classBuilderMode == ClassBuilderMode.LIGHT_CLASSES) return
if (state.classBuilderMode != ClassBuilderMode.FULL) return
super.generate()
if (shouldGeneratePartHierarchy) {
v.newMethod(OtherOrigin(packageFragment), Opcodes.ACC_PUBLIC, "<init>", "()V", null, null).apply {
visitCode()
visitVarInsn(Opcodes.ALOAD, 0)
visitMethodInsn(Opcodes.INVOKESPECIAL, superClassInternalName, "<init>", "()V", false)
visitInsn(Opcodes.RETURN)
visitMaxs(1, 1)
visitEnd()
}
}
if (requiresDeferredStaticInitialization) {
staticInitClassBuilder.apply {
newField(OtherOrigin(packageFragment), Opcodes.ACC_STATIC or Opcodes.ACC_PRIVATE or Opcodes.ACC_VOLATILE,
CLINIT_SYNC_NAME, "I", null, null)
newSpecialMethod(packageFragment, CLINIT_TRIGGER_NAME).apply {
visitCode()
visitFieldInsn(Opcodes.GETSTATIC, staticInitClassType.internalName, CLINIT_SYNC_NAME, "I")
visitInsn(Opcodes.RETURN)
visitMaxs(1, 0)
visitEnd()
}
newSpecialMethod(packageFragment, "<clinit>").apply {
visitCode()
visitMethodInsn(Opcodes.INVOKESTATIC, partType.internalName, DEFERRED_PART_CLINIT_NAME, "()V", false)
visitInsn(Opcodes.ICONST_0)
visitFieldInsn(Opcodes.PUTSTATIC, staticInitClassType.internalName, CLINIT_SYNC_NAME, "I")
visitInsn(Opcodes.RETURN)
visitMaxs(1, 0)
visitEnd()
}
}
}
}
override fun generateDeclaration() {
v.defineClass(element, Opcodes.V1_6,
Opcodes.ACC_FINAL or Opcodes.ACC_SYNTHETIC or Opcodes.ACC_SUPER,
filePartType.internalName,
null,
"java/lang/Object",
ArrayUtil.EMPTY_STRING_ARRAY)
v.defineClass(element, Opcodes.V1_6, partClassAttributes, partType.internalName, null, superClassInternalName, ArrayUtil.EMPTY_STRING_ARRAY)
v.visitSource(element.name, null)
generatePropertyMetadataArrayFieldIfNeeded(filePartType)
generatePropertyMetadataArrayFieldIfNeeded(partType)
}
override fun generateBody() {
@@ -69,6 +137,20 @@ class MultifileClassPartCodegen(
}
}
override fun createClInitMethodVisitor(contextDescriptor: DeclarationDescriptor): MethodVisitor =
if (requiresDeferredStaticInitialization)
v.newSpecialMethod(contextDescriptor, DEFERRED_PART_CLINIT_NAME)
else
super.createClInitMethodVisitor(contextDescriptor)
override fun done() {
super.done()
if (staticInitClassBuilder.isComputed) {
staticInitClassBuilder.done()
}
}
override fun generateKotlinMetadataAnnotation() {
val members = ArrayList<DeclarationDescriptor>()
for (declaration in element.declarations) {
@@ -89,11 +171,37 @@ class MultifileClassPartCodegen(
writeKotlinMetadata(v, KotlinClassHeader.Kind.MULTIFILE_CLASS_PART) { av ->
AsmUtil.writeAnnotationData(av, serializer, packageProto)
av.visit(JvmAnnotationNames.METADATA_MULTIFILE_CLASS_NAME_FIELD_NAME, multifileClassType.internalName)
av.visit(JvmAnnotationNames.METADATA_MULTIFILE_CLASS_NAME_FIELD_NAME, facadeClassType.internalName)
val multifileClassKind = if (shouldGeneratePartHierarchy) INHERITING else DELEGATING
av.visit(JvmAnnotationNames.METADATA_MULTIFILE_CLASS_KIND_FIELD_NAME, multifileClassKind.id)
}
}
override fun generateSyntheticParts() {
generateSyntheticAccessors()
}
override fun beforeMethodBody(mv: MethodVisitor) {
if (requiresDeferredStaticInitialization) {
mv.visitMethodInsn(Opcodes.INVOKESTATIC, staticInitClassType.internalName, CLINIT_TRIGGER_NAME, "()V", false)
}
}
companion object {
private val OPEN_PART_CLASS_ATTRIBUTES = Opcodes.ACC_SUPER
private val FINAL_PART_CLASS_ATTRIBUTES = Opcodes.ACC_SYNTHETIC or Opcodes.ACC_SUPER or Opcodes.ACC_FINAL
private val STATE_INITIALIZER_CLASS_ATTRIBUTES = Opcodes.ACC_SYNTHETIC or Opcodes.ACC_SUPER or Opcodes.ACC_FINAL
private val STATIC_INIT_CLASS_SUFFIX = "__Clinit"
private val CLINIT_TRIGGER_NAME = "\$\$clinitTrigger"
private val CLINIT_SYNC_NAME = "\$\$clinitSync"
private val DEFERRED_PART_CLINIT_NAME = "\$\$clinit"
@JvmStatic fun isStaticInitTrigger(insn: AbstractInsnNode) =
insn.opcode == Opcodes.INVOKESTATIC
&& insn is MethodInsnNode
&& insn.owner.endsWith(STATIC_INIT_CLASS_SUFFIX)
&& insn.name == CLINIT_TRIGGER_NAME
&& insn.desc == "()V"
}
}

View File

@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotated;
import org.jetbrains.kotlin.descriptors.annotations.AnnotationSplitter;
import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget;
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
import org.jetbrains.kotlin.fileClasses.JvmFileClassUtilKt;
import org.jetbrains.kotlin.load.java.JvmAbi;
import org.jetbrains.kotlin.psi.*;
import org.jetbrains.kotlin.psi.psiUtil.PsiUtilsKt;
@@ -141,9 +142,10 @@ public class PropertyCodegen {
Annotations propertyAnnotations = annotationSplitter.getAnnotationsForTarget(AnnotationUseSiteTarget.PROPERTY);
// Fields and '$annotations' methods for const properties are generated in the multi-file facade
boolean isBackingFieldOwner =
descriptor.isConst() ? !(context instanceof MultifileClassPartContext) : CodegenContextUtil.isImplClassOwner(context);
// Fields and '$annotations' methods for non-private const properties are generated in the multi-file facade
boolean isBackingFieldOwner = descriptor.isConst() && !Visibilities.isPrivate(descriptor.getVisibility())
? !(context instanceof MultifileClassPartContext)
: CodegenContextUtil.isImplClassOwner(context);
if (isBackingFieldOwner) {
Annotations fieldAnnotations = annotationSplitter.getAnnotationsForTarget(AnnotationUseSiteTarget.FIELD);
@@ -184,6 +186,9 @@ public class PropertyCodegen {
// Companion object properties always should have accessors, because their backing fields are moved/copied to the outer class
if (isCompanionObject(descriptor.getContainingDeclaration())) return true;
// Non-const properties from multifile classes have accessors regardless of visibility
if (!descriptor.isConst() && JvmFileClassUtilKt.isInsideJvmMultifileClassFile(declaration)) return true;
// Private class properties have accessors only in cases when those accessors are non-trivial
if (Visibilities.isPrivate(descriptor.getVisibility())) {
return !isDefaultAccessor;
@@ -343,7 +348,7 @@ public class PropertyCodegen {
FieldVisitor fv = builder.newField(
JvmDeclarationOriginKt.OtherOrigin(element, propertyDescriptor), modifiers, name, type.getDescriptor(),
typeMapper.mapFieldSignature(kotlinType, propertyDescriptor), defaultValue
isDelegate ? null : typeMapper.mapFieldSignature(kotlinType, propertyDescriptor), defaultValue
);
Annotated fieldAnnotated = new AnnotatedWithFakeAnnotations(propertyDescriptor, annotations);

View File

@@ -0,0 +1,20 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.codegen
fun ClassBuilderMode.shouldGenerateMetadata() =
this == ClassBuilderMode.FULL || this == ClassBuilderMode.KAPT

View File

@@ -250,13 +250,14 @@ public abstract class CodegenContext<T extends DeclarationDescriptor> {
}
@NotNull
public FieldOwnerContext<PackageFragmentDescriptor> intoMultifileClassPart(
public MultifileClassPartContext intoMultifileClassPart(
@NotNull PackageFragmentDescriptor descriptor,
@NotNull Type multifileClassType,
@NotNull Type filePartType,
@NotNull Type filePartInitializerType,
@NotNull KtFile sourceFile
) {
return new MultifileClassPartContext(descriptor, this, multifileClassType, filePartType, sourceFile);
return new MultifileClassPartContext(descriptor, this, multifileClassType, filePartType, filePartInitializerType, sourceFile);
}
@NotNull

View File

@@ -24,16 +24,19 @@ import org.jetbrains.org.objectweb.asm.Type;
public class MultifileClassPartContext extends MultifileClassContextBase implements DelegatingToPartContext, FacadePartWithSourceFile {
private final KtFile sourceFile;
private final Type partInitializerType;
public MultifileClassPartContext(
PackageFragmentDescriptor descriptor,
CodegenContext parent,
Type multifileClassType,
Type filePartType,
Type partInitializerType,
@NotNull KtFile sourceFile
) {
super(descriptor, parent, multifileClassType, filePartType);
this.sourceFile = sourceFile;
this.partInitializerType = partInitializerType;
}
@Nullable
@@ -42,6 +45,11 @@ public class MultifileClassPartContext extends MultifileClassContextBase impleme
return getFilePartType();
}
@NotNull
public Type getPartInitializerType() {
return partInitializerType;
}
@NotNull
@Override
public KtFile getSourceFile() {

View File

@@ -285,6 +285,8 @@ public class AnonymousObjectTransformer extends ObjectTransformer<AnonymousObjec
"<init>", constructorDescriptor,
null, ArrayUtil.EMPTY_STRING_ARRAY);
final Label newBodyStartLabel = new Label();
constructorVisitor.visitLabel(newBodyStartLabel);
//initialize captured fields
List<NewJavaField> newFieldsWithSkipped = TransformationUtilsKt.getNewFieldsToGenerate(allCapturedBuilder.listCaptured());
List<FieldInfo> fieldInfoWithSkipped = TransformationUtilsKt.transformToFieldInfo(
@@ -318,7 +320,20 @@ public class AnonymousObjectTransformer extends ObjectTransformer<AnonymousObjec
}
}
inlineMethodAndUpdateGlobalResult(parentRemapper, capturedFieldInitializer, constructor, constructorInlineBuilder, true);
MethodNode intermediateMethodNode = new MethodNode(AsmUtil.NO_FLAG_PACKAGE_PRIVATE, "<init>", constructorDescriptor, null, ArrayUtil.EMPTY_STRING_ARRAY);
inlineMethodAndUpdateGlobalResult(parentRemapper, intermediateMethodNode, constructor, constructorInlineBuilder, true);
AbstractInsnNode first = intermediateMethodNode.instructions.getFirst();
final Label oldStartLabel = first instanceof LabelNode ? ((LabelNode) first).getLabel() : null;
intermediateMethodNode.accept(new MethodBodyVisitor(capturedFieldInitializer) {
@Override
public void visitLocalVariable(String name, String desc, String signature, Label start, Label end, int index) {
if (oldStartLabel == start) {
start = newBodyStartLabel;//patch for jack&jill
}
super.visitLocalVariable(name, desc, signature, start, end, index);
}
});
constructorVisitor.visitEnd();
AsmUtil.genClosureFields(TransformationUtilsKt.toNameTypePair(TransformationUtilsKt.filterSkipped(newFieldsWithSkipped)), classBuilder);
}

View File

@@ -66,9 +66,7 @@ import java.util.*;
import static org.jetbrains.kotlin.codegen.AsmUtil.getMethodAsmFlags;
import static org.jetbrains.kotlin.codegen.AsmUtil.isPrimitive;
import static org.jetbrains.kotlin.codegen.inline.InlineCodegenUtil.API;
import static org.jetbrains.kotlin.codegen.inline.InlineCodegenUtil.addInlineMarker;
import static org.jetbrains.kotlin.codegen.inline.InlineCodegenUtil.getConstant;
import static org.jetbrains.kotlin.codegen.inline.InlineCodegenUtil.*;
import static org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils.isFunctionLiteral;
public class InlineCodegen extends CallGenerator {
@@ -395,6 +393,7 @@ public class InlineCodegen extends CallGenerator {
List<MethodInliner.PointForExternalFinallyBlocks> infos = MethodInliner.processReturns(adapter, labelOwner, true, null);
generateAndInsertFinallyBlocks(adapter, infos, ((StackValue.Local)remapper.remap(parameters.getArgsSizeOnStack() + 1).value).index);
removeStaticInitializationTrigger(adapter);
removeFinallyMarkers(adapter);
adapter.accept(new MethodBodyVisitor(codegen.v));
@@ -404,6 +403,21 @@ public class InlineCodegen extends CallGenerator {
return result;
}
private static void removeStaticInitializationTrigger(MethodNode methodNode) {
InsnList insnList = methodNode.instructions;
AbstractInsnNode insn = insnList.getFirst();
while (insn != null) {
if (MultifileClassPartCodegen.isStaticInitTrigger(insn)) {
AbstractInsnNode clinitTriggerCall = insn;
insn = insn.getNext();
insnList.remove(clinitTriggerCall);
}
else {
insn = insn.getNext();
}
}
}
private InlineCallSiteInfo getInlineCallSiteInfo() {
MethodContext context = codegen.getContext();
MemberCodegen<?> parentCodegen = codegen.getParentCodegen();

View File

@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
import org.jetbrains.kotlin.resolve.inline.InlineUtil
import org.jetbrains.org.objectweb.asm.Label
import org.jetbrains.org.objectweb.asm.Type
import org.jetbrains.org.objectweb.asm.tree.MethodNode
@@ -51,11 +52,16 @@ class InlineCodegenForDefaultBody(
private val jvmSignature = state.typeMapper.mapSignatureWithGeneric(functionDescriptor, context.contextKind)
private val methodStartLabel = Label()
init {
assert(InlineUtil.isInline(function)) {
"InlineCodegen can inline only inline functions and array constructors: " + function
}
InlineCodegen.reportIncrementalInfo(functionDescriptor, codegen.context.functionDescriptor.original, jvmSignature, state)
//InlineCodegenForDefaultBody created just after visitCode call
codegen.v.visitLabel(methodStartLabel)
}
override fun genCallInner(callableMethod: Callable, resolvedCall: ResolvedCall<*>?, callDefault: Boolean, codegen: ExpressionCodegen) {
@@ -70,7 +76,13 @@ class InlineCodegenForDefaultBody(
node.signature,
node.exceptions.toTypedArray())
node.accept(InlineAdapter(transformedMethod, 0, childSourceMapper))
val argsSize = (Type.getArgumentsAndReturnSizes(jvmSignature.asmMethod.descriptor) ushr 2) - if (callableMethod.isStaticCall()) 1 else 0
node.accept(object : InlineAdapter(transformedMethod, 0, childSourceMapper) {
override fun visitLocalVariable(name: String, desc: String, signature: String?, start: Label, end: Label, index: Int) {
val startLabel = if (index < argsSize) methodStartLabel else start
super.visitLocalVariable(name, desc, signature, startLabel, end, index)
}
})
transformedMethod.accept(MethodBodyVisitor(codegen.v))
}

View File

@@ -292,8 +292,8 @@ public class MethodInliner {
super.visitMethodInsn(opcode, changeOwnerForExternalPackage(owner, opcode), name, desc, itf);
}
}
else if (ReifiedTypeInliner.isNeedClassReificationMarker(new MethodInsnNode(opcode, owner, name, desc, false))) {
// we will put it if needed in anew processing
else if (!inliningContext.isInliningLambda && ReifiedTypeInliner.isNeedClassReificationMarker(new MethodInsnNode(opcode, owner, name, desc, false))) {
//we shouldn't process here content of inlining lambda it should be reified at external level
}
else {
super.visitMethodInsn(opcode, changeOwnerForExternalPackage(owner, opcode), name, desc, itf);

View File

@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.codegen.serialization;
import com.intellij.openapi.util.Pair;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.codegen.ClassBuilderMode;
import org.jetbrains.kotlin.codegen.state.GenerationState;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor;
@@ -43,6 +44,7 @@ public class JvmSerializerExtension extends SerializerExtension {
private final AnnotationSerializer annotationSerializer;
private final boolean useTypeTable;
private final String moduleName;
private final ClassBuilderMode classBuilderMode;
public JvmSerializerExtension(@NotNull JvmSerializationBindings bindings, @NotNull GenerationState state) {
this.bindings = bindings;
@@ -50,6 +52,7 @@ public class JvmSerializerExtension extends SerializerExtension {
this.annotationSerializer = new AnnotationSerializer(stringTable);
this.useTypeTable = state.getUseTypeTableInSerializer();
this.moduleName = state.getModuleName();
this.classBuilderMode = state.getClassBuilderMode();
}
@NotNull
@@ -144,6 +147,16 @@ public class JvmSerializerExtension extends SerializerExtension {
proto.setExtension(JvmProtoBuf.propertySignature, signature);
}
@Override
public void serializeErrorType(@NotNull KotlinType type, @NotNull ProtoBuf.Type.Builder builder) {
if (classBuilderMode == ClassBuilderMode.KAPT) {
builder.setClassName(stringTable.getStringIndex("error.NonExistingClass"));
return;
}
super.serializeErrorType(type, builder);
}
private class SignatureSerializer {
@Nullable
public JvmProtoBuf.JvmMethodSignature methodSignature(@Nullable FunctionDescriptor descriptor, @NotNull Method method) {

View File

@@ -183,7 +183,7 @@ class BuilderFactoryForDuplicateSignatureDiagnostics(
descriptor.getParentJavaStaticClassScope()?.run {
getContributedDescriptors(DescriptorKindFilter.FUNCTIONS)
.filter {
it is FunctionDescriptor && Visibilities.isVisibleWithIrrelevantReceiver(it, descriptor)
it is FunctionDescriptor && Visibilities.isVisibleIgnoringReceiver(it, descriptor)
}
.forEach(::processMember)
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
* Copyright 2010-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -57,6 +57,7 @@ class GenerationState @JvmOverloads constructor(
disableInline: Boolean = false,
disableOptimization: Boolean = false,
val useTypeTableInSerializer: Boolean = false,
val inheritMultifileParts: Boolean = false,
val packagesWithObsoleteParts: Collection<FqName> = emptySet(),
val obsoleteMultifileClasses: Collection<FqName> = emptySet(),
// for PackageCodegen in incremental compilation mode

View File

@@ -34,6 +34,7 @@ import org.jetbrains.kotlin.codegen.signature.BothSignatureWriter;
import org.jetbrains.kotlin.codegen.signature.JvmSignatureWriter;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.fileClasses.FileClasses;
import org.jetbrains.kotlin.fileClasses.JvmFileClassInfo;
import org.jetbrains.kotlin.fileClasses.JvmFileClassUtil;
import org.jetbrains.kotlin.fileClasses.JvmFileClassesProvider;
import org.jetbrains.kotlin.load.java.BuiltinMethodsWithSpecialGenericSignature;
@@ -448,7 +449,7 @@ public class KotlinTypeMapper {
}
if (ErrorUtils.isError(descriptor)) {
if (classBuilderMode != ClassBuilderMode.LIGHT_CLASSES) {
if (classBuilderMode == ClassBuilderMode.FULL) {
throw new IllegalStateException(generateErrorMessageForErrorType(jetType, descriptor));
}
Type asmType = Type.getObjectType("error/NonExistentClass");
@@ -924,7 +925,7 @@ public class KotlinTypeMapper {
? JvmAbi.getterName(propertyName)
: JvmAbi.setterName(propertyName);
return updateMemberNameIfInternal(isAccessor ? "access$" + accessorName : accessorName, descriptor);
return mangleMemberNameIfRequired(isAccessor ? "access$" + accessorName : accessorName, descriptor);
}
else if (isFunctionLiteral(descriptor)) {
PsiElement element = DescriptorToSourceUtils.getSourceFromDescriptor(descriptor);
@@ -944,7 +945,7 @@ public class KotlinTypeMapper {
return OperatorNameConventions.INVOKE.asString();
}
else {
return updateMemberNameIfInternal(descriptor.getName().asString(), descriptor);
return mangleMemberNameIfRequired(descriptor.getName().asString(), descriptor);
}
}
@@ -973,13 +974,21 @@ public class KotlinTypeMapper {
}
@NotNull
private String updateMemberNameIfInternal(@NotNull String name, @NotNull CallableMemberDescriptor descriptor) {
private String mangleMemberNameIfRequired(@NotNull String name, @NotNull CallableMemberDescriptor descriptor) {
if (descriptor.getContainingDeclaration() instanceof ScriptDescriptor) {
//script properties should be public
return name;
}
if (DescriptorUtils.isTopLevelDeclaration(descriptor)) {
if (Visibilities.isPrivate(descriptor.getVisibility()) && !(descriptor instanceof ConstructorDescriptor) && !"<clinit>".equals(name)) {
KtFile containingFile = DescriptorToSourceUtils.getContainingFile(descriptor);
assert containingFile != null : "Private descriptor accessed outside of corresponding file scope: " + descriptor;
JvmFileClassInfo fileClassInfo = JvmFileClassUtil.getFileClassInfoNoResolve(containingFile);
if (fileClassInfo.getWithJvmMultifileClass()) {
return name + "$" + fileClassInfo.getFileClassFqName().shortName().asString();
}
}
return name;
}
@@ -1248,7 +1257,7 @@ public class KotlinTypeMapper {
}
private void writeFormalTypeParameter(@NotNull TypeParameterDescriptor typeParameterDescriptor, @NotNull JvmSignatureWriter sw) {
if (classBuilderMode == ClassBuilderMode.LIGHT_CLASSES && typeParameterDescriptor.getName().isSpecial()) {
if (classBuilderMode != ClassBuilderMode.FULL && typeParameterDescriptor.getName().isSpecial()) {
// If a type parameter has no name, the code below fails, but it should recover in case of light classes
return;
}

View File

@@ -58,6 +58,8 @@ public abstract class CommonCompilerArguments {
public List<String> freeArgs = new SmartList<String>();
public List<String> unknownExtraFlags = new SmartList<String>();
@NotNull
public String executableScriptFileName() {
return "kotlinc";

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
* Copyright 2010-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -64,6 +64,9 @@ public class K2JVMCompilerArguments extends CommonCompilerArguments {
@Argument(value = "Xreport-perf", description = "Report detailed performance statistics")
public boolean reportPerf;
@Argument(value = "Xmultifile-parts-inherit", description = "Compile multifile classes as a hierarchy of parts and facade")
public boolean inheritMultifileParts;
@Argument(value = "Xallow-kotlin-package", description = "Allow compiling code in package 'kotlin'")
public boolean allowKotlinPackage;

View File

@@ -22,6 +22,9 @@ import com.intellij.openapi.Disposable;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.SystemInfo;
import com.sampullara.cli.Args;
import kotlin.Pair;
import kotlin.collections.CollectionsKt;
import kotlin.jvm.functions.Function1;
import org.fusesource.jansi.AnsiConsole;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -42,7 +45,7 @@ import java.util.Properties;
import static org.jetbrains.kotlin.cli.common.ExitCode.*;
public abstract class CLICompiler<A extends CommonCompilerArguments> {
static {
static private void setIdeaIoUseFallback() {
if (SystemInfo.isWindows) {
Properties properties = System.getProperties();
@@ -87,7 +90,7 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> {
private A parseArguments(@NotNull PrintStream errStream, @NotNull MessageRenderer messageRenderer, @NotNull String[] args) {
try {
A arguments = createArguments();
arguments.freeArgs = Args.parse(arguments, args);
parseArguments(args, arguments);
return arguments;
}
catch (IllegalArgumentException e) {
@@ -104,6 +107,26 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> {
return null;
}
@SuppressWarnings("WeakerAccess") // Used in maven (see KotlinCompileMojoBase.java)
public void parseArguments(@NotNull String[] args, @NotNull A arguments) {
Pair<List<String>, List<String>> unparsedArgs =
CollectionsKt.partition(Args.parse(arguments, args, false), new Function1<String, Boolean>() {
@Override
public Boolean invoke(String s) {
return s.startsWith("-X");
}
});
arguments.unknownExtraFlags = unparsedArgs.getFirst();
arguments.freeArgs = unparsedArgs.getSecond();
for (String argument : arguments.freeArgs) {
if (argument.startsWith("-")) {
throw new IllegalArgumentException("Invalid argument: " + argument);
}
}
}
/**
* Allow derived classes to add additional command line arguments
*/
@@ -169,6 +192,8 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> {
messageCollector = new FilteringMessageCollector(messageCollector, Predicates.equalTo(CompilerMessageSeverity.WARNING));
}
reportUnknownExtraFlags(messageCollector, arguments);
GroupingMessageCollector groupingCollector = new GroupingMessageCollector(messageCollector);
try {
ExitCode exitCode = OK;
@@ -192,6 +217,7 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> {
Disposable rootDisposable = Disposer.newDisposable();
try {
MessageSeverityCollector severityCollector = new MessageSeverityCollector(groupingCollector);
setIdeaIoUseFallback();
ExitCode code = doExecute(arguments, services, severityCollector, rootDisposable);
exitCode = severityCollector.anyReported(CompilerMessageSeverity.ERROR) ? COMPILATION_ERROR : code;
}
@@ -226,6 +252,16 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> {
}
}
private void reportUnknownExtraFlags(@NotNull MessageCollector collector, @NotNull A arguments) {
for (String flag : arguments.unknownExtraFlags) {
collector.report(
CompilerMessageSeverity.WARNING,
"Flag is not supported by this version of the compiler: " + flag,
CompilerMessageLocation.NO_LOCATION
);
}
}
@NotNull
protected abstract ExitCode doExecute(
@NotNull A arguments,

View File

@@ -280,6 +280,7 @@ open class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
configuration.put(JVMConfigurationKeys.DISABLE_INLINE, arguments.noInline)
configuration.put(JVMConfigurationKeys.DISABLE_OPTIMIZATION, arguments.noOptimize)
configuration.put(JVMConfigurationKeys.DECLARATIONS_JSON_PATH, arguments.declarationsOutputPath)
configuration.put(JVMConfigurationKeys.INHERIT_MULTIFILE_PARTS, arguments.inheritMultifileParts);
configuration.put(CLIConfigurationKeys.ALLOW_KOTLIN_PACKAGE, arguments.allowKotlinPackage);
configuration.put(CLIConfigurationKeys.REPORT_PERF, arguments.reportPerf);
}

View File

@@ -33,10 +33,7 @@ import org.jetbrains.kotlin.descriptors.PackageViewDescriptor
import org.jetbrains.kotlin.fileClasses.JvmFileClassUtil
import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.psi.KtClassOrObject
import org.jetbrains.kotlin.psi.KtDeclaration
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.psi.KtPsiUtil
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.resolve.*
import org.jetbrains.kotlin.resolve.lazy.KotlinCodeAnalyzer
import org.jetbrains.kotlin.resolve.lazy.ResolveSessionUtils
@@ -141,6 +138,8 @@ class CliLightClassGenerationSupport(project: Project) : LightClassGenerationSup
return bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, declaration)
}
override fun analyze(element: KtElement) = bindingContext
override fun getFacadeClasses(facadeFqName: FqName, scope: GlobalSearchScope): Collection<PsiClass> {
val filesForFacade = findFilesForFacade(facadeFqName, scope)
if (filesForFacade.isEmpty()) return emptyList()
@@ -149,6 +148,11 @@ class CliLightClassGenerationSupport(project: Project) : LightClassGenerationSup
KtLightClassForFacade.createForFacade(psiManager, facadeFqName, scope, filesForFacade))
}
override fun getMultifilePartClasses(partFqName: FqName, scope: GlobalSearchScope): Collection<PsiClass> {
//
return emptyList()
}
override fun findFilesForFacade(facadeFqName: FqName, scope: GlobalSearchScope): Collection<KtFile> {
if (facadeFqName.isRoot) return emptyList()

View File

@@ -109,10 +109,7 @@ class KotlinCoreEnvironment private constructor(
private val sourceFiles = ArrayList<KtFile>()
private val javaRoots = ArrayList<JavaRoot>()
val configuration: CompilerConfiguration = configuration.copy().let {
it.setReadOnly(true)
it
}
val configuration: CompilerConfiguration = configuration.copy().apply { setReadOnly(true) }
init {
PersistentFSConstants.setMaxIntellisenseFileSize(FileUtilRt.LARGE_FOR_CONTENT_LOADING)

View File

@@ -399,6 +399,7 @@ object KotlinToJVMBytecodeCompiler {
configuration.get(JVMConfigurationKeys.DISABLE_INLINE, false),
configuration.get(JVMConfigurationKeys.DISABLE_OPTIMIZATION, false),
/* useTypeTableInSerializer = */ false,
configuration.get(JVMConfigurationKeys.INHERIT_MULTIFILE_PARTS, false),
packagesWithObsoleteParts,
obsoleteMultifileClasses,
targetId,

View File

@@ -35,6 +35,8 @@ public class JVMConfigurationKeys {
CompilerConfigurationKey.create("disable inline");
public static final CompilerConfigurationKey<Boolean> DISABLE_OPTIMIZATION =
CompilerConfigurationKey.create("disable optimization");
public static final CompilerConfigurationKey<Boolean> INHERIT_MULTIFILE_PARTS =
CompilerConfigurationKey.create("compile multifile classes to a hierarchy of parts and facade");
public static final CompilerConfigurationKey<IncrementalCompilationComponents> INCREMENTAL_COMPILATION_COMPONENTS =
CompilerConfigurationKey.create("incremental cache provider");

View File

@@ -149,3 +149,6 @@ messages/**)
*** SKIP_DEBUG;
*** SKIP_FRAMES;
}
# for kotlin-android-extensions in maven
-keep class com.intellij.openapi.module.ModuleServiceManager { public *; }

View File

@@ -64,7 +64,7 @@ class LazyClasspathWatcher(classpath: Iterable<String>,
.flatMap { it.walk().filter(::isClasspathFile) }
.map { FileId(it, it.lastModified(), it.md5Digest()) }
.toList()
val nowMs = TimeUnit.MILLISECONDS.toMillis(System.nanoTime())
val nowMs = TimeUnit.NANOSECONDS.toMillis(System.nanoTime())
lastUpdate.set(nowMs)
lastDigestUpdate.set(nowMs)
}
@@ -80,7 +80,7 @@ class LazyClasspathWatcher(classpath: Iterable<String>,
val isChanged: Boolean get() {
if (lastChangedStatus.get()) return true
val nowMs = TimeUnit.MILLISECONDS.toMillis(System.nanoTime())
val nowMs = TimeUnit.NANOSECONDS.toMillis(System.nanoTime())
if (nowMs - lastUpdate.get() < checkPeriod) return false
val checkDigest = nowMs - lastDigestUpdate.get() > digestCheckPeriod
@@ -106,7 +106,7 @@ class LazyClasspathWatcher(classpath: Iterable<String>,
true // io error considered as change
}
} != null
lastUpdate.set(TimeUnit.MILLISECONDS.toMillis(System.nanoTime()))
lastUpdate.set(TimeUnit.NANOSECONDS.toMillis(System.nanoTime()))
if (checkDigest) lastDigestUpdate.set(lastUpdate.get())
return changed

View File

@@ -18,12 +18,15 @@ package org.jetbrains.kotlin.fileClasses
import com.intellij.psi.util.CachedValueProvider
import com.intellij.psi.util.CachedValuesManager
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
import org.jetbrains.kotlin.load.java.descriptors.getImplClassNameForDeserialized
import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedCallableMemberDescriptor
object JvmFileClassUtil {
@@ -84,14 +87,21 @@ object JvmFileClassUtil {
it.calleeExpression?.constructorReferenceExpression?.getReferencedName() == shortName
}
@JvmStatic
private fun getLiteralStringFromRestrictedConstExpression(argumentExpression: KtExpression?): String? {
@JvmStatic private fun getLiteralStringFromRestrictedConstExpression(argumentExpression: KtExpression?): String? {
val stringTemplate = argumentExpression as? KtStringTemplateExpression ?: return null
val stringTemplateEntries = stringTemplate.entries
if (stringTemplateEntries.size != 1) return null
val singleEntry = stringTemplateEntries[0] as? KtLiteralStringTemplateEntry ?: return null
return singleEntry.text
}
@JvmStatic fun isFromMultifileClass(declarationElement: KtElement, descriptor: DeclarationDescriptor): Boolean {
if (DescriptorUtils.isTopLevelDeclaration(descriptor)) {
val fileClassInfo = JvmFileClassUtil.getFileClassInfoNoResolve(declarationElement.getContainingKtFile())
return fileClassInfo.withJvmMultifileClass
}
return false
}
}
internal class ParsedJvmFileClassAnnotations(val name: String, val multipleFiles: Boolean)

View File

@@ -30,7 +30,7 @@ import org.jetbrains.kotlin.utils.addToStdlib.check
// then use this upper bound instead of star projection
// - Otherwise no non-projection parametrization exists for such 'samType'
//
// See Non-wildcard parametrization in §9.9 of JLS 8 for clarification
// See Non-wildcard parametrization in JLS 8 p.9.9 for clarification
internal fun nonProjectionParametrization(samType: KotlinType): KotlinType? {
if (samType.arguments.none { it.projectionKind != Variance.INVARIANT }) return samType
val parameters = samType.constructor.parameters

View File

@@ -74,7 +74,7 @@ class JavaTypeAccessibilityChecker : AdditionalTypeChecker {
if (visitedTypeConstructors.contains(typeConstructor)) return
visitedTypeConstructors.add(typeConstructor)
if (typeConstructor is JavaClassDescriptor && !Visibilities.isVisibleWithIrrelevantReceiver(typeConstructor, scopeOwner)) {
if (typeConstructor is JavaClassDescriptor && !Visibilities.isVisibleIgnoringReceiver(typeConstructor, scopeOwner)) {
inaccessibleTypes.add(type)
}
for (typeProjection in type.arguments) {

View File

@@ -0,0 +1,55 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.resolve.jvm.checkers
import org.jetbrains.kotlin.descriptors.Visibilities
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.resolve.calls.checkers.CallChecker
import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
import org.jetbrains.kotlin.resolve.calls.smartcasts.getReceiverValueWithSmartCast
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
import org.jetbrains.kotlin.synthetic.SamAdapterExtensionFunctionDescriptor
import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor
object ProtectedSyntheticExtensionCallChecker : CallChecker {
override fun check(resolvedCall: ResolvedCall<*>, context: BasicCallResolutionContext) {
val descriptor = resolvedCall.resultingDescriptor
val sourceFunction = when (descriptor) {
is SyntheticJavaPropertyDescriptor -> descriptor.getMethod
is SamAdapterExtensionFunctionDescriptor -> descriptor.sourceFunction
else -> return
}
val from = context.scope.ownerDescriptor
// Already reported
if (!Visibilities.isVisibleIgnoringReceiver(descriptor, from)) return
if (resolvedCall.dispatchReceiver != null && resolvedCall.extensionReceiver !is ReceiverValue) return
val receiverValue = resolvedCall.extensionReceiver as ReceiverValue
val receiverTypes = listOf(receiverValue.type) + context.dataFlowInfo.getPredictableTypes(
DataFlowValueFactory.createDataFlowValue(receiverValue, context))
if (receiverTypes.none { Visibilities.isVisible(getReceiverValueWithSmartCast(null, it), sourceFunction, from) }) {
context.trace.report(Errors.INVISIBLE_MEMBER.on(resolvedCall.call.callElement, descriptor, descriptor.visibility, from))
}
}
}

View File

@@ -49,7 +49,7 @@ public class DefaultErrorMessagesJvm implements DefaultErrorMessages.Extension {
}
};
public static final DiagnosticFactoryToRendererMap MAP = new DiagnosticFactoryToRendererMap("JVM");
private static final DiagnosticFactoryToRendererMap MAP = new DiagnosticFactoryToRendererMap("JVM");
static {
MAP.put(ErrorsJvm.CONFLICTING_JVM_DECLARATIONS, "Platform declaration clash: {0}", CONFLICTING_JVM_DECLARATIONS_DATA);
MAP.put(ErrorsJvm.ACCIDENTAL_OVERRIDE, "Accidental override: {0}", CONFLICTING_JVM_DECLARATIONS_DATA);
@@ -57,17 +57,17 @@ public class DefaultErrorMessagesJvm implements DefaultErrorMessages.Extension {
MAP.put(ErrorsJvm.MISSING_DEPENDENCY_CLASS, "Cannot access class ''{0}''. Check your module classpath for missing or conflicting dependencies", Renderers.TO_STRING);
MAP.put(ErrorsJvm.JVM_STATIC_NOT_IN_OBJECT, "Only functions in named objects and companion objects of classes can be annotated with ''@JvmStatic''");
MAP.put(ErrorsJvm.JVM_STATIC_ON_CONST_OR_JVM_FIELD, "''@JvmStatic'' annotation is useless for const or ''@JvmField'' properties");
MAP.put(ErrorsJvm.OVERRIDE_CANNOT_BE_STATIC, "Override member cannot be ''@JvmStatic'' in object");
MAP.put(ErrorsJvm.OVERLOADS_WITHOUT_DEFAULT_ARGUMENTS, "''@JvmOverloads'' annotation has no effect for methods without default arguments");
MAP.put(ErrorsJvm.OVERLOADS_ABSTRACT, "''@JvmOverloads'' annotation cannot be used on abstract methods");
MAP.put(ErrorsJvm.OVERLOADS_PRIVATE, "''@JvmOverloads'' annotation has no effect on private and local declarations");
MAP.put(ErrorsJvm.INAPPLICABLE_JVM_NAME, "''@JvmName'' annotation is not applicable to this declaration");
MAP.put(ErrorsJvm.JVM_STATIC_NOT_IN_OBJECT, "Only functions in named objects and companion objects of classes can be annotated with '@JvmStatic'");
MAP.put(ErrorsJvm.JVM_STATIC_ON_CONST_OR_JVM_FIELD, "'@JvmStatic' annotation is useless for const or '@JvmField' properties");
MAP.put(ErrorsJvm.OVERRIDE_CANNOT_BE_STATIC, "Override member cannot be '@JvmStatic' in object");
MAP.put(ErrorsJvm.OVERLOADS_WITHOUT_DEFAULT_ARGUMENTS, "'@JvmOverloads' annotation has no effect for methods without default arguments");
MAP.put(ErrorsJvm.OVERLOADS_ABSTRACT, "'@JvmOverloads' annotation cannot be used on abstract methods");
MAP.put(ErrorsJvm.OVERLOADS_PRIVATE, "'@JvmOverloads' annotation has no effect on private and local declarations");
MAP.put(ErrorsJvm.INAPPLICABLE_JVM_NAME, "'@JvmName' annotation is not applicable to this declaration");
MAP.put(ErrorsJvm.ILLEGAL_JVM_NAME, "Illegal JVM name");
MAP.put(ErrorsJvm.VOLATILE_ON_VALUE, "''@Volatile'' annotation cannot be used on immutable properties");
MAP.put(ErrorsJvm.VOLATILE_ON_DELEGATE, "''@Volatile'' annotation cannot be used on delegated properties");
MAP.put(ErrorsJvm.SYNCHRONIZED_ON_ABSTRACT, "''@Synchronized'' annotation cannot be used on abstract functions");
MAP.put(ErrorsJvm.VOLATILE_ON_VALUE, "'@Volatile' annotation cannot be used on immutable properties");
MAP.put(ErrorsJvm.VOLATILE_ON_DELEGATE, "'@Volatile' annotation cannot be used on delegated properties");
MAP.put(ErrorsJvm.SYNCHRONIZED_ON_ABSTRACT, "'@Synchronized' annotation cannot be used on abstract functions");
MAP.put(ErrorsJvm.EXTERNAL_DECLARATION_CANNOT_BE_ABSTRACT, "External declaration can not be abstract");
MAP.put(ErrorsJvm.EXTERNAL_DECLARATION_CANNOT_HAVE_BODY, "External declaration can not have a body");
MAP.put(ErrorsJvm.EXTERNAL_DECLARATION_IN_INTERFACE, "Members of interfaces can not be external");
@@ -101,9 +101,9 @@ public class DefaultErrorMessagesJvm implements DefaultErrorMessages.Extension {
MAP.put(ErrorsJvm.INAPPLICABLE_JVM_FIELD, "{0}", Renderers.TO_STRING);
MAP.put(ErrorsJvm.JVM_SYNTHETIC_ON_DELEGATE, "''@JvmSynthetic'' annotation cannot be used on delegated properties");
MAP.put(ErrorsJvm.JVM_SYNTHETIC_ON_DELEGATE, "'@JvmSynthetic' annotation cannot be used on delegated properties");
MAP.put(ErrorsJvm.STRICTFP_ON_CLASS, "''@Strictfp'' annotation on classes is unsupported yet");
MAP.put(ErrorsJvm.STRICTFP_ON_CLASS, "'@Strictfp' annotation on classes is unsupported yet");
MAP.put(ErrorsJvm.SUPER_CALL_WITH_DEFAULT_PARAMETERS, "Super-calls with default arguments are not allowed. Please specify all arguments of ''super.{0}'' explicitly", Renderers.TO_STRING);
}

View File

@@ -18,7 +18,6 @@ package org.jetbrains.kotlin.resolve.jvm.diagnostics
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.psi.KtClassOrObject
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
@@ -68,9 +67,9 @@ fun PackagePart(file: KtFile, descriptor: PackageFragmentDescriptor): JvmDeclara
/**
* @param representativeFile one of the files representing this multifile class (will be used for diagnostics)
*/
fun MultifileClass(representativeFile: KtFile?, descriptor: PackageFragmentDescriptor, multifileClassFqName: FqName): JvmDeclarationOrigin =
fun MultifileClass(representativeFile: KtFile?, descriptor: PackageFragmentDescriptor): JvmDeclarationOrigin =
JvmDeclarationOrigin(MULTIFILE_CLASS, representativeFile, descriptor)
fun MultifileClassPart(file: KtFile, descriptor: PackageFragmentDescriptor, multifileClassFqName: FqName): JvmDeclarationOrigin =
fun MultifileClassPart(file: KtFile, descriptor: PackageFragmentDescriptor): JvmDeclarationOrigin =
JvmDeclarationOrigin(MULTIFILE_CLASS_PART, file, descriptor)
fun TraitImpl(element: KtClassOrObject, descriptor: ClassDescriptor): JvmDeclarationOrigin = JvmDeclarationOrigin(INTERFACE_DEFAULT_IMPL, element, descriptor)

View File

@@ -51,7 +51,8 @@ object JvmPlatformConfigurator : PlatformConfigurator(
ProtectedInSuperClassCompanionCallChecker(),
UnsupportedSyntheticCallableReferenceChecker(),
SuperCallWithDefaultArgumentsChecker(),
MissingDependencyClassChecker()
MissingDependencyClassChecker(),
ProtectedSyntheticExtensionCallChecker
),
additionalTypeCheckers = listOf(

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -120,7 +120,7 @@ class JavaSyntheticPropertiesScope(storageManager: StorageManager, private val l
val getMethod = possibleGetMethodNames
.flatMap { memberScope.getContributedFunctions(it, NoLookupLocation.FROM_SYNTHETIC_SCOPE) }
.singleOrNull {
isGoodGetMethod(it) && it.hasJavaOriginInHierarchy()
it.hasJavaOriginInHierarchy() && isGoodGetMethod(it)
} ?: return result(null, possibleGetMethodNames)

View File

@@ -169,7 +169,10 @@ class SamAdapterFunctionsScope(storageManager: StorageManager) : SyntheticScope
}
val sourceFunctionSubstitutor = TypeSubstitutor.create(substitutionMap)
val sourceFunctionSubstitutor =
TypeConstructorSubstitution.createByConstructorsMap(
substitutionMap, configuration.originalSubstitutor.substitution.approximateCapturedTypes()).buildSubstitutor()
descriptor.sourceFunction = original.sourceFunction.substitute(sourceFunctionSubstitutor)
return descriptor

View File

@@ -36,7 +36,7 @@ fun syntheticExtensionVisibility(originalDescriptor: DeclarationDescriptorWithVi
else -> object : Visibility(originalVisibility.name, originalVisibility.isPublicAPI) {
override fun isVisible(receiver: ReceiverValue?, what: DeclarationDescriptorWithVisibility, from: DeclarationDescriptor)
= originalVisibility.isVisible(receiver, originalDescriptor, from)
= originalVisibility.isVisible(Visibilities.ALWAYS_SUITABLE_RECEIVER, originalDescriptor, from)
override fun mustCheckInImports()
= throw UnsupportedOperationException("Should never be called for this visibility")

View File

@@ -466,7 +466,7 @@ public class ControlFlowInformationProvider {
ResolvedCall<? extends CallableDescriptor> resolvedCall = CallUtilKt.getResolvedCall(expression, trace.getBindingContext());
ReceiverValue receiverValue = null;
if (resolvedCall != null) {
receiverValue = resolvedCall.getDispatchReceiver();
receiverValue = ResolvedCallUtilKt.getDispatchReceiverWithSmartCast(resolvedCall);
}
if (Visibilities.isVisible(receiverValue, variableDescriptor, descriptor) && setterDescriptor != null

View File

@@ -793,16 +793,31 @@ class ControlFlowProcessor(private val trace: BindingTrace) {
override fun visitBreakExpression(expression: KtBreakExpression) {
val loop = getCorrespondingLoop(expression)
if (loop != null) {
checkJumpDoesNotCrossFunctionBoundary(expression, loop)
builder.getExitPoint(loop)?.let { builder.jump(it, expression) }
if (jumpDoesNotCrossFunctionBoundary(expression, loop)) {
builder.getExitPoint(loop)?.let { builder.jump(it, expression) }
}
}
}
override fun visitContinueExpression(expression: KtContinueExpression) {
val loop = getCorrespondingLoop(expression)
if (loop != null) {
checkJumpDoesNotCrossFunctionBoundary(expression, loop)
builder.jump(builder.getConditionEntryPoint(loop), expression)
if (jumpDoesNotCrossFunctionBoundary(expression, loop)) {
builder.jump(builder.getConditionEntryPoint(loop), expression)
}
}
}
private fun getNearestLoopExpression(expression: KtExpression) = expression.getStrictParentOfType<KtLoopExpression>()
private fun getCorrespondingLoopWithoutLabel(expression: KtExpression): KtLoopExpression? {
val parentLoop = getNearestLoopExpression(expression) ?: return null
val parentBody = parentLoop.body
return if (parentBody != null && parentBody.textRange.contains(expression.textRange)) {
parentLoop
}
else {
getNearestLoopExpression(parentLoop)
}
}
@@ -821,7 +836,7 @@ class ControlFlowProcessor(private val trace: BindingTrace) {
}
}
else {
loop = builder.currentLoop
loop = getCorrespondingLoopWithoutLabel(expression)
if (loop == null) {
trace.report(BREAK_OR_CONTINUE_OUTSIDE_A_LOOP.on(expression))
}
@@ -842,13 +857,24 @@ class ControlFlowProcessor(private val trace: BindingTrace) {
return loop
}
private fun checkJumpDoesNotCrossFunctionBoundary(jumpExpression: KtExpressionWithLabel, jumpTarget: KtElement) {
private fun jumpDoesNotCrossFunctionBoundary(jumpExpression: KtExpressionWithLabel, jumpTarget: KtElement): Boolean {
val bindingContext = trace.bindingContext
val labelExprEnclosingFunc = BindingContextUtils.getEnclosingFunctionDescriptor(bindingContext, jumpExpression)
val labelTargetEnclosingFunc = BindingContextUtils.getEnclosingFunctionDescriptor(bindingContext, jumpTarget)
if (labelExprEnclosingFunc !== labelTargetEnclosingFunc) {
trace.report(BREAK_OR_CONTINUE_JUMPS_ACROSS_FUNCTION_BOUNDARY.on(jumpExpression))
return if (labelExprEnclosingFunc !== labelTargetEnclosingFunc) {
// Check to report only once
if (builder.getExitPoint(jumpTarget) != null ||
// Local class secondary constructors are handled differently
// They are the only local class element NOT included in owner pseudocode
// See generateInitializersForScriptClassOrObject && generateDeclarationForLocalClassOrObjectIfNeeded
labelExprEnclosingFunc is ConstructorDescriptor && !labelExprEnclosingFunc.isPrimary) {
trace.report(BREAK_OR_CONTINUE_JUMPS_ACROSS_FUNCTION_BOUNDARY.on(jumpExpression))
}
false
}
else {
true
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -73,6 +73,8 @@ public interface Errors {
DiagnosticFactory3.create(ERROR);
DiagnosticFactory3<PsiElement, DeclarationDescriptor, Visibility, DeclarationDescriptor> INVISIBLE_MEMBER = DiagnosticFactory3.create(ERROR, CALL_ELEMENT);
DiagnosticFactory1<KtExpression, ConstructorDescriptor> PROTECTED_CONSTRUCTOR_NOT_IN_SUPER_CALL = DiagnosticFactory1.create(ERROR);
// Exposed visibility group
DiagnosticFactory3<PsiElement, EffectiveVisibility, DescriptorWithRelation, EffectiveVisibility> EXPOSED_PROPERTY_TYPE = DiagnosticFactory3.create(ERROR);
DiagnosticFactory3<PsiElement, EffectiveVisibility, DescriptorWithRelation, EffectiveVisibility> EXPOSED_FUNCTION_RETURN_TYPE = DiagnosticFactory3.create(ERROR);
@@ -96,7 +98,8 @@ public interface Errors {
DiagnosticFactory0<KtTypeProjection> PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT = DiagnosticFactory0.create(ERROR, VARIANCE_IN_PROJECTION);
DiagnosticFactory2<KtTypeReference, KotlinType, KotlinType> UPPER_BOUND_VIOLATED = DiagnosticFactory2.create(ERROR);
DiagnosticFactory0<KtNullableType> REDUNDANT_NULLABLE = DiagnosticFactory0.create(WARNING, NULLABLE_TYPE);
DiagnosticFactory1<KtElement, Integer> WRONG_NUMBER_OF_TYPE_ARGUMENTS = DiagnosticFactory1.create(ERROR);
DiagnosticFactory2<KtElement, Integer, DeclarationDescriptor> WRONG_NUMBER_OF_TYPE_ARGUMENTS = DiagnosticFactory2.create(ERROR);
DiagnosticFactory1<KtElement, String> TYPE_ARGUMENTS_NOT_ALLOWED = DiagnosticFactory1.create(ERROR);
DiagnosticFactory2<KtTypeReference, Integer, String> NO_TYPE_ARGUMENTS_ON_RHS = DiagnosticFactory2.create(ERROR);
DiagnosticFactory1<KtTypeProjection, ClassifierDescriptor> CONFLICTING_PROJECTION = DiagnosticFactory1.create(ERROR, VARIANCE_IN_PROJECTION);
DiagnosticFactory1<KtTypeProjection, ClassifierDescriptor> REDUNDANT_PROJECTION = DiagnosticFactory1.create(WARNING, VARIANCE_IN_PROJECTION);

View File

@@ -51,7 +51,7 @@ object PositioningStrategies {
when (element) {
is KtObjectLiteralExpression -> {
val objectDeclaration = element.objectDeclaration
val objectKeyword = objectDeclaration.getObjectKeyword()
val objectKeyword = objectDeclaration.getObjectKeyword()!!
val delegationSpecifierList = objectDeclaration.getSuperTypeList()
if (delegationSpecifierList == null) {
return markElement(objectKeyword)
@@ -60,8 +60,8 @@ object PositioningStrategies {
}
is KtObjectDeclaration -> {
return markRange(
element.getObjectKeyword(),
element.getNameIdentifier() ?: element.getObjectKeyword()
element.getObjectKeyword()!!,
element.getNameIdentifier() ?: element.getObjectKeyword()!!
)
}
is KtConstructorDelegationCall -> {
@@ -265,7 +265,7 @@ object PositioningStrategies {
}
val elementToMark = when (element) {
is KtObjectDeclaration -> element.getObjectKeyword()
is KtObjectDeclaration -> element.getObjectKeyword()!!
is KtPropertyAccessor -> element.getNamePlaceholder()
is KtAnonymousInitializer -> element
else -> throw IllegalArgumentException(

View File

@@ -30,7 +30,7 @@ open class PositioningStrategy<E : PsiElement> {
return mark(diagnostic.psiElement)
}
protected open fun mark(element: E): List<TextRange> {
open fun mark(element: E): List<TextRange> {
return markElement(element)
}

View File

@@ -97,6 +97,8 @@ public class DefaultErrorMessages {
MAP.put(INVISIBLE_REFERENCE, "Cannot access ''{0}'': it is ''{1}'' in {2}", NAME, TO_STRING, NAME_OF_PARENT_OR_FILE);
MAP.put(INVISIBLE_MEMBER, "Cannot access ''{0}'': it is ''{1}'' in {2}", NAME, TO_STRING, NAME_OF_PARENT_OR_FILE);
MAP.put(PROTECTED_CONSTRUCTOR_NOT_IN_SUPER_CALL, "Protected constructor ''{0}'' from other classes can only be used in super-call", Renderers.SHORT_NAMES_IN_TYPES);
MAP.put(EXPOSED_PROPERTY_TYPE, "''{0}'' property exposes its ''{2}'' type{1}", TO_STRING, TO_STRING, TO_STRING);
MAP.put(EXPOSED_FUNCTION_RETURN_TYPE, "''{0}'' function exposes its ''{2}'' return type{1}", TO_STRING, TO_STRING, TO_STRING);
MAP.put(EXPOSED_PARAMETER_TYPE, "''{0}'' function exposes its ''{2}'' parameter type{1}", TO_STRING, TO_STRING, TO_STRING);
@@ -146,14 +148,14 @@ public class DefaultErrorMessages {
MAP.put(INAPPLICABLE_TARGET_ON_PROPERTY, "''@{0}:'' annotations could be applied only to property declarations", TO_STRING);
MAP.put(INAPPLICABLE_TARGET_PROPERTY_IMMUTABLE, "''@{0}:'' annotations could be applied only to mutable properties", TO_STRING);
MAP.put(INAPPLICABLE_TARGET_PROPERTY_HAS_NO_DELEGATE, "''@delegate:'' annotations could be applied only to delegated properties");
MAP.put(INAPPLICABLE_TARGET_PROPERTY_HAS_NO_BACKING_FIELD, "''@field:'' annotations could be applied only to properties with backing fields");
MAP.put(INAPPLICABLE_RECEIVER_TARGET, "''@receiver:'' annotations could be applied only to extension function or extension property declarations");
MAP.put(INAPPLICABLE_PARAM_TARGET, "''@param:'' annotations could be applied only to primary constructor parameters");
MAP.put(INAPPLICABLE_TARGET_PROPERTY_HAS_NO_DELEGATE, "'@delegate:' annotations could be applied only to delegated properties");
MAP.put(INAPPLICABLE_TARGET_PROPERTY_HAS_NO_BACKING_FIELD, "'@field:' annotations could be applied only to properties with backing fields");
MAP.put(INAPPLICABLE_RECEIVER_TARGET, "'@receiver:' annotations could be applied only to extension function or extension property declarations");
MAP.put(INAPPLICABLE_PARAM_TARGET, "'@param:' annotations could be applied only to primary constructor parameters");
MAP.put(REDUNDANT_ANNOTATION_TARGET, "Redundant annotation target ''{0}''", STRING);
MAP.put(REDUNDANT_MODIFIER, "Modifier ''{0}'' is redundant because ''{1}'' is present", TO_STRING, TO_STRING);
MAP.put(ABSTRACT_MODIFIER_IN_INTERFACE, "Modifier ''abstract'' is redundant in interface");
MAP.put(ABSTRACT_MODIFIER_IN_INTERFACE, "Modifier 'abstract' is redundant in interface");
MAP.put(REDUNDANT_MODIFIER_IN_GETTER, "Visibility modifiers are redundant in getter");
MAP.put(TYPE_PARAMETERS_IN_ENUM, "Enum class cannot have type parameters");
MAP.put(TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM,
@@ -236,8 +238,8 @@ public class DefaultErrorMessages {
MAP.put(NON_MEMBER_FUNCTION_NO_BODY, "Function ''{0}'' must have a body", NAME);
MAP.put(FUNCTION_DECLARATION_WITH_NO_NAME, "Function declaration must have a name");
MAP.put(ANONYMOUS_FUNCTION_WITH_NAME, "Anonymous functions with names are prohibited");
MAP.put(NON_FINAL_MEMBER_IN_FINAL_CLASS, "\"open\" has no effect in a final class");
MAP.put(NON_FINAL_MEMBER_IN_OBJECT, "\"open\" has no effect in an object");
MAP.put(NON_FINAL_MEMBER_IN_FINAL_CLASS, "'open' has no effect in a final class");
MAP.put(NON_FINAL_MEMBER_IN_OBJECT, "'open' has no effect in an object");
MAP.put(ANONYMOUS_FUNCTION_PARAMETER_WITH_DEFAULT_VALUE, "An anonymous function is not allowed to specify default values for its parameters");
MAP.put(USELESS_VARARG_ON_PARAMETER, "Vararg on this parameter is useless");
@@ -270,7 +272,7 @@ public class DefaultErrorMessages {
MAP.put(VAL_REASSIGNMENT, "Val cannot be reassigned", NAME);
MAP.put(CAPTURED_VAL_INITIALIZATION, "Captured values initialization is forbidden due to possible reassignment", NAME);
MAP.put(SETTER_PROJECTED_OUT, "Setter for ''{0}'' is removed by type projection", NAME);
MAP.put(INVISIBLE_SETTER, "Cannot assign to ''{0}'': the setter is ''{1}'' in {2}", NAME, TO_STRING, NAME_OF_PARENT_OR_FILE);
MAP.put(INVISIBLE_SETTER, "Cannot assign to ''{0}'': the setter is {1} in {2}", NAME, TO_STRING, NAME_OF_PARENT_OR_FILE);
MAP.put(INITIALIZATION_BEFORE_DECLARATION, "Variable cannot be initialized before declaration", NAME);
MAP.put(VARIABLE_EXPECTED, "Variable expected");
@@ -315,7 +317,7 @@ public class DefaultErrorMessages {
MAP.put(EQUALS_MISSING, "No method 'equals(Any?): Boolean' available");
MAP.put(ASSIGNMENT_IN_EXPRESSION_CONTEXT, "Assignments are not expressions, and only expressions are allowed in this context");
MAP.put(SUPER_IS_NOT_AN_EXPRESSION, "''{0}'' is not an expression, it can only be used on the left-hand side of a dot ('.')", STRING);
MAP.put(SUPER_IS_NOT_AN_EXPRESSION, "''{0}'' is not an expression, it can only be used on the left-hand side of a dot (''.'')", STRING);
MAP.put(SUPER_CANT_BE_EXTENSION_RECEIVER, "''{0}'' is not an expression, it can not be used as a receiver for extension functions", STRING);
MAP.put(DECLARATION_IN_ILLEGAL_CONTEXT, "Declarations are not allowed in this position");
MAP.put(SETTER_PARAMETER_WITH_DEFAULT_VALUE, "Setter parameters cannot have default values");
@@ -350,12 +352,12 @@ public class DefaultErrorMessages {
MAP.put(HAS_NEXT_FUNCTION_NONE_APPLICABLE, "None of the hasNext() functions is applicable for iterator() of type ''{0}''", RENDER_TYPE);
MAP.put(HAS_NEXT_FUNCTION_TYPE_MISMATCH, "The ''iterator().hasNext()'' function of the loop range must return Boolean, but returns {0}", RENDER_TYPE);
MAP.put(NEXT_MISSING, "next() cannot be called on iterator() of type ''{0}''", RENDER_TYPE);
MAP.put(NEXT_AMBIGUITY, "next() is ambiguous for iterator() of type ''{0}''", RENDER_TYPE);
MAP.put(NEXT_NONE_APPLICABLE, "None of the next() functions is applicable for iterator() of type ''{0}''", RENDER_TYPE);
MAP.put(NEXT_MISSING, "''next()'' cannot be called on ''iterator()'' of type ''{0}''", RENDER_TYPE);
MAP.put(NEXT_AMBIGUITY, "''next()'' is ambiguous for ''iterator()'' of type ''{0}''", RENDER_TYPE);
MAP.put(NEXT_NONE_APPLICABLE, "None of the ''next()'' functions is applicable for ''iterator()'' of type ''{0}''", RENDER_TYPE);
MAP.put(ITERATOR_MISSING, "For-loop range must have an iterator() method");
MAP.put(ITERATOR_ON_NULLABLE, "Not nullable value required to call an iterator() method on for-loop range");
MAP.put(ITERATOR_MISSING, "For-loop range must have an 'iterator()' method");
MAP.put(ITERATOR_ON_NULLABLE, "Not nullable value required to call an 'iterator()' method on for-loop range");
MAP.put(ITERATOR_AMBIGUITY, "Method ''iterator()'' is ambiguous for this expression: {0}", AMBIGUOUS_CALLS);
MAP.put(DELEGATE_SPECIAL_FUNCTION_MISSING, "Missing ''{0}'' method on delegate of type ''{1}''", STRING, RENDER_TYPE);
@@ -372,11 +374,11 @@ public class DefaultErrorMessages {
MAP.put(UNDERSCORE_IS_RESERVED, "Names _, __, ___, ..., are reserved in Kotlin");
MAP.put(INVALID_CHARACTERS, "Name {0}", STRING);
MAP.put(INAPPLICABLE_OPERATOR_MODIFIER, "'operator' modifier is inapplicable on this function: {0}", STRING);
MAP.put(INAPPLICABLE_OPERATOR_MODIFIER, "''operator'' modifier is inapplicable on this function: {0}", STRING);
MAP.put(INAPPLICABLE_INFIX_MODIFIER, "'infix' modifier is inapplicable on this function");
MAP.put(OPERATOR_MODIFIER_REQUIRED, "'operator' modifier is required on ''{0}'' in ''{1}''", NAME, STRING);
MAP.put(INFIX_MODIFIER_REQUIRED, "'infix' modifier is required on ''{0}'' in ''{1}''", NAME, STRING);
MAP.put(OPERATOR_MODIFIER_REQUIRED, "''operator'' modifier is required on ''{0}'' in ''{1}''", NAME, STRING);
MAP.put(INFIX_MODIFIER_REQUIRED, "''infix'' modifier is required on ''{0}'' in ''{1}''", NAME, STRING);
MAP.put(RETURN_IN_FUNCTION_WITH_EXPRESSION_BODY,
"Returns are not allowed for functions with expression body. Use block body in '{...}'");
@@ -429,8 +431,8 @@ public class DefaultErrorMessages {
MAP.put(ELSE_MISPLACED_IN_WHEN, "'else' entry must be the last one in a when-expression");
MAP.put(COMMA_IN_WHEN_CONDITION_WITHOUT_ARGUMENT, "Deprecated syntax. Use '||' instead of commas in when-condition for 'when' without argument");
MAP.put(NO_ELSE_IN_WHEN, "'when' expression must be exhaustive, add necessary {0}", RENDER_WHEN_MISSING_CASES);
MAP.put(NON_EXHAUSTIVE_WHEN, "'when' expression on enum is recommended to be exhaustive, add {0}", RENDER_WHEN_MISSING_CASES);
MAP.put(NO_ELSE_IN_WHEN, "''when'' expression must be exhaustive, add necessary {0}", RENDER_WHEN_MISSING_CASES);
MAP.put(NON_EXHAUSTIVE_WHEN, "''when'' expression on enum is recommended to be exhaustive, add {0}", RENDER_WHEN_MISSING_CASES);
MAP.put(TYPE_MISMATCH_IN_RANGE, "Type mismatch: incompatible types of range and element checked in it");
MAP.put(CYCLIC_INHERITANCE_HIERARCHY, "There's a cycle in the inheritance hierarchy for this type");
@@ -470,7 +472,7 @@ public class DefaultErrorMessages {
MAP.put(VALUE_PARAMETER_WITH_NO_TYPE_ANNOTATION, "A type annotation is required on a value parameter");
MAP.put(BREAK_OR_CONTINUE_OUTSIDE_A_LOOP, "'break' and 'continue' are only allowed inside a loop");
MAP.put(BREAK_OR_CONTINUE_IN_WHEN, "'break' and 'continue' are not allowed in 'when' statements. Consider using labels to continue/break from the outer loop");
MAP.put(BREAK_OR_CONTINUE_JUMPS_ACROSS_FUNCTION_BOUNDARY, "'break' or 'continue' jumps across a function boundary");
MAP.put(BREAK_OR_CONTINUE_JUMPS_ACROSS_FUNCTION_BOUNDARY, "'break' or 'continue' jumps across a function or a class boundary");
MAP.put(NOT_A_LOOP_LABEL, "The label ''{0}'' does not denote a loop", STRING);
MAP.put(NOT_A_RETURN_LABEL, "The label ''{0}'' does not reference to a context from which we can return", STRING);
@@ -479,7 +481,7 @@ public class DefaultErrorMessages {
MAP.put(DYNAMIC_SUPERTYPE, "A supertype cannot be dynamic");
MAP.put(REDUNDANT_NULLABLE, "Redundant '?'");
MAP.put(UNSAFE_CALL, "Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type {0}", RENDER_TYPE);
MAP.put(UNSAFE_IMPLICIT_INVOKE_CALL, "Reference has a nullable type {0}, use explicit '?.invoke()' to make function-like call instead", RENDER_TYPE);
MAP.put(UNSAFE_IMPLICIT_INVOKE_CALL, "Reference has a nullable type ''{0}'', use explicit ''?.invoke()'' to make a function-like call instead", RENDER_TYPE);
MAP.put(AMBIGUOUS_LABEL, "Ambiguous label");
MAP.put(UNSUPPORTED, "Unsupported [{0}]", STRING);
MAP.put(EXCEPTION_FROM_ANALYZER, "Internal Error occurred while analyzing this expression:\n{0}", THROWABLE);
@@ -539,8 +541,8 @@ public class DefaultErrorMessages {
RENDER_TYPE);
MAP.put(TYPE_MISMATCH_IN_CONDITION, "Condition must be of type Boolean, but is of type {0}", RENDER_TYPE);
MAP.put(INCOMPATIBLE_TYPES, "Incompatible types: {0} and {1}", RENDER_TYPE, RENDER_TYPE);
MAP.put(IMPLICIT_NOTHING_RETURN_TYPE, "''Nothing'' return type needs to be specified explicitly");
MAP.put(IMPLICIT_NOTHING_PROPERTY_TYPE, "''Nothing'' property type needs to be specified explicitly");
MAP.put(IMPLICIT_NOTHING_RETURN_TYPE, "'Nothing' return type needs to be specified explicitly");
MAP.put(IMPLICIT_NOTHING_PROPERTY_TYPE, "'Nothing' property type needs to be specified explicitly");
MAP.put(IMPLICIT_INTERSECTION_TYPE, "Inferred type {0} is an intersection, please specify the required type explicitly", RENDER_TYPE);
MAP.put(EXPECTED_CONDITION, "Expected condition of type Boolean");
@@ -584,7 +586,7 @@ public class DefaultErrorMessages {
MAP.put(OVERRIDING_FINAL_MEMBER_BY_DELEGATION, "''{0}'' implicitly overrides a final member ''{1}'' by delegation",
SHORT_NAMES_IN_TYPES, SHORT_NAMES_IN_TYPES);
MAP.put(VAR_OVERRIDDEN_BY_VAL_BY_DELEGATION, "val-property ''{0}'' implicitly overrides a var-property ''{1}'' by delegation",
MAP.put(VAR_OVERRIDDEN_BY_VAL_BY_DELEGATION, "Val-property ''{0}'' implicitly overrides a var-property ''{1}'' by delegation",
SHORT_NAMES_IN_TYPES, SHORT_NAMES_IN_TYPES);
MAP.put(VAR_OVERRIDDEN_BY_VAL, "Var-property {0} cannot be overridden by val-property {1}", FQ_NAMES_IN_TYPES, FQ_NAMES_IN_TYPES);
@@ -604,7 +606,7 @@ public class DefaultErrorMessages {
DECLARATION_NAME_WITH_KIND);
MAP.put(FUNCTION_EXPECTED, "Expression ''{0}''{1} cannot be invoked as a function. " +
"The function '" + OperatorNameConventions.INVOKE.asString() + "()' is not found",
"The function ''" + OperatorNameConventions.INVOKE.asString() + "()'' is not found",
ELEMENT_TEXT, new DiagnosticParameterRenderer<KotlinType>() {
@NotNull
@Override
@@ -626,7 +628,7 @@ public class DefaultErrorMessages {
MAP.put(RESULT_TYPE_MISMATCH, "{0} must return {1} but returns {2}", STRING, RENDER_TYPE, RENDER_TYPE);
MAP.put(UNSAFE_INFIX_CALL,
"Infix call corresponds to a dot-qualified call ''{0}.{1}({2})'' which is not allowed on a nullable receiver ''{0}''. " +
"Use '?.'-qualified call instead",
"Use ''?.''-qualified call instead",
STRING, STRING, STRING);
MAP.put(OVERLOAD_RESOLUTION_AMBIGUITY, "Overload resolution ambiguity: {0}", AMBIGUOUS_CALLS);
@@ -654,9 +656,10 @@ public class DefaultErrorMessages {
MAP.put(TYPE_INFERENCE_FAILED_ON_SPECIAL_CONSTRUCT, "Type inference for control flow expression failed. Please specify its type explicitly.");
MAP.put(WRONG_NUMBER_OF_TYPE_ARGUMENTS, "{0,choice,0#No type arguments|1#Type argument|1<{0,number,integer} type arguments} expected", (DiagnosticParameterRenderer) null);
MAP.put(NO_TYPE_ARGUMENTS_ON_RHS, "{0,choice,0#No type arguments|1#Type argument|1<{0,number,integer} type arguments} expected. " +
"Use ''{1}'' if you don''t want to pass type arguments", null, STRING);
String wrongNumberOfTypeArguments = "{0,choice,0#No type arguments|1#One type argument|1<{0,number,integer} type arguments} expected";
MAP.put(WRONG_NUMBER_OF_TYPE_ARGUMENTS, wrongNumberOfTypeArguments + " for {1}", null, WITHOUT_MODIFIERS);
MAP.put(NO_TYPE_ARGUMENTS_ON_RHS, wrongNumberOfTypeArguments + ". Use ''{1}'' if you don''t want to pass type arguments", null, STRING);
MAP.put(TYPE_ARGUMENTS_NOT_ALLOWED, "Type arguments are not allowed {0}", STRING);
MAP.put(TYPE_PARAMETER_AS_REIFIED, "Cannot use ''{0}'' as reified type parameter. Use a class instead.", NAME);
MAP.put(REIFIED_TYPE_PARAMETER_NO_INLINE, "Only type parameters of inline functions can be reified");
@@ -681,7 +684,7 @@ public class DefaultErrorMessages {
MAP.put(CONST_VAL_NOT_TOP_LEVEL_OR_OBJECT, "Const 'val' are only allowed on top level or in objects");
MAP.put(CONST_VAL_WITH_DELEGATE, "Const 'val' should not have a delegate");
MAP.put(CONST_VAL_WITH_GETTER, "Const 'val' should not have a getter");
MAP.put(TYPE_CANT_BE_USED_FOR_CONST_VAL, "Const 'val' has type ''{0}''. Only primitives and String are allowed", RENDER_TYPE);
MAP.put(TYPE_CANT_BE_USED_FOR_CONST_VAL, "Const ''val'' has type ''{0}''. Only primitives and String are allowed", RENDER_TYPE);
MAP.put(CONST_VAL_WITHOUT_INITIALIZER, "Const 'val' should have an initializer");
MAP.put(CONST_VAL_WITH_NON_CONST_INITIALIZER, "Const 'val' initializer should be a constant value");
MAP.put(NON_CONST_VAL_USED_IN_CONSTANT_EXPRESSION, "Only 'const val' can be used in constant expressions");
@@ -725,7 +728,7 @@ public class DefaultErrorMessages {
MAP.put(NON_PUBLIC_CALL_FROM_PUBLIC_INLINE, "Public-API inline function cannot access non-public-API ''{0}''", SHORT_NAMES_IN_TYPES, SHORT_NAMES_IN_TYPES);
MAP.put(PRIVATE_CLASS_MEMBER_FROM_INLINE, "Non-private inline function cannot access members of private classes: ''{0}''", SHORT_NAMES_IN_TYPES, SHORT_NAMES_IN_TYPES);
MAP.put(NOT_YET_SUPPORTED_IN_INLINE, "''{0}'' construction is not yet supported in inline functions", ELEMENT_TEXT, SHORT_NAMES_IN_TYPES);
MAP.put(DECLARATION_CANT_BE_INLINED, "''inline'' modifier is not allowed on virtual members. Only private or final members can be inlined");
MAP.put(DECLARATION_CANT_BE_INLINED, "'inline' modifier is not allowed on virtual members. Only private or final members can be inlined");
MAP.put(NOTHING_TO_INLINE, "Expected performance impact of inlining ''{0}'' can be insignificant. Inlining works best for functions with lambda parameters", SHORT_NAMES_IN_TYPES);
MAP.put(USAGE_IS_NOT_INLINABLE, "Illegal usage of inline-parameter ''{0}'' in ''{1}''. Add ''noinline'' modifier to the parameter declaration", ELEMENT_TEXT, SHORT_NAMES_IN_TYPES);
MAP.put(NULLABLE_INLINE_PARAMETER, "Inline-parameter ''{0}'' of ''{1}'' must not be nullable. Add ''noinline'' modifier to the parameter declaration or make its type not nullable", ELEMENT_TEXT, SHORT_NAMES_IN_TYPES);

View File

@@ -433,6 +433,9 @@ object Renderers {
@JvmField val FQ_NAMES_IN_TYPES = DescriptorRenderer.FQ_NAMES_IN_TYPES.asRenderer()
@JvmField val COMPACT = DescriptorRenderer.COMPACT.asRenderer()
@JvmField val WITHOUT_MODIFIERS = DescriptorRenderer.withOptions {
modifiers = emptySet()
}.asRenderer()
@JvmField val SHORT_NAMES_IN_TYPES = DescriptorRenderer.SHORT_NAMES_IN_TYPES.asRenderer()
@JvmField val COMPACT_WITH_MODIFIERS = DescriptorRenderer.COMPACT_WITH_MODIFIERS.asRenderer()
@JvmField val DEPRECATION_RENDERER = DescriptorRenderer.ONLY_NAMES_WITH_SHORT_TYPES.withOptions {

View File

@@ -46,9 +46,12 @@ import org.jetbrains.kotlin.kdoc.parser.KDocKnownTag;
%state TAG_BEGINNING
%state TAG_TEXT_BEGINNING
%state CONTENTS
%state CODE_BLOCK
%state CODE_BLOCK_LINE_BEGINNING
%state CODE_BLOCK_CONTENTS_BEGINNING
WHITE_SPACE_CHAR =[\ \t\f\n\r]
NOT_WHITE_SPACE_CHAR=[^\ \t\f\n\r]
WHITE_SPACE_CHAR =[\ \t\f\n]
NOT_WHITE_SPACE_CHAR=[^\ \t\f\n]
DIGIT=[0-9]
ALPHA=[:jletter:]
@@ -58,6 +61,8 @@ QUALIFIED_NAME_START={ALPHA}
QUALIFIED_NAME_CHAR={ALPHA}|{DIGIT}|[\.]
QUALIFIED_NAME={QUALIFIED_NAME_START}{QUALIFIED_NAME_CHAR}*
CODE_LINK=\[{QUALIFIED_NAME}\]
CODE_FENCE_START=("```" | "~~~").*
CODE_FENCE_END=("```" | "~~~")
%%
@@ -143,6 +148,11 @@ CODE_LINK=\[{QUALIFIED_NAME}\]
return KDocTokens.MARKDOWN_INLINE_LINK;
}
{CODE_FENCE_START} {
yybegin(CODE_BLOCK_LINE_BEGINNING);
return KDocTokens.TEXT;
}
/* We're only interested in parsing links that can become code references,
meaning they contain only identifier characters and characters that can be
used in type declarations. No brackets, backticks, asterisks or anything like that.
@@ -155,4 +165,47 @@ CODE_LINK=\[{QUALIFIED_NAME}\]
return KDocTokens.TEXT; }
}
<CODE_BLOCK_LINE_BEGINNING> {
"*"+ {
yybegin(CODE_BLOCK_CONTENTS_BEGINNING);
return KDocTokens.LEADING_ASTERISK;
}
}
<CODE_BLOCK_LINE_BEGINNING, CODE_BLOCK_CONTENTS_BEGINNING> {
{CODE_FENCE_END} / [ \t\f]* [\n] [ \t\f]* {
// Code fence end
yybegin(CONTENTS);
return KDocTokens.TEXT;
}
{WHITE_SPACE_CHAR}+ {
if (yytextContainLineBreaks()) {
yybegin(CODE_BLOCK_LINE_BEGINNING);
return TokenType.WHITE_SPACE;
}
return KDocTokens.TEXT;
}
. {
yybegin(CODE_BLOCK);
return KDocTokens.TEXT;
}
}
<CODE_BLOCK_LINE_BEGINNING, CODE_BLOCK_CONTENTS_BEGINNING, CODE_BLOCK> {
{WHITE_SPACE_CHAR}+ {
if (yytextContainLineBreaks()) {
yybegin(CODE_BLOCK_LINE_BEGINNING);
return TokenType.WHITE_SPACE;
}
return KDocTokens.TEXT;
}
. {
yybegin(CODE_BLOCK);
return KDocTokens.TEXT;
}
}
. { return TokenType.BAD_CHARACTER; }

View File

@@ -1,4 +1,4 @@
/* The following code was generated by JFlex 1.4.3 on 12/9/15 7:45 PM */
/* The following code was generated by JFlex 1.4.3 on 4/5/16 7:39 PM */
package org.jetbrains.kotlin.kdoc.lexer;
@@ -6,25 +6,29 @@ import com.intellij.lexer.FlexLexer;
import com.intellij.psi.TokenType;
import com.intellij.psi.tree.IElementType;
import com.intellij.util.text.CharArrayUtil;
import java.lang.Character;
import org.jetbrains.kotlin.kdoc.parser.KDocKnownTag;
/**
* This class is a scanner generated by
* <a href="http://www.jflex.de/">JFlex</a> 1.4.3
* on 12/9/15 7:45 PM from the specification file
* <tt>/home/user/projects/kotlin/compiler/frontend/src/org/jetbrains/kotlin/kdoc/lexer/KDoc.flex</tt>
* on 4/5/16 7:39 PM from the specification file
* <tt>/Users/yole/jetbrains/kotlin/compiler/frontend/src/org/jetbrains/kotlin/kdoc/lexer/KDoc.flex</tt>
*/
class _KDocLexer implements FlexLexer {
/** initial size of the lookahead buffer */
private static final int ZZ_BUFFERSIZE = 16384;
/** lexical states */
public static final int CODE_BLOCK_CONTENTS_BEGINNING = 16;
public static final int TAG_TEXT_BEGINNING = 8;
public static final int CODE_BLOCK = 12;
public static final int CODE_BLOCK_LINE_BEGINNING = 14;
public static final int CONTENTS_BEGINNING = 4;
public static final int LINE_BEGINNING = 2;
public static final int CONTENTS = 10;
public static final int YYINITIAL = 0;
public static final int TAG_TEXT_BEGINNING = 8;
public static final int LINE_BEGINNING = 2;
public static final int TAG_BEGINNING = 6;
/**
@@ -34,92 +38,75 @@ class _KDocLexer implements FlexLexer {
* l is of the form l = 2*k, k a non negative integer
*/
private static final int ZZ_LEXSTATE[] = {
0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5
0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7,
8, 8
};
/**
* Translates characters to character classes
*/
private static final String ZZ_CMAP_PACKED =
"\11\0\1\1\1\12\1\0\2\1\22\0\1\1\3\0\1\3\3\0"+
"\1\14\1\15\1\10\3\0\1\4\1\7\12\2\6\0\1\11\32\3"+
"\1\5\1\13\1\6\1\0\1\3\1\0\32\3\47\0\4\3\4\0"+
"\1\3\12\0\1\3\4\0\1\3\5\0\27\3\1\0\37\3\1\0"+
"\u01ca\3\4\0\14\3\16\0\5\3\7\0\1\3\1\0\1\3\201\0"+
"\5\3\1\0\2\3\2\0\4\3\10\0\1\3\1\0\3\3\1\0"+
"\1\3\1\0\24\3\1\0\123\3\1\0\213\3\10\0\236\3\11\0"+
"\46\3\2\0\1\3\7\0\47\3\110\0\33\3\5\0\3\3\30\0"+
"\1\3\24\0\53\3\43\0\2\3\1\0\143\3\1\0\1\3\17\0"+
"\2\3\7\0\2\3\12\0\3\3\2\0\1\3\20\0\1\3\1\0"+
"\36\3\35\0\131\3\13\0\1\3\30\0\41\3\11\0\2\3\4\0"+
"\1\3\5\0\26\3\4\0\1\3\11\0\1\3\3\0\1\3\27\0"+
"\31\3\253\0\66\3\3\0\1\3\22\0\1\3\7\0\12\3\17\0"+
"\7\3\1\0\7\3\5\0\10\3\2\0\2\3\2\0\26\3\1\0"+
"\7\3\1\0\1\3\3\0\4\3\3\0\1\3\20\0\1\3\15\0"+
"\2\3\1\0\3\3\16\0\4\3\7\0\1\3\11\0\6\3\4\0"+
"\2\3\2\0\26\3\1\0\7\3\1\0\2\3\1\0\2\3\1\0"+
"\2\3\37\0\4\3\1\0\1\3\23\0\3\3\20\0\11\3\1\0"+
"\3\3\1\0\26\3\1\0\7\3\1\0\2\3\1\0\5\3\3\0"+
"\1\3\22\0\1\3\17\0\2\3\17\0\1\3\23\0\10\3\2\0"+
"\2\3\2\0\26\3\1\0\7\3\1\0\2\3\1\0\5\3\3\0"+
"\1\3\36\0\2\3\1\0\3\3\17\0\1\3\21\0\1\3\1\0"+
"\6\3\3\0\3\3\1\0\4\3\3\0\2\3\1\0\1\3\1\0"+
"\2\3\3\0\2\3\3\0\3\3\3\0\14\3\26\0\1\3\50\0"+
"\1\3\13\0\10\3\1\0\3\3\1\0\27\3\1\0\12\3\1\0"+
"\5\3\3\0\1\3\32\0\2\3\6\0\2\3\43\0\10\3\1\0"+
"\3\3\1\0\27\3\1\0\12\3\1\0\5\3\3\0\1\3\40\0"+
"\1\3\1\0\2\3\17\0\2\3\22\0\10\3\1\0\3\3\1\0"+
"\51\3\2\0\1\3\20\0\1\3\21\0\2\3\30\0\6\3\5\0"+
"\22\3\3\0\30\3\1\0\11\3\1\0\1\3\2\0\7\3\72\0"+
"\60\3\1\0\2\3\13\0\10\3\72\0\2\3\1\0\1\3\2\0"+
"\2\3\1\0\1\3\2\0\1\3\6\0\4\3\1\0\7\3\1\0"+
"\3\3\1\0\1\3\1\0\1\3\2\0\2\3\1\0\4\3\1\0"+
"\2\3\11\0\1\3\2\0\5\3\1\0\1\3\25\0\2\3\42\0"+
"\1\3\77\0\10\3\1\0\44\3\33\0\5\3\163\0\53\3\24\0"+
"\1\3\20\0\6\3\4\0\4\3\3\0\1\3\3\0\2\3\7\0"+
"\3\3\4\0\15\3\14\0\1\3\21\0\46\3\12\0\53\3\1\0"+
"\1\3\3\0\u0149\3\1\0\4\3\2\0\7\3\1\0\1\3\1\0"+
"\4\3\2\0\51\3\1\0\4\3\2\0\41\3\1\0\4\3\2\0"+
"\7\3\1\0\1\3\1\0\4\3\2\0\17\3\1\0\71\3\1\0"+
"\4\3\2\0\103\3\45\0\20\3\20\0\125\3\14\0\u026c\3\2\0"+
"\21\3\1\0\32\3\5\0\113\3\3\0\3\3\17\0\15\3\1\0"+
"\4\3\16\0\22\3\16\0\22\3\16\0\15\3\1\0\3\3\17\0"+
"\64\3\43\0\1\3\3\0\2\3\103\0\130\3\10\0\51\3\1\0"+
"\1\3\5\0\106\3\12\0\35\3\63\0\36\3\2\0\5\3\13\0"+
"\54\3\25\0\7\3\70\0\27\3\11\0\65\3\122\0\1\3\135\0"+
"\57\3\21\0\7\3\67\0\36\3\15\0\2\3\20\0\46\3\32\0"+
"\44\3\51\0\3\3\12\0\44\3\153\0\4\3\1\0\4\3\16\0"+
"\300\3\100\0\u0116\3\2\0\6\3\2\0\46\3\2\0\6\3\2\0"+
"\10\3\1\0\1\3\1\0\1\3\1\0\1\3\1\0\37\3\2\0"+
"\65\3\1\0\7\3\1\0\1\3\3\0\3\3\1\0\7\3\3\0"+
"\4\3\2\0\6\3\4\0\15\3\5\0\3\3\1\0\7\3\102\0"+
"\2\3\23\0\1\3\34\0\1\3\15\0\1\3\20\0\15\3\3\0"+
"\32\3\110\0\1\3\4\0\1\3\2\0\12\3\1\0\1\3\3\0"+
"\5\3\6\0\1\3\1\0\1\3\1\0\1\3\1\0\4\3\1\0"+
"\13\3\2\0\4\3\5\0\5\3\4\0\1\3\21\0\51\3\u0a77\0"+
"\57\3\1\0\57\3\1\0\205\3\6\0\4\3\21\0\46\3\12\0"+
"\66\3\11\0\1\3\20\0\27\3\11\0\7\3\1\0\7\3\1\0"+
"\7\3\1\0\7\3\1\0\7\3\1\0\7\3\1\0\7\3\1\0"+
"\7\3\120\0\1\3\u01d5\0\3\3\31\0\11\3\7\0\5\3\2\0"+
"\5\3\4\0\126\3\6\0\3\3\1\0\132\3\1\0\4\3\5\0"+
"\51\3\3\0\136\3\21\0\33\3\65\0\20\3\u0200\0\u19b6\3\112\0"+
"\u51cc\3\64\0\u048d\3\103\0\56\3\2\0\u010d\3\3\0\20\3\12\0"+
"\2\3\24\0\57\3\20\0\31\3\10\0\120\3\47\0\11\3\2\0"+
"\147\3\2\0\4\3\1\0\2\3\16\0\12\3\120\0\10\3\1\0"+
"\3\3\1\0\4\3\1\0\27\3\25\0\1\3\7\0\64\3\16\0"+
"\62\3\76\0\6\3\3\0\1\3\16\0\34\3\12\0\27\3\31\0"+
"\35\3\7\0\57\3\34\0\1\3\60\0\51\3\27\0\3\3\1\0"+
"\10\3\24\0\27\3\3\0\1\3\5\0\60\3\1\0\1\3\3\0"+
"\2\3\2\0\5\3\2\0\1\3\1\0\1\3\30\0\3\3\43\0"+
"\6\3\2\0\6\3\2\0\6\3\11\0\7\3\1\0\7\3\221\0"+
"\43\3\35\0\u2ba4\3\14\0\27\3\4\0\61\3\u2104\0\u012e\3\2\0"+
"\76\3\2\0\152\3\46\0\7\3\14\0\5\3\5\0\1\3\1\0"+
"\12\3\1\0\15\3\1\0\5\3\1\0\1\3\1\0\2\3\1\0"+
"\2\3\1\0\154\3\41\0\u016b\3\22\0\100\3\2\0\66\3\50\0"+
"\15\3\66\0\2\3\30\0\3\3\31\0\1\3\6\0\5\3\1\0"+
"\207\3\7\0\1\3\34\0\32\3\4\0\1\3\1\0\32\3\13\0"+
"\131\3\3\0\6\3\2\0\6\3\2\0\6\3\2\0\3\3\3\0"+
"\2\3\3\0\2\3\31\0";
"\11\0\1\1\1\11\1\0\1\1\23\0\1\1\3\0\1\3\3\0"+
"\1\16\1\17\1\13\3\0\1\4\1\12\12\2\6\0\1\14\32\3"+
"\1\5\1\15\1\6\1\0\1\3\1\7\32\3\3\0\1\10\43\0"+
"\4\3\4\0\1\3\12\0\1\3\4\0\1\3\5\0\27\3\1\0"+
"\37\3\1\0\u013f\3\31\0\162\3\4\0\14\3\16\0\5\3\11\0"+
"\1\3\213\0\1\3\13\0\1\3\1\0\3\3\1\0\1\3\1\0"+
"\24\3\1\0\54\3\1\0\46\3\1\0\5\3\4\0\202\3\10\0"+
"\105\3\1\0\46\3\2\0\2\3\6\0\20\3\41\0\46\3\2\0"+
"\1\3\7\0\47\3\110\0\33\3\5\0\3\3\56\0\32\3\5\0"+
"\13\3\43\0\2\3\1\0\143\3\1\0\1\3\17\0\2\3\7\0"+
"\2\3\12\0\3\3\2\0\1\3\20\0\1\3\1\0\36\3\35\0"+
"\3\3\60\0\46\3\13\0\1\3\u0152\0\66\3\3\0\1\3\22\0"+
"\1\3\7\0\12\3\43\0\10\3\2\0\2\3\2\0\26\3\1\0"+
"\7\3\1\0\1\3\3\0\4\3\3\0\1\3\36\0\2\3\1\0"+
"\3\3\16\0\4\3\21\0\6\3\4\0\2\3\2\0\26\3\1\0"+
"\7\3\1\0\2\3\1\0\2\3\1\0\2\3\37\0\4\3\1\0"+
"\1\3\23\0\3\3\20\0\11\3\1\0\3\3\1\0\26\3\1\0"+
"\7\3\1\0\2\3\1\0\5\3\3\0\1\3\22\0\1\3\17\0"+
"\2\3\17\0\1\3\23\0\10\3\2\0\2\3\2\0\26\3\1\0"+
"\7\3\1\0\2\3\1\0\5\3\3\0\1\3\36\0\2\3\1\0"+
"\3\3\17\0\1\3\21\0\1\3\1\0\6\3\3\0\3\3\1\0"+
"\4\3\3\0\2\3\1\0\1\3\1\0\2\3\3\0\2\3\3\0"+
"\3\3\3\0\10\3\1\0\3\3\77\0\1\3\13\0\10\3\1\0"+
"\3\3\1\0\27\3\1\0\12\3\1\0\5\3\46\0\2\3\43\0"+
"\10\3\1\0\3\3\1\0\27\3\1\0\12\3\1\0\5\3\3\0"+
"\1\3\40\0\1\3\1\0\2\3\43\0\10\3\1\0\3\3\1\0"+
"\27\3\1\0\20\3\46\0\2\3\43\0\22\3\3\0\30\3\1\0"+
"\11\3\1\0\1\3\2\0\7\3\72\0\60\3\1\0\2\3\13\0"+
"\10\3\72\0\2\3\1\0\1\3\2\0\2\3\1\0\1\3\2\0"+
"\1\3\6\0\4\3\1\0\7\3\1\0\3\3\1\0\1\3\1\0"+
"\1\3\2\0\2\3\1\0\4\3\1\0\2\3\11\0\1\3\2\0"+
"\5\3\1\0\1\3\25\0\2\3\42\0\1\3\77\0\10\3\1\0"+
"\42\3\35\0\4\3\164\0\42\3\1\0\5\3\1\0\2\3\45\0"+
"\6\3\112\0\46\3\12\0\51\3\7\0\132\3\5\0\104\3\5\0"+
"\122\3\6\0\7\3\1\0\77\3\1\0\1\3\1\0\4\3\2\0"+
"\7\3\1\0\1\3\1\0\4\3\2\0\47\3\1\0\1\3\1\0"+
"\4\3\2\0\37\3\1\0\1\3\1\0\4\3\2\0\7\3\1\0"+
"\1\3\1\0\4\3\2\0\7\3\1\0\7\3\1\0\27\3\1\0"+
"\37\3\1\0\1\3\1\0\4\3\2\0\7\3\1\0\47\3\1\0"+
"\23\3\105\0\125\3\14\0\u026c\3\2\0\10\3\12\0\32\3\5\0"+
"\113\3\3\0\3\3\17\0\15\3\1\0\4\3\16\0\22\3\16\0"+
"\22\3\16\0\15\3\1\0\3\3\17\0\64\3\43\0\1\3\3\0"+
"\2\3\103\0\130\3\10\0\51\3\127\0\35\3\63\0\36\3\2\0"+
"\5\3\u038b\0\154\3\224\0\234\3\4\0\132\3\6\0\26\3\2\0"+
"\6\3\2\0\46\3\2\0\6\3\2\0\10\3\1\0\1\3\1\0"+
"\1\3\1\0\1\3\1\0\37\3\2\0\65\3\1\0\7\3\1\0"+
"\1\3\3\0\3\3\1\0\7\3\3\0\4\3\2\0\6\3\4\0"+
"\15\3\5\0\3\3\1\0\7\3\102\0\2\3\23\0\1\3\34\0"+
"\1\3\15\0\1\3\40\0\22\3\120\0\1\3\4\0\1\3\2\0"+
"\12\3\1\0\1\3\3\0\5\3\6\0\1\3\1\0\1\3\1\0"+
"\1\3\1\0\4\3\1\0\3\3\1\0\7\3\3\0\3\3\5\0"+
"\5\3\26\0\44\3\u0e81\0\3\3\31\0\11\3\7\0\5\3\2\0"+
"\5\3\4\0\126\3\6\0\3\3\1\0\137\3\5\0\50\3\4\0"+
"\136\3\21\0\30\3\70\0\20\3\u0200\0\u19b6\3\112\0\u51a6\3\132\0"+
"\u048d\3\u0773\0\u2ba4\3\u215c\0\u012e\3\2\0\73\3\225\0\7\3\14\0"+
"\5\3\5\0\1\3\1\0\12\3\1\0\15\3\1\0\5\3\1\0"+
"\1\3\1\0\2\3\1\0\2\3\1\0\154\3\41\0\u016b\3\22\0"+
"\100\3\2\0\66\3\50\0\15\3\66\0\2\3\30\0\3\3\31\0"+
"\1\3\6\0\5\3\1\0\207\3\7\0\1\3\34\0\32\3\4\0"+
"\1\3\1\0\32\3\12\0\132\3\3\0\6\3\2\0\6\3\2\0"+
"\6\3\2\0\3\3\3\0\2\3\3\0\2\3\31\0";
/**
* Translates characters to character classes
@@ -132,12 +119,13 @@ class _KDocLexer implements FlexLexer {
private static final int [] ZZ_ACTION = zzUnpackAction();
private static final String ZZ_ACTION_PACKED_0 =
"\6\0\3\1\1\2\1\3\1\2\1\4\3\2\1\5"+
"\1\6\1\7\3\5\1\0\1\10\4\0\1\11\1\12"+
"\2\0\1\13\2\0\1\14\1\15\2\16\1\0\2\17";
"\11\0\3\1\1\2\1\3\3\2\1\4\3\2\1\5"+
"\1\6\1\7\3\5\1\10\1\11\3\10\1\12\1\0"+
"\1\13\6\0\1\14\1\15\4\0\1\16\2\0\1\17"+
"\1\20\1\21\1\0\2\22\1\0\1\23\1\24\1\23";
private static int [] zzUnpackAction() {
int [] result = new int[42];
int [] result = new int[60];
int offset = 0;
offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result);
return result;
@@ -162,15 +150,17 @@ class _KDocLexer implements FlexLexer {
private static final int [] ZZ_ROWMAP = zzUnpackRowMap();
private static final String ZZ_ROWMAP_PACKED_0 =
"\0\0\0\16\0\34\0\52\0\70\0\106\0\124\0\142"+
"\0\160\0\124\0\176\0\214\0\232\0\250\0\160\0\266"+
"\0\124\0\304\0\322\0\340\0\160\0\356\0\374\0\124"+
"\0\160\0\u010a\0\u0118\0\u0126\0\124\0\u0134\0\u0142\0\u0150"+
"\0\124\0\u015e\0\u016c\0\124\0\124\0\u010a\0\u0126\0\u017a"+
"\0\u010a\0\124";
"\0\0\0\20\0\40\0\60\0\100\0\120\0\140\0\160"+
"\0\200\0\220\0\240\0\260\0\220\0\300\0\320\0\340"+
"\0\360\0\u0100\0\u0110\0\260\0\u0120\0\220\0\u0130\0\u0140"+
"\0\u0150\0\260\0\u0160\0\220\0\u0170\0\260\0\u0180\0\u0190"+
"\0\u01a0\0\u01b0\0\220\0\260\0\u01c0\0\u01d0\0\u01e0\0\u01f0"+
"\0\u0200\0\220\0\u0210\0\u0220\0\u0230\0\u0240\0\u0250\0\220"+
"\0\u0260\0\u0270\0\u0280\0\220\0\220\0\u0290\0\u01c0\0\u01e0"+
"\0\u02a0\0\u01c0\0\u02b0\0\220";
private static int [] zzUnpackRowMap() {
int [] result = new int[42];
int [] result = new int[60];
int offset = 0;
offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result);
return result;
@@ -193,25 +183,33 @@ class _KDocLexer implements FlexLexer {
private static final int [] ZZ_TRANS = zzUnpackTrans();
private static final String ZZ_TRANS_PACKED_0 =
"\7\7\1\10\1\11\1\7\1\0\3\7\1\12\1\13"+
"\3\12\1\14\2\12\1\15\1\12\1\13\1\16\3\12"+
"\1\13\3\12\1\14\2\12\1\17\1\20\1\13\1\16"+
"\2\12\1\21\1\22\1\21\1\23\1\21\1\24\2\21"+
"\1\25\1\21\1\22\4\21\1\22\3\21\1\26\2\21"+
"\1\25\1\21\1\22\3\21\1\12\1\13\3\12\1\14"+
"\2\12\1\17\1\12\1\13\1\16\2\12\26\0\1\27"+
"\14\0\1\30\1\31\6\0\1\13\10\0\1\13\3\0"+
"\3\32\1\33\1\32\1\0\1\34\7\32\7\0\1\30"+
"\1\15\12\0\2\35\12\0\1\36\13\0\1\22\10\0"+
"\1\22\5\0\3\23\14\0\1\37\15\0\1\40\22\0"+
"\1\41\5\0\5\32\1\0\1\34\11\32\3\33\1\0"+
"\1\42\14\32\1\0\1\34\5\32\1\43\1\32\2\0"+
"\2\36\14\0\3\37\1\0\1\44\11\0\3\40\1\0"+
"\1\45\7\0\5\46\1\0\1\47\5\46\1\43\1\46"+
"\5\43\1\50\7\43\1\51\15\50\1\52";
"\11\12\1\0\1\13\1\14\4\12\1\15\1\16\3\15"+
"\1\17\1\15\1\20\1\21\1\16\1\15\1\22\1\15"+
"\1\23\3\15\1\16\3\15\1\17\1\15\1\20\1\21"+
"\1\16\1\15\1\24\1\25\1\23\2\15\1\26\1\27"+
"\1\26\1\30\1\26\1\31\3\26\1\27\1\26\1\32"+
"\5\26\1\27\3\26\1\33\3\26\1\27\1\26\1\32"+
"\4\26\1\15\1\16\3\15\1\17\1\15\1\20\1\21"+
"\1\16\1\15\1\24\1\15\1\23\2\15\1\34\1\35"+
"\7\34\1\35\1\34\1\36\5\34\1\35\5\34\1\37"+
"\1\40\1\35\1\34\1\41\5\34\1\35\5\34\1\37"+
"\1\40\1\35\1\34\1\36\4\34\33\0\1\42\16\0"+
"\1\43\1\44\5\0\1\16\7\0\1\16\6\0\3\45"+
"\1\46\1\45\1\0\1\47\11\45\7\0\1\50\20\0"+
"\1\51\21\0\1\43\1\22\11\0\2\52\14\0\1\53"+
"\15\0\1\27\7\0\1\27\10\0\3\30\16\0\1\54"+
"\17\0\1\55\15\0\1\35\7\0\1\35\15\0\1\56"+
"\20\0\1\57\21\0\1\43\1\41\17\0\1\60\4\0"+
"\5\45\1\0\1\47\13\45\3\46\1\0\1\61\16\45"+
"\1\0\1\47\7\45\1\62\1\45\7\0\1\63\20\0"+
"\1\63\11\0\2\53\16\0\3\54\1\0\1\64\13\0"+
"\3\55\1\0\1\65\20\0\1\66\20\0\1\66\7\0"+
"\5\67\1\0\1\70\7\67\1\62\1\67\5\62\1\71"+
"\11\62\1\72\11\63\1\0\6\63\1\0\1\66\7\0"+
"\1\73\6\0\17\71\1\74\1\0\1\73\16\0";
private static int [] zzUnpackTrans() {
int [] result = new int[392];
int [] result = new int[704];
int offset = 0;
offset = zzUnpackTrans(ZZ_TRANS_PACKED_0, offset, result);
return result;
@@ -252,12 +250,12 @@ class _KDocLexer implements FlexLexer {
private static final int [] ZZ_ATTRIBUTE = zzUnpackAttribute();
private static final String ZZ_ATTRIBUTE_PACKED_0 =
"\6\0\1\11\2\1\1\11\6\1\1\11\5\1\1\0"+
"\1\11\4\0\1\11\1\1\2\0\1\11\2\0\2\11"+
"\2\1\1\0\1\1\1\11";
"\11\0\1\11\2\1\1\11\10\1\1\11\5\1\1\11"+
"\5\1\1\0\1\11\6\0\1\11\1\1\4\0\1\11"+
"\2\0\1\1\2\11\1\0\2\1\1\0\2\1\1\11";
private static int [] zzUnpackAttribute() {
int [] result = new int[42];
int [] result = new int[60];
int offset = 0;
offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result);
return result;
@@ -357,7 +355,7 @@ class _KDocLexer implements FlexLexer {
char [] map = new char[0x10000];
int i = 0; /* index in packed string */
int j = 0; /* index in unpacked array */
while (i < 1568) {
while (i < 1216) {
int count = packed.charAt(i++);
char value = packed.charAt(i++);
do map[j++] = value; while (--count > 0);
@@ -580,12 +578,82 @@ class _KDocLexer implements FlexLexer {
zzMarkedPos = zzMarkedPosL;
switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
case 10:
case 15:
{ yybegin(CODE_BLOCK_LINE_BEGINNING);
return KDocTokens.TEXT;
}
case 21: break;
case 13:
{ KDocKnownTag tag = KDocKnownTag.findByTagName(zzBuffer.subSequence(zzStartRead, zzMarkedPos));
yybegin(tag != null && tag.isReferenceRequired() ? TAG_BEGINNING : TAG_TEXT_BEGINNING);
return KDocTokens.TAG_NAME;
}
case 16: break;
case 22: break;
case 10:
{ yybegin(CODE_BLOCK_CONTENTS_BEGINNING);
return KDocTokens.LEADING_ASTERISK;
}
case 23: break;
case 1:
{ return TokenType.BAD_CHARACTER;
}
case 24: break;
case 14:
{ yybegin(CONTENTS_BEGINNING);
return KDocTokens.START;
}
case 25: break;
case 2:
{ yybegin(CONTENTS);
return KDocTokens.TEXT;
}
case 26: break;
case 9:
{ if (yytextContainLineBreaks()) {
yybegin(CODE_BLOCK_LINE_BEGINNING);
return TokenType.WHITE_SPACE;
}
return KDocTokens.TEXT;
}
case 27: break;
case 20:
// lookahead expression with fixed base length
zzMarkedPos = zzStartRead + 3;
{ // Code fence end
yybegin(CONTENTS);
return KDocTokens.TEXT;
}
case 28: break;
case 19:
{ yybegin(CONTENTS);
return KDocTokens.MARKDOWN_INLINE_LINK;
}
case 29: break;
case 5:
{ yybegin(CONTENTS);
return KDocTokens.TEXT;
}
case 30: break;
case 12:
{ yybegin(CONTENTS);
return KDocTokens.MARKDOWN_ESCAPED_CHAR;
}
case 31: break;
case 16:
{ yybegin(TAG_TEXT_BEGINNING);
return KDocTokens.MARKDOWN_LINK;
}
case 32: break;
case 4:
{ yybegin(CONTENTS_BEGINNING);
return KDocTokens.LEADING_ASTERISK;
}
case 33: break;
case 8:
{ yybegin(CODE_BLOCK);
return KDocTokens.TEXT;
}
case 34: break;
case 3:
{ if (yytextContainLineBreaks()) {
yybegin(LINE_BEGINNING);
@@ -595,75 +663,36 @@ class _KDocLexer implements FlexLexer {
return KDocTokens.TEXT; // internal white space
}
}
case 17: break;
case 11:
{ yybegin(CONTENTS_BEGINNING);
return KDocTokens.START;
}
case 18: break;
case 15:
case 35: break;
case 18:
// lookahead expression with fixed lookahead length
yypushback(1);
{ yybegin(CONTENTS);
return KDocTokens.MARKDOWN_INLINE_LINK;
return KDocTokens.MARKDOWN_LINK;
}
case 19: break;
case 8:
case 36: break;
case 17:
{ yybegin(CONTENTS);
return KDocTokens.MARKDOWN_LINK;
}
case 37: break;
case 11:
{ if (isLastToken()) return KDocTokens.END;
else return KDocTokens.TEXT;
}
case 20: break;
case 5:
{ yybegin(CONTENTS);
return KDocTokens.TEXT;
}
case 21: break;
case 12:
{ yybegin(TAG_TEXT_BEGINNING);
return KDocTokens.MARKDOWN_LINK;
}
case 22: break;
case 38: break;
case 7:
{ yybegin(TAG_TEXT_BEGINNING);
return KDocTokens.MARKDOWN_LINK;
}
case 23: break;
case 39: break;
case 6:
{ if (yytextContainLineBreaks()) {
yybegin(LINE_BEGINNING);
}
return TokenType.WHITE_SPACE;
}
case 24: break;
case 14:
// lookahead expression with fixed lookahead length
yypushback(1);
{ yybegin(CONTENTS);
return KDocTokens.MARKDOWN_LINK;
}
case 25: break;
case 13:
{ yybegin(CONTENTS);
return KDocTokens.MARKDOWN_LINK;
}
case 26: break;
case 1:
{ return TokenType.BAD_CHARACTER;
}
case 27: break;
case 9:
{ yybegin(CONTENTS);
return KDocTokens.MARKDOWN_ESCAPED_CHAR;
}
case 28: break;
case 2:
{ yybegin(CONTENTS);
return KDocTokens.TEXT;
}
case 29: break;
case 4:
{ yybegin(CONTENTS_BEGINNING);
return KDocTokens.LEADING_ASTERISK;
}
case 30: break;
case 40: break;
default:
if (zzInput == YYEOF && zzStartRead == zzCurrentPos) {
zzAtEOF = true;

View File

@@ -9,7 +9,7 @@ import com.intellij.util.containers.Stack;
/**
* This class is a scanner generated by
* This class is a scanner generated by
* <a href="http://www.jflex.de/">JFlex</a> 1.4.3
* on 12/9/15 7:45 PM from the specification file
* <tt>/home/user/projects/kotlin/compiler/frontend/src/org/jetbrains/kotlin/lexer/Kotlin.flex</tt>
@@ -33,14 +33,14 @@ class _JetLexer implements FlexLexer {
* at the beginning of a line
* l is of the form l = 2*k, k a non negative integer
*/
private static final int ZZ_LEXSTATE[] = {
private static final int ZZ_LEXSTATE[] = {
0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 4, 4, 5, 5
};
/**
/**
* Translates characters to character classes
*/
private static final String ZZ_CMAP_PACKED =
private static final String ZZ_CMAP_PACKED =
"\11\0\1\3\1\7\1\0\1\3\23\0\1\3\1\13\1\27\1\12"+
"\1\10\1\67\1\65\1\24\1\73\1\74\1\36\1\62\1\76\1\23"+
"\1\20\1\11\1\14\11\1\1\70\1\75\1\63\1\60\1\64\1\61"+
@@ -128,12 +128,12 @@ class _JetLexer implements FlexLexer {
"\32\4\13\0\131\4\3\0\6\4\2\0\6\4\2\0\6\4\2\0"+
"\3\4\43\0";
/**
/**
* Translates characters to character classes
*/
private static final char [] ZZ_CMAP = zzUnpackCMap(ZZ_CMAP_PACKED);
/**
/**
* Translates DFA states to action switch labels.
*/
private static final int [] ZZ_ACTION = zzUnpackAction();
@@ -181,7 +181,7 @@ class _JetLexer implements FlexLexer {
}
/**
/**
* Translates a state to a row index in the transition table
*/
private static final int [] ZZ_ROWMAP = zzUnpackRowMap();
@@ -236,7 +236,7 @@ class _JetLexer implements FlexLexer {
return j;
}
/**
/**
* The transition table of the DFA
*/
private static final int [] ZZ_TRANS = zzUnpackTrans();
@@ -618,7 +618,7 @@ class _JetLexer implements FlexLexer {
private final Stack<State> states = new Stack<State>();
private int lBraceCount;
private int commentStart;
private int commentDepth;
@@ -656,7 +656,7 @@ class _JetLexer implements FlexLexer {
}
/**
/**
* Unpacks the compressed character translation table.
*
* @param packed the packed character translation table

View File

@@ -564,7 +564,7 @@ public class KotlinParsing extends AbstractKotlinParsing {
* : "get"
* : "set"
* : "param"
* : "sparam"
* : "setparam"
* ;
*/
private boolean parseAnnotationOrList(AnnotationParsingMode mode) {

View File

@@ -62,7 +62,7 @@ open class KtClass : KtClassOrObject {
}
protected fun getQualifiedName(): String? {
val stub = getStub()
val stub = stub
if (stub != null) {
val fqName = stub.getFqName()
return fqName?.asString()
@@ -71,12 +71,12 @@ open class KtClass : KtClassOrObject {
val parts = ArrayList<String>()
var current: KtClassOrObject? = this
while (current != null) {
parts.add(current.getName()!!)
parts.add(current.name!!)
current = PsiTreeUtil.getParentOfType<KtClassOrObject>(current, KtClassOrObject::class.java)
}
val file = getContainingFile()
val file = containingFile
if (file !is KtFile) return null
val fileQualifiedName = file.getPackageFqName().asString()
val fileQualifiedName = file.packageFqName.asString()
if (!fileQualifiedName.isEmpty()) {
parts.add(fileQualifiedName)
}

View File

@@ -34,24 +34,28 @@ abstract class KtClassOrObject :
constructor(stub: KotlinClassOrObjectStub<out KtClassOrObject>, nodeType: IStubElementType<*, *>) : super(stub, nodeType)
fun getSuperTypeList(): KtSuperTypeList? = getStubOrPsiChild(KtStubElementTypes.SUPER_TYPE_LIST)
open fun getSuperTypeListEntries(): List<KtSuperTypeListEntry> = getSuperTypeList()?.getEntries().orEmpty()
open fun getSuperTypeListEntries(): List<KtSuperTypeListEntry> = getSuperTypeList()?.entries.orEmpty()
fun addSuperTypeListEntry(superTypeListEntry: KtSuperTypeListEntry): KtSuperTypeListEntry {
getSuperTypeList()?.let {
val single = it.entries.singleOrNull()
if (single != null && single.typeReference?.typeElement == null) {
return single.replace(superTypeListEntry) as KtSuperTypeListEntry
}
return EditCommaSeparatedListHelper.addItem(it, getSuperTypeListEntries(), superTypeListEntry)
}
val psiFactory = KtPsiFactory(this)
val specifierListToAdd = psiFactory.createSuperTypeCallEntry("A()").replace(superTypeListEntry).getParent()
val specifierListToAdd = psiFactory.createSuperTypeCallEntry("A()").replace(superTypeListEntry).parent
val colon = addBefore(psiFactory.createColon(), getBody())
return (addAfter(specifierListToAdd, colon) as KtSuperTypeList).getEntries().first()
return (addAfter(specifierListToAdd, colon) as KtSuperTypeList).entries.first()
}
fun removeSuperTypeListEntry(superTypeListEntry: KtSuperTypeListEntry) {
val specifierList = getSuperTypeList() ?: return
assert(superTypeListEntry.getParent() === specifierList)
assert(superTypeListEntry.parent === specifierList)
if (specifierList.getEntries().size > 1) {
if (specifierList.entries.size > 1) {
EditCommaSeparatedListHelper.removeItem<KtElement>(superTypeListEntry)
}
else {
@@ -63,35 +67,35 @@ abstract class KtClassOrObject :
fun getBody(): KtClassBody? = getStubOrPsiChild(KtStubElementTypes.CLASS_BODY)
fun addDeclaration(declaration: KtDeclaration): KtDeclaration {
inline fun <reified T: KtDeclaration> addDeclaration(declaration: T): T {
val body = getOrCreateBody()
val anchor = PsiTreeUtil.skipSiblingsBackward(body.rBrace ?: body.getLastChild()!!, PsiWhiteSpace::class.java)
return body.addAfter(declaration, anchor) as KtDeclaration
val anchor = PsiTreeUtil.skipSiblingsBackward(body.rBrace ?: body.lastChild!!, PsiWhiteSpace::class.java)
return body.addAfter(declaration, anchor) as T
}
fun addDeclarationAfter(declaration: KtDeclaration, anchor: PsiElement?): KtDeclaration {
val anchorBefore = anchor ?: getDeclarations().lastOrNull() ?: return addDeclaration(declaration)
return getOrCreateBody().addAfter(declaration, anchorBefore) as KtDeclaration
inline fun <reified T: KtDeclaration> addDeclarationAfter(declaration: T, anchor: PsiElement?): T {
val anchorBefore = anchor ?: declarations.lastOrNull() ?: return addDeclaration(declaration)
return getOrCreateBody().addAfter(declaration, anchorBefore) as T
}
fun addDeclarationBefore(declaration: KtDeclaration, anchor: PsiElement?): KtDeclaration {
val anchorAfter = anchor ?: getDeclarations().firstOrNull() ?: return addDeclaration(declaration)
return getOrCreateBody().addBefore(declaration, anchorAfter) as KtDeclaration
inline fun <reified T: KtDeclaration> addDeclarationBefore(declaration: T, anchor: PsiElement?): T {
val anchorAfter = anchor ?: declarations.firstOrNull() ?: return addDeclaration(declaration)
return getOrCreateBody().addBefore(declaration, anchorAfter) as T
}
fun isTopLevel(): Boolean = getStub()?.isTopLevel() ?: (getParent() is KtFile)
fun isTopLevel(): Boolean = stub?.isTopLevel() ?: (parent is KtFile)
fun isLocal(): Boolean = getStub()?.isLocal() ?: KtPsiUtil.isLocal(this)
fun isLocal(): Boolean = stub?.isLocal() ?: KtPsiUtil.isLocal(this)
override fun getDeclarations() = getBody()?.getDeclarations().orEmpty()
override fun getDeclarations() = getBody()?.declarations.orEmpty()
override fun getPresentation(): ItemPresentation? = ItemPresentationProviders.getItemPresentation(this)
fun getPrimaryConstructor(): KtPrimaryConstructor? = getStubOrPsiChild(KtStubElementTypes.PRIMARY_CONSTRUCTOR)
fun getPrimaryConstructorModifierList(): KtModifierList? = getPrimaryConstructor()?.getModifierList()
fun getPrimaryConstructorParameterList(): KtParameterList? = getPrimaryConstructor()?.getValueParameterList()
fun getPrimaryConstructorParameters(): List<KtParameter> = getPrimaryConstructorParameterList()?.getParameters().orEmpty()
fun getPrimaryConstructorModifierList(): KtModifierList? = getPrimaryConstructor()?.modifierList
fun getPrimaryConstructorParameterList(): KtParameterList? = getPrimaryConstructor()?.valueParameterList
fun getPrimaryConstructorParameters(): List<KtParameter> = getPrimaryConstructorParameterList()?.parameters.orEmpty()
fun hasExplicitPrimaryConstructor(): Boolean = getPrimaryConstructor() != null
@@ -106,7 +110,7 @@ abstract class KtClassOrObject :
CheckUtil.checkWritable(this);
val file = getContainingKtFile();
if (!isTopLevel() || file.getDeclarations().size > 1) {
if (!isTopLevel() || file.declarations.size > 1) {
super.delete()
}
else {

View File

@@ -99,13 +99,25 @@ abstract class KtCodeFragment(
override fun addImportsFromString(imports: String?) {
if (imports == null || imports.isEmpty()) return
this.imports.addAll(imports.split(IMPORT_SEPARATOR))
imports.split(IMPORT_SEPARATOR).forEach {
addImport(it)
}
// we need this code to force re-highlighting, otherwise it does not work by some reason
val tempElement = KtPsiFactory(project).createColon()
add(tempElement).delete()
}
fun addImport(import: String) {
val contextFile = getContextContainingFile()
if (contextFile != null) {
if (contextFile.importDirectives.find { it.text == import } == null) {
imports.add(import)
}
}
}
fun importsAsImportList(): KtImportList? {
if (!imports.isEmpty() && context != null) {
return KtPsiFactory(this).createAnalyzableFile("imports_for_codeFragment.kt", imports.joinToString("\n"), context).importList
@@ -146,7 +158,11 @@ abstract class KtCodeFragment(
private fun initImports(imports: String?) {
if (imports != null && !imports.isEmpty()) {
this.imports.addAll(imports.split(IMPORT_SEPARATOR).map { it.check { it.startsWith("import ") } ?: "import $it" })
val importsWithPrefix = imports.split(IMPORT_SEPARATOR).map { it.check { it.startsWith("import ") } ?: "import ${it.trim()}" }
importsWithPrefix.forEach {
addImport(it)
}
}
}

View File

@@ -45,8 +45,8 @@ class KtObjectDeclaration : KtClassOrObject {
override fun setName(@NonNls name: String): PsiElement {
if (nameIdentifier == null) {
val psiFactory = KtPsiFactory(project)
val result = addAfter(psiFactory.createIdentifier(name), getObjectKeyword())
addAfter(psiFactory.createWhiteSpace(), getObjectKeyword())
val result = addAfter(psiFactory.createIdentifier(name), getObjectKeyword()!!)
addAfter(psiFactory.createWhiteSpace(), getObjectKeyword()!!)
return result
}
@@ -58,7 +58,7 @@ class KtObjectDeclaration : KtClassOrObject {
fun isCompanion(): Boolean = _stub?.isCompanion() ?: hasModifier(KtTokens.COMPANION_KEYWORD)
override fun getTextOffset(): Int = nameIdentifier?.textRange?.startOffset
?: getObjectKeyword().textRange.startOffset
?: getObjectKeyword()!!.textRange.startOffset
override fun <R, D> accept(visitor: KtVisitor<R, D>, data: D): R {
return visitor.visitObjectDeclaration(this, data)
@@ -66,5 +66,5 @@ class KtObjectDeclaration : KtClassOrObject {
fun isObjectLiteral(): Boolean = _stub?.isObjectLiteral() ?: (parent is KtObjectLiteralExpression)
fun getObjectKeyword(): PsiElement = findChildByType(KtTokens.OBJECT_KEYWORD)!!
fun getObjectKeyword(): PsiElement? = findChildByType(KtTokens.OBJECT_KEYWORD)
}

View File

@@ -56,6 +56,8 @@ public class KtStringTemplateExpression extends KtExpressionImpl implements PsiL
@Override
public PsiLanguageInjectionHost updateText(@NotNull String text) {
KtExpression newExpression = new KtPsiFactory(getProject()).createExpressionIfPossible(text);
if (newExpression instanceof KtStringTemplateExpression) return (KtStringTemplateExpression) replace(newExpression);
return ElementManipulators.handleContentChange(this, text);
}

View File

@@ -367,6 +367,9 @@ fun KtStringTemplateExpression.getContentRange(): TextRange {
return TextRange(start, if (lastChild.elementType == KtTokens.CLOSING_QUOTE) length - lastChild.textLength else length)
}
val KtStringTemplateExpression.plainContent: String
get() = getContentRange().substring(text)
fun KtStringTemplateExpression.isSingleQuoted(): Boolean
= node.firstChildNode.textLength == 1
@@ -403,6 +406,7 @@ fun KtDeclaration.visibilityModifierType(): KtModifierKeywordToken?
= visibilityModifier()?.node?.elementType as KtModifierKeywordToken?
fun KtStringTemplateExpression.isPlain() = entries.all { it is KtLiteralStringTemplateEntry }
fun KtStringTemplateExpression.isPlainWithEscapes() = entries.all { it is KtLiteralStringTemplateEntry || it is KtEscapeStringTemplateEntry }
val KtDeclaration.containingClassOrObject: KtClassOrObject?
get() = (parent as? KtClassBody)?.parent as? KtClassOrObject

View File

@@ -101,6 +101,9 @@ public interface BindingContext {
*/
WritableSlice<KtExpression, Qualifier> QUALIFIER = new BasicWritableSlice<KtExpression, Qualifier>(DO_NOTHING);
WritableSlice<KtSuperExpression, KotlinType> THIS_TYPE_FOR_SUPER_EXPRESSION =
new BasicWritableSlice<KtSuperExpression, KotlinType>(DO_NOTHING);
WritableSlice<KtReferenceExpression, DeclarationDescriptor> REFERENCE_TARGET =
new BasicWritableSlice<KtReferenceExpression, DeclarationDescriptor>(DO_NOTHING);
// if 'A' really means 'A.Companion' then this slice stores class descriptor for A, REFERENCE_TARGET stores descriptor Companion in this case

View File

@@ -125,9 +125,18 @@ public class BindingContextUtils {
return descriptor;
}
@Nullable
public static FunctionDescriptor getEnclosingFunctionDescriptor(@NotNull BindingContext context, @NotNull KtElement element) {
KtFunction function = PsiTreeUtil.getParentOfType(element, KtFunction.class);
return (FunctionDescriptor)context.get(DECLARATION_TO_DESCRIPTOR, function);
KtElement functionOrClass = PsiTreeUtil.getParentOfType(element, KtFunction.class, KtClassOrObject.class);
DeclarationDescriptor descriptor = context.get(DECLARATION_TO_DESCRIPTOR, functionOrClass);
if (functionOrClass instanceof KtFunction) {
if (descriptor instanceof FunctionDescriptor) return (FunctionDescriptor) descriptor;
return null;
}
else {
if (descriptor instanceof ClassDescriptor) return ((ClassDescriptor) descriptor).getUnsubstitutedPrimaryConstructor();
return null;
}
}
public static void reportAmbiguousLabel(

View File

@@ -525,20 +525,17 @@ public class BodyResolver {
@NotNull ClassDescriptorWithResolutionScopes classDescriptor
) {
LexicalScope scopeForInitializers = classDescriptor.getScopeForInitializerResolution();
if (!classDescriptor.getConstructors().isEmpty()) {
KtExpression body = anonymousInitializer.getBody();
if (body != null) {
PreliminaryDeclarationVisitor.Companion.createForDeclaration(
(KtDeclaration) anonymousInitializer.getParent().getParent(), trace);
expressionTypingServices.getTypeInfo(
scopeForInitializers, body, NO_EXPECTED_TYPE, outerDataFlowInfo, trace, /*isStatement = */true
);
}
processModifiersOnInitializer(anonymousInitializer, scopeForInitializers);
KtExpression body = anonymousInitializer.getBody();
if (body != null) {
PreliminaryDeclarationVisitor.Companion.createForDeclaration(
(KtDeclaration) anonymousInitializer.getParent().getParent(), trace);
expressionTypingServices.getTypeInfo(
scopeForInitializers, body, NO_EXPECTED_TYPE, outerDataFlowInfo, trace, /*isStatement = */true
);
}
else {
processModifiersOnInitializer(anonymousInitializer, scopeForInitializers);
if (classDescriptor.getConstructors().isEmpty()) {
trace.report(ANONYMOUS_INITIALIZER_IN_INTERFACE.on(anonymousInitializer));
processModifiersOnInitializer(anonymousInitializer, scopeForInitializers);
}
}

View File

@@ -99,7 +99,6 @@ class DeclarationsChecker(
for ((classOrObject, classDescriptor) in bodiesResolveContext.declaredClasses.entries) {
checkSupertypesForConsistency(classDescriptor, classOrObject)
checkTypesInClassHeader(classOrObject)
checkClassOrObjectMembers(classDescriptor)
when (classOrObject) {
is KtClass -> {
@@ -344,17 +343,6 @@ class DeclarationsChecker(
}
}
private fun checkClassOrObjectMembers(classDescriptor: ClassDescriptorWithResolutionScopes) {
for (memberDescriptor in classDescriptor.declaredCallableMembers) {
if (memberDescriptor.kind != CallableMemberDescriptor.Kind.DECLARATION) continue
val member = DescriptorToSourceUtils.descriptorToDeclaration(memberDescriptor) as? KtFunction
if (member != null && memberDescriptor is FunctionDescriptor) {
checkFunctionExposedType(member, memberDescriptor)
checkVarargParameters(trace, memberDescriptor)
}
}
}
private fun checkPrimaryConstructor(classOrObject: KtClassOrObject, classDescriptor: ClassDescriptor) {
val primaryConstructor = classDescriptor.unsubstitutedPrimaryConstructor ?: return
val declaration = classOrObject.getPrimaryConstructor() ?: return
@@ -664,6 +652,9 @@ class DeclarationsChecker(
trace.report(DEPRECATED_TYPE_PARAMETER_SYNTAX.on(typeParameterList))
}
checkTypeParameterConstraints(function)
checkImplicitCallableType(function, functionDescriptor)
checkFunctionExposedType(function, functionDescriptor)
checkVarargParameters(trace, functionDescriptor)
val containingDescriptor = functionDescriptor.containingDeclaration
val hasAbstractModifier = function.hasModifier(KtTokens.ABSTRACT_KEYWORD)
@@ -689,21 +680,19 @@ class DeclarationsChecker(
if (!hasBody && !hasAbstractModifier && !hasExternalModifier && !inTrait) {
trace.report(NON_ABSTRACT_FUNCTION_WITH_NO_BODY.on(function, functionDescriptor))
}
return
}
if (!function.hasBody() && !hasAbstractModifier && !hasExternalModifier) {
trace.report(NON_MEMBER_FUNCTION_NO_BODY.on(function, functionDescriptor))
else /* top-level only */ {
if (!function.hasBody() && !hasAbstractModifier && !hasExternalModifier) {
trace.report(NON_MEMBER_FUNCTION_NO_BODY.on(function, functionDescriptor))
}
}
checkImplicitCallableType(function, functionDescriptor)
checkFunctionExposedType(function, functionDescriptor)
checkVarargParameters(trace, functionDescriptor)
}
private fun checkImplicitCallableType(declaration: KtCallableDeclaration, descriptor: CallableDescriptor) {
descriptor.returnType?.let {
if (declaration.typeReference == null) {
val target = declaration.nameIdentifier ?: declaration
if (it.isNothing()) {
if (it.isNothing() && !declaration.hasModifier(KtTokens.OVERRIDE_KEYWORD)) {
trace.report(
(if (declaration is KtProperty) IMPLICIT_NOTHING_PROPERTY_TYPE else IMPLICIT_NOTHING_RETURN_TYPE).on(target)
)

View File

@@ -897,16 +897,6 @@ public class DescriptorResolver {
annotationSplitter.getAnnotationsForTarget(PROPERTY_GETTER),
annotationResolver.resolveAnnotationsWithoutArguments(scopeWithTypeParameters, getter.getModifierList(), trace)));
KotlinType outType = propertyDescriptor.getType();
KotlinType returnType = outType;
KtTypeReference returnTypeReference = getter.getReturnTypeReference();
if (returnTypeReference != null) {
returnType = typeResolver.resolveType(scopeWithTypeParameters, returnTypeReference, trace, true);
if (!TypeUtils.equalTypes(returnType, outType)) {
trace.report(WRONG_GETTER_RETURN_TYPE.on(returnTypeReference, propertyDescriptor.getReturnType(), outType));
}
}
getterDescriptor = new PropertyGetterDescriptorImpl(
propertyDescriptor, getterAnnotations,
resolveModalityFromModifiers(getter, propertyDescriptor.getModality()),
@@ -914,10 +904,8 @@ public class DescriptorResolver {
/* isDefault = */ false, getter.hasModifier(EXTERNAL_KEYWORD),
CallableMemberDescriptor.Kind.DECLARATION, null, KotlinSourceElementKt.toSourceElement(getter)
);
if (returnType.isError() && !getter.hasBlockBody() && getter.hasBody()) {
returnType = inferReturnTypeFromExpressionBody(storageManager, expressionTypingServices, trace, scopeWithTypeParameters,
DataFlowInfoFactory.EMPTY, getter, getterDescriptor);
}
KotlinType returnType =
determineGetterReturnType(scopeWithTypeParameters, trace, getterDescriptor, getter, propertyDescriptor.getType());
getterDescriptor.initialize(returnType);
trace.record(BindingContext.PROPERTY_ACCESSOR, getter, getterDescriptor);
}
@@ -930,6 +918,37 @@ public class DescriptorResolver {
return getterDescriptor;
}
@NotNull
private KotlinType determineGetterReturnType(
@NotNull LexicalScope scope,
@NotNull BindingTrace trace,
@NotNull PropertyGetterDescriptor getterDescriptor,
@NotNull KtPropertyAccessor getter,
@NotNull KotlinType propertyType
) {
KtTypeReference returnTypeReference = getter.getReturnTypeReference();
if (returnTypeReference != null) {
KotlinType explicitReturnType = typeResolver.resolveType(scope, returnTypeReference, trace, true);
if (!TypeUtils.equalTypes(explicitReturnType, propertyType)) {
trace.report(WRONG_GETTER_RETURN_TYPE.on(returnTypeReference, propertyType, explicitReturnType));
}
return explicitReturnType;
}
// If a property has no type specified in the PSI but the getter does (or has an initializer e.g. "val x get() = ..."),
// infer the correct type for the getter but leave the error type for the property.
// This is useful for an IDE quick fix which would add the type to the property
KtProperty property = getter.getProperty();
if (!property.hasDelegateExpressionOrInitializer() && property.getTypeReference() == null &&
getter.hasBody() && !getter.hasBlockBody()) {
return inferReturnTypeFromExpressionBody(
storageManager, expressionTypingServices, trace, scope, DataFlowInfoFactory.EMPTY, getter, getterDescriptor
);
}
return propertyType;
}
@NotNull
/*package*/ static DeferredType inferReturnTypeFromExpressionBody(
@NotNull StorageManager storageManager,

View File

@@ -203,9 +203,9 @@ object ModifierCheckerCore {
trace.report(Errors.REPEATED_MODIFIER.on (secondNode.psi, first))
}
Compatibility.REDUNDANT ->
trace.report(Errors.REDUNDANT_MODIFIER.on(secondNode.psi, first, second))
trace.report(Errors.REDUNDANT_MODIFIER.on(secondNode.psi, second, first))
Compatibility.REVERSE_REDUNDANT ->
trace.report(Errors.REDUNDANT_MODIFIER.on(firstNode.psi, second, first))
trace.report(Errors.REDUNDANT_MODIFIER.on(firstNode.psi, first, second))
Compatibility.DEPRECATED -> {
trace.report(Errors.DEPRECATED_MODIFIER_PAIR.on(firstNode.psi, first, second))
trace.report(Errors.DEPRECATED_MODIFIER_PAIR.on(secondNode.psi, second, first))

View File

@@ -1027,7 +1027,7 @@ public class OverrideResolver {
all.addAll((Collection) supertype.getMemberScope().getContributedVariables(declared.getName(), NoLookupLocation.WHEN_CHECK_OVERRIDES));
for (CallableMemberDescriptor fromSuper : all) {
if (OverridingUtil.DEFAULT.isOverridableBy(fromSuper, declared, null).getResult() == OVERRIDABLE) {
if (Visibilities.isVisibleWithIrrelevantReceiver(fromSuper, declared)) {
if (Visibilities.isVisibleIgnoringReceiver(fromSuper, declared)) {
throw new IllegalStateException("Descriptor " + fromSuper + " is overridable by " + declared +
" and visible but does not appear in its getOverriddenDescriptors()");
}

View File

@@ -609,7 +609,7 @@ class QualifiedExpressionResolver(val symbolUsageValidator: SymbolUsageValidator
if (Visibilities.isPrivate(visibility)) return false
if (!visibility.mustCheckInImports()) return true
}
return Visibilities.isVisibleWithIrrelevantReceiver(descriptor, shouldBeVisibleFrom)
return Visibilities.isVisibleIgnoringReceiver(descriptor, shouldBeVisibleFrom)
}
}

View File

@@ -69,7 +69,7 @@ private val DEFAULT_DECLARATION_CHECKERS = listOf(
private val DEFAULT_CALL_CHECKERS = listOf(CapturingInClosureChecker(), InlineCheckerWrapper(), ReifiedTypeParameterSubstitutionChecker(),
SafeCallChecker(), InvokeConventionChecker(), CallReturnsArrayOfNothingChecker(),
ConstructorHeaderCallChecker)
ConstructorHeaderCallChecker, ProtectedConstructorCallChecker)
private val DEFAULT_TYPE_CHECKERS = emptyList<AdditionalTypeChecker>()
private val DEFAULT_VALIDATORS = listOf(DeprecatedSymbolValidator(), OperatorValidator(), InfixValidator())

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -306,7 +306,7 @@ class TypeResolver(
val arguments = resolveTypeProjections(c, ErrorUtils.createErrorType("No type").constructor, type.typeArguments)
if (!arguments.isEmpty()) {
c.trace.report(WRONG_NUMBER_OF_TYPE_ARGUMENTS.on(type.typeArgumentList!!, 0))
c.trace.report(TYPE_ARGUMENTS_NOT_ALLOWED.on(type.typeArgumentList!!, "for type parameters"))
}
val containing = typeParameter.containingDeclaration
@@ -445,7 +445,10 @@ class TypeResolver(
if (currentArguments.size != currentParameters.size) {
c.trace.report(
WRONG_NUMBER_OF_TYPE_ARGUMENTS.on(qualifierPart.typeArguments ?: qualifierPart.expression, currentParameters.size))
WRONG_NUMBER_OF_TYPE_ARGUMENTS.on(
qualifierPart.typeArguments ?: qualifierPart.expression, currentParameters.size, classDescriptorChain[index]
)
)
return null
}
@@ -461,7 +464,7 @@ class TypeResolver(
for (qualifierPart in nonClassQualifierParts) {
if (qualifierPart.typeArguments != null) {
c.trace.report(WRONG_NUMBER_OF_TYPE_ARGUMENTS.on(qualifierPart.typeArguments, 0))
c.trace.report(TYPE_ARGUMENTS_NOT_ALLOWED.on(qualifierPart.typeArguments, "here"))
return null
}
}
@@ -471,7 +474,7 @@ class TypeResolver(
val typeParametersToSpecify =
parameters.subList(result.size, parameters.size).takeWhile { it.original.containingDeclaration is ClassDescriptor }
if (typeParametersToSpecify.any { parameter -> !parameter.isDeclaredInScope(c) }) {
c.trace.report(WRONG_NUMBER_OF_TYPE_ARGUMENTS.on(qualifierParts.last().expression, parameters.size))
c.trace.report(WRONG_NUMBER_OF_TYPE_ARGUMENTS.on(qualifierParts.last().expression, parameters.size, classDescriptor))
return null
}
}

View File

@@ -181,24 +181,6 @@ fun resolveCallableReferenceTarget(
}
}
private fun createReflectionTypeForFunction(
descriptor: FunctionDescriptor,
receiverType: KotlinType?,
reflectionTypes: ReflectionTypes
): KotlinType? {
val returnType = descriptor.returnType ?: return null
val valueParametersTypes = ExpressionTypingUtils.getValueParametersTypes(descriptor.valueParameters)
return reflectionTypes.getKFunctionType(Annotations.EMPTY, receiverType, valueParametersTypes, returnType)
}
private fun createReflectionTypeForProperty(
descriptor: PropertyDescriptor,
receiverType: KotlinType?,
reflectionTypes: ReflectionTypes
): KotlinType {
return reflectionTypes.getKPropertyType(Annotations.EMPTY, receiverType, descriptor.type, descriptor.isVar)
}
private fun bindFunctionReference(expression: KtCallableReferenceExpression, type: KotlinType, context: ResolutionContext<*>) {
val functionDescriptor = AnonymousFunctionDescriptor(
context.scope.ownerDescriptor,
@@ -230,7 +212,8 @@ private fun createReflectionTypeForCallableDescriptor(
lhsType: KotlinType?,
reflectionTypes: ReflectionTypes,
trace: BindingTrace?,
reportOn: KtExpression?
reportOn: KtExpression?,
ignoreReceiver: Boolean
): KotlinType? {
val extensionReceiver = descriptor.extensionReceiverParameter
val dispatchReceiver = descriptor.dispatchReceiverParameter?.let { dispatchReceiver ->
@@ -248,15 +231,19 @@ private fun createReflectionTypeForCallableDescriptor(
}
val receiverType =
if (extensionReceiver != null || dispatchReceiver != null)
if ((extensionReceiver != null || dispatchReceiver != null) && !ignoreReceiver)
lhsType ?: extensionReceiver?.type ?: dispatchReceiver?.type
else null
return when (descriptor) {
is FunctionDescriptor ->
createReflectionTypeForFunction(descriptor, receiverType, reflectionTypes)
is PropertyDescriptor ->
createReflectionTypeForProperty(descriptor, receiverType, reflectionTypes)
is FunctionDescriptor -> {
val returnType = descriptor.returnType ?: return null
val valueParametersTypes = ExpressionTypingUtils.getValueParametersTypes(descriptor.valueParameters)
return reflectionTypes.getKFunctionType(Annotations.EMPTY, receiverType, valueParametersTypes, returnType)
}
is PropertyDescriptor -> {
reflectionTypes.getKPropertyType(Annotations.EMPTY, receiverType, descriptor.type, descriptor.isVar)
}
is VariableDescriptor -> {
if (reportOn != null) {
trace?.report(UNSUPPORTED.on(reportOn, "References to variables aren't supported yet"))
@@ -270,9 +257,10 @@ private fun createReflectionTypeForCallableDescriptor(
fun getReflectionTypeForCandidateDescriptor(
descriptor: CallableDescriptor,
reflectionTypes: ReflectionTypes
reflectionTypes: ReflectionTypes,
ignoreReceiver: Boolean
): KotlinType? =
createReflectionTypeForCallableDescriptor(descriptor, null, reflectionTypes, null, null)
createReflectionTypeForCallableDescriptor(descriptor, null, reflectionTypes, null, null, ignoreReceiver)
fun createReflectionTypeForResolvedCallableReference(
reference: KtCallableReferenceExpression,
@@ -282,7 +270,7 @@ fun createReflectionTypeForResolvedCallableReference(
reflectionTypes: ReflectionTypes
): KotlinType? {
val type = createReflectionTypeForCallableDescriptor(
descriptor, lhsType, reflectionTypes, context.trace, reference.getCallableReference()
descriptor, lhsType, reflectionTypes, context.trace, reference.callableReference, reference.typeReference == null
) ?: return null
when (descriptor) {
is FunctionDescriptor -> {
@@ -310,7 +298,8 @@ fun getResolvedCallableReferenceShapeType(
null
overloadResolutionResults.isSingleResult ->
OverloadResolutionResultsUtil.getResultingCall(overloadResolutionResults, context.contextDependency)?.let { call ->
createReflectionTypeForCallableDescriptor(call.resultingDescriptor, lhsType, reflectionTypes, context.trace, reference)
createReflectionTypeForCallableDescriptor(call.resultingDescriptor, lhsType, reflectionTypes, context.trace, reference,
reference.typeReference == null)
}
expectedTypeUnknown /* && overload resolution was ambiguous */ ->
functionPlaceholders.createFunctionPlaceholderType(emptyList(), false)

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -315,7 +315,7 @@ public class ArgumentTypeResolver {
* Visits function call arguments and determines data flow information changes
*/
public void analyzeArgumentsAndRecordTypes(
@NotNull CallResolutionContext<?> context
@NotNull CallResolutionContext<?> context, @NotNull ResolveArgumentsMode resolveArgumentsMode
) {
MutableDataFlowInfoForArguments infoForArguments = context.dataFlowInfoForArguments;
Call call = context.call;
@@ -326,7 +326,7 @@ public class ArgumentTypeResolver {
CallResolutionContext<?> newContext = context.replaceDataFlowInfo(infoForArguments.getInfo(argument));
// Here we go inside arguments and determine additional data flow information for them
KotlinTypeInfo typeInfoForCall = getArgumentTypeInfo(expression, newContext, SHAPE_FUNCTION_ARGUMENTS);
KotlinTypeInfo typeInfoForCall = getArgumentTypeInfo(expression, newContext, resolveArgumentsMode);
infoForArguments.updateInfo(argument, typeInfoForCall.getDataFlowInfo());
}
}

View File

@@ -20,16 +20,14 @@ import com.intellij.lang.ASTNode
import com.intellij.psi.PsiElement
import com.intellij.psi.util.PsiTreeUtil
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.diagnostics.Errors.*
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
import org.jetbrains.kotlin.resolve.*
import org.jetbrains.kotlin.resolve.bindingContextUtil.recordDataFlowInfo
import org.jetbrains.kotlin.resolve.bindingContextUtil.recordScope
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.ResolveArgumentsMode
import org.jetbrains.kotlin.resolve.calls.callUtil.getCalleeExpressionIfAny
import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext
import org.jetbrains.kotlin.resolve.calls.context.CheckArgumentTypesMode
@@ -38,6 +36,7 @@ import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext
import org.jetbrains.kotlin.resolve.calls.context.TemporaryTraceAndCache
import org.jetbrains.kotlin.resolve.calls.model.DataFlowInfoForArgumentsImpl
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
import org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResults
import org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResults.Code.CANDIDATES_WITH_WRONG_RECEIVER
import org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResults.Code.NAME_NOT_FOUND
import org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResultsUtil
@@ -64,6 +63,7 @@ import javax.inject.Inject
class CallExpressionResolver(
private val callResolver: CallResolver,
private val constantExpressionEvaluator: ConstantExpressionEvaluator,
private val argumentTypeResolver: ArgumentTypeResolver,
private val dataFlowAnalyzer: DataFlowAnalyzer,
private val builtIns: KotlinBuiltIns,
private val qualifiedExpressionResolver: QualifiedExpressionResolver,
@@ -247,6 +247,13 @@ class CallExpressionResolver(
temporaryForVariable.commit()
context.trace.report(FUNCTION_EXPECTED.on(calleeExpression, calleeExpression,
type ?: ErrorUtils.createErrorType("")))
argumentTypeResolver.analyzeArgumentsAndRecordTypes(
BasicCallResolutionContext.create(
context, call, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS,
DataFlowInfoForArgumentsImpl(initialDataFlowInfoForArguments, call)
),
ResolveArgumentsMode.RESOLVE_FUNCTION_ARGUMENTS
)
return noTypeInfo(context)
}
}
@@ -257,13 +264,7 @@ class CallExpressionResolver(
private fun KtQualifiedExpression.elementChain(context: ExpressionTypingContext) =
qualifiedExpressionResolver.resolveQualifierInExpressionAndUnroll(this, context) {
nameExpression ->
val temporaryForVariable = TemporaryTraceAndCache.create(
context, "trace to resolve as local variable or property", nameExpression)
val call = CallMaker.makePropertyCall(null, null, nameExpression)
val contextForVariable = BasicCallResolutionContext.create(
context.replaceTraceAndCache(temporaryForVariable),
call, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS)
val resolutionResult = callResolver.resolveSimpleProperty(contextForVariable)
val resolutionResult = resolveSimpleName(context, nameExpression)
if (resolutionResult.isSingleResult && resolutionResult.resultingDescriptor is FakeCallableDescriptorForObject) {
false
@@ -274,6 +275,17 @@ class CallExpressionResolver(
}
}
fun resolveSimpleName(
context: ExpressionTypingContext, expression: KtSimpleNameExpression
): OverloadResolutionResults<VariableDescriptor> {
val temporaryForVariable = TemporaryTraceAndCache.create(context, "trace to resolve as local variable or property", expression)
val call = CallMaker.makePropertyCall(null, null, expression)
val contextForVariable = BasicCallResolutionContext.create(
context.replaceTraceAndCache(temporaryForVariable), call, CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS
)
return callResolver.resolveSimpleProperty(contextForVariable)
}
private fun getUnsafeSelectorTypeInfo(
receiver: Receiver,
callOperationNode: ASTNode?,

View File

@@ -575,7 +575,7 @@ public class CallResolver {
@NotNull TracingStrategy tracing
) {
if (context.checkArguments == CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS) {
argumentTypeResolver.analyzeArgumentsAndRecordTypes(context);
argumentTypeResolver.analyzeArgumentsAndRecordTypes(context, ResolveArgumentsMode.SHAPE_FUNCTION_ARGUMENTS);
}
List<KtTypeProjection> typeArguments = context.call.getTypeArguments();

View File

@@ -36,6 +36,7 @@ import org.jetbrains.kotlin.resolve.validation.InfixValidator
import org.jetbrains.kotlin.types.*
import org.jetbrains.kotlin.types.TypeUtils.DONT_CARE
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
import org.jetbrains.kotlin.types.typeUtil.contains
import org.jetbrains.kotlin.util.OperatorNameConventions
enum class ResolveArgumentsMode {
@@ -47,7 +48,7 @@ enum class ResolveArgumentsMode {
fun hasUnknownFunctionParameter(type: KotlinType): Boolean {
assert(ReflectionTypes.isCallableType(type)) { "type $type is not a function or property" }
return getParameterArgumentsOfCallableType(type).any {
TypeUtils.contains(it.type, DONT_CARE) || ErrorUtils.containsUninferredParameter(it.type)
it.type.contains { TypeUtils.isDontCarePlaceholder(it) } || ErrorUtils.containsUninferredParameter(it.type)
}
}

View File

@@ -43,6 +43,7 @@ import org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus
import org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus.*
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
import org.jetbrains.kotlin.resolve.calls.smartcasts.SmartCastManager
import org.jetbrains.kotlin.resolve.calls.smartcasts.getReceiverValueWithSmartCast
import org.jetbrains.kotlin.resolve.calls.util.FakeCallableDescriptorForObject
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
import org.jetbrains.kotlin.resolve.scopes.receivers.Receiver
@@ -58,8 +59,7 @@ class CandidateResolver(
private val reflectionTypes: ReflectionTypes,
private val smartCastManager: SmartCastManager
) {
fun <D : CallableDescriptor, F : D> performResolutionForCandidateCall(
fun <D : CallableDescriptor> performResolutionForCandidateCall(
context: CallCandidateResolutionContext<D>,
checkArguments: CheckArgumentTypesMode
): Unit = with(context) {
@@ -76,7 +76,7 @@ class CandidateResolver(
}
if (!context.isDebuggerContext) {
checkVisibility()
checkVisibilityWithoutReceiver()
}
when (checkArguments) {
@@ -98,9 +98,9 @@ class CandidateResolver(
}
private fun CallCandidateResolutionContext<*>.checkValueArguments() = checkAndReport {
if (call.getTypeArguments().isEmpty()
if (call.typeArguments.isEmpty()
&& !candidateDescriptor.typeParameters.isEmpty()
&& candidateCall.getKnownTypeParametersSubstitutor() == null
&& candidateCall.knownTypeParametersSubstitutor == null
) {
genericCandidateResolver.inferTypeArguments(this)
}
@@ -110,41 +110,42 @@ class CandidateResolver(
}
private fun CallCandidateResolutionContext<*>.processTypeArguments() = check {
val jetTypeArguments = call.getTypeArguments()
val ktTypeArguments = call.typeArguments
if (candidateCall.knownTypeParametersSubstitutor != null) {
candidateCall.setResultingSubstitutor(candidateCall.knownTypeParametersSubstitutor!!)
}
else if (!jetTypeArguments.isEmpty()) {
else if (!ktTypeArguments.isEmpty()) {
// Explicit type arguments passed
val typeArguments = ArrayList<KotlinType>()
for (projection in jetTypeArguments) {
for (projection in ktTypeArguments) {
val type = projection.typeReference?.let { trace.bindingContext.get(BindingContext.TYPE, it) }
?: ErrorUtils.createErrorType("Star projection in a call")
typeArguments.add(type)
}
val expectedTypeArgumentCount = candidateDescriptor.typeParameters.size
for (index in jetTypeArguments.size..expectedTypeArgumentCount - 1) {
for (index in ktTypeArguments.size..expectedTypeArgumentCount - 1) {
typeArguments.add(ErrorUtils.createErrorType(
"Explicit type argument expected for " + candidateDescriptor.typeParameters.get(index).name))
"Explicit type argument expected for " + candidateDescriptor.typeParameters[index].name
))
}
val substitution = FunctionDescriptorUtil.createSubstitution(candidateDescriptor as FunctionDescriptor, typeArguments)
val substitutor = TypeSubstitutor.create(SubstitutionFilteringInternalResolveAnnotations(substitution))
if (expectedTypeArgumentCount != jetTypeArguments.size) {
if (expectedTypeArgumentCount != ktTypeArguments.size) {
candidateCall.addStatus(OTHER_ERROR)
tracing.wrongNumberOfTypeArguments(trace, expectedTypeArgumentCount)
tracing.wrongNumberOfTypeArguments(trace, expectedTypeArgumentCount, candidateDescriptor)
}
else {
checkGenericBoundsInAFunctionCall(jetTypeArguments, typeArguments, candidateDescriptor, substitutor, trace)
checkGenericBoundsInAFunctionCall(ktTypeArguments, typeArguments, candidateDescriptor, substitutor, trace)
}
candidateCall.setResultingSubstitutor(substitutor)
}
}
private fun <D : CallableDescriptor, F : D> CallCandidateResolutionContext<D>.mapArguments()
private fun <D : CallableDescriptor> CallCandidateResolutionContext<D>.mapArguments()
= check {
val argumentMappingStatus = ValueArgumentsToParametersMapper.mapValueArgumentsToParameters(
call, tracing, candidateCall, Sets.newLinkedHashSet<ValueArgument>())
@@ -153,11 +154,14 @@ class CandidateResolver(
}
}
private fun <D : CallableDescriptor, F : D> CallCandidateResolutionContext<D>.checkExpectedCallableType()
private fun <D : CallableDescriptor> CallCandidateResolutionContext<D>.checkExpectedCallableType()
= check {
if (!noExpectedType(expectedType)) {
val candidate = candidateCall.getCandidateDescriptor()
val candidateReflectionType = getReflectionTypeForCandidateDescriptor(candidate, reflectionTypes);
val candidate = candidateCall.candidateDescriptor
val candidateReflectionType = getReflectionTypeForCandidateDescriptor(
candidate, reflectionTypes,
call.callElement.parent.let { it is KtCallableReferenceExpression && it.typeReference == null }
);
if (candidateReflectionType != null) {
if (!KotlinTypeChecker.DEFAULT.isSubtypeOf(candidateReflectionType, expectedType)) {
candidateCall.addStatus(OTHER_ERROR)
@@ -169,9 +173,17 @@ class CandidateResolver(
}
}
private fun CallCandidateResolutionContext<*>.checkVisibility() = checkAndReport {
val invisibleMember = Visibilities.findInvisibleMember(candidateCall.dispatchReceiver, candidateDescriptor, scope.ownerDescriptor)
if (invisibleMember != null) {
private fun CallCandidateResolutionContext<*>.checkVisibilityWithoutReceiver() = checkAndReport {
checkVisibilityWithDispatchReceiver(Visibilities.ALWAYS_SUITABLE_RECEIVER, null)
}
private fun CallCandidateResolutionContext<*>.checkVisibilityWithDispatchReceiver(
receiverArgument: ReceiverValue?,
smartCastType: KotlinType?
): ResolutionStatus {
val invisibleMember = Visibilities.findInvisibleMember(
getReceiverValueWithSmartCast(receiverArgument, smartCastType), candidateDescriptor, scope.ownerDescriptor)
return if (invisibleMember != null) {
tracing.invisibleMember(trace, invisibleMember)
OTHER_ERROR
} else {
@@ -179,16 +191,30 @@ class CandidateResolver(
}
}
private fun CallCandidateResolutionContext<*>.isCandidateVisibleOrExtensionReceiver(
receiverArgument: ReceiverValue?,
smartCastType: KotlinType?,
isDispatchReceiver: Boolean
) = !isDispatchReceiver || isCandidateVisible(receiverArgument, smartCastType)
private fun CallCandidateResolutionContext<*>.isCandidateVisible(
receiverArgument: ReceiverValue?,
smartCastType: KotlinType?
) = Visibilities.findInvisibleMember(
getReceiverValueWithSmartCast(receiverArgument, smartCastType),
candidateDescriptor, scope.ownerDescriptor
) == null
private fun CallCandidateResolutionContext<*>.checkExtensionReceiver() = checkAndReport {
val receiverParameter = candidateCall.getCandidateDescriptor().extensionReceiverParameter
val receiverArgument = candidateCall.getExtensionReceiver()
val receiverParameter = candidateCall.candidateDescriptor.extensionReceiverParameter
val receiverArgument = candidateCall.extensionReceiver
if (receiverParameter != null && receiverArgument == null) {
tracing.missingReceiver(candidateCall.getTrace(), receiverParameter)
tracing.missingReceiver(candidateCall.trace, receiverParameter)
OTHER_ERROR
}
else if (receiverParameter == null && receiverArgument != null) {
tracing.noReceiverAllowed(candidateCall.getTrace())
if (call.getCalleeExpression() is KtSimpleNameExpression) {
tracing.noReceiverAllowed(candidateCall.trace)
if (call.calleeExpression is KtSimpleNameExpression) {
RECEIVER_PRESENCE_ERROR
}
else {
@@ -202,7 +228,7 @@ class CandidateResolver(
private fun CallCandidateResolutionContext<*>.checkDispatchReceiver() = checkAndReport {
val candidateDescriptor = candidateDescriptor
val dispatchReceiver = candidateCall.getDispatchReceiver()
val dispatchReceiver = candidateCall.dispatchReceiver
if (dispatchReceiver != null) {
var nestedClass: ClassDescriptor? = null
if (candidateDescriptor is ConstructorDescriptor
@@ -214,12 +240,12 @@ class CandidateResolver(
nestedClass = candidateDescriptor.getReferencedDescriptor()
}
if (nestedClass != null) {
tracing.nestedClassAccessViaInstanceReference(trace, nestedClass, candidateCall.getExplicitReceiverKind())
tracing.nestedClassAccessViaInstanceReference(trace, nestedClass, candidateCall.explicitReceiverKind)
return@checkAndReport OTHER_ERROR
}
}
assert((dispatchReceiver != null) == (candidateCall.getResultingDescriptor().dispatchReceiverParameter != null)) {
assert((dispatchReceiver != null) == (candidateCall.resultingDescriptor.dispatchReceiverParameter != null)) {
"Shouldn't happen because of TaskPrioritizer: $candidateDescriptor"
}
@@ -235,17 +261,17 @@ class CandidateResolver(
if (!context.call.callElement.insideScript()) return true
// In "this@Outer.foo()" the error will be reported on "this@Outer" instead
if (context.call.getExplicitReceiver() != null || context.call.getDispatchReceiver() != null) return true
if (context.call.explicitReceiver != null || context.call.dispatchReceiver != null) return true
val candidateThis = getDeclaringClass(context.candidateCall.getCandidateDescriptor())
val candidateThis = getDeclaringClass(context.candidateCall.candidateDescriptor)
if (candidateThis == null || candidateThis.kind.isSingleton) return true
return DescriptorResolver.checkHasOuterClassInstance(context.scope, context.trace, context.call.getCallElement(), candidateThis)
return DescriptorResolver.checkHasOuterClassInstance(context.scope, context.trace, context.call.callElement, candidateThis)
}
private fun CallCandidateResolutionContext<*>.checkAbstractAndSuper() = check {
val descriptor = candidateDescriptor
val expression = candidateCall.getCall().getCalleeExpression()
val expression = candidateCall.call.calleeExpression
if (expression is KtSimpleNameExpression) {
// 'B' in 'class A: B()' is JetConstructorCalleeExpression
@@ -257,7 +283,7 @@ class CandidateResolver(
}
}
val superDispatchReceiver = getReceiverSuper(candidateCall.getDispatchReceiver())
val superDispatchReceiver = getReceiverSuper(candidateCall.dispatchReceiver)
if (superDispatchReceiver != null) {
if (descriptor is MemberDescriptor && descriptor.modality == Modality.ABSTRACT) {
tracing.abstractSuperCall(trace)
@@ -267,9 +293,9 @@ class CandidateResolver(
// 'super' cannot be passed as an argument, for receiver arguments expression typer does not track this
// See TaskPrioritizer for more
val superExtensionReceiver = getReceiverSuper(candidateCall.getExtensionReceiver())
val superExtensionReceiver = getReceiverSuper(candidateCall.extensionReceiver)
if (superExtensionReceiver != null) {
trace.report(SUPER_CANT_BE_EXTENSION_RECEIVER.on(superExtensionReceiver, superExtensionReceiver.getText()))
trace.report(SUPER_CANT_BE_EXTENSION_RECEIVER.on(superExtensionReceiver, superExtensionReceiver.text))
candidateCall.addStatus(OTHER_ERROR)
}
}
@@ -317,23 +343,19 @@ class CandidateResolver(
private fun <D : CallableDescriptor, C : CallResolutionContext<C>> checkValueArgumentTypes(
context: CallResolutionContext<C>,
candidateCall: MutableResolvedCall<D>,
resolveFunctionArgumentBodies: ResolveArgumentsMode): ValueArgumentsCheckingResult {
resolveFunctionArgumentBodies: ResolveArgumentsMode
): ValueArgumentsCheckingResult {
var resultStatus = SUCCESS
val argumentTypes = Lists.newArrayList<KotlinType>()
val infoForArguments = candidateCall.getDataFlowInfoForArguments()
for (entry in candidateCall.getValueArguments().entries) {
val parameterDescriptor = entry.key
val resolvedArgument = entry.value
val infoForArguments = candidateCall.dataFlowInfoForArguments
for ((parameterDescriptor, resolvedArgument) in candidateCall.valueArguments) {
for (argument in resolvedArgument.arguments) {
val expression = argument.getArgumentExpression() ?: continue
val expectedType = getEffectiveExpectedType(parameterDescriptor, argument)
val newContext = context.replaceDataFlowInfo(infoForArguments.getInfo(argument)).replaceExpectedType(expectedType)
val typeInfoForCall = argumentTypeResolver.getArgumentTypeInfo(
expression, newContext, resolveFunctionArgumentBodies)
val typeInfoForCall = argumentTypeResolver.getArgumentTypeInfo(expression, newContext, resolveFunctionArgumentBodies)
val type = typeInfoForCall.type
infoForArguments.updateInfo(argument, typeInfoForCall.dataFlowInfo)
@@ -377,15 +399,13 @@ class CandidateResolver(
expression: KtExpression,
expectedType: KotlinType,
actualType: KotlinType,
context: ResolutionContext<*>): KotlinType? {
context: ResolutionContext<*>
): KotlinType? {
val receiverToCast = ExpressionReceiver.create(KtPsiUtil.safeDeparenthesize(expression), actualType, context.trace.bindingContext)
val variants = smartCastManager.getSmartCastVariantsExcludingReceiver(context, receiverToCast)
for (possibleType in variants) {
if (KotlinTypeChecker.DEFAULT.isSubtypeOf(possibleType, expectedType)) {
return possibleType
}
return variants.firstOrNull { possibleType ->
KotlinTypeChecker.DEFAULT.isSubtypeOf(possibleType, expectedType)
}
return null
}
private fun CallCandidateResolutionContext<*>.checkReceiverTypeError(): Unit = check {
@@ -399,7 +419,7 @@ class CandidateResolver(
assert(callExtensionReceiver is ReceiverValue?) { "Expected ReceiverValue, got $callExtensionReceiver" }
checkReceiverTypeError(extensionReceiver, callExtensionReceiver as ReceiverValue?)
}
checkReceiverTypeError(dispatchReceiver, candidateCall.getDispatchReceiver())
checkReceiverTypeError(dispatchReceiver, candidateCall.dispatchReceiver)
}
private fun CallCandidateResolutionContext<*>.checkReceiverTypeError(
@@ -428,15 +448,30 @@ class CandidateResolver(
resultStatus = resultStatus.combine(context.checkReceiver(
candidateCall,
candidateCall.getResultingDescriptor().extensionReceiverParameter,
candidateCall.resultingDescriptor.extensionReceiverParameter,
candidateCall.extensionReceiver as ReceiverValue?,
candidateCall.getExplicitReceiverKind().isExtensionReceiver, false))
candidateCall.explicitReceiverKind.isExtensionReceiver,
implicitInvokeCheck = false, isDispatchReceiver = false
))
resultStatus = resultStatus.combine(context.checkReceiver(candidateCall,
candidateCall.getResultingDescriptor().dispatchReceiverParameter, candidateCall.getDispatchReceiver(),
candidateCall.getExplicitReceiverKind().isDispatchReceiver,
resultStatus = resultStatus.combine(context.checkReceiver(
candidateCall,
candidateCall.resultingDescriptor.dispatchReceiverParameter, candidateCall.dispatchReceiver,
candidateCall.explicitReceiverKind.isDispatchReceiver,
// for the invocation 'foo(1)' where foo is a variable of function type we should mark 'foo' if there is unsafe call error
context.call is CallForImplicitInvoke))
implicitInvokeCheck = context.call is CallForImplicitInvoke,
isDispatchReceiver = true
))
if (!context.isDebuggerContext
&& candidateCall.dispatchReceiver != null
// Do not report error if it's already reported when checked without receiver
&& context.isCandidateVisible(receiverArgument = Visibilities.ALWAYS_SUITABLE_RECEIVER, smartCastType = null)) {
resultStatus = resultStatus.combine(
context.checkVisibilityWithDispatchReceiver(
candidateCall.dispatchReceiver, candidateCall.smartCastDispatchReceiverType))
}
return resultStatus
}
@@ -445,7 +480,9 @@ class CandidateResolver(
receiverParameter: ReceiverParameterDescriptor?,
receiverArgument: ReceiverValue?,
isExplicitReceiver: Boolean,
implicitInvokeCheck: Boolean): ResolutionStatus {
implicitInvokeCheck: Boolean,
isDispatchReceiver: Boolean
): ResolutionStatus {
if (receiverParameter == null || receiverArgument == null) return SUCCESS
val candidateDescriptor = candidateCall.candidateDescriptor
if (TypeUtils.dependsOnTypeParameters(receiverParameter.type, candidateDescriptor.typeParameters)) return SUCCESS
@@ -465,11 +502,11 @@ class CandidateResolver(
val call = candidateCall.call
val safeAccess = isExplicitReceiver && !implicitInvokeCheck && call.isExplicitSafeCall()
val expectedReceiverParameterType = if (safeAccess) TypeUtils.makeNullable(receiverParameter.type) else receiverParameter.type
val smartCastNeeded = !ArgumentTypeResolver.isSubtypeOfForArgumentType(receiverArgument.type, expectedReceiverParameterType)
val notNullReceiverExpected = !ArgumentTypeResolver.isSubtypeOfForArgumentType(receiverArgument.type, expectedReceiverParameterType)
val smartCastNeeded =
notNullReceiverExpected || !isCandidateVisibleOrExtensionReceiver(receiverArgument, null, isDispatchReceiver)
var reportUnsafeCall = false
val dataFlowValue = DataFlowValueFactory.createDataFlowValue(receiverArgument, this)
val nullability = dataFlowInfo.getPredictableNullability(dataFlowValue)
var nullableImplicitInvokeReceiver = false
var receiverArgumentType = receiverArgument.type
if (implicitInvokeCheck && call is CallForImplicitInvoke && call.isSafeCall()) {
@@ -483,6 +520,9 @@ class CandidateResolver(
}
}
}
val dataFlowValue = DataFlowValueFactory.createDataFlowValue(receiverArgument, this)
val nullability = dataFlowInfo.getPredictableNullability(dataFlowValue)
val expression = (receiverArgument as? ExpressionReceiver)?.expression
if (nullability.canBeNull() && !nullability.canBeNonNull()) {
if (!TypeUtils.isNullableType(expectedReceiverParameterType)) {
@@ -496,14 +536,20 @@ class CandidateResolver(
// Look if smart cast has some useful nullability info
val smartCastResult = SmartCastManager.checkAndRecordPossibleCast(
dataFlowValue, expectedReceiverParameterType, expression, this, candidateCall.call.calleeExpression, /*recordType =*/true
dataFlowValue, expectedReceiverParameterType,
{ possibleSmartCast -> isCandidateVisibleOrExtensionReceiver(receiverArgument, possibleSmartCast, isDispatchReceiver) },
expression, this, candidateCall.call.calleeExpression, /*recordType =*/true
)
if (smartCastResult == null) {
reportUnsafeCall = true
if (notNullReceiverExpected) {
reportUnsafeCall = true
}
}
else {
candidateCall.setSmartCastDispatchReceiverType(smartCastResult.resultType)
if (isDispatchReceiver) {
candidateCall.setSmartCastDispatchReceiverType(smartCastResult.resultType)
}
if (!smartCastResult.isCorrect) {
// Error about unstable smart cast reported within checkAndRecordPossibleCast
return OTHER_ERROR
@@ -522,16 +568,17 @@ class CandidateResolver(
inner class ValueArgumentsCheckingResult(val status: ResolutionStatus, val argumentTypes: List<KotlinType>)
private fun checkGenericBoundsInAFunctionCall(
jetTypeArguments: List<KtTypeProjection>,
ktTypeArguments: List<KtTypeProjection>,
typeArguments: List<KotlinType>,
functionDescriptor: CallableDescriptor,
substitutor: TypeSubstitutor,
trace: BindingTrace) {
trace: BindingTrace
) {
val typeParameters = functionDescriptor.typeParameters
for (i in 0..Math.min(typeParameters.size, jetTypeArguments.size) - 1) {
val typeParameterDescriptor = typeParameters.get(i)
val typeArgument = typeArguments.get(i)
val typeReference = jetTypeArguments.get(i).getTypeReference()
for (i in 0..Math.min(typeParameters.size, ktTypeArguments.size) - 1) {
val typeParameterDescriptor = typeParameters[i]
val typeArgument = typeArguments[i]
val typeReference = ktTypeArguments[i].typeReference
if (typeReference != null) {
DescriptorResolver.checkBounds(typeReference, typeArgument, typeParameterDescriptor, substitutor, trace)
}
@@ -539,7 +586,7 @@ class CandidateResolver(
}
private fun <D : CallableDescriptor> CallCandidateResolutionContext<D>.shouldContinue() =
candidateResolveMode == CandidateResolveMode.FULLY || candidateCall.getStatus().possibleTransformToSuccess()
candidateResolveMode == CandidateResolveMode.FULLY || candidateCall.status.possibleTransformToSuccess()
private inline fun <D : CallableDescriptor> CallCandidateResolutionContext<D>.check(
checker: CallCandidateResolutionContext<D>.() -> Unit
@@ -547,13 +594,14 @@ class CandidateResolver(
if (shouldContinue()) checker()
}
private inline fun <D : CallableDescriptor> CallCandidateResolutionContext<D>.
checkAndReport(checker: CallCandidateResolutionContext<D>.() -> ResolutionStatus) {
private inline fun <D : CallableDescriptor> CallCandidateResolutionContext<D>.checkAndReport(
checker: CallCandidateResolutionContext<D>.() -> ResolutionStatus
) {
if (shouldContinue()) {
candidateCall.addStatus(checker())
}
}
private val CallCandidateResolutionContext<*>.candidateDescriptor: CallableDescriptor get() = candidateCall.getCandidateDescriptor()
private val CallCandidateResolutionContext<*>.candidateDescriptor: CallableDescriptor
get() = candidateCall.candidateDescriptor
}

View File

@@ -0,0 +1,59 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.resolve.calls.checkers
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
import org.jetbrains.kotlin.descriptors.Visibilities
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.psi.KtConstructorCalleeExpression
import org.jetbrains.kotlin.psi.KtConstructorDelegationReferenceExpression
import org.jetbrains.kotlin.psi.KtSuperTypeCallEntry
import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
import org.jetbrains.kotlin.resolve.descriptorUtil.parentsWithSelf
object ProtectedConstructorCallChecker : CallChecker {
override fun check(resolvedCall: ResolvedCall<*>, context: BasicCallResolutionContext) {
val descriptor = resolvedCall.resultingDescriptor as? ConstructorDescriptor ?: return
val constructorOwner = descriptor.containingDeclaration.original
val scopeOwner = context.scope.ownerDescriptor
if (descriptor.visibility.normalize() != Visibilities.PROTECTED) return
// Error already reported
if (!Visibilities.isVisibleWithAnyReceiver(descriptor, scopeOwner)) return
val calleeExpression = resolvedCall.call.calleeExpression ?: return
// Permit constructor super-calls
when (calleeExpression) {
is KtConstructorCalleeExpression -> if (calleeExpression.parent is KtSuperTypeCallEntry) return
is KtConstructorDelegationReferenceExpression -> return
}
// Permit calls within class
if (scopeOwner.parentsWithSelf.any { it.original === constructorOwner }) return
// Using FALSE_IF_PROTECTED helps us to check that descriptor doesn't meet conditions of java package/static-protected
// (i.e. being in the same package)
// And without ProtectedConstructorCallChecker such calls would be allowed only because they are performed within subclass
// of constructor owner
@Suppress("DEPRECATION")
if (Visibilities.findInvisibleMember(Visibilities.FALSE_IF_PROTECTED, descriptor, scopeOwner) == descriptor) {
context.trace.report(Errors.PROTECTED_CONSTRUCTOR_NOT_IN_SUPER_CALL.on(calleeExpression, descriptor))
}
}
}

View File

@@ -16,15 +16,14 @@
package org.jetbrains.kotlin.resolve.calls.resolvedCallUtil
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.psi.KtPsiUtil
import org.jetbrains.kotlin.psi.KtThisExpression
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext
import org.jetbrains.kotlin.resolve.calls.context.CallResolutionContext
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
import org.jetbrains.kotlin.resolve.calls.smartcasts.getReceiverValueWithSmartCast
import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind
import org.jetbrains.kotlin.resolve.descriptorUtil.getOwnerForEffectiveDispatchReceiverParameter
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
@@ -88,4 +87,7 @@ private fun ResolvedCall<*>.hasSafeNullableReceiver(context: CallResolutionConte
fun ResolvedCall<*>.makeNullableTypeIfSafeReceiver(type: KotlinType?, context: CallResolutionContext<*>) =
type?.let { TypeUtils.makeNullableIfNeeded(type, hasSafeNullableReceiver(context)) }
fun ResolvedCall<*>.hasBothReceivers() = dispatchReceiver != null && extensionReceiver != null
fun ResolvedCall<*>.hasBothReceivers() = dispatchReceiver != null && extensionReceiver != null
fun ResolvedCall<*>.getDispatchReceiverWithSmartCast(): ReceiverValue?
= getReceiverValueWithSmartCast(dispatchReceiver, smartCastDispatchReceiverType)

View File

@@ -179,9 +179,24 @@ public class SmartCastManager {
@NotNull ResolutionContext c,
@Nullable KtExpression calleeExpression,
boolean recordExpressionType
) {
return checkAndRecordPossibleCast(
dataFlowValue, expectedType, null, expression, c, calleeExpression, recordExpressionType);
}
@Nullable
public static SmartCastResult checkAndRecordPossibleCast(
@NotNull DataFlowValue dataFlowValue,
@NotNull KotlinType expectedType,
@Nullable Function1<KotlinType, Boolean> additionalPredicate,
@Nullable KtExpression expression,
@NotNull ResolutionContext c,
@Nullable KtExpression calleeExpression,
boolean recordExpressionType
) {
for (KotlinType possibleType : c.dataFlowInfo.getCollectedTypes(dataFlowValue)) {
if (ArgumentTypeResolver.isSubtypeOfForArgumentType(possibleType, expectedType)) {
if (ArgumentTypeResolver.isSubtypeOfForArgumentType(possibleType, expectedType)
&& (additionalPredicate == null || additionalPredicate.invoke(possibleType))) {
if (expression != null) {
recordCastOrError(expression, possibleType, c.trace, dataFlowValue, recordExpressionType);
}
@@ -209,7 +224,8 @@ public class SmartCastManager {
boolean immanentlyNotNull = !dataFlowValue.getImmanentNullability().canBeNull();
KotlinType nullableExpectedType = TypeUtils.makeNullable(expectedType);
if (ArgumentTypeResolver.isSubtypeOfForArgumentType(dataFlowValue.getType(), nullableExpectedType)) {
if (ArgumentTypeResolver.isSubtypeOfForArgumentType(dataFlowValue.getType(), nullableExpectedType)
&& (additionalPredicate == null || additionalPredicate.invoke(dataFlowValue.getType()))) {
if (!immanentlyNotNull) {
if (expression != null) {
recordCastOrError(expression, dataFlowValue.getType(), c.trace, dataFlowValue, recordExpressionType);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -103,14 +103,13 @@ public abstract class AbstractTracingStrategy implements TracingStrategy {
}
@Override
public void wrongNumberOfTypeArguments(@NotNull BindingTrace trace, int expectedTypeArgumentCount) {
public void wrongNumberOfTypeArguments(
@NotNull BindingTrace trace, int expectedTypeArgumentCount, @NotNull CallableDescriptor descriptor
) {
KtTypeArgumentList typeArgumentList = call.getTypeArgumentList();
if (typeArgumentList != null) {
trace.report(WRONG_NUMBER_OF_TYPE_ARGUMENTS.on(typeArgumentList, expectedTypeArgumentCount));
}
else {
trace.report(WRONG_NUMBER_OF_TYPE_ARGUMENTS.on(reference, expectedTypeArgumentCount));
}
trace.report(WRONG_NUMBER_OF_TYPE_ARGUMENTS.on(
typeArgumentList != null ? typeArgumentList : reference, expectedTypeArgumentCount, descriptor
));
}
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -67,7 +67,7 @@ public interface TracingStrategy {
public void noValueForParameter(@NotNull BindingTrace trace, @NotNull ValueParameterDescriptor valueParameter) {}
@Override
public void wrongNumberOfTypeArguments(@NotNull BindingTrace trace, int expectedTypeArgumentCount) {}
public void wrongNumberOfTypeArguments(@NotNull BindingTrace trace, int expectedTypeArgumentCount, @NotNull CallableDescriptor descriptor) {}
@Override
public <D extends CallableDescriptor> void ambiguity(@NotNull BindingTrace trace, @NotNull Collection<? extends ResolvedCall<D>> descriptors) {}
@@ -132,7 +132,11 @@ public interface TracingStrategy {
void noValueForParameter(@NotNull BindingTrace trace, @NotNull ValueParameterDescriptor valueParameter);
void wrongNumberOfTypeArguments(@NotNull BindingTrace trace, int expectedTypeArgumentCount);
void wrongNumberOfTypeArguments(
@NotNull BindingTrace trace,
int expectedTypeArgumentCount,
@NotNull CallableDescriptor descriptor
);
<D extends CallableDescriptor> void ambiguity(@NotNull BindingTrace trace, @NotNull Collection<? extends ResolvedCall<D>> descriptors);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -126,7 +126,7 @@ class TracingStrategyForImplicitConstructorDelegationCall(
unexpectedError("noReceiverAllowed")
}
override fun wrongNumberOfTypeArguments(trace: BindingTrace, expectedTypeArgumentCount: Int) {
override fun wrongNumberOfTypeArguments(trace: BindingTrace, expectedTypeArgumentCount: Int, descriptor: CallableDescriptor) {
unexpectedError("wrongNumberOfTypeArguments")
}

View File

@@ -160,7 +160,7 @@ open class FileScopeProviderImpl(
override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? {
if (name in excludedNames) return null
val classifier = scope.getContributedClassifier(name, location) ?: return null
val visible = Visibilities.isVisibleWithIrrelevantReceiver(classifier as ClassDescriptor, fromDescriptor)
val visible = Visibilities.isVisibleIgnoringReceiver(classifier as ClassDescriptor, fromDescriptor)
return classifier.check { filteringKind == if (visible) FilteringKind.VISIBLE_CLASSES else FilteringKind.INVISIBLE_CLASSES }
}

View File

@@ -180,7 +180,7 @@ class LazyImportScope(
val visibility = descriptor.visibility
val includeVisible = filteringKind == FilteringKind.VISIBLE_CLASSES
if (!visibility.mustCheckInImports()) return includeVisible
return Visibilities.isVisibleWithIrrelevantReceiver(descriptor, importResolver.moduleDescriptor) == includeVisible
return Visibilities.isVisibleIgnoringReceiver(descriptor, importResolver.moduleDescriptor) == includeVisible
}
override fun getContributedClassifier(name: Name, location: LookupLocation): ClassifierDescriptor? {

View File

@@ -124,9 +124,11 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
this.declarationProvider = c.getDeclarationProviderFactory().getClassMemberDeclarationProvider(classLikeInfo);
StorageManager storageManager = c.getStorageManager();
this.unsubstitutedMemberScope = createMemberScope(c, this.declarationProvider);
this.kind = classLikeInfo.getClassKind();
this.staticScope = kind == ClassKind.ENUM_CLASS ? new StaticScopeForKotlinEnum(this) : MemberScope.Empty.INSTANCE;
this.staticScope = kind == ClassKind.ENUM_CLASS ? new StaticScopeForKotlinEnum(storageManager, this) : MemberScope.Empty.INSTANCE;
this.typeConstructor = new LazyClassTypeConstructor();
@@ -154,8 +156,6 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
this.isInner = isInnerClass(modifierList) && !ModifiersChecker.isIllegalInner(this);
this.isData = modifierList != null && modifierList.hasModifier(KtTokens.DATA_KEYWORD);
StorageManager storageManager = c.getStorageManager();
// Annotation entries are taken from both own annotations (if any) and object literal annotations (if any)
List<KtAnnotationEntry> annotationEntries = new ArrayList<KtAnnotationEntry>();
if (classOrObject != null && classOrObject.getParent() instanceof KtObjectLiteralExpression) {

View File

@@ -17,10 +17,7 @@
package org.jetbrains.kotlin.resolve.scopes.receivers
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.psi.KtConstructorDelegationReferenceExpression
import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.kotlin.psi.KtReferenceExpression
import org.jetbrains.kotlin.psi.KtThisExpression
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.types.KotlinType
@@ -40,6 +37,12 @@ interface ExpressionReceiver : ReceiverValue {
type: KotlinType
) : ExpressionReceiverImpl(expression, type), ThisClassReceiver
private class SuperExpressionReceiver(
override val thisType: KotlinType,
expression: KtExpression,
type: KotlinType
) : ExpressionReceiverImpl(expression, type), SuperCallReceiverValue
fun create(
expression: KtExpression,
type: KotlinType,
@@ -56,7 +59,14 @@ interface ExpressionReceiver : ReceiverValue {
if (referenceExpression != null) {
val descriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, referenceExpression)
if (descriptor is ClassDescriptor) {
return ThisExpressionClassReceiver(descriptor.original as ClassDescriptor, expression, type)
return ThisExpressionClassReceiver(descriptor.original, expression, type)
}
}
else if (expression is KtSuperExpression) {
// if there is no THIS_TYPE_FOR_SUPER_EXPRESSION in binding context, we fall through into more restrictive option
// i.e. just return common ExpressionReceiverImpl
bindingContext[BindingContext.THIS_TYPE_FOR_SUPER_EXPRESSION, expression]?.let {
thisType -> return SuperExpressionReceiver(thisType, expression, type)
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
package org.jetbrains.kotlin.storage
import com.intellij.openapi.util.ModificationTracker
import org.jetbrains.kotlin.util.ReenteringLazyValueComputationException
import java.util.concurrent.atomic.AtomicLong
import org.jetbrains.kotlin.utils.rethrow
@@ -24,7 +25,10 @@ open class ExceptionTracker : ModificationTracker, LockBasedStorageManager.Excep
private val cancelledTracker: AtomicLong = AtomicLong()
override fun handleException(throwable: Throwable): RuntimeException {
incCounter()
// should not increment counter when ReenteringLazyValueComputationException is thrown since it implements correct frontend behaviour
if (throwable !is ReenteringLazyValueComputationException) {
incCounter()
}
throw rethrow(throwable)
}

View File

@@ -120,7 +120,7 @@ public class CastDiagnosticsUtil {
if (typeChecker.isSubtypeOf(supertype, subtype)) return false;
// downcasting to a non-reified type parameter is always erased
if (TypeUtils.isNonReifiedTypeParemeter(subtype)) return true;
if (TypeUtils.isNonReifiedTypeParameter(subtype)) return true;
// Check that we are actually casting to a generic type
// NOTE: this does not account for 'as Array<List<T>>'

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