Compare commits

...

72 Commits

Author SHA1 Message Date
Ilya Chernikov
5595bea2ea Remove xerces from compiler uberjar, pack compiler with explicit jar names
xercesImpl was unnecessarily added to the compiler uberjar during migration
to the idea platform 171. This caused NCDFE about classes from org.w3c
package.
And to simplify application of this commit and to ensure that only required
jars are packed into the uberjar, the build.xml was altered to use
explicit list of the jars from the ideaSdk/core directory, rather than
a mask.

Fixes #KT-17143 and #KT-17157
2017-03-30 19:28:46 +02:00
Mikhail Glukhikh
36a6288dee Inline function: add extra tests taken from intellij-community
(cherry picked from commit 8cfcd7e)
2017-03-30 19:51:05 +03:00
Mikhail Glukhikh
411962ee57 Inline function: keep the function if some usages are not processed
(cherry picked from commit b8b7d1f)
2017-03-30 19:50:49 +03:00
Mikhail Glukhikh
6532442701 Inline function: process usages in children-first order
(cherry picked from commit 091e875)
2017-03-30 19:50:34 +03:00
Mikhail Glukhikh
53cfd2095d Inline function: use "function" in GUI messages
(cherry picked from commit fc0bf47)
2017-03-30 19:50:19 +03:00
Mikhail Glukhikh
6b47229cf8 Inline function: handle callable references through lambdas
(cherry picked from commit 93b624f)
2017-03-30 19:50:05 +03:00
Mikhail Glukhikh
6991eadcf5 Inline function: handle recursive calls
(cherry picked from commit 75bb599)
2017-03-30 19:49:49 +03:00
Mikhail Glukhikh
25ed1553d1 Introduce dialog for function inlining #KT-6159 Fixed
See KotlinInlineFunctionProcessor and KotlinInlineFunctionDialog

(cherry picked from commit e79f006)
2017-03-30 19:49:34 +03:00
Mikhail Glukhikh
279bbb4732 KT-6159: generate Unit while code inlining when needed
(cherry picked from commit b6803af)
2017-03-30 19:49:17 +03:00
Mikhail Glukhikh
d6f86b7c05 Minor: deprecation fix in ScopeUtils
(cherry picked from commit 7de0197)
2017-03-30 19:49:03 +03:00
Mikhail Glukhikh
61664c02cd Fix code inlining for expression body with multiple occurrences
So #KT-17022 Fixed

(cherry picked from commit 081caad)
2017-03-30 19:48:43 +03:00
Mikhail Glukhikh
52a33cc494 Minor: style fix in KotlinInlineFunctionHandler
(cherry picked from commit 96846d0)
2017-03-30 19:48:24 +03:00
Mikhail Glukhikh
f80e78ac57 KT-6159: rename duplicates met
(cherry picked from commit 7788834)
2017-03-30 19:48:10 +03:00
Mikhail Glukhikh
d3587bb028 Do not perform function inlining if it's not supported
(cherry picked from commit 342118d)
2017-03-30 19:47:55 +03:00
Mikhail Glukhikh
2aff73b432 KT-6159: allow local / private functions inlining
(cherry picked from commit de86106)
2017-03-30 19:47:41 +03:00
Mikhail Glukhikh
f08fd888a8 Some inline tests that do not work
(cherry picked from commit 127b7c8)
2017-03-30 19:47:19 +03:00
Mikhail Glukhikh
08abb61e12 KT-6159: Inline function refactoring enabled
(cherry picked from commit 1d5b8ea)
2017-03-30 19:47:01 +03:00
Dmitry Jemerov
ef6669e865 Optimize isReferenceTo() when searching for PsiMethod usages
Avoid resolving references when we know from context that a reference
at given location can't resolve to a PsiMethod.

(cherry picked from commit f255f2a)
2017-03-30 15:34:48 +02:00
Mikhail Glukhikh
e7f7673123 Use library-only sources as resolve scope from library #KT-12264 Fixed
(cherry picked from commit e3f0a60)
2017-03-30 14:02:00 +03:00
Mikhail Glukhikh
e85ca8de52 Evaluate allImplementingModules lazily #KT-17136 Fixed
(cherry picked from commit a35b770)
2017-03-29 18:22:01 +03:00
Simon Ogorodnik
c6385f9309 Fix ImportFixBase to compute suggestions not on EDT
(cherry picked from commit ddcff3c)
2017-03-29 17:36:47 +03:00
Vyacheslav Gerasimov
c2417ac243 Add changelog for 1.1.2
(cherry picked from commit 94b261d)
2017-03-29 16:12:39 +03:00
Dmitry Petrov
9e236c4a23 KT-16264 Forbid usage of _ without backticks
Forbid underscore-only (_, __, ___, ...) names as callees and as types.

If CHECK_TYPE directive is on, filter out UNDERSCORE_USAGE_WITHOUT_BACKTICKS messages.
2017-03-29 15:54:34 +03:00
Yan Zhulanow
dd32987eb2 Fix 'kotlin-spring' and 'kotlin-noarg' Gradle plugin importing (KT-17049)
Allopen and Noarg plugins now use 'presets' that should be handled in the Gradle importer as well.
2017-03-29 13:52:00 +03:00
Pavel V. Talanov
b141f3754a KtLightElements: fix KtLightMember not extending KtLightDeclaration
Fix problem introduced in 4b85fd9fbe
2017-03-28 19:48:19 +03:00
Yan Zhulanow
2fc74d2819 Minor: fix failing CliTestGenerated#testPluginSimple test
Add missing Android Dialog stub cause Android Extensions plugin now generates the synthetic property for Dialog.
2017-03-28 16:09:23 +03:00
Dmitry Jemerov
6c6e163881 Log fallbacks to plain text search when searching expressions of type
This will help diagnose performance problems in IDEA inspections.

(cherry picked from commit 8ec70f4)
2017-03-28 13:07:50 +02:00
Sergey Igushkin
0ee4ddfda9 Support omitting version of org.jetbrains.kotlin dependencies
Related to #KT-12792

(cherry picked from commit ae2b4f5)
2017-03-28 08:39:35 +03:00
Sergey Igushkin
01c92992c9 Fixed classes copying fail in cases when destinationDir has changed
Added @Input to the property returning classes dirs: it will make
Gradle fall back to non-incremental input when the property value
changes.

Issues: #KT-16820 Fixed

(cherry picked from commit 9ba84df)
2017-03-28 08:39:11 +03:00
Jonathan Leitschuh
4154bba5a3 Java IC compatibility fix for Gradle 2.14+
Added version check to switch between old and new approaches because
Gradle versions before 2.14 have a bug in Java IC.
Added Kotlin classes to Java task input.
Added  annotationsFile into task input to include it into up-to-date check.

Related issues: #KT-16585 Fixed

(cherry picked from commit cc0ac36)
2017-03-28 08:38:51 +03:00
Ilya Gorbunov
cf6cef71e2 Remove 'nearly_stateless' category, do not mention statefulness for terminal operations.
#KT-16994

(cherry picked from commit c98c2d9)
2017-03-28 00:11:53 +03:00
Ilya Gorbunov
ce5a104eb2 Sequence operation classification regarding their statefulness and laziness.
#KT-16994 Fixed

(cherry picked from commit 4018db6)
2017-03-28 00:11:46 +03:00
Simon Ogorodnik
94b5148d5b Revert: Fix Sample reference to resolve cross-module packages correctly 2017-03-27 21:41:07 +03:00
Pavel V. Talanov
5c0831d5ad findDecompiledDeclaration: find builtIns more accurately
Use resolveScope of a reference to help searching for builtIn binaries
Do not search non-builtIn descriptors in random scopes
2017-03-27 21:23:40 +03:00
Alexander Udalov
894f85d822 Disallow using named arguments for members of header classes
#KT-17083 Fixed

(cherry picked from commit ccd3781403)
2017-03-27 20:12:17 +03:00
Alexander Udalov
9e1a4992d8 Allow impl declarations to have flexible types
Types of the corresponding parameters (or type parameter bounds, types
in supertypes, etc) are now compatible not only if they're equal, but
also if values of those types are mutually assignable (if "a" is subtype
of "b" and "b" is subtype of "a")

 #KT-17005 Fixed

(cherry picked from commit b971ac9312)
2017-03-27 20:12:15 +03:00
Alexander Udalov
1b7198cb03 Allow impl declarations to have non-stable parameter names
#KT-17027 Fixed

(cherry picked from commit 116380a826)
2017-03-27 20:12:14 +03:00
Alexander Udalov
24182e39d8 Render incompatible impl member in "no impl for header" diagnostic
(cherry picked from commit 633798db18)
2017-03-27 20:12:12 +03:00
Alexander Udalov
b6e32cc03d Serialize and deserialize 'header' modifier for descriptors
This fixes KT-17001 because now 'header' modifier is loaded correctly
for deserialized members and the standard disambiguation in
OverloadingConflictResolver.compareCallsByUsedArguments takes place,
where header members are discriminated against the corresponding impl
members

 #KT-17001 Fixed

(cherry picked from commit db1f039586)
2017-03-27 20:12:10 +03:00
Pavel V. Talanov
4518c5bac6 Light class tests: hidden deprecated affects codegen
Provide fix later
2017-03-27 18:02:43 +03:00
Pavel V. Talanov
58ad4b1386 Lazy light classes: can't use laziness for classes with supertypes delegates 2017-03-27 18:02:41 +03:00
Pavel V. Talanov
1f62636400 KtLightMethod: isVarArgs() does not trigger exact delegate computation 2017-03-27 18:02:39 +03:00
Pavel V. Talanov
b10adf2de0 Light members: allow to get modifier list without computing delegate 2017-03-27 18:02:38 +03:00
Pavel V. Talanov
5befeb4ccf LazyLightClassDataHolder: rollback optimization on suspected inherited internal visibility
Internal visibility affects member names
2017-03-27 18:02:36 +03:00
Pavel V. Talanov
614a4fec22 Light classes: refactor, move getOrigin to corresponding classes 2017-03-27 18:02:34 +03:00
Pavel V. Talanov
bd45c70083 Lazy light classes: fix visibility modifier in case of inherited protected visibility 2017-03-27 18:02:33 +03:00
Pavel V. Talanov
2961301297 LightClassTest: test corner cases related to inherited visiblity
EA-99155
 #KT-16899 Fixed
2017-03-27 18:02:31 +03:00
Pavel V. Talanov
bdde75a6a3 Refactor light members: introduce KtLightMemberImpl
Holds common code for fields and methods
2017-03-27 18:02:29 +03:00
Pavel V. Talanov
e325523034 Introduce KotlinOverridableInternalMembersShortNameIndex
Keeping track of all potentially overridable internal members
To optimize certain scenarios in light classes
2017-03-27 18:02:27 +03:00
Pavel V. Talanov
84f17ba1a1 Minor, stubs: isTrait -> isInterface 2017-03-27 18:02:25 +03:00
Alexander Udalov
c649752e8e Do not use CoreJavaFileManager in KotlinCliJavaFileManagerImpl
The inheritance is still needed because of the code in intellij-core,
specifically in JavaCoreProjectEnvironment.addSourcesToClasspath and
CoreJavaDirectoryService.getPackage, which assumes that the
JavaFileManager instance in the project is a CoreJavaFileManager

(cherry picked from commit 1c7ac2da5a)
2017-03-27 17:20:10 +03:00
Alexander Udalov
9cace66246 Support nested classes in KotlinCliJavaFileManagerImpl.findClass
findClass(String, GlobalSearchScope) is invoked for example when we're
resolving supertypes of classes in Java libraries. Previously, it never
found nested classes and falled back to CoreJavaFileManager's
implementation, which lacks a fix for the original issue (KT-12664,
which was fixed in JvmDependenciesIndex in 5a533a52 and 164c72e8)

 #KT-16931 Fixed

(cherry picked from commit c67eb84369)
2017-03-27 17:20:08 +03:00
Alexander Udalov
6375fb773d Refactor JvmDependenciesIndex
- Move collectKnownClassNamesInPackage to the only place where it's used
- Fix warnings/inspections and simplify implementation a bit

(cherry picked from commit f1a1ebae01)
2017-03-27 17:20:07 +03:00
Alexander Udalov
b6f1cf8107 Refactor KotlinJavaPsiFacade.KotlinPsiElementFinderImpl
Split KotlinPsiElementFinderImpl into two classes: one is used in the
compiler (boolean field isCliFileManager previously handled that), the
other is used in IDE and possibly other non-CLI scenarios.

Also avoid a possible class cast exception in
KotlinJavaPsiFacade.knownClassNamesInPackage

(cherry picked from commit 801a93edbc)
2017-03-27 17:20:05 +03:00
Ilya Gorbunov
86ced88e0d Run gradle unit tests with Java 8
(cherry picked from commit d54f114)
2017-03-27 11:39:32 +03:00
Ilya Gorbunov
06e909acad Fix missing kotlin-test dependencies
(previously it was bundled to kotlin-compiler-embeddable)

(cherry picked from commit 6dc4056)
2017-03-27 11:39:32 +03:00
Vyacheslav Gerasimov
95d774697c Fix MovePropertyToConstructorIntention and broken tests
(cherry picked from commit 8c41e44)
2017-03-27 11:39:32 +03:00
Alexey Sedunov
7bc246f614 Move: Fix conflict checking when switching between similar libraries
#KT-17006 Fixed

(cherry picked from commit 298ee26)
2017-03-26 16:28:49 +03:00
Alexey Sedunov
a2bb0ace05 Resolution Facade: Add explicit property for file target platform
(cherry picked from commit 45b8cd2)
2017-03-26 16:28:33 +03:00
Alexey Sedunov
3594294d0a Move: Fix runtime unconfiguration for multiple modules
(cherry picked from commit 87ea13b)
2017-03-26 16:28:13 +03:00
Alexey Sedunov
fca79f9bf9 Move: Fix processing of calls and callable references
Fix CCE on callable references to Java methods.
Fix qualification of callable references without receivers.
Fix processing of calls/callable references to object extensions
and extension members.
Do not explicate short companion references

 #KT-16809 Fixed

(cherry picked from commit 1d01624)
2017-03-26 16:28:00 +03:00
Alexey Sedunov
fd5bb25349 Move: Perform extension import insertion after reference shortening
(cherry picked from commit 5849555)
2017-03-26 16:27:46 +03:00
Alexey Sedunov
5fbd738f24 Refactor KotlinShortenReferencesRefactringHelper
Rename refactoring helper and its infrastructure
Add support for different request types

(cherry picked from commit b3274ac)
2017-03-26 16:27:34 +03:00
Alexey Sedunov
63e4beab76 Move: Do not shorten references unaffected by the refactoring
(cherry picked from commit dc04b20)
2017-03-26 16:27:12 +03:00
Alexey Sedunov
89caa70987 Shorten References: Skip companion receivers on callable references
This is temporary fix due to KT-13934 which prevents resolution
of references like X::foo where foo is a member or extension
of X companion object

(cherry picked from commit aad11ff)
2017-03-26 16:26:58 +03:00
Alexey Sedunov
ea8b082355 Move: Fix "scanEntireFile" values after the refactoring
#KT-17032 Fixed

(cherry picked from commit d71cefe)
2017-03-26 16:26:01 +03:00
Alexey Sedunov
ae0218431c Kotlin Facet: Detect module platform by 'kotlin'/'kotlin2js' plugin
(cherry picked from commit b818ef0)
2017-03-26 16:25:23 +03:00
Alexey Sedunov
77dff7b7f5 Kotlin Facet: Fix settings initialization
(cherry picked from commit 0ad2822)
2017-03-26 16:24:40 +03:00
Alexander Udalov
15502b4153 Update to ASM 6-alpha from intellij 171
Will be needed to read module-info files
2017-03-24 20:17:43 +03:00
Alexander Udalov
b9891c36e2 Remove unused library 'intellij-core-analysis' 2017-03-24 20:17:40 +03:00
Yan Zhulanow
d3a9008bd3 Kapt3: Fix Maven build on CI
'tools_jar_profile' Maven profile is activated only if 'kotlin-annotation-processing-maven-build.txt' exists.
It already works this say for the 'kotlin-annotation-processing' artifact.
2017-03-24 20:06:09 +03:00
Yan Zhulanow
249a3a0ec9 Kapt3: Use 'compilerArgs' safely (KT-16990)
'android-apt' (com.neenbedankt) adds the 'File' instance to 'compilerArgs' (List<String>).
2017-03-24 20:06:02 +03:00
372 changed files with 6766 additions and 1079 deletions

View File

@@ -8,7 +8,7 @@
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$PROJECT_DIR$/dependencies/asm5-src.zip!/" />
<root url="jar://$PROJECT_DIR$/dependencies/asm-src.zip!/" />
</SOURCES>
</library>
</component>

View File

@@ -10,8 +10,8 @@
<JAVADOC />
<SOURCES>
<root url="jar://$PROJECT_DIR$/dependencies/guava-19.0-sources.jar!/" />
<root url="jar://$PROJECT_DIR$/dependencies/asm5-src.zip!/" />
<root url="jar://$PROJECT_DIR$/ideaSDK/sources/sources.jar!/" />
<root url="jar://$PROJECT_DIR$/dependencies/asm-src.zip!/" />
</SOURCES>
<jarDirectory url="file://$PROJECT_DIR$/ideaSDK/lib" recursive="false" />
</library>

View File

@@ -10,8 +10,8 @@
<JAVADOC />
<SOURCES>
<root url="jar://$PROJECT_DIR$/dependencies/guava-19.0-sources.jar!/" />
<root url="jar://$PROJECT_DIR$/dependencies/asm5-src.zip!/" />
<root url="jar://$PROJECT_DIR$/ideaSDK/sources/sources.jar!/" />
<root url="jar://$PROJECT_DIR$/dependencies/asm-src.zip!/" />
</SOURCES>
<jarDirectory url="file://$PROJECT_DIR$/ideaSDK/core" recursive="false" />
</library>

View File

@@ -1,17 +0,0 @@
<component name="libraryTable">
<library name="intellij-core-analysis">
<ANNOTATIONS>
<root url="file://$PROJECT_DIR$/annotations" />
<root url="jar://$PROJECT_DIR$/ideaSDK/sources/sources.jar!/" />
</ANNOTATIONS>
<CLASSES>
<root url="jar://$PROJECT_DIR$/ideaSDK/core-analysis/intellij-core-analysis.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$PROJECT_DIR$/dependencies/asm5-src.zip!/" />
<root url="jar://$PROJECT_DIR$/dependencies/guava-19.0-sources.jar!/" />
<root url="jar://$PROJECT_DIR$/ideaSDK/sources/sources.jar!/" />
</SOURCES>
</library>
</component>

View File

@@ -3,6 +3,259 @@
<!-- Find: ([^\`/\[])(KT-\d+) -->
<!-- Replace: $1[`$2`](https://youtrack.jetbrains.com/issue/$2) -->
## 1.1.2
### Compiler
- [`KT-3805`](https://youtrack.jetbrains.com/issue/KT-3805) Report error on double constants out of range
- [`KT-6014`](https://youtrack.jetbrains.com/issue/KT-6014) Wrong ABSTRACT_MEMBER_NOT_IMPLEMENTED for toString implemented by delegation
- [`KT-8689`](https://youtrack.jetbrains.com/issue/KT-8689) NoSuchMethodError on local functions inside inlined lambda with variables captured from outer context
- [`KT-8959`](https://youtrack.jetbrains.com/issue/KT-8959) Missing diagnostic when trying to call inner class constructor qualificated with outer class name
- [`KT-11010`](https://youtrack.jetbrains.com/issue/KT-11010) NDFDE for local object with type parameters
- [`KT-11314`](https://youtrack.jetbrains.com/issue/KT-11314) Abstract generic class with Array<Array<T>> parameter compiles fine but fails at runtime with "Bad type on operand stack" VerifyError
- [`KT-12477`](https://youtrack.jetbrains.com/issue/KT-12477) Do not report 'const' inapplicability on property of error type
- [`KT-12839`](https://youtrack.jetbrains.com/issue/KT-12839) Two null checks are generated when manually null checking platform type
- [`KT-12881`](https://youtrack.jetbrains.com/issue/KT-12881) Descriptor wasn't found for declaration TYPE_PARAMETER
- [`KT-13342`](https://youtrack.jetbrains.com/issue/KT-13342) Unqualified super call should not resolve to a method of supertype overriden in another supertype
- [`KT-14058`](https://youtrack.jetbrains.com/issue/KT-14058) Unexpected error MISSING_DEPENDENCY_CLASS
- [`KT-14236`](https://youtrack.jetbrains.com/issue/KT-14236) Allow to use emptyArray in annotation
- [`KT-14536`](https://youtrack.jetbrains.com/issue/KT-14536) IllegalStateException: Type parameter T not found for lazy class Companion at LazyDeclarationResolver visitTypeParameter
- [`KT-14565`](https://youtrack.jetbrains.com/issue/KT-14565) Cannot pop operand off empty stack when compiling enum class
- [`KT-14566`](https://youtrack.jetbrains.com/issue/KT-14566) Make kotlin.jvm.internal.Ref$...Ref classes serializable
- [`KT-14567`](https://youtrack.jetbrains.com/issue/KT-14567) VerifyError: Bad type on operand stack (generics with operator methods)
- [`KT-14607`](https://youtrack.jetbrains.com/issue/KT-14607) Incorrect class name "ava/lang/Void from AsyncTask extension function
- [`KT-14811`](https://youtrack.jetbrains.com/issue/KT-14811) Unecessary checkcast generated in parameterized functions.
- [`KT-14865`](https://youtrack.jetbrains.com/issue/KT-14865) Throwable exception at KotlinParser parseLambdaExpression on typing { inside a string inside a lambda
- [`KT-14963`](https://youtrack.jetbrains.com/issue/KT-14963) unnecessary checkcast java/lang/Object
- [`KT-15105`](https://youtrack.jetbrains.com/issue/KT-15105) Comparing Chars in a Pair results in ClassCastException
- [`KT-15109`](https://youtrack.jetbrains.com/issue/KT-15109) Subclass from a type alias with named parameter in constructor will produce compiler exception
- [`KT-15192`](https://youtrack.jetbrains.com/issue/KT-15192) Compiler crashes on certain companion objects: "Error generating constructors of class Companion with kind IMPLEMENTATION"
- [`KT-15230`](https://youtrack.jetbrains.com/issue/KT-15230) Multiplatform: impl member with generic type is not matched to header class correctly
- [`KT-15382`](https://youtrack.jetbrains.com/issue/KT-15382) Merge light-analysis tests into black box codegen tests
- [`KT-15424`](https://youtrack.jetbrains.com/issue/KT-15424) javac crash when calling Kotlin function having generic varargs with default and @JvmOverloads
- [`KT-15516`](https://youtrack.jetbrains.com/issue/KT-15516) Compiler error when passing suspending extension-functions as parameter and casting stuff to Any
- [`KT-15521`](https://youtrack.jetbrains.com/issue/KT-15521) Header classes shadow their implementations in platform specific project
- [`KT-15574`](https://youtrack.jetbrains.com/issue/KT-15574) Can't instantiate Array through Type Alias
- [`KT-15594`](https://youtrack.jetbrains.com/issue/KT-15594) java.lang.VerifyError when referencing normal getter in @JvmStatic getters inside an object
- [`KT-15742`](https://youtrack.jetbrains.com/issue/KT-15742) Update to Idea 171
- [`KT-15759`](https://youtrack.jetbrains.com/issue/KT-15759) tailrec suspend function fails to compile
- [`KT-15802`](https://youtrack.jetbrains.com/issue/KT-15802) Java constant referenced using subclass is not considered a constant expression
- [`KT-15862`](https://youtrack.jetbrains.com/issue/KT-15862) Inline generic functions can unexpectedly box primitives
- [`KT-15871`](https://youtrack.jetbrains.com/issue/KT-15871) Unnecessary boxing for equality operator on inlined primitive values
- [`KT-15872`](https://youtrack.jetbrains.com/issue/KT-15872) Constant folding is mistakenly triggered for user function
- [`KT-15901`](https://youtrack.jetbrains.com/issue/KT-15901) Unstable smart cast target after type check
- [`KT-15946`](https://youtrack.jetbrains.com/issue/KT-15946) Kotlin-JPA plugin support for @Embeddable
- [`KT-15951`](https://youtrack.jetbrains.com/issue/KT-15951) Callable reference to class constructor from object is not resolved
- [`KT-15993`](https://youtrack.jetbrains.com/issue/KT-15993) Property annotations are stored in private fields and killed by obfuscators
- [`KT-15997`](https://youtrack.jetbrains.com/issue/KT-15997) Reified generics don't work properly with crossinline functions
- [`KT-16077`](https://youtrack.jetbrains.com/issue/KT-16077) Redundant private getter for private var in a class within a JvmMultifileClass annotated file
- [`KT-16113`](https://youtrack.jetbrains.com/issue/KT-16113) Support destructuring parameters of suspend lambda with suspend componentX
- [`KT-16194`](https://youtrack.jetbrains.com/issue/KT-16194) Code with unnecessary safe call contains redundant boxing/unboxing for primitive values
- [`KT-16232`](https://youtrack.jetbrains.com/issue/KT-16232) Prohibit objects inside inner classes
- [`KT-16233`](https://youtrack.jetbrains.com/issue/KT-16233) Prohibit inner sealed classes
- [`KT-16245`](https://youtrack.jetbrains.com/issue/KT-16245) Redundant null-check generated for a cast of already non-nullable value
- [`KT-16250`](https://youtrack.jetbrains.com/issue/KT-16250) Import methods from typealias to object throws compiler exception "Should be class or package: typealias"
- [`KT-16252`](https://youtrack.jetbrains.com/issue/KT-16252) IDL2K: Add ItemArrayLike interface implementation to collection-like classes
- [`KT-16272`](https://youtrack.jetbrains.com/issue/KT-16272) Missing deprecation and SinceKotlin-related diagnostic for variable as function call
- [`KT-16278`](https://youtrack.jetbrains.com/issue/KT-16278) Public member method can't be used for callable reference because of private static with the same name
- [`KT-16372`](https://youtrack.jetbrains.com/issue/KT-16372) 'mod is deprecated' warning should not be shown when language version is 1.0
- [`KT-16484`](https://youtrack.jetbrains.com/issue/KT-16484) SimpleTypeImpl should not be created for error type: ErrorScope
- [`KT-16528`](https://youtrack.jetbrains.com/issue/KT-16528) Error: Loop in supertypes when using Java classes with type parameters having raw interdependent supertypes
- [`KT-16532`](https://youtrack.jetbrains.com/issue/KT-16532) Kotlin 1.1 RC - Android cross-inline synchronized won't run
- [`KT-16538`](https://youtrack.jetbrains.com/issue/KT-16538) No smart cast when equals is present
- [`KT-16555`](https://youtrack.jetbrains.com/issue/KT-16555) VerifyError: Bad type on operand stack
- [`KT-16572`](https://youtrack.jetbrains.com/issue/KT-16572) Add links to Mozilla Developer Network to kdocs of classes that we generate from IDL
- [`KT-16627`](https://youtrack.jetbrains.com/issue/KT-16627) Do not make private members open in all-open plugin
- [`KT-16699`](https://youtrack.jetbrains.com/issue/KT-16699) Script resolving doesn't work with custom templates located in an external jar
- [`KT-16713`](https://youtrack.jetbrains.com/issue/KT-16713) Insufficient maximum stack size
- [`KT-16720`](https://youtrack.jetbrains.com/issue/KT-16720) ClassCastException during compilation
- [`KT-16732`](https://youtrack.jetbrains.com/issue/KT-16732) Type 'java/lang/Number' (current frame, stack[0]) is not assignable to 'java/lang/Character
- [`KT-16782`](https://youtrack.jetbrains.com/issue/KT-16782) Enum entry is incorrectly forbidden on LHS of '::' with language version 1.0
- [`KT-16812`](https://youtrack.jetbrains.com/issue/KT-16812) import in .kts file does not works
- [`KT-16815`](https://youtrack.jetbrains.com/issue/KT-16815) Assertion error from compiler: unexpected classifier: class DeserializedTypeAliasDescriptor
- [`KT-16927`](https://youtrack.jetbrains.com/issue/KT-16927) Using `KotlinJsr223JvmLocalScriptEngineFactory` causes multiple warnings
- [`KT-16929`](https://youtrack.jetbrains.com/issue/KT-16929) `VerifyError` when using bound method reference on generic property
- [`KT-16931`](https://youtrack.jetbrains.com/issue/KT-16931) Compiler cannot see inner class when for outer class exist folder with same name
- [`KT-16956`](https://youtrack.jetbrains.com/issue/KT-16956) Prohibit using function calls inside default parameter values of annotations
- [`KT-16968`](https://youtrack.jetbrains.com/issue/KT-16968) AssertionError: Cannot load extensions/common.xml from kotlin-compiler.jar after update to IDEA 171
- [`KT-17001`](https://youtrack.jetbrains.com/issue/KT-17001) Overload ambiguity between header and impl top level declarations
- [`KT-17005`](https://youtrack.jetbrains.com/issue/KT-17005) Impossible to provide impl with typealias due to platform types in signature
- [`KT-17027`](https://youtrack.jetbrains.com/issue/KT-17027) Allow impl declarations to have non-stable (and thus potentially different) parameter names
- [`KT-17083`](https://youtrack.jetbrains.com/issue/KT-17083) Disallow using named arguments for members of header classes
### Tools
- [`KT-15420`](https://youtrack.jetbrains.com/issue/KT-15420) Maven, all-open plugin: in console the settings of all-open are always reported as empty
#### Kapt
- [`KT-12432`](https://youtrack.jetbrains.com/issue/KT-12432) Dagger 2 does not generate Component which was referenced from Kotlin file.
- [`KT-8558`](https://youtrack.jetbrains.com/issue/KT-8558) KAPT only works with service-declared annotation processors
- [`KT-16753`](https://youtrack.jetbrains.com/issue/KT-16753) kapt3 generates invalid stubs when IC is enabled
- [`KT-16458`](https://youtrack.jetbrains.com/issue/KT-16458) kotlin-kapt / kapt3: "cannot find symbol" error for companion object with same name as enclosing class
- [`KT-14478`](https://youtrack.jetbrains.com/issue/KT-14478) Add APT / Kapt support to the maven plugin
- [`KT-14070`](https://youtrack.jetbrains.com/issue/KT-14070) Kapt3: kapt doesn't compile generated Kotlin files and doesn't use the "kapt.kotlin.generated" folder anymore
#### Gradle
- [`KT-15084`](https://youtrack.jetbrains.com/issue/KT-15084) Navigation into sources of gradle-script-kotlin doesn't work
- [`KT-16003`](https://youtrack.jetbrains.com/issue/KT-16003) Gradle Plugin Fails When Run From Jenkins On Multiple Nodes
- [`KT-16585`](https://youtrack.jetbrains.com/issue/KT-16585) Kotlin Gradle Plugin makes using Gradle Java incremental compiler not work
- [`KT-16902`](https://youtrack.jetbrains.com/issue/KT-16902) Gradle plugin compilation on daemon fails on Linux ARM
- [`KT-14619`](https://youtrack.jetbrains.com/issue/KT-14619) Gradle: The '-d' option with a directory destination is ignored because '-module' is specified
- [`KT-12792`](https://youtrack.jetbrains.com/issue/KT-12792) Automatically configure standard library dependency and set its version equal to compiler version if not specified
- [`KT-15994`](https://youtrack.jetbrains.com/issue/KT-15994) Compiler arguments are not copied from the main compile task to kapt task
- [`KT-16820`](https://youtrack.jetbrains.com/issue/KT-16820) Changing compileKotlin.destinationDir leads to failure in :copyMainKotlinClasses task due to an NPE
- [`KT-16917`](https://youtrack.jetbrains.com/issue/KT-16917) First connection to daemon after start timeouts when DNS is slow
### Android support
- [`KT-16624`](https://youtrack.jetbrains.com/issue/KT-16624) Implement quickfix "Add TargetApi/RequiresApi annotation" for Android api issues
- [`KT-16625`](https://youtrack.jetbrains.com/issue/KT-16625) Implement quickfix "Surround with if (VERSION.SDK_INT >= VERSION_CODES.SOME_VERSION) { ... }" for Android api issues
- [`KT-16840`](https://youtrack.jetbrains.com/issue/KT-16840) Kotlin Gradle plugin fails with Android Gradle plugin 2.4.0-alpha1
- [`KT-16897`](https://youtrack.jetbrains.com/issue/KT-16897) Gradle plugin 1.1.1 duplicates all main classes into Android instrumentation test APK
- [`KT-16957`](https://youtrack.jetbrains.com/issue/KT-16957) Android Extensions: Support Dialog class
- [`KT-15023`](https://youtrack.jetbrains.com/issue/KT-15023) Android `gradle installDebugAndroidTest` fails unless you first call `gradle assembleDebugAndroidTest`
- [`KT-12769`](https://youtrack.jetbrains.com/issue/KT-12769) "Name for method must be provided" error occurs on trying to use spaces in method name in integration tests in Android
- [`KT-12819`](https://youtrack.jetbrains.com/issue/KT-12819) Kotlin Lint: False positive for "Unconditional layout inflation" when using elvis operator
- [`KT-15116`](https://youtrack.jetbrains.com/issue/KT-15116) Kotlin Lint: problems in property accessors are not reported
- [`KT-15156`](https://youtrack.jetbrains.com/issue/KT-15156) Kotlin Lint: problems in annotation parameters are not reported
- [`KT-15179`](https://youtrack.jetbrains.com/issue/KT-15179) Kotlin Lint: problems inside local function are not reported
- [`KT-14870`](https://youtrack.jetbrains.com/issue/KT-14870) Kotlin Lint: problems inside local class are not reported
- [`KT-14920`](https://youtrack.jetbrains.com/issue/KT-14920) Kotlin Lint: "Android Lint for Kotlin | Incorrect support annotation usage" inspection does not report problems
- [`KT-14947`](https://youtrack.jetbrains.com/issue/KT-14947) Kotlin Lint: "Calling new methods on older versions" could suggest specific quick fixes
- [`KT-12741`](https://youtrack.jetbrains.com/issue/KT-12741) Android Extensions: Enable IDE plugin only if it is enabled in the build.gradle file
- [`KT-13122`](https://youtrack.jetbrains.com/issue/KT-13122) Implement '@RequiresApi' intention for android and don't report warning on annotated classes
- [`KT-16680`](https://youtrack.jetbrains.com/issue/KT-16680) Stack overflow in UAST containsLocalTypes()
- [`KT-15451`](https://youtrack.jetbrains.com/issue/KT-15451) Support "Android String Reference" folding in Kotlin files
- [`KT-16132`](https://youtrack.jetbrains.com/issue/KT-16132) Renaming property provided by kotlinx leads to renaming another members
### IDE
- [`KT-4578`](https://youtrack.jetbrains.com/issue/KT-4578) Intention to move property between class body and constructor parameter
- [`KT-7516`](https://youtrack.jetbrains.com/issue/KT-7516) Rename refactoring doesn't rename related labels
- [`KT-7520`](https://youtrack.jetbrains.com/issue/KT-7520) Exception when try rename label from usage
- [`KT-8568`](https://youtrack.jetbrains.com/issue/KT-8568) Provide a QuickFix to replace type `Array<Int>` in annotation with `IntArray`
- [`KT-8955`](https://youtrack.jetbrains.com/issue/KT-8955) Refactor / Move package: KNPE at KotlinMoveDirectoryWithClassesHelper.postProcessUsages() with not matching package statement
- [`KT-9275`](https://youtrack.jetbrains.com/issue/KT-9275) Unhelpful IDE warning "Configure Kotlin"
- [`KT-10393`](https://youtrack.jetbrains.com/issue/KT-10393) Detect calls to functions returning a lambda from expression body which ignore the return value
- [`KT-11234`](https://youtrack.jetbrains.com/issue/KT-11234) Debugger won't hit breakpoint in nested lamba
- [`KT-11393`](https://youtrack.jetbrains.com/issue/KT-11393) Inspection to highlight and warn on usage of internal members in other module from Java
- [`KT-11828`](https://youtrack.jetbrains.com/issue/KT-11828) Configure Kotlin in Project: failure for Gradle modules without build.gradle (IDEA creates them)
- [`KT-11863`](https://youtrack.jetbrains.com/issue/KT-11863) Refactor / Move: moving referred file level elements to another package keeps reference to old FQN
- [`KT-12002`](https://youtrack.jetbrains.com/issue/KT-12002) Improve completion for closure parameters to work in more places
- [`KT-12004`](https://youtrack.jetbrains.com/issue/KT-12004) IDE inspection that destructuring variable name matches the other name in data class
- [`KT-12183`](https://youtrack.jetbrains.com/issue/KT-12183) Intention converting several calls with same receiver to 'with'/`apply`/`run`
- [`KT-12261`](https://youtrack.jetbrains.com/issue/KT-12261) Partial body resolve doesn't resolve anything in object literal used as an expression body of a method
- [`KT-13013`](https://youtrack.jetbrains.com/issue/KT-13013) "Go to Type Declaration" doesn't work for extension receiver and implict lambda parameter
- [`KT-13111`](https://youtrack.jetbrains.com/issue/KT-13111) Support bound references in lambda-to-reference intention / inspection
- [`KT-13135`](https://youtrack.jetbrains.com/issue/KT-13135) IDE goes in an infinite indexing loop if a .kotlin_module file is corrupted
- [`KT-13190`](https://youtrack.jetbrains.com/issue/KT-13190) Refactor / Move: no warning on moving class containing internal member to different module
- [`KT-13341`](https://youtrack.jetbrains.com/issue/KT-13341) Convert lambda to function reference intention is not available for object member calls
- [`KT-13755`](https://youtrack.jetbrains.com/issue/KT-13755) When (java?) class is moved redundant imports are not removed
- [`KT-13911`](https://youtrack.jetbrains.com/issue/KT-13911) Refactor / Move: "Problems Detected" dialog is not shown on moving whole .kt file
- [`KT-14129`](https://youtrack.jetbrains.com/issue/KT-14129) for/iter postfix templates should be applied for string, ranges and mutable collections
- [`KT-14134`](https://youtrack.jetbrains.com/issue/KT-14134) Allow to apply for/iter postfix template to map
- [`KT-14401`](https://youtrack.jetbrains.com/issue/KT-14401) Can't rename implicit lambda parameter 'it' when caret is placed right after the last character
- [`KT-14483`](https://youtrack.jetbrains.com/issue/KT-14483) "Argument of NotNull parameter must be not null" in KotlinTryCatchSurrounder when using "try" postfix template
- [`KT-14727`](https://youtrack.jetbrains.com/issue/KT-14727) Wrong samples for some postfix templates
- [`KT-14871`](https://youtrack.jetbrains.com/issue/KT-14871) Idea and Maven is not in sync with ModuleKind for Kotlin projects
- [`KT-14986`](https://youtrack.jetbrains.com/issue/KT-14986) Disable postfix completion when typing package statements
- [`KT-15075`](https://youtrack.jetbrains.com/issue/KT-15075) KNPE in "Specify explicit lambda signature"
- [`KT-15107`](https://youtrack.jetbrains.com/issue/KT-15107) Cannot navigate to Regex from jvm and js libraries in multiplatform project
- [`KT-15190`](https://youtrack.jetbrains.com/issue/KT-15190) Refactor / Move: false Problems Detected on moving class using parent's protected member
- [`KT-15200`](https://youtrack.jetbrains.com/issue/KT-15200) Show implementation should show inherited classes if a typealias to base class/interface is used
- [`KT-15250`](https://youtrack.jetbrains.com/issue/KT-15250) Convert anonymous object to lambda is shown when conversion not possible due implicit calls on this
- [`KT-15339`](https://youtrack.jetbrains.com/issue/KT-15339) Extract Superclass is enabled for any element: CommonRefactoringUtil$RefactoringErrorHintException: "Superclass cannot be extracted from interface" at ExtractSuperRefactoring.performRefactoring()
- [`KT-15398`](https://youtrack.jetbrains.com/issue/KT-15398) Annotations find usages in annotation instance site
- [`KT-15536`](https://youtrack.jetbrains.com/issue/KT-15536) Highlight usages: Class with primary constructor isn't highlighted when caret is on constructor invocation
- [`KT-15559`](https://youtrack.jetbrains.com/issue/KT-15559) Kotlin: Moving classes to different packages breaks references to companion object's properties
- [`KT-15556`](https://youtrack.jetbrains.com/issue/KT-15556) Convert lambda to reference isn't proposed for parameterless constructor
- [`KT-15586`](https://youtrack.jetbrains.com/issue/KT-15586) ISE during "Move to a separate file"
- [`KT-15628`](https://youtrack.jetbrains.com/issue/KT-15628) Change error message if both KotlinJavaRuntime and KotlinJavaScript libraries are present in the module dependencies
- [`KT-15768`](https://youtrack.jetbrains.com/issue/KT-15768) It would be nice to show in Kotlin facet what compiler plugins are on and their options
- [`KT-15822`](https://youtrack.jetbrains.com/issue/KT-15822) Move class refactoring leaves unused imports
- [`KT-15842`](https://youtrack.jetbrains.com/issue/KT-15842) Introduce new icons for multiplatform navigation
- [`KT-15855`](https://youtrack.jetbrains.com/issue/KT-15855) Can't evaluate expression in @JvmStatic method
- [`KT-15947`](https://youtrack.jetbrains.com/issue/KT-15947) Kotlin facet: Target platform on importing from a maven project should be filled the same way for different artifacts
- [`KT-15966`](https://youtrack.jetbrains.com/issue/KT-15966) Create quickfix for DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE
- [`KT-16022`](https://youtrack.jetbrains.com/issue/KT-16022) Kotlin facet: provide UI to navigate to project settings
- [`KT-16023`](https://youtrack.jetbrains.com/issue/KT-16023) Kotlin facet: When "Use project settings" is enabled, respective fields should show values from the project settings
- [`KT-16032`](https://youtrack.jetbrains.com/issue/KT-16032) Kotlin code formatter merges comment line with non-comment line
- [`KT-16038`](https://youtrack.jetbrains.com/issue/KT-16038) UI blocked on pasting java code into a kotlin file
- [`KT-16062`](https://youtrack.jetbrains.com/issue/KT-16062) Kotlin breakpoint doesn't work in some lambda in Rider project.
- [`KT-16074`](https://youtrack.jetbrains.com/issue/KT-16074) Introduce a quick-fix adding noinline modifier for a value parameter of suspend function type
- [`KT-16078`](https://youtrack.jetbrains.com/issue/KT-16078) Formatter puts empty body braces on different lines when KDoc is present
- [`KT-16108`](https://youtrack.jetbrains.com/issue/KT-16108) Cannot rename class on the companion object reference
- [`KT-16131`](https://youtrack.jetbrains.com/issue/KT-16131) Add quickfix for: Cannot access member: it is invisible (private in supertype)
- [`KT-16162`](https://youtrack.jetbrains.com/issue/KT-16162) IAE for destructuring declaration entry from KotlinFinalClassOrFunSpringInspection
- [`KT-16188`](https://youtrack.jetbrains.com/issue/KT-16188) Add create class quickfix
- [`KT-16198`](https://youtrack.jetbrains.com/issue/KT-16198) Extract method refactoring should order parameters by first usage
- [`KT-16214`](https://youtrack.jetbrains.com/issue/KT-16214) Do not hide package kotlin.reflect.jvm.internal from auto-import and completion, inside package "kotlin.reflect"
- [`KT-16258`](https://youtrack.jetbrains.com/issue/KT-16258) Add intention to add missing components to destructuring assignment
- [`KT-16265`](https://youtrack.jetbrains.com/issue/KT-16265) Parameter info doesn't work with type alias constructor
- [`KT-16292`](https://youtrack.jetbrains.com/issue/KT-16292) Support "Reference to lambda" for bound references
- [`KT-16313`](https://youtrack.jetbrains.com/issue/KT-16313) Kotlin facet: unify filling up information about included AllOpen/NoArg plugins on importing from Maven and Gradle
- [`KT-16316`](https://youtrack.jetbrains.com/issue/KT-16316) IDE: don't show Kotlin Scripting section when target platform is JavaScript
- [`KT-16317`](https://youtrack.jetbrains.com/issue/KT-16317) IDE: some fields stay enabled in an facet when use project settings was chosen
- [`KT-16342`](https://youtrack.jetbrains.com/issue/KT-16342) Kotlin facet: JavaScript platform is not detected if there are 2 versions of stdlib in dependencies
- [`KT-16353`](https://youtrack.jetbrains.com/issue/KT-16353) Configure Kotlin in Project: configurators are not suggested for Gradle module in non-Gradle project with separate sub-modules for source sets
- [`KT-16381`](https://youtrack.jetbrains.com/issue/KT-16381) Configure Kotlin dialog suggests modules already configured with other platforms
- [`KT-16401`](https://youtrack.jetbrains.com/issue/KT-16401) Configure Kotlin in the project adds incorrect dependency kotlin-stdlib-jre8 to 1.0.x language
- [`KT-16525`](https://youtrack.jetbrains.com/issue/KT-16525) Breakpoint-skip on special Kotlin calls
- [`KT-16550`](https://youtrack.jetbrains.com/issue/KT-16550) Kotlin facet from Maven: provide error messages if additional command line parameters are set several times
- [`KT-16556`](https://youtrack.jetbrains.com/issue/KT-16556) Move refactoring shows Refactoring cannot be performed warning.
- [`KT-16571`](https://youtrack.jetbrains.com/issue/KT-16571) Configure Kotlin in Project does not suggest just published version
- [`KT-16590`](https://youtrack.jetbrains.com/issue/KT-16590) Configure kotlin warning popup after each sync gradle
- [`KT-16596`](https://youtrack.jetbrains.com/issue/KT-16596) Hang in IntelliJ while scanning zips
- [`KT-16605`](https://youtrack.jetbrains.com/issue/KT-16605) NPE caused by Rename Refactoring of backing field when caret is after the last character
- [`KT-16646`](https://youtrack.jetbrains.com/issue/KT-16646) The flag to enable coroutines does not sync from gradle file in Android Studio
- [`KT-16647`](https://youtrack.jetbrains.com/issue/KT-16647) Don't create kotlinc.xml if the settings don't differ from the defaults
- [`KT-16649`](https://youtrack.jetbrains.com/issue/KT-16649) All Gradle related classes should be moved to optional dependency section of plugin.xml
- [`KT-16667`](https://youtrack.jetbrains.com/issue/KT-16667) Kotlin debugger "smart step into" fail on method defined in the middle of class hierarchy
- [`KT-16698`](https://youtrack.jetbrains.com/issue/KT-16698) Kotlin facet: modules created from different gradle sourcesets have the same module options
- [`KT-16700`](https://youtrack.jetbrains.com/issue/KT-16700) Kotlin facet: jdkHome path containing spaces splits into several additional args after import
- [`KT-16776`](https://youtrack.jetbrains.com/issue/KT-16776) Kotlin facet, import from maven: free arguments from submodule doesn't override arguments from parent module
- [`KT-16788`](https://youtrack.jetbrains.com/issue/KT-16788) Importing Kotlin Maven projects results in invalid .iml
- [`KT-16800`](https://youtrack.jetbrains.com/issue/KT-16800) Autocomplete for closure with single arguments
- [`KT-16809`](https://youtrack.jetbrains.com/issue/KT-16809) Move refactoring fails badly
- [`KT-16827`](https://youtrack.jetbrains.com/issue/KT-16827) kotlin javascript module not recognized by gradle sync when an android module is present
- [`KT-16848`](https://youtrack.jetbrains.com/issue/KT-16848) Regression: completion after dot in string interpolation expression doesn't work if there are no curly braces
- [`KT-16857`](https://youtrack.jetbrains.com/issue/KT-16857) False "Remove redundant 'let'" suggestion
- [`KT-16888`](https://youtrack.jetbrains.com/issue/KT-16888) "Multiple values are not allowed for plugin option org.jetbrains.kotlin.android:package" when rebuilding project
- [`KT-16903`](https://youtrack.jetbrains.com/issue/KT-16903) "Convert to primary constructor" doesn't update supertype constructor call in supertypes list in case of implicit superclass constructor call
- [`KT-16928`](https://youtrack.jetbrains.com/issue/KT-16928) Surround with null check quickfix works badly in case of qualifier
- [`KT-16980`](https://youtrack.jetbrains.com/issue/KT-16980) Accessing language version settings for a module performs runtime version detection on every access with no caching
- [`KT-16991`](https://youtrack.jetbrains.com/issue/KT-16991) Navigate to receiver from this in extension function
- [`KT-16992`](https://youtrack.jetbrains.com/issue/KT-16992) Navigate to lambda start from auto-generated 'it' parameter
- [`KT-17002`](https://youtrack.jetbrains.com/issue/KT-17002) Make "Lambda to Reference" inspection off by default
- [`KT-17006`](https://youtrack.jetbrains.com/issue/KT-17006) Refactor / Move: usage of library function is reported as problem on move between modules with different library versions
- [`KT-17032`](https://youtrack.jetbrains.com/issue/KT-17032) Refactor / Move updates references to not moved class from the same file
- [`KT-13740`](https://youtrack.jetbrains.com/issue/KT-13740) Plugin crashes at accidentally wrong annotation argument type
### JS
- [`KT-6627`](https://youtrack.jetbrains.com/issue/KT-6627) JS: test sources doesn't compile from IDE
- [`KT-13610`](https://youtrack.jetbrains.com/issue/KT-13610) JS: boxed Double.NaN is not equal to itself
- [`KT-16012`](https://youtrack.jetbrains.com/issue/KT-16012) JS: prohibit nested declarations, except interfaces inside external interface
- [`KT-16043`](https://youtrack.jetbrains.com/issue/KT-16043) IDL: mark inline helper function as InlineOnly
- [`KT-16058`](https://youtrack.jetbrains.com/issue/KT-16058) JS: getValue/setValue don't work if they are declared as suspend
- [`KT-16164`](https://youtrack.jetbrains.com/issue/KT-16164) JS: Bad getCallableRef in suspend function
- [`KT-16350`](https://youtrack.jetbrains.com/issue/KT-16350) KotlinJS - wrong code generated when temporary variables generated for RHS of `&&` operation
- [`KT-16377`](https://youtrack.jetbrains.com/issue/KT-16377) JS: losing declarations of temporary variables in secondary constructors
- [`KT-16545`](https://youtrack.jetbrains.com/issue/KT-16545) JS: ::class crashes at runtime for primitive types (e.g. Int::class, or Double::class)
### Reflection
- [`KT-9453`](https://youtrack.jetbrains.com/issue/KT-9453) ClassCastException: java.lang.Class cannot be cast to kotlin.reflect.KClass
- [`KT-11254`](https://youtrack.jetbrains.com/issue/KT-11254) Make callable references Serializable on JVM
- [`KT-11316`](https://youtrack.jetbrains.com/issue/KT-11316) NPE in hashCode of KProperty object created for delegated property
- [`KT-12630`](https://youtrack.jetbrains.com/issue/KT-12630) KotlinReflectionInternalError on referencing some functions from stdlib
- [`KT-14731`](https://youtrack.jetbrains.com/issue/KT-14731) When starting application from test source root, kotlin function reflection fails in objects defined in sources
- [`KT-15847`](https://youtrack.jetbrains.com/issue/KT-15847) NullPointerException when calling hashCode() on a top level function reference
### Libraries
- [`KT-16922`](https://youtrack.jetbrains.com/issue/KT-16922) buildSequence/Iterator: Infinite sequence terminates prematurely
- [`KT-16923`](https://youtrack.jetbrains.com/issue/KT-16923) Progression iterator doesn't throw after completion
- [`KT-16994`](https://youtrack.jetbrains.com/issue/KT-16994) Classify sequence operations as stateful/stateless and intermediate/terminal
## 1.1.1
### IDE

View File

@@ -9743,6 +9743,7 @@ public final class DebugProtoBuf {
*ClassKind
*isInner
*isData
*isHeader
* </pre>
*/
boolean hasFlags();
@@ -9756,6 +9757,7 @@ public final class DebugProtoBuf {
*ClassKind
*isInner
*isData
*isHeader
* </pre>
*/
int getFlags();
@@ -10463,6 +10465,7 @@ public final class DebugProtoBuf {
*ClassKind
*isInner
*isData
*isHeader
* </pre>
*/
public boolean hasFlags() {
@@ -10478,6 +10481,7 @@ public final class DebugProtoBuf {
*ClassKind
*isInner
*isData
*isHeader
* </pre>
*/
public int getFlags() {
@@ -11822,6 +11826,7 @@ public final class DebugProtoBuf {
*ClassKind
*isInner
*isData
*isHeader
* </pre>
*/
public boolean hasFlags() {
@@ -11837,6 +11842,7 @@ public final class DebugProtoBuf {
*ClassKind
*isInner
*isData
*isHeader
* </pre>
*/
public int getFlags() {
@@ -11852,6 +11858,7 @@ public final class DebugProtoBuf {
*ClassKind
*isInner
*isData
*isHeader
* </pre>
*/
public Builder setFlags(int value) {
@@ -11870,6 +11877,7 @@ public final class DebugProtoBuf {
*ClassKind
*isInner
*isData
*isHeader
* </pre>
*/
public Builder clearFlags() {
@@ -17725,6 +17733,8 @@ public final class DebugProtoBuf {
*isInline
*isTailrec
*isExternal
*isSuspend
*isHeader
* </pre>
*/
boolean hasFlags();
@@ -17741,6 +17751,8 @@ public final class DebugProtoBuf {
*isInline
*isTailrec
*isExternal
*isSuspend
*isHeader
* </pre>
*/
int getFlags();
@@ -18084,6 +18096,8 @@ public final class DebugProtoBuf {
*isInline
*isTailrec
*isExternal
*isSuspend
*isHeader
* </pre>
*/
public boolean hasFlags() {
@@ -18102,6 +18116,8 @@ public final class DebugProtoBuf {
*isInline
*isTailrec
*isExternal
*isSuspend
*isHeader
* </pre>
*/
public int getFlags() {
@@ -18913,6 +18929,8 @@ public final class DebugProtoBuf {
*isInline
*isTailrec
*isExternal
*isSuspend
*isHeader
* </pre>
*/
public boolean hasFlags() {
@@ -18931,6 +18949,8 @@ public final class DebugProtoBuf {
*isInline
*isTailrec
*isExternal
*isSuspend
*isHeader
* </pre>
*/
public int getFlags() {
@@ -18949,6 +18969,8 @@ public final class DebugProtoBuf {
*isInline
*isTailrec
*isExternal
*isSuspend
*isHeader
* </pre>
*/
public Builder setFlags(int value) {
@@ -18970,6 +18992,8 @@ public final class DebugProtoBuf {
*isInline
*isTailrec
*isExternal
*isSuspend
*isHeader
* </pre>
*/
public Builder clearFlags() {
@@ -20015,6 +20039,7 @@ public final class DebugProtoBuf {
*hasConstant
*isExternal
*isDelegated
*isHeader
* </pre>
*/
boolean hasFlags();
@@ -20034,6 +20059,7 @@ public final class DebugProtoBuf {
*hasConstant
*isExternal
*isDelegated
*isHeader
* </pre>
*/
int getFlags();
@@ -20391,6 +20417,7 @@ public final class DebugProtoBuf {
*hasConstant
*isExternal
*isDelegated
*isHeader
* </pre>
*/
public boolean hasFlags() {
@@ -20412,6 +20439,7 @@ public final class DebugProtoBuf {
*hasConstant
*isExternal
*isDelegated
*isHeader
* </pre>
*/
public int getFlags() {
@@ -21211,6 +21239,7 @@ public final class DebugProtoBuf {
*hasConstant
*isExternal
*isDelegated
*isHeader
* </pre>
*/
public boolean hasFlags() {
@@ -21232,6 +21261,7 @@ public final class DebugProtoBuf {
*hasConstant
*isExternal
*isDelegated
*isHeader
* </pre>
*/
public int getFlags() {
@@ -21253,6 +21283,7 @@ public final class DebugProtoBuf {
*hasConstant
*isExternal
*isDelegated
*isHeader
* </pre>
*/
public Builder setFlags(int value) {
@@ -21277,6 +21308,7 @@ public final class DebugProtoBuf {
*hasConstant
*isExternal
*isDelegated
*isHeader
* </pre>
*/
public Builder clearFlags() {

View File

@@ -584,7 +584,18 @@
</fileset>
<zipgroupfileset dir="${basedir}/lib" includes="*.jar"/>
<zipgroupfileset dir="${basedir}/ideaSDK/core" includes="*.jar" excludes="util.jar"/>
<zipfileset src="${basedir}/ideaSDK/core/annotations.jar"/>
<zipfileset src="${basedir}/ideaSDK/core/asm-all.jar"/>
<zipfileset src="${basedir}/ideaSDK/core/guava-19.0.jar"/>
<zipfileset src="${basedir}/ideaSDK/core/intellij-core.jar"/>
<zipfileset src="${basedir}/ideaSDK/core/jdom.jar"/>
<zipfileset src="${basedir}/ideaSDK/core/jna.jar"/>
<zipfileset src="${basedir}/ideaSDK/core/log4j.jar"/>
<zipfileset src="${basedir}/ideaSDK/core/picocontainer.jar"/>
<zipfileset src="${basedir}/ideaSDK/core/snappy-in-java-0.5.1.jar"/>
<zipfileset src="${basedir}/ideaSDK/core/trove4j.jar"/>
<zipfileset src="${basedir}/ideaSDK/core/xpp3-1.1.4-min.jar"/>
<zipfileset src="${basedir}/ideaSDK/core/xstream-1.4.8.jar"/>
<zipfileset src="${idea.sdk}/lib/jna-platform.jar"/>
<zipfileset src="${idea.sdk}/lib/oromatcher.jar"/>
<zipfileset src="${idea.sdk}/jps/jps-model.jar"/>

View File

@@ -20,10 +20,7 @@ import com.intellij.core.CoreJavaFileManager
import com.intellij.openapi.diagnostic.Logger
import com.intellij.openapi.util.text.StringUtil
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.PsiClass
import com.intellij.psi.PsiClassOwner
import com.intellij.psi.PsiManager
import com.intellij.psi.PsiPackage
import com.intellij.psi.*
import com.intellij.psi.impl.file.PsiPackageImpl
import com.intellij.psi.search.GlobalSearchScope
import org.jetbrains.kotlin.cli.jvm.index.JavaRoot
@@ -35,6 +32,9 @@ import org.jetbrains.kotlin.util.PerformanceCounter
import java.util.*
import kotlin.properties.Delegates
// TODO: do not inherit from CoreJavaFileManager to avoid accidental usage of its methods which do not use caches/indices
// Currently, the only relevant usage of this class as CoreJavaFileManager is at CoreJavaDirectoryService.getPackage,
// which is indirectly invoked from PsiPackage.getSubPackages
class KotlinCliJavaFileManagerImpl(private val myPsiManager: PsiManager) : CoreJavaFileManager(myPsiManager), KotlinCliJavaFileManager {
private val perfCounter = PerformanceCounter.create("Find Java class")
private var index: JvmDependenciesIndex by Delegates.notNull()
@@ -44,44 +44,64 @@ class KotlinCliJavaFileManagerImpl(private val myPsiManager: PsiManager) : CoreJ
this.index = packagesCache
}
override fun findClass(classId: ClassId, searchScope: GlobalSearchScope): PsiClass? {
return perfCounter.time {
val classNameWithInnerClasses = classId.relativeClassName.asString()
index.findClass(classId) { dir, type ->
findClassGivenPackage(allScope, dir, classNameWithInnerClasses, type)
}?.takeIf { it.containingFile.virtualFile in searchScope }
override fun findClass(classId: ClassId, searchScope: GlobalSearchScope): PsiClass? = perfCounter.time {
val relativeClassName = classId.relativeClassName.asString()
index.findClass(classId) { dir, type ->
findClassGivenPackage(allScope, dir, relativeClassName, type)
}?.takeIf { it.containingFile.virtualFile in searchScope }
}
// this method is called from IDEA to resolve dependencies in Java code
// which supposedly shouldn't have errors so the dependencies exist in general
override fun findClass(qName: String, scope: GlobalSearchScope): PsiClass? {
// String cannot be reliably converted to ClassId because we don't know where the package name ends and class names begin.
// For example, if qName is "a.b.c.d.e", we should either look for a top level class "e" in the package "a.b.c.d",
// or, for example, for a nested class with the relative qualified name "c.d.e" in the package "a.b".
// Below, we start by looking for the top level class "e" in the package "a.b.c.d" first, then for the class "d.e" in the package
// "a.b.c", and so on, until we find something. Most classes are top level, so most of the times the search ends quickly
forEachClassId(qName) { classId ->
findClass(classId, scope)?.let { return it }
}
return null
}
private inline fun forEachClassId(fqName: String, block: (ClassId) -> Unit) {
var classId = fqName.toSafeTopLevelClassId() ?: return
while (true) {
block(classId)
val packageFqName = classId.packageFqName
if (packageFqName.isRoot) break
classId = ClassId(
packageFqName.parent(),
FqName(packageFqName.shortName().asString() + "." + classId.relativeClassName.asString()),
false
)
}
}
override fun findClass(qName: String, scope: GlobalSearchScope): PsiClass? {
// this method is called from IDEA to resolve dependencies in Java code
// which supposedly shouldn't have errors so the dependencies exist in general
// Most classes are top level classes so we will try to find them fast
// but we must sometimes fallback to support finding inner/nested classes
return qName.toSafeTopLevelClassId()?.let { classId -> findClass(classId, scope) } ?: super.findClass(qName, scope)
}
override fun findClasses(qName: String, scope: GlobalSearchScope): Array<PsiClass> {
return perfCounter.time {
val classIdAsTopLevelClass = qName.toSafeTopLevelClassId() ?: return@time super.findClasses(qName, scope)
val result = ArrayList<PsiClass>()
val classNameWithInnerClasses = classIdAsTopLevelClass.relativeClassName.asString()
index.traverseDirectoriesInPackage(classIdAsTopLevelClass.packageFqName) { dir, rootType ->
val psiClass = findClassGivenPackage(scope, dir, classNameWithInnerClasses, rootType)
override fun findClasses(qName: String, scope: GlobalSearchScope): Array<PsiClass> = perfCounter.time {
val result = ArrayList<PsiClass>(1)
forEachClassId(qName) { classId ->
val relativeClassName = classId.relativeClassName.asString()
index.traverseDirectoriesInPackage(classId.packageFqName) { dir, rootType ->
val psiClass = findClassGivenPackage(scope, dir, relativeClassName, rootType)
if (psiClass != null) {
result.add(psiClass)
}
// traverse all
true
}
if (result.isEmpty()) {
super.findClasses(qName, scope)
}
else {
result.toTypedArray()
if (result.isNotEmpty()) {
return@time result.toTypedArray()
}
}
PsiClass.EMPTY_ARRAY
}
override fun findPackage(packageName: String): PsiPackage? {
@@ -121,7 +141,29 @@ class KotlinCliJavaFileManagerImpl(private val myPsiManager: PsiManager) : CoreJ
return findClassInPsiFile(classNameWithInnerClasses, file)
}
override fun knownClassNamesInPackage(packageFqName: FqName) = index.collectKnownClassNamesInPackage(packageFqName)
override fun knownClassNamesInPackage(packageFqName: FqName): Set<String> {
val result = hashSetOf<String>()
index.traverseDirectoriesInPackage(packageFqName, continueSearch = {
dir, _ ->
for (child in dir.children) {
if (child.extension == "class" || child.extension == "java") {
result.add(child.nameWithoutExtension)
}
}
true
})
return result
}
override fun findModules(moduleName: String, scope: GlobalSearchScope): Collection<PsiJavaModule> {
// TODO
return emptySet()
}
override fun getNonTrivialPackagePrefixes(): Collection<String> = emptyList()
companion object {
private val LOG = Logger.getInstance(KotlinCliJavaFileManagerImpl::class.java)
@@ -168,4 +210,4 @@ catch (e: AssertionError) {
}
private fun String.toSafeFqName(): FqName? = safely { FqName(this) }
private fun String.toSafeTopLevelClassId(): ClassId? = safely { ClassId.topLevel(FqName(this)) }
private fun String.toSafeTopLevelClassId(): ClassId? = safely { ClassId.topLevel(FqName(this)) }

View File

@@ -23,7 +23,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock
import kotlin.concurrent.read
import kotlin.concurrent.write
class JvmDependenciesDynamicCompoundIndex() : JvmDependenciesIndex {
class JvmDependenciesDynamicCompoundIndex : JvmDependenciesIndex {
private val indices = arrayListOf<JvmDependenciesIndex>()
private val lock = ReentrantReadWriteLock()
@@ -36,13 +36,9 @@ class JvmDependenciesDynamicCompoundIndex() : JvmDependenciesIndex {
fun addNewIndexForRoots(roots: Iterable<JavaRoot>): JvmDependenciesIndex? =
lock.read {
val alreadyIndexed = indexedRoots.toHashSet()
val newRoots = roots.filter { !alreadyIndexed.contains(it) }
val newRoots = roots.filter { root -> root !in alreadyIndexed }
if (newRoots.isEmpty()) null
else {
val index = JvmDependenciesIndexImpl(newRoots)
addIndex(index)
index
}
else JvmDependenciesIndexImpl(newRoots).also(this::addIndex)
}
override val indexedRoots: Sequence<JavaRoot> get() = indices.asSequence().flatMap { it.indexedRoots }
@@ -51,22 +47,15 @@ class JvmDependenciesDynamicCompoundIndex() : JvmDependenciesIndex {
classId: ClassId,
acceptedRootTypes: Set<JavaRoot.RootType>,
findClassGivenDirectory: (VirtualFile, JavaRoot.RootType) -> T?
): T? =
lock.read {
indices.asSequence().mapNotNull { it.findClass(classId, acceptedRootTypes, findClassGivenDirectory) }.firstOrNull()
}
): T? = lock.read {
indices.asSequence().mapNotNull { it.findClass(classId, acceptedRootTypes, findClassGivenDirectory) }.firstOrNull()
}
override fun traverseDirectoriesInPackage(
packageFqName: FqName,
acceptedRootTypes: Set<JavaRoot.RootType>,
continueSearch: (VirtualFile, JavaRoot.RootType) -> Boolean
) {
lock.read {
indices.forEach { it.traverseDirectoriesInPackage(packageFqName, acceptedRootTypes, continueSearch) }
}
}
override fun collectKnownClassNamesInPackage(packageFqName: FqName): Set<String> = lock.read {
indices.flatMapTo(hashSetOf()) { it.collectKnownClassNamesInPackage(packageFqName) }
) = lock.read {
indices.forEach { it.traverseDirectoriesInPackage(packageFqName, acceptedRootTypes, continueSearch) }
}
}

View File

@@ -35,10 +35,6 @@ interface JvmDependenciesIndex {
acceptedRootTypes: Set<JavaRoot.RootType> = JavaRoot.SourceAndBinary,
continueSearch: (VirtualFile, JavaRoot.RootType) -> Boolean
)
fun collectKnownClassNamesInPackage(
packageFqName: FqName
): Set<String>
}
data class JavaRoot(val file: VirtualFile, val type: RootType, val prefixFqName: FqName? = null) {

View File

@@ -39,24 +39,21 @@ class JvmDependenciesIndexImpl(_roots: List<JavaRoot>): JvmDependenciesIndex {
private class Cache {
private val innerPackageCaches = HashMap<String, Cache>()
operator fun get(name: String) = innerPackageCaches.getOrPut(name) { Cache() }
operator fun get(name: String) = innerPackageCaches.getOrPut(name, ::Cache)
// indices of roots that are known to contain this package
// if this list contains [1, 3, 5] then roots with indices 1, 3 and 5 are known to contain this package, 2 and 4 are known not to (no information about roots 6 or higher)
// if this list contains maxIndex that means that all roots containing this package are known
val rootIndices = IntArrayList()
val rootIndices = IntArrayList(2)
}
// root "Cache" object corresponds to DefaultPackage which exists in every root. Roots with non-default fqname are also listed here but
// they will be ignored on requests with invalid fqname prefix.
private val rootCache: Cache by lazy {
with(Cache()) {
roots.indices.forEach {
rootIndices.add(it)
}
Cache().apply {
roots.indices.forEach(rootIndices::add)
rootIndices.add(maxIndex)
rootIndices.trimToSize()
this
}
}
@@ -72,7 +69,7 @@ class JvmDependenciesIndexImpl(_roots: List<JavaRoot>): JvmDependenciesIndex {
acceptedRootTypes: Set<JavaRoot.RootType>,
findClassGivenDirectory: (VirtualFile, JavaRoot.RootType) -> T?
): T? {
return search(FindClassRequest(classId, acceptedRootTypes)) { dir, rootType ->
return findClassCached(classId, acceptedRootTypes) { dir, rootType ->
val found = findClassGivenDirectory(dir, rootType)
HandleResult(found, continueSearch = found == null)
}
@@ -88,73 +85,51 @@ class JvmDependenciesIndexImpl(_roots: List<JavaRoot>): JvmDependenciesIndex {
}
}
override fun collectKnownClassNamesInPackage(
packageFqName: FqName
): Set<String> {
val result = hashSetOf<String>()
traverseDirectoriesInPackage(packageFqName, continueSearch = {
dir, _ ->
for (child in dir.children) {
if (child.extension != "class" && child.extension != "java") continue
result.add(child.nameWithoutExtension)
}
true
})
return result
}
private data class HandleResult<out T : Any>(val result: T?, val continueSearch: Boolean)
private fun <T : Any> search(
request: SearchRequest,
private fun <T : Any> findClassCached(
classId: ClassId,
acceptedRootTypes: Set<JavaRoot.RootType>,
handler: (VirtualFile, JavaRoot.RootType) -> HandleResult<T>
): T? {
// make a decision based on information saved from last class search
if (request !is FindClassRequest || lastClassSearch?.first?.classId != request.classId) {
return doSearch(request, handler)
if (lastClassSearch?.first?.classId != classId) {
return search(FindClassRequest(classId, acceptedRootTypes), handler)
}
val (cachedRequest, cachedResult) = lastClassSearch!!
return when (cachedResult) {
is SearchResult.NotFound -> {
val limitedRootTypes = request.acceptedRootTypes.toHashSet()
limitedRootTypes.removeAll(cachedRequest.acceptedRootTypes)
val limitedRootTypes = acceptedRootTypes - cachedRequest.acceptedRootTypes
if (limitedRootTypes.isEmpty()) {
null
}
else {
doSearch(FindClassRequest(request.classId, limitedRootTypes), handler)
search(FindClassRequest(classId, limitedRootTypes), handler)
}
}
is SearchResult.Found -> {
if (cachedRequest.acceptedRootTypes == request.acceptedRootTypes) {
if (cachedRequest.acceptedRootTypes == acceptedRootTypes) {
handler(cachedResult.packageDirectory, cachedResult.root.type).result
}
else {
doSearch(request, handler)
search(FindClassRequest(classId, acceptedRootTypes), handler)
}
}
}
}
private fun <T : Any> doSearch(request: SearchRequest, handler: (VirtualFile, JavaRoot.RootType) -> HandleResult<T>): T? {
val findClassRequest = request as? FindClassRequest
fun <T : Any> found(packageDirectory: VirtualFile, root: JavaRoot, result: T): T {
if (findClassRequest != null) {
lastClassSearch = Pair(findClassRequest, SearchResult.Found(packageDirectory, root))
private fun <T : Any> search(request: SearchRequest, handler: (VirtualFile, JavaRoot.RootType) -> HandleResult<T>): T? {
fun <T : Any> found(packageDirectory: VirtualFile, root: JavaRoot, result: T): T = result.also {
if (request is FindClassRequest) {
lastClassSearch = Pair(request, SearchResult.Found(packageDirectory, root))
}
return result
}
fun <T : Any> notFound(): T? {
if (findClassRequest != null) {
lastClassSearch = Pair(findClassRequest, SearchResult.NotFound)
fun <T : Any> notFound(): T? = null.also {
if (request is FindClassRequest) {
lastClassSearch = Pair(request, SearchResult.NotFound)
}
return null
}
fun handle(root: JavaRoot, targetDirInRoot: VirtualFile): T? {
@@ -197,7 +172,7 @@ class JvmDependenciesIndexImpl(_roots: List<JavaRoot>): JvmDependenciesIndex {
return notFound()
}
// try to find a target directory corresponding to package represented by packagesPath in a given root reprenting by index
// try to find a target directory corresponding to package represented by packagesPath in a given root represented by index
// possibly filling "Cache" objects with new information
private fun travelPath(rootIndex: Int, packagesPath: List<String>, fillCachesAfter: Int, cachesPath: List<Cache>): VirtualFile? {
if (rootIndex >= maxIndex) {

View File

@@ -44,9 +44,9 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.idea.KotlinLanguage;
import org.jetbrains.kotlin.load.java.JavaClassFinderImpl;
import org.jetbrains.kotlin.name.ClassId;
import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus;
import org.jetbrains.kotlin.name.ClassId;
import java.util.ArrayList;
import java.util.Arrays;
@@ -112,8 +112,8 @@ public class KotlinJavaPsiFacade {
}
for (KotlinPsiElementFinderWrapper finder : finders()) {
if (finder instanceof KotlinPsiElementFinderImpl) {
PsiClass aClass = ((KotlinPsiElementFinderImpl) finder).findClass(classId, scope);
if (finder instanceof CliFinder) {
PsiClass aClass = ((CliFinder) finder).findClass(classId, scope);
if (aClass != null) return aClass;
}
else {
@@ -152,8 +152,8 @@ public class KotlinJavaPsiFacade {
public Set<String> knownClassNamesInPackage(@NotNull FqName packageFqName) {
KotlinPsiElementFinderWrapper[] finders = finders();
if (finders.length == 1) {
return ((KotlinPsiElementFinderImpl) finders[0]).knownClassNamesInPackage(packageFqName);
if (finders.length == 1 && finders[0] instanceof CliFinder) {
return ((CliFinder) finders[0]).knownClassNamesInPackage(packageFqName);
}
return null;
@@ -197,9 +197,14 @@ public class KotlinJavaPsiFacade {
}
@NotNull
protected KotlinPsiElementFinderWrapper[] calcFinders() {
private KotlinPsiElementFinderWrapper[] calcFinders() {
List<KotlinPsiElementFinderWrapper> elementFinders = new ArrayList<KotlinPsiElementFinderWrapper>();
elementFinders.add(new KotlinPsiElementFinderImpl(getProject()));
JavaFileManager javaFileManager = findJavaFileManager(project);
elementFinders.add(
javaFileManager instanceof KotlinCliJavaFileManager
? new CliFinder((KotlinCliJavaFileManager) javaFileManager)
: new NonCliFinder(project, javaFileManager)
);
List<PsiElementFinder> nonKotlinFinders = ArraysKt.filter(
getProject().getExtensions(PsiElementFinder.EP_NAME), new Function1<PsiElementFinder, Boolean>() {
@@ -220,6 +225,15 @@ public class KotlinJavaPsiFacade {
return elementFinders.toArray(new KotlinPsiElementFinderWrapper[elementFinders.size()]);
}
@NotNull
private static JavaFileManager findJavaFileManager(@NotNull Project project) {
JavaFileManager javaFileManager = ServiceManager.getService(project, JavaFileManager.class);
if (javaFileManager == null) {
throw new IllegalStateException("JavaFileManager component is not found in project");
}
return javaFileManager;
}
public PsiPackage findPackage(@NotNull String qualifiedName, GlobalSearchScope searchScope) {
PackageCache cache = SoftReference.dereference(packageCache);
if (cache == null) {
@@ -342,59 +356,56 @@ public class KotlinJavaPsiFacade {
}
}
static class KotlinPsiElementFinderImpl implements KotlinPsiElementFinderWrapper, DumbAware {
private final JavaFileManager javaFileManager;
private final boolean isCliFileManager;
private static class CliFinder implements KotlinPsiElementFinderWrapper, DumbAware {
private final KotlinCliJavaFileManager javaFileManager;
private final PsiManager psiManager;
private final PackageIndex packageIndex;
public KotlinPsiElementFinderImpl(Project project) {
this.javaFileManager = findJavaFileManager(project);
this.isCliFileManager = javaFileManager instanceof KotlinCliJavaFileManager;
this.packageIndex = PackageIndex.getInstance(project);
this.psiManager = PsiManager.getInstance(project);
public CliFinder(@NotNull KotlinCliJavaFileManager javaFileManager) {
this.javaFileManager = javaFileManager;
}
@NotNull
private static JavaFileManager findJavaFileManager(@NotNull Project project) {
JavaFileManager javaFileManager = ServiceManager.getService(project, JavaFileManager.class);
if (javaFileManager == null) {
throw new IllegalStateException("JavaFileManager component is not found in project");
}
return javaFileManager;
}
@Override
public PsiClass findClass(@NotNull String qualifiedName, @NotNull GlobalSearchScope scope) {
return javaFileManager.findClass(qualifiedName, scope);
}
public PsiClass findClass(@NotNull ClassId classId, @NotNull GlobalSearchScope scope) {
if (isCliFileManager) {
return ((KotlinCliJavaFileManager) javaFileManager).findClass(classId, scope);
}
return findClass(classId.asSingleFqName().asString(), scope);
return javaFileManager.findClass(classId, scope);
}
@Nullable
public Set<String> knownClassNamesInPackage(@NotNull FqName packageFqName) {
if (isCliFileManager) {
return ((KotlinCliJavaFileManager) javaFileManager).knownClassNamesInPackage(packageFqName);
}
return null;
return javaFileManager.knownClassNamesInPackage(packageFqName);
}
@Override
public PsiPackage findPackage(@NotNull String qualifiedName, @NotNull GlobalSearchScope scope) {
if (isCliFileManager) {
return javaFileManager.findPackage(qualifiedName);
}
return javaFileManager.findPackage(qualifiedName);
}
@Override
public boolean isSameResultForAnyScope() {
return false;
}
}
private static class NonCliFinder implements KotlinPsiElementFinderWrapper, DumbAware {
private final JavaFileManager javaFileManager;
private final PsiManager psiManager;
private final PackageIndex packageIndex;
public NonCliFinder(@NotNull Project project, @NotNull JavaFileManager javaFileManager) {
this.javaFileManager = javaFileManager;
this.packageIndex = PackageIndex.getInstance(project);
this.psiManager = PsiManager.getInstance(project);
}
@Override
public PsiClass findClass(@NotNull String qualifiedName, @NotNull GlobalSearchScope scope) {
return javaFileManager.findClass(qualifiedName, scope);
}
@Override
public PsiPackage findPackage(@NotNull String qualifiedName, @NotNull GlobalSearchScope scope) {
Query<VirtualFile> dirs = packageIndex.getDirsByPackageName(qualifiedName, true);
return hasDirectoriesInScope(dirs, scope) ? new PsiPackageImpl(psiManager, qualifiedName) : null;
}

View File

@@ -196,6 +196,12 @@ abstract class AnalyzerFacade<in P : PlatformAnalysisParameters> {
return module.modulesWhoseInternalsAreVisible().mapTo(LinkedHashSet()) { resolverForProject.descriptorForModule(it as M) }
}
fun computeImplementingModules(module: M): Set<ModuleDescriptorImpl> =
if (modulePlatforms(module) != MultiTargetPlatform.Common) emptySet()
else modules
.filter { modulePlatforms(it) != MultiTargetPlatform.Common && module in it.dependencies() }
.mapTo(mutableSetOf(), resolverForProject::descriptorForModule)
fun setupModuleDependencies() {
modules.forEach {
module ->
@@ -203,7 +209,8 @@ abstract class AnalyzerFacade<in P : PlatformAnalysisParameters> {
LazyModuleDependencies(
storageManager,
{ computeDependencyDescriptors(module) },
{ computeModulesWhoseInternalsAreVisible(module) }
{ computeModulesWhoseInternalsAreVisible(module) },
{ computeImplementingModules(module) }
)
)
}

View File

@@ -570,7 +570,8 @@ public interface Errors {
enum BadNamedArgumentsTarget {
NON_KOTLIN_FUNCTION,
INVOKE_ON_FUNCTION_TYPE
INVOKE_ON_FUNCTION_TYPE,
HEADER_CLASS_MEMBER,
}
DiagnosticFactory0<KtExpression> VARARG_OUTSIDE_PARENTHESES = DiagnosticFactory0.create(ERROR);
@@ -705,6 +706,7 @@ public interface Errors {
DiagnosticFactory1<KtSimpleNameExpression, KotlinType> COMPARE_TO_TYPE_MISMATCH = DiagnosticFactory1.create(ERROR);
DiagnosticFactory1<PsiElement, String> YIELD_IS_RESERVED = DiagnosticFactory1.create(ERROR);
DiagnosticFactory0<PsiElement> UNDERSCORE_IS_RESERVED = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<PsiElement> UNDERSCORE_USAGE_WITHOUT_BACKTICKS = DiagnosticFactory0.create(ERROR);
DiagnosticFactory1<PsiElement, String> INVALID_CHARACTERS = DiagnosticFactory1.create(ERROR);
DiagnosticFactory1<PsiElement, String> INAPPLICABLE_OPERATOR_MODIFIER = DiagnosticFactory1.create(ERROR);

View File

@@ -207,6 +207,8 @@ public class DefaultErrorMessages {
return "non-Kotlin functions";
case INVOKE_ON_FUNCTION_TYPE:
return "function types";
case HEADER_CLASS_MEMBER:
return "members of header classes";
default:
throw new AssertionError(target);
}
@@ -463,6 +465,7 @@ public class DefaultErrorMessages {
MAP.put(COMPARE_TO_TYPE_MISMATCH, "''compareTo()'' must return Int, but returns {0}", RENDER_TYPE);
MAP.put(UNDERSCORE_IS_RESERVED, "Names _, __, ___, ..., are reserved in Kotlin");
MAP.put(UNDERSCORE_USAGE_WITHOUT_BACKTICKS, "Names _, __, ___, ... can be used only in back-ticks (`_`, `__`, `___`, ...)");
MAP.put(YIELD_IS_RESERVED, "{0}", STRING);
MAP.put(INVALID_CHARACTERS, "Name {0}", STRING);

View File

@@ -48,10 +48,14 @@ object PlatformIncompatibilityDiagnosticRenderer :
append("The following declaration")
if (descriptors.size == 1) append(" is") else append("s are")
append(" incompatible")
incompatibility.reason?.let { append(" because $it") }
incompatibility.reason?.let { appendln(" because $it:") }
for (descriptor in descriptors) {
append(indent + " ")
appendln(renderDescriptor(descriptor))
}
incompatibility.unimplemented?.let { unimplemented ->
appendln(".")
append(indent)
appendln("No implementations are found for members listed below:")
for ((descriptor, mapping) in unimplemented) {
@@ -63,12 +67,6 @@ object PlatformIncompatibilityDiagnosticRenderer :
}
render(mapping, indent + INDENTATION_UNIT, renderDescriptor)
}
} ?: run {
appendln(":")
for (descriptor in descriptors) {
append(indent + " ")
appendln(renderDescriptor(descriptor))
}
}
}
}

View File

@@ -32,6 +32,7 @@ import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.ImportPath
import org.jetbrains.kotlin.resolve.TargetPlatform
@JvmOverloads
fun KtPsiFactory(project: Project?, markGenerated: Boolean = true): KtPsiFactory = KtPsiFactory(project!!, markGenerated)
@@ -45,6 +46,7 @@ private val DO_NOT_ANALYZE_NOTIFICATION = "This file was created by KtPsiFactory
var KtFile.doNotAnalyze: String? by UserDataProperty(Key.create("DO_NOT_ANALYZE"))
var KtFile.analysisContext: PsiElement? by UserDataProperty(Key.create("ANALYSIS_CONTEXT"))
var PsiFile.moduleInfo: ModuleInfo? by UserDataProperty(Key.create("MODULE_INFO"))
var KtFile.targetPlatform: TargetPlatform? by UserDataProperty(Key.create("TARGET_PLATFORM"))
/**
* @param markGenerated This needs to be set to true if the `KtPsiFactory` is going to be used for creating elements that are going

View File

@@ -66,6 +66,13 @@ fun KtSimpleNameExpression.getQualifiedElement(): KtElement {
}
}
fun KtSimpleNameExpression.getQualifiedElementOrCallableRef(): KtElement {
val parent = parent
if (parent is KtCallableReferenceExpression && parent.callableReference == this) return parent
return getQualifiedElement()
}
fun KtSimpleNameExpression.getTopmostParentQualifiedExpressionForSelector(): KtQualifiedExpression? {
return generateSequence<KtExpression>(this) {
val parentQualified = it.parent as? KtQualifiedExpression

View File

@@ -78,7 +78,7 @@ interface KotlinImportDirectiveStub : StubElement<KtImportDirective> {
fun isValid(): Boolean
}
interface KotlinModifierListStub : StubElement<KtModifierList> {
interface KotlinModifierListStub : StubElement<KtDeclarationModifierList> {
fun hasModifier(modifierToken: KtModifierKeywordToken): Boolean
}

View File

@@ -31,7 +31,7 @@ class KotlinClassStubImpl(
private val qualifiedName: StringRef?,
private val name: StringRef?,
private val superNames: Array<StringRef>,
private val isTrait: Boolean,
private val isInterface: Boolean,
private val isEnumEntry: Boolean,
private val isLocal: Boolean,
private val isTopLevel: Boolean
@@ -42,7 +42,7 @@ class KotlinClassStubImpl(
return FqName(stringRef)
}
override fun isInterface() = isTrait
override fun isInterface() = isInterface
override fun isEnumEntry() = isEnumEntry
override fun isLocal() = isLocal
override fun getName() = StringRef.toString(name)

View File

@@ -18,12 +18,12 @@ package org.jetbrains.kotlin.psi.stubs.impl;
import com.intellij.psi.stubs.StubElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.psi.KtModifierList;
import org.jetbrains.kotlin.lexer.KtModifierKeywordToken;
import org.jetbrains.kotlin.psi.KtDeclarationModifierList;
import org.jetbrains.kotlin.psi.stubs.KotlinModifierListStub;
import org.jetbrains.kotlin.psi.stubs.elements.KtModifierListElementType;
import org.jetbrains.kotlin.lexer.KtModifierKeywordToken;
public class KotlinModifierListStubImpl extends KotlinStubBaseImpl<KtModifierList> implements KotlinModifierListStub {
public class KotlinModifierListStubImpl extends KotlinStubBaseImpl<KtDeclarationModifierList> implements KotlinModifierListStub {
private final int mask;

View File

@@ -27,6 +27,7 @@ import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.codeFragmentUtil.suppressDiagnosticsInDebugMode
import org.jetbrains.kotlin.psi.psiUtil.getTopmostParentQualifiedExpressionForSelector
import org.jetbrains.kotlin.resolve.calls.CallExpressionElement
import org.jetbrains.kotlin.resolve.calls.checkers.UnderscoreUsageChecker
import org.jetbrains.kotlin.resolve.calls.unrollToLeftMostQualifiedExpression
import org.jetbrains.kotlin.resolve.descriptorUtil.module
import org.jetbrains.kotlin.resolve.scopes.ImportingScope
@@ -143,7 +144,6 @@ class QualifiedExpressionResolver {
val (name, simpleName) = qualifierPartList.single()
val descriptor = scope.findClassifier(name, KotlinLookupLocation(simpleName))
storeResult(trace, simpleName, descriptor, ownerDescriptor, position = QualifierPosition.TYPE, isQualifier = true)
return TypeQualifierResolutionResult(qualifierPartList, descriptor)
}
@@ -597,6 +597,8 @@ class QualifiedExpressionResolver {
trace.record(BindingContext.REFERENCE_TARGET, referenceExpression, descriptor)
UnderscoreUsageChecker.checkSimpleNameUsage(descriptor, referenceExpression, trace)
if (descriptor is DeclarationDescriptorWithVisibility) {
val fromToCheck =
if (shouldBeVisibleFrom is PackageFragmentDescriptor && shouldBeVisibleFrom.source == SourceElement.NO_SOURCE && referenceExpression.containingFile !is DummyHolder) {

View File

@@ -95,7 +95,8 @@ private val DEFAULT_CALL_CHECKERS = listOf(
DeprecatedCallChecker, CallReturnsArrayOfNothingChecker(), InfixCallChecker(), OperatorCallChecker(),
ConstructorHeaderCallChecker, ProtectedConstructorCallChecker, ApiVersionCallChecker,
CoroutineSuspendCallChecker, BuilderFunctionsCallChecker, DslScopeViolationCallChecker, MissingDependencyClassChecker,
CallableReferenceCompatibilityChecker()
CallableReferenceCompatibilityChecker(),
UnderscoreUsageChecker
)
private val DEFAULT_TYPE_CHECKERS = emptyList<AdditionalTypeChecker>()
private val DEFAULT_CLASSIFIER_USAGE_CHECKERS = listOf(

View File

@@ -23,9 +23,7 @@ import kotlin.collections.CollectionsKt;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.builtins.functions.FunctionInvokeDescriptor;
import org.jetbrains.kotlin.descriptors.CallableDescriptor;
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor;
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.diagnostics.Diagnostic;
import org.jetbrains.kotlin.name.Name;
import org.jetbrains.kotlin.psi.*;
@@ -42,8 +40,7 @@ import java.util.Map;
import java.util.Set;
import static org.jetbrains.kotlin.diagnostics.Errors.*;
import static org.jetbrains.kotlin.diagnostics.Errors.BadNamedArgumentsTarget.INVOKE_ON_FUNCTION_TYPE;
import static org.jetbrains.kotlin.diagnostics.Errors.BadNamedArgumentsTarget.NON_KOTLIN_FUNCTION;
import static org.jetbrains.kotlin.diagnostics.Errors.BadNamedArgumentsTarget.*;
import static org.jetbrains.kotlin.resolve.BindingContext.REFERENCE_TARGET;
import static org.jetbrains.kotlin.resolve.calls.ValueArgumentsToParametersMapper.Status.*;
@@ -189,11 +186,19 @@ public class ValueArgumentsToParametersMapper {
KtSimpleNameExpression nameReference = argumentName.getReferenceExpression();
KtPsiUtilKt.checkReservedYield(nameReference, candidateCall.getTrace());
if (!candidate.hasStableParameterNames() && nameReference != null) {
report(NAMED_ARGUMENTS_NOT_ALLOWED.on(
nameReference,
candidate instanceof FunctionInvokeDescriptor ? INVOKE_ON_FUNCTION_TYPE : NON_KOTLIN_FUNCTION
));
if (nameReference != null) {
if (candidate instanceof MemberDescriptor && ((MemberDescriptor) candidate).isHeader() &&
candidate.getContainingDeclaration() instanceof ClassDescriptor) {
// We do not allow named arguments for members of header classes until we're able to use both
// headers and platform definitions when compiling platform code
report(NAMED_ARGUMENTS_NOT_ALLOWED.on(nameReference, HEADER_CLASS_MEMBER));
}
else if (!candidate.hasStableParameterNames()) {
report(NAMED_ARGUMENTS_NOT_ALLOWED.on(
nameReference,
candidate instanceof FunctionInvokeDescriptor ? INVOKE_ON_FUNCTION_TYPE : NON_KOTLIN_FUNCTION
));
}
}
if (candidate.hasStableParameterNames() && nameReference != null &&

View File

@@ -0,0 +1,63 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.resolve.calls.checkers
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.descriptors.ConstructorDescriptor
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.psi.KtCallExpression
import org.jetbrains.kotlin.psi.KtElement
import org.jetbrains.kotlin.psi.KtSimpleNameExpression
import org.jetbrains.kotlin.resolve.BindingTrace
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
import org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCall
object UnderscoreUsageChecker : CallChecker {
override fun check(resolvedCall: ResolvedCall<*>, reportOn: PsiElement, context: CallCheckerContext) {
if (resolvedCall is VariableAsFunctionResolvedCall) return
val descriptor = resolvedCall.resultingDescriptor
val namedDescriptor = if (descriptor is ConstructorDescriptor) descriptor.containingDeclaration else descriptor
if (!namedDescriptor.name.asString().isUnderscoreOnlyName()) return
checkCallElement(resolvedCall.call.callElement, context)
}
private fun checkCallElement(ktElement: KtElement, context: CallCheckerContext) {
when (ktElement) {
is KtSimpleNameExpression ->
checkSimpleNameUsage(ktElement, context.trace)
is KtCallExpression ->
ktElement.calleeExpression?.let { checkCallElement(it, context) }
}
}
private fun checkSimpleNameUsage(ktName: KtSimpleNameExpression, trace: BindingTrace) {
if (ktName.text.isUnderscoreOnlyName()) {
trace.report(Errors.UNDERSCORE_USAGE_WITHOUT_BACKTICKS.on(ktName))
}
}
fun checkSimpleNameUsage(descriptor: DeclarationDescriptor, ktName: KtSimpleNameExpression, trace: BindingTrace) {
if (descriptor.name.asString().isUnderscoreOnlyName()) {
checkSimpleNameUsage(ktName, trace)
}
}
fun String.isUnderscoreOnlyName() =
isNotEmpty() && all { it == '_' }
}

View File

@@ -42,6 +42,7 @@ import org.jetbrains.kotlin.resolve.scopes.getDescriptorsFiltered
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.TypeConstructorSubstitution
import org.jetbrains.kotlin.types.TypeSubstitutor
import org.jetbrains.kotlin.types.TypeUtils
import org.jetbrains.kotlin.types.typeUtil.asTypeProjection
import org.jetbrains.kotlin.utils.SmartList
import org.jetbrains.kotlin.utils.keysToMap
@@ -266,11 +267,11 @@ class HeaderImplDeclarationChecker(val moduleToCheck: ModuleDescriptor? = null)
val substitutor = Substitutor(aTypeParams, bTypeParams, parentSubstitutor)
if (aParams.map { substitutor(it.type) } != bParams.map { it.type } ||
aExtensionReceiver?.type?.let(substitutor) != bExtensionReceiver?.type) return Incompatible.ParameterTypes
if (substitutor(a.returnType) != b.returnType) return Incompatible.ReturnType
if (!areCompatibleTypeLists(aParams.map { substitutor(it.type) }, bParams.map { it.type }) ||
!areCompatibleTypes(aExtensionReceiver?.type?.let(substitutor), bExtensionReceiver?.type)) return Incompatible.ParameterTypes
if (!areCompatibleTypes(substitutor(a.returnType), b.returnType)) return Incompatible.ReturnType
if (!equalsBy(aParams, bParams, ValueParameterDescriptor::getName)) return Incompatible.ParameterNames
if (b.hasStableParameterNames() && !equalsBy(aParams, bParams, ValueParameterDescriptor::getName)) return Incompatible.ParameterNames
if (!equalsBy(aTypeParams, bTypeParams, TypeParameterDescriptor::getName)) return Incompatible.TypeParameterNames
if (a.modality != b.modality) return Incompatible.Modality
@@ -292,8 +293,19 @@ class HeaderImplDeclarationChecker(val moduleToCheck: ModuleDescriptor? = null)
return Compatible
}
private fun areCompatibleTypes(a: KotlinType?, b: KotlinType?): Boolean {
return if (a != null) b != null && TypeUtils.equalTypes(a, b) else b == null
}
private fun areCompatibleTypeLists(a: List<KotlinType?>, b: List<KotlinType?>): Boolean {
for (i in a.indices) {
if (!areCompatibleTypes(a[i], b[i])) return false
}
return true
}
private fun areCompatibleTypeParameters(a: List<TypeParameterDescriptor>, b: List<TypeParameterDescriptor>, substitutor: Substitutor): Compatibility {
if (a.map { substitutor(it.defaultType) } != b.map { it.defaultType }) return Incompatible.TypeParameterUpperBounds
if (!areCompatibleTypeLists(a.map { substitutor(it.defaultType) }, b.map { it.defaultType })) return Incompatible.TypeParameterUpperBounds
if (!equalsBy(a, b, TypeParameterDescriptor::getVariance)) return Incompatible.TypeParameterVariance
if (!equalsBy(a, b, TypeParameterDescriptor::isReified)) return Incompatible.TypeParameterReified
@@ -362,7 +374,9 @@ class HeaderImplDeclarationChecker(val moduleToCheck: ModuleDescriptor? = null)
// and not added if an explicit supertype _is_ specified
val aSupertypes = a.typeConstructor.supertypes.filterNot(KotlinBuiltIns::isAny)
val bSupertypes = b.typeConstructor.supertypes.filterNot(KotlinBuiltIns::isAny)
if (!bSupertypes.containsAll(aSupertypes.map(substitutor))) return Incompatible.Supertypes
if (aSupertypes.map(substitutor).any { aSupertype ->
bSupertypes.none { bSupertype -> areCompatibleTypes(aSupertype, bSupertype) }
}) return Incompatible.Supertypes
areCompatibleClassScopes(a, b, checkImpl && !implTypealias, substitutor).let { if (it != Compatible) return it }

View File

@@ -37,21 +37,6 @@ public class ClsWrapperStubPsiFactory extends StubPsiFactory {
private ClsWrapperStubPsiFactory() { }
@Nullable
public static LightMemberOriginForDeclaration getMemberOrigin(@NotNull PsiMember member) {
if (member instanceof ClsRepositoryPsiElement<?>) {
StubElement stubElement = ((ClsRepositoryPsiElement<?>) member).getStub();
if (stubElement instanceof UserDataHolder) {
LightElementOrigin origin = ((UserDataHolder) stubElement).getUserData(ORIGIN);
if (origin instanceof LightMemberOriginForDeclaration) {
return (LightMemberOriginForDeclaration) origin;
}
}
}
return null;
}
@Override
public PsiClass createClass(@NotNull PsiClassStub stub) {
final PsiElement origin = getOriginalElement(stub);

View File

@@ -16,13 +16,12 @@
package org.jetbrains.kotlin.asJava.elements
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiField
import com.intellij.psi.PsiNamedElement
import com.intellij.psi.*
import com.intellij.psi.impl.PsiVariableEx
import org.jetbrains.kotlin.asJava.builder.LightMemberOrigin
import org.jetbrains.kotlin.psi.KtDeclaration
import org.jetbrains.kotlin.psi.KtElement
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOriginKind
interface KtLightElement<out T : KtElement, out D : PsiElement> : PsiNamedElement {
val kotlinOrigin: T?
@@ -30,8 +29,16 @@ interface KtLightElement<out T : KtElement, out D : PsiElement> : PsiNamedElemen
val clsDelegate: D
}
interface KtLightDeclaration<out T: KtDeclaration, out D: PsiElement>: KtLightElement<T, D>
interface KtLightDeclaration<out T : KtDeclaration, out D : PsiElement> : KtLightElement<T, D>
interface KtLightField : PsiField, KtLightDeclaration<KtDeclaration, PsiField>, PsiVariableEx {
interface KtLightMember<out D : PsiMember> : PsiMember, KtLightDeclaration<KtDeclaration, D>, PsiNameIdentifierOwner, PsiDocCommentOwner {
val lightMemberOrigin: LightMemberOrigin?
}
interface KtLightField : PsiField, KtLightMember<PsiField>, PsiVariableEx
interface KtLightMethod : PsiAnnotationMethod, KtLightMember<PsiMethod> {
val isDelegated: Boolean
get() = lightMemberOrigin?.originKind == JvmDeclarationOriginKind.DELEGATION
|| lightMemberOrigin?.originKind == JvmDeclarationOriginKind.DELEGATION_TO_DEFAULT_IMPLS
}

View File

@@ -16,12 +16,8 @@
package org.jetbrains.kotlin.asJava.elements
import com.intellij.navigation.ItemPresentation
import com.intellij.navigation.ItemPresentationProviders
import com.intellij.openapi.util.TextRange
import com.intellij.psi.*
import com.intellij.psi.impl.PsiVariableEx
import com.intellij.psi.impl.light.LightElement
import com.intellij.util.IncorrectOperationException
import org.jetbrains.annotations.NonNls
import org.jetbrains.kotlin.asJava.builder.ClsWrapperStubPsiFactory
@@ -30,42 +26,24 @@ import org.jetbrains.kotlin.asJava.builder.LightMemberOriginForDeclaration
import org.jetbrains.kotlin.asJava.classes.KtLightClass
import org.jetbrains.kotlin.asJava.classes.KtLightClassForEnumEntry
import org.jetbrains.kotlin.asJava.classes.lazyPub
import org.jetbrains.kotlin.idea.KotlinLanguage
import org.jetbrains.kotlin.psi.KtDeclaration
import org.jetbrains.kotlin.psi.KtEnumEntry
import org.jetbrains.kotlin.psi.KtNamedDeclaration
import java.lang.UnsupportedOperationException
// Copied from com.intellij.psi.impl.light.LightField
sealed class KtLightFieldImpl<T: PsiField>(
sealed class KtLightFieldImpl<D : PsiField>(
override val lightMemberOrigin: LightMemberOrigin?,
computeRealDelegate: () -> T,
private val containingClass: KtLightClass,
private val dummyDelegate: PsiField?
) : LightElement(containingClass.manager, KotlinLanguage.INSTANCE), KtLightField {
private val lightIdentifier by lazyPub { KtLightIdentifier(this, kotlinOrigin as? KtNamedDeclaration) }
computeRealDelegate: () -> D,
containingClass: KtLightClass,
dummyDelegate: PsiField?
) : KtLightMemberImpl<PsiField>(computeRealDelegate, lightMemberOrigin, containingClass, dummyDelegate), KtLightField {
override val clsDelegate: T by lazyPub(computeRealDelegate)
override val clsDelegate: D
@Suppress("UNCHECKED_CAST")
get() = super.clsDelegate as D
@Throws(IncorrectOperationException::class)
override fun setInitializer(initializer: PsiExpression?) = throw IncorrectOperationException("Not supported")
override fun getUseScope() = kotlinOrigin?.useScope ?: super.getUseScope()
override fun getPresentation(): ItemPresentation? = (kotlinOrigin ?: this).let { ItemPresentationProviders.getItemPresentation(it) }
override fun getName() = dummyDelegate?.name ?: clsDelegate.name
override fun getNameIdentifier() = lightIdentifier
override fun getDocComment() = clsDelegate.docComment
override fun isDeprecated() = clsDelegate.isDeprecated
override fun getContainingClass() = containingClass
override fun getContainingFile() = containingClass.containingFile
override fun getType() = clsDelegate.type
override fun getTypeElement() = clsDelegate.typeElement
@@ -84,34 +62,12 @@ sealed class KtLightFieldImpl<T: PsiField>(
return this
}
private val _modifierList by lazyPub {
if (lightMemberOrigin is LightMemberOriginForDeclaration)
clsDelegate.modifierList?.let { KtLightModifierList(it, this) }
else clsDelegate.modifierList
}
override fun getModifierList() = _modifierList
override fun hasModifierProperty(@NonNls name: String) = (dummyDelegate ?: clsDelegate).hasModifierProperty(name)
override fun getText() = kotlinOrigin?.text ?: ""
override fun getTextRange() = kotlinOrigin?.textRange ?: TextRange.EMPTY_RANGE
override fun isValid() = containingClass.isValid
override fun toString(): String = "${this::class.java.simpleName}:$name"
override fun equals(other: Any?): Boolean =
other is KtLightFieldImpl<*> &&
this.name == other.name &&
this.containingClass == other.containingClass
override fun hashCode() = 31 * containingClass.hashCode() + (name?.hashCode() ?: 0)
override val kotlinOrigin: KtDeclaration? get() = lightMemberOrigin?.originalElement
override fun getNavigationElement() = kotlinOrigin ?: super.getNavigationElement()
override fun hashCode() = 31 * containingClass.hashCode() + name.hashCode()
override fun computeConstantValue(visitedVars: MutableSet<PsiVariable>?): Any? {
return (clsDelegate as PsiVariableEx).computeConstantValue(visitedVars)
@@ -124,8 +80,6 @@ sealed class KtLightFieldImpl<T: PsiField>(
return super.isEquivalentTo(another)
}
override fun isWritable() = kotlinOrigin?.isWritable ?: false
override fun copy() = Factory.create(lightMemberOrigin?.copy(), clsDelegate, containingClass)
@@ -134,7 +88,7 @@ sealed class KtLightFieldImpl<T: PsiField>(
computeDelegate: () -> PsiEnumConstant,
containingClass: KtLightClass,
dummyDelegate: PsiField?
) : KtLightFieldImpl<PsiEnumConstant>(origin, computeDelegate , containingClass, dummyDelegate), PsiEnumConstant {
) : KtLightFieldImpl<PsiEnumConstant>(origin, computeDelegate, containingClass, dummyDelegate), PsiEnumConstant {
private val initializingClass by lazyPub {
val kotlinEnumEntry = (lightMemberOrigin as? LightMemberOriginForDeclaration)?.originalElement as? KtEnumEntry
if (kotlinEnumEntry != null && kotlinEnumEntry.declarations.isNotEmpty()) {
@@ -184,8 +138,9 @@ sealed class KtLightFieldImpl<T: PsiField>(
}
fun fromClsFields(delegateClass: PsiClass, containingClass: KtLightClass) = delegateClass.fields.map {
val origin = ClsWrapperStubPsiFactory.getMemberOrigin(it)
KtLightFieldImpl.create(origin, it, containingClass)
KtLightFieldImpl.create(getOrigin(it), it, containingClass)
}
fun getOrigin(field: PsiField) = getMemberOrigin(field)
}
}

View File

@@ -0,0 +1,136 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.asJava.elements
import com.intellij.navigation.ItemPresentation
import com.intellij.navigation.ItemPresentationProviders
import com.intellij.openapi.util.TextRange
import com.intellij.openapi.util.UserDataHolder
import com.intellij.psi.*
import com.intellij.psi.impl.compiled.ClsRepositoryPsiElement
import com.intellij.psi.impl.light.LightElement
import org.jetbrains.kotlin.asJava.builder.ClsWrapperStubPsiFactory.ORIGIN
import org.jetbrains.kotlin.asJava.builder.LightElementOrigin
import org.jetbrains.kotlin.asJava.builder.LightMemberOrigin
import org.jetbrains.kotlin.asJava.builder.LightMemberOriginForDeclaration
import org.jetbrains.kotlin.asJava.classes.KtLightClass
import org.jetbrains.kotlin.asJava.classes.lazyPub
import org.jetbrains.kotlin.idea.KotlinLanguage
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.KtDeclaration
import org.jetbrains.kotlin.psi.KtNamedDeclaration
abstract class KtLightMemberImpl<out D : PsiMember>(
computeRealDelegate: () -> D,
override val lightMemberOrigin: LightMemberOrigin?,
private val containingClass: KtLightClass,
private val dummyDelegate: D?
) : LightElement(containingClass.manager, KotlinLanguage.INSTANCE), PsiMember, KtLightMember<D> {
override val clsDelegate by lazyPub(computeRealDelegate)
private val lightIdentifier by lazyPub { KtLightIdentifier(this, kotlinOrigin as? KtNamedDeclaration) }
private val _modifierList by lazyPub {
if (lightMemberOrigin is LightMemberOriginForDeclaration)
KtLightModifierList(this, dummyDelegate?.modifierList)
else clsDelegate.modifierList!!
}
override fun hasModifierProperty(name: String) = _modifierList.hasModifierProperty(name)
override fun getModifierList(): PsiModifierList = _modifierList
override fun toString(): String = "${this::class.java.simpleName}:$name"
override fun getContainingClass() = containingClass
override fun getContainingFile() = containingClass.containingFile
override fun getParent(): PsiElement = containingClass
override fun isValid() = containingClass.isValid
override fun getName(): String = dummyDelegate?.name ?: clsDelegate.name!!
override fun getNameIdentifier(): PsiIdentifier = lightIdentifier
override fun getUseScope() = kotlinOrigin?.useScope ?: super.getUseScope()
override val kotlinOrigin: KtDeclaration? get() = lightMemberOrigin?.originalElement
override fun getNavigationElement() = kotlinOrigin ?: super.getNavigationElement()
override fun getPresentation(): ItemPresentation? = (kotlinOrigin ?: this).let { ItemPresentationProviders.getItemPresentation(it) }
override fun getText() = kotlinOrigin?.text ?: ""
override fun getTextRange() = kotlinOrigin?.textRange ?: TextRange.EMPTY_RANGE
override fun isWritable() = kotlinOrigin?.isWritable ?: false
override fun getDocComment() = (clsDelegate as PsiDocCommentOwner).docComment
override fun isDeprecated() = (clsDelegate as PsiDocCommentOwner).isDeprecated
}
private val visibilityModifiers = arrayOf(PsiModifier.PRIVATE, PsiModifier.PACKAGE_LOCAL, PsiModifier.PROTECTED, PsiModifier.PUBLIC)
internal fun getMemberOrigin(member: PsiMember): LightMemberOriginForDeclaration? {
if (member !is ClsRepositoryPsiElement<*>) return null
val stubElement = member.stub as? UserDataHolder ?: return null
return stubElement.getUserData<LightElementOrigin>(ORIGIN) as? LightMemberOriginForDeclaration ?: return null
}
class KtLightModifierList(
private val owner: KtLightMember<*>,
private val dummyDelegate: PsiModifierList?
) : LightElement(owner.manager, KotlinLanguage.INSTANCE), PsiModifierList {
private val clsDelegate by lazyPub { owner.clsDelegate.modifierList!! }
private val _annotations by lazyPub { computeAnnotations(this, clsDelegate) }
override fun hasModifierProperty(name: String): Boolean {
if (dummyDelegate != null) {
if (name in visibilityModifiers) {
if (owner.kotlinOrigin?.hasModifier(KtTokens.OVERRIDE_KEYWORD) ?: false) {
return clsDelegate.hasModifierProperty(name)
}
}
return dummyDelegate.hasModifierProperty(name)
}
return clsDelegate.hasModifierProperty(name)
}
override fun hasExplicitModifier(name: String) = hasModifierProperty(name)
override fun setModifierProperty(name: String, value: Boolean) = clsDelegate.setModifierProperty(name, value)
override fun checkSetModifierProperty(name: String, value: Boolean) = clsDelegate.checkSetModifierProperty(name, value)
override fun addAnnotation(qualifiedName: String) = clsDelegate.addAnnotation(qualifiedName)
override fun getApplicableAnnotations(): Array<out PsiAnnotation> = annotations
override fun getAnnotations(): Array<out PsiAnnotation> = _annotations.value
override fun findAnnotation(qualifiedName: String) = annotations.firstOrNull { it.qualifiedName == qualifiedName }
override fun getParent() = owner
override fun getText(): String? = ""
override fun getTextRange() = TextRange.EMPTY_RANGE
override fun copy(): PsiElement = KtLightModifierList(owner, dummyDelegate)
override fun getReferences() = PsiReference.EMPTY_ARRAY
override fun isEquivalentTo(another: PsiElement?) =
another is KtLightModifierList && owner == another.owner
override fun toString() = "Light modifier list of $owner"
}

View File

@@ -16,13 +16,8 @@
package org.jetbrains.kotlin.asJava.elements
import com.intellij.core.JavaCoreBundle
import com.intellij.navigation.ItemPresentation
import com.intellij.openapi.util.TextRange
import com.intellij.psi.*
import com.intellij.psi.impl.compiled.ClsTypeElementImpl
import com.intellij.psi.impl.light.LightElement
import com.intellij.psi.javadoc.PsiDocComment
import com.intellij.psi.scope.PsiScopeProcessor
import com.intellij.psi.util.*
import com.intellij.util.IncorrectOperationException
@@ -32,29 +27,17 @@ import org.jetbrains.kotlin.asJava.classes.KtLightClass
import org.jetbrains.kotlin.asJava.classes.lazyPub
import org.jetbrains.kotlin.asJava.propertyNameByAccessor
import org.jetbrains.kotlin.asJava.unwrapped
import org.jetbrains.kotlin.idea.KotlinLanguage
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.jvm.KotlinJavaPsiFacade
import org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOriginKind
interface KtLightMethod : PsiAnnotationMethod, KtLightDeclaration<KtDeclaration, PsiMethod> {
val lightMethodOrigin: LightMemberOrigin?
val isDelegated: Boolean
}
class KtLightMethodImpl private constructor(
computeRealDelegate: () -> PsiMethod,
override val lightMethodOrigin: LightMemberOrigin?,
private val containingClass: KtLightClass,
lightMemberOrigin: LightMemberOrigin?,
containingClass: KtLightClass,
private val dummyDelegate: PsiMethod? = null
) : LightElement(containingClass.manager, containingClass.language), KtLightMethod {
override val kotlinOrigin: KtDeclaration? get() = lightMethodOrigin?.originalElement as? KtDeclaration
override val clsDelegate by lazyPub(computeRealDelegate)
private val lightIdentifier by lazyPub { KtLightIdentifier(this, kotlinOrigin as? KtNamedDeclaration) }
) : KtLightMemberImpl<PsiMethod>(computeRealDelegate, lightMemberOrigin, containingClass, dummyDelegate), KtLightMethod {
private val returnTypeElem by lazyPub {
val delegateTypeElement = clsDelegate.returnTypeElement as? ClsTypeElementImpl
delegateTypeElement?.let { ClsTypeElementImpl(this, it.canonicalText, /*ClsTypeElementImpl.VARIANCE_NONE */ 0.toChar()) }
@@ -62,8 +45,6 @@ class KtLightMethodImpl private constructor(
private val calculatingReturnType = ThreadLocal<Boolean>()
override fun getContainingClass(): KtLightClass = containingClass
private val paramsList: PsiParameterList by lazyPub {
KtLightParameterList(this, dummyDelegate?.parameterList?.parametersCount ?: clsDelegate.parameterList.parametersCount) {
clsDelegate.parameterList.parameters.mapIndexed { index, clsParameter -> KtLightParameter(clsParameter, index, this@KtLightMethodImpl) }
@@ -74,7 +55,7 @@ class KtLightMethodImpl private constructor(
val cacheManager = CachedValuesManager.getManager(clsDelegate.project)
cacheManager.createCachedValue<PsiTypeParameterList>(
{
val origin = (lightMethodOrigin as? LightMemberOriginForDeclaration)?.originalElement
val origin = (lightMemberOrigin as? LightMemberOriginForDeclaration)?.originalElement
val list = if (origin != null) {
if (origin is KtClassOrObject) {
KotlinLightTypeParameterListBuilder(manager)
@@ -91,16 +72,6 @@ class KtLightMethodImpl private constructor(
)
}
override fun getNavigationElement(): PsiElement = kotlinOrigin?.navigationElement ?: super.getNavigationElement()
override fun getPresentation(): ItemPresentation? = kotlinOrigin?.presentation ?: super.getPresentation()
override fun getParent(): PsiElement = containingClass
override fun getText() = kotlinOrigin?.text ?: ""
override fun getTextRange() = kotlinOrigin?.textRange ?: TextRange.EMPTY_RANGE
override val isDelegated: Boolean
get() = lightMethodOrigin?.originKind == JvmDeclarationOriginKind.DELEGATION
|| lightMethodOrigin?.originKind == JvmDeclarationOriginKind.DELEGATION_TO_DEFAULT_IMPLS
override fun accept(visitor: PsiElementVisitor) {
if (visitor is JavaElementVisitor) {
visitor.visitMethod(this)
@@ -136,31 +107,22 @@ class KtLightMethodImpl private constructor(
} ?: throwCanNotModify()
}
private fun throwCanNotModify(): Nothing {
throw IncorrectOperationException(JavaCoreBundle.message("psi.error.attempt.to.edit.class.file"))
}
private val _modifierList by lazyPub {
if (lightMethodOrigin is LightMemberOriginForDeclaration)
KtLightModifierList(clsDelegate.modifierList, this)
else clsDelegate.modifierList
}
// TODO: add message
private fun throwCanNotModify(): Nothing = throw IncorrectOperationException()
override fun getModifierList(): PsiModifierList {
if (calculatingReturnType.get() == true) {
return KotlinJavaPsiFacade.getInstance(project).emptyModifierList
}
return _modifierList
return super.getModifierList()!!
}
override fun getNameIdentifier() = lightIdentifier
override fun getParameterList() = paramsList
override fun getTypeParameterList() = typeParamsList.value
override fun getTypeParameters(): Array<PsiTypeParameter> =
typeParameterList?.let { it.typeParameters } ?: PsiTypeParameter.EMPTY_ARRAY
typeParameterList?.typeParameters ?: PsiTypeParameter.EMPTY_ARRAY
override fun getSignature(substitutor: PsiSubstitutor): MethodSignature {
if (substitutor == PsiSubstitutor.EMPTY) {
@@ -170,13 +132,9 @@ class KtLightMethodImpl private constructor(
}
override fun copy(): PsiElement {
return Factory.create(clsDelegate, lightMethodOrigin?.copy(), containingClass)
return Factory.create(clsDelegate, lightMemberOrigin?.copy(), containingClass)
}
override fun getUseScope() = kotlinOrigin?.useScope ?: super.getUseScope()
override fun getLanguage() = KotlinLanguage.INSTANCE
override fun processDeclarations(processor: PsiScopeProcessor, state: ResolveState, lastParent: PsiElement?, place: PsiElement): Boolean {
return typeParameters.all { processor.execute(it, state) }
}
@@ -200,12 +158,10 @@ class KtLightMethodImpl private constructor(
other is KtLightMethodImpl &&
this.name == other.name &&
this.containingClass == other.containingClass &&
this.lightMethodOrigin == other.lightMethodOrigin &&
this.lightMemberOrigin == other.lightMemberOrigin &&
this._memberIndex == other._memberIndex
override fun hashCode(): Int = ((getName().hashCode() * 31 + (lightMethodOrigin?.hashCode() ?: 0)) * 31 + containingClass.hashCode()) * 31 + (_memberIndex?.hashCode() ?: 0)
override fun toString(): String = "${this::class.java.simpleName}:$name"
override fun hashCode(): Int = ((getName().hashCode() * 31 + (lightMemberOrigin?.hashCode() ?: 0)) * 31 + containingClass.hashCode()) * 31 + (_memberIndex?.hashCode() ?: 0)
override fun getDefaultValue() = (clsDelegate as? PsiAnnotationMethod)?.defaultValue
@@ -244,37 +200,30 @@ class KtLightMethodImpl private constructor(
origin: LightMemberOriginForDeclaration?,
computeRealDelegate: () -> PsiMethod
): KtLightMethodImpl {
return KtLightMethodImpl(computeRealDelegate, adjustMethodOrigin(origin), containingClass, dummyDelegate)
return KtLightMethodImpl(computeRealDelegate, origin, containingClass, dummyDelegate)
}
fun fromClsMethods(delegateClass: PsiClass, containingClass: KtLightClass) = delegateClass.methods.map {
val origin = ClsWrapperStubPsiFactory.getMemberOrigin(it)
KtLightMethodImpl.create(it, adjustMethodOrigin(origin), containingClass)
KtLightMethodImpl.create(it, getOrigin(it), containingClass)
}
fun getOrigin(method: PsiMethod) = adjustMethodOrigin(getMemberOrigin(method))
}
override fun getName() = dummyDelegate?.name ?: clsDelegate.name
override fun hasModifierProperty(name: String) = (dummyDelegate ?: clsDelegate).hasModifierProperty(name)
override fun getThrowsList() = clsDelegate.throwsList
override fun hasTypeParameters() = clsDelegate.hasTypeParameters()
override fun isVarArgs() = clsDelegate.isVarArgs
override fun isVarArgs() = (dummyDelegate ?: clsDelegate).isVarArgs
override fun isConstructor() = dummyDelegate?.isConstructor ?: clsDelegate.isConstructor
override fun getHierarchicalMethodSignature() = clsDelegate.hierarchicalMethodSignature
override fun getDocComment() = clsDelegate.docComment
override fun findSuperMethodSignaturesIncludingStatic(checkAccess: Boolean) = clsDelegate.findSuperMethodSignaturesIncludingStatic(checkAccess)
override fun getBody() = null
override fun isDeprecated() = clsDelegate.isDeprecated
override fun findDeepestSuperMethod() = clsDelegate.findDeepestSuperMethod()
override fun findDeepestSuperMethods() = clsDelegate.findDeepestSuperMethods()
@@ -284,10 +233,6 @@ class KtLightMethodImpl private constructor(
override fun findSuperMethods(checkAccess: Boolean) = clsDelegate.findSuperMethods(checkAccess)
override fun findSuperMethods(parentClass: PsiClass?) = clsDelegate.findSuperMethods(parentClass)
override fun getContainingFile() = parent.containingFile
override fun isValid() = containingClass.isValid
}
fun KtLightMethod.isTraitFakeOverride(): Boolean {

View File

@@ -16,14 +16,14 @@
package org.jetbrains.kotlin.asJava.elements
import com.intellij.openapi.util.TextRange
import com.intellij.psi.*
import com.intellij.psi.PsiAnnotation
import com.intellij.psi.PsiAnnotationOwner
import com.intellij.psi.PsiModifierList
import com.intellij.psi.impl.light.LightModifierList
import com.intellij.psi.util.CachedValue
import com.intellij.psi.util.CachedValueProvider
import com.intellij.psi.util.CachedValuesManager
import com.intellij.psi.util.PsiModificationTracker
import com.intellij.util.ArrayUtil
import org.jetbrains.annotations.NonNls
import org.jetbrains.kotlin.asJava.LightClassGenerationSupport
import org.jetbrains.kotlin.asJava.classes.lazyPub
@@ -54,43 +54,6 @@ abstract class KtLightModifierListWithExplicitModifiers(
override fun addAnnotation(@NonNls qualifiedName: String) = delegate.addAnnotation(qualifiedName)
}
class KtLightModifierList(
private val delegate: PsiModifierList,
private val owner: PsiModifierListOwner
) : PsiModifierList by delegate {
private val _annotations by lazyPub { computeAnnotations(this, delegate) }
override fun getAnnotations(): Array<out PsiAnnotation> = _annotations.value
override fun findAnnotation(@NonNls qualifiedName: String) = annotations.firstOrNull { it.qualifiedName == qualifiedName }
override fun addAnnotation(@NonNls qualifiedName: String) = delegate.addAnnotation(qualifiedName)
override fun getParent() = owner
override fun getText(): String? = ""
override fun getLanguage() = KotlinLanguage.INSTANCE
override fun getTextRange() = TextRange.EMPTY_RANGE
override fun getStartOffsetInParent() = -1
override fun getTextLength() = 0
override fun getPrevSibling(): PsiElement? = null
override fun getNextSibling(): PsiElement? = null
override fun findElementAt(offset: Int): PsiElement? = null
override fun findReferenceAt(offset: Int): PsiReference? = null
override fun getTextOffset() = -1
override fun isWritable() = false
override fun isPhysical() = false
override fun textToCharArray(): CharArray = ArrayUtil.EMPTY_CHAR_ARRAY;
override fun textMatches(text: CharSequence): Boolean = getText() == text.toString()
override fun textMatches(element: PsiElement): Boolean = text == element.text
override fun textContains(c: Char): Boolean = text?.contains(c) ?: false
override fun copy(): PsiElement = KtLightModifierList(delegate, owner)
override fun getReferences() = PsiReference.EMPTY_ARRAY
override fun isEquivalentTo(another: PsiElement?) =
another is KtLightModifierList && delegate == another.delegate && owner == another.owner
}
internal fun computeAnnotations(lightElement: PsiModifierList,
delegate: PsiAnnotationOwner): CachedValue<Array<out PsiAnnotation>> {
fun doCompute(): Array<PsiAnnotation> {

View File

@@ -53,7 +53,7 @@ public class KtLightParameter extends LightParameter implements KtLightDeclarati
this.index = index;
this.method = method;
if (method.getLightMethodOrigin() instanceof LightMemberOriginForDeclaration) {
if (method.getLightMemberOrigin() instanceof LightMemberOriginForDeclaration) {
this.modifierList = new KtLightModifierListWithExplicitModifiers(this, ArrayUtil.EMPTY_STRING_ARRAY) {
@Override
public PsiAnnotationOwner getDelegate() {

View File

@@ -58,7 +58,7 @@ fun HierarchicalScope.collectDescriptorsFiltered(
}
@Deprecated("Use getOwnProperties instead") fun LexicalScope.findLocalVariable(name: Name): VariableDescriptor? {
@Deprecated("Use getContributedProperties instead") fun LexicalScope.findLocalVariable(name: Name): VariableDescriptor? {
return findFirstFromMeAndParent {
when {
it is LexicalScopeWrapper -> it.delegate.findLocalVariable(name)

View File

@@ -65,7 +65,8 @@ class DescriptorSerializer private constructor(
val flags = Flags.getClassFlags(
hasAnnotations(classDescriptor), classDescriptor.visibility, classDescriptor.modality, classDescriptor.kind,
classDescriptor.isInner, classDescriptor.isCompanionObject, classDescriptor.isData, classDescriptor.isExternal
classDescriptor.isInner, classDescriptor.isCompanionObject, classDescriptor.isData, classDescriptor.isExternal,
classDescriptor.isHeader
)
if (flags != builder.flags) {
builder.flags = flags
@@ -150,8 +151,6 @@ class DescriptorSerializer private constructor(
var hasGetter = false
var hasSetter = false
val lateInit = descriptor.isLateInit
val isConst = descriptor.isConst
val compileTimeConstant = descriptor.compileTimeInitializer
val hasConstant = compileTimeConstant != null && compileTimeConstant !is NullValue
@@ -187,8 +186,8 @@ class DescriptorSerializer private constructor(
val flags = Flags.getPropertyFlags(
hasAnnotations, descriptor.visibility, descriptor.modality, descriptor.kind, descriptor.isVar,
hasGetter, hasSetter, hasConstant, isConst, lateInit, descriptor.isExternal,
@Suppress("DEPRECATION") descriptor.isDelegated
hasGetter, hasSetter, hasConstant, descriptor.isConst, descriptor.isLateInit, descriptor.isExternal,
@Suppress("DEPRECATION") descriptor.isDelegated, descriptor.isHeader
)
if (flags != builder.flags) {
builder.flags = flags
@@ -233,7 +232,8 @@ class DescriptorSerializer private constructor(
val flags = Flags.getFunctionFlags(
hasAnnotations(descriptor), descriptor.visibility, descriptor.modality, descriptor.kind, descriptor.isOperator,
descriptor.isInfix, descriptor.isInline, descriptor.isTailrec, descriptor.isExternal, descriptor.isSuspend
descriptor.isInfix, descriptor.isInline, descriptor.isTailrec, descriptor.isExternal, descriptor.isSuspend,
descriptor.isHeader
)
if (flags != builder.flags) {
builder.flags = flags

View File

@@ -0,0 +1,9 @@
public final class B implements p.I {
private final p.I f;
public B(@org.jetbrains.annotations.NotNull p.I f) { /* compiled code */ }
public void f() { /* compiled code */ }
public void g() { /* compiled code */ }
}

View File

@@ -0,0 +1,13 @@
// p.B
package p
class B(private val f: I) : I by f {
}
interface I {
fun g()
fun f()
}
// LAZINESS:NoLaziness

View File

@@ -0,0 +1,2 @@
public final class HiddenDeprecatedKt {
}

View File

@@ -0,0 +1,7 @@
// a.HiddenDeprecatedKt
package a
@Deprecated("f", level = DeprecationLevel.HIDDEN)
fun f() {
}

View File

@@ -0,0 +1,7 @@
public final class C {
public final void f(@org.jetbrains.annotations.NotNull int... i) { /* compiled code */ }
public final void p(int i, @org.jetbrains.annotations.NotNull java.lang.String... s) { /* compiled code */ }
public C() { /* compiled code */ }
}

View File

@@ -0,0 +1,12 @@
// C
class C {
fun f(vararg i: Int) {
}
fun p(i: Int, vararg s: String) {
}
}

View File

@@ -0,0 +1,6 @@
package p
abstract class A {
internal val ap: Int = 4
internal fun af(): Int
}

View File

@@ -0,0 +1,7 @@
public final class C extends p.A {
public int getAp$production_sources_for_module_light_idea_test_case() { /* compiled code */ }
public int af$production_sources_for_module_light_idea_test_case() { /* compiled code */ }
public C() { /* compiled code */ }
}

View File

@@ -0,0 +1,13 @@
// p.C
package p
class C : A() {
override val ap: Int
get() = super.c
override fun af(): Int {
return super.foo()
}
}
// LAZINESS:NoConsistency

View File

@@ -0,0 +1,11 @@
package p
abstract class A {
open internal val ap: Int = 4
abstract internal fun af(): Int
}
interface I {
internal val ip: Int
internal fun if(): Int
}

View File

@@ -0,0 +1,13 @@
public final class C extends p.A implements p.I {
private final int ip = 5;
public int getAp$production_sources_for_module_light_idea_test_case() { /* compiled code */ }
public int af$production_sources_for_module_light_idea_test_case() { /* compiled code */ }
public int getIp$production_sources_for_module_light_idea_test_case() { /* compiled code */ }
public int $$<no name provided>$production_sources_for_module_light_idea_test_case /* Real name is '<no name provided>$production_sources_for_module_light_idea_test_case' */() { /* compiled code */ }
public C() { /* compiled code */ }
}

View File

@@ -0,0 +1,16 @@
// p.C
package p
class C : A(), I {
override val ap: Int
get() = super.c
override fun af(): Int {
return super.foo()
}
override val ip = 5
override fun if() = 5
}
// LAZINESS:NoLaziness

View File

@@ -0,0 +1,6 @@
package p
abstract class A {
protected val ap: Int = 4
abstract protected fun af(): Int
}

View File

@@ -0,0 +1,7 @@
public final class C extends p.A {
protected int getAp() { /* compiled code */ }
protected int af() { /* compiled code */ }
public C() { /* compiled code */ }
}

View File

@@ -0,0 +1,13 @@
// p.C
package p
class C : A() {
override val ap: Int
get() = super.c
override fun af(): Int {
return super.foo()
}
}
// LAZINESS:NoLaziness

View File

@@ -10,3 +10,4 @@ class C: Tr {
override val v = 1
}
// LAZINESS:NoLaziness

View File

@@ -6,4 +6,6 @@ interface Base {
class C : Base {
override fun foo(): Unit {}
}
}
// LAZINESS:NoLaziness

View File

@@ -6,4 +6,5 @@ interface Base<T> {
class C : Base<Unit> {
override fun foo(t: Unit) {}
}
}
// LAZINESS:NoLaziness

View File

@@ -6,4 +6,8 @@ public open class Activity {
public open class Fragment {
public open fun getView(): android.view.View = null!!
}
}
open class Dialog {
open fun findViewById(id: Int): android.view.View? = null
}

View File

@@ -10,5 +10,5 @@ fun box() : String {
val (`_`, c) = A()
return if (a == 1 && b == 2 && _ == 1 && c == 2) "OK" else "fail"
return if (a == 1 && b == 2 && `_` == 1 && c == 2) "OK" else "fail"
}

View File

@@ -31,7 +31,7 @@ fun doTest(): String {
}
for ((_, `_`) in C(2)..C(4)) {
s += "$_;"
s += "$`_`;"
}
return s

View File

@@ -0,0 +1,6 @@
package test;
public class Baz implements Foo.Bar {
@Override
public void bar() {}
}

View File

@@ -2,6 +2,6 @@ package test;
public class Foo {
public interface Bar {
void bar();
}
}

View File

@@ -1,3 +1,5 @@
import test.Foo.Bar
import test.Baz
val f: Bar? = null
val g: Baz? = Baz().apply { bar() }

View File

@@ -58,6 +58,8 @@ With that, an exact type of an expression can be checked in the following way:
expr checkType { _<A>() }
}
`CHECK_TYPE` directive also disables `UNDERSCORE_USAGE_WITHOUT_BACKTICKS` diagnostics output.
#### Usage:
// !CHECK_TYPE

View File

@@ -5,14 +5,14 @@
@___("") data class Pair(val x: Int, val y: Int)
class <!UNDERSCORE_IS_RESERVED!>_<!><<!UNDERSCORE_IS_RESERVED!>________<!>>
val <!UNDERSCORE_IS_RESERVED!>______<!> = _<Int>()
val <!UNDERSCORE_IS_RESERVED!>______<!> = <!UNDERSCORE_USAGE_WITHOUT_BACKTICKS!>_<!><Int>()
fun <!UNDERSCORE_IS_RESERVED!>__<!>(<!UNDERSCORE_IS_RESERVED!>___<!>: Int, y: _<Int>?): Int {
val (_, <!UNUSED_VARIABLE!>z<!>) = Pair(___ - 1, 42)
val (x, <!UNDERSCORE_IS_RESERVED!>__________<!>) = Pair(___ - 1, 42)
fun <!UNDERSCORE_IS_RESERVED!>__<!>(<!UNDERSCORE_IS_RESERVED!>___<!>: Int, y: <!UNDERSCORE_USAGE_WITHOUT_BACKTICKS!>_<!><Int>?): Int {
val (_, <!UNUSED_VARIABLE!>z<!>) = Pair(<!UNDERSCORE_USAGE_WITHOUT_BACKTICKS!>___<!> - 1, 42)
val (x, <!UNDERSCORE_IS_RESERVED!>__________<!>) = Pair(<!UNDERSCORE_USAGE_WITHOUT_BACKTICKS!>___<!> - 1, 42)
val <!UNDERSCORE_IS_RESERVED!>____<!> = x
// in backquotes: allowed
val `_` = __________
val `_` = <!UNDERSCORE_USAGE_WITHOUT_BACKTICKS!>__________<!>
val q = fun(_: Int, <!UNDERSCORE_IS_RESERVED, UNUSED_PARAMETER!>__<!>: Int) {}
q(1, 2)
@@ -21,7 +21,7 @@ fun <!UNDERSCORE_IS_RESERVED!>__<!>(<!UNDERSCORE_IS_RESERVED!>___<!>: Int, y: _<
fun localFun(<!UNDERSCORE_IS_RESERVED!>_<!>: String) = 1
<!UNDERSCORE_IS_RESERVED!>__<!>@ return if (y != null) __(____, y) else __(`_`, ______)
<!UNDERSCORE_IS_RESERVED!>__<!>@ return if (y != null) <!UNDERSCORE_USAGE_WITHOUT_BACKTICKS!>__<!>(<!UNDERSCORE_USAGE_WITHOUT_BACKTICKS!>____<!>, y) else <!UNDERSCORE_USAGE_WITHOUT_BACKTICKS!>__<!>(`_`, <!UNDERSCORE_USAGE_WITHOUT_BACKTICKS!>______<!>)
}
@@ -42,5 +42,5 @@ fun oneUnderscore(<!UNDERSCORE_IS_RESERVED!>_<!>: Int) {}
fun doIt(f: (Any?) -> Any?) = f(null)
val something = doIt { <!UNDERSCORE_IS_RESERVED!>__<!> -> __ }
val something = doIt { <!UNDERSCORE_IS_RESERVED!>__<!> -> <!UNDERSCORE_USAGE_WITHOUT_BACKTICKS!>__<!> }
val something2 = doIt { _ -> 1 }

View File

@@ -0,0 +1,6 @@
package test
annotation class `__`(val value: String)
@<!UNDERSCORE_USAGE_WITHOUT_BACKTICKS!>__<!>("") class TestAnn
@`__`("") class TestAnn2

View File

@@ -0,0 +1,26 @@
package
package test {
@test.__(value = "") public final class TestAnn {
public constructor TestAnn()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@test.__(value = "") public final class TestAnn2 {
public constructor TestAnn2()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final annotation class __ : kotlin.Annotation {
public constructor __(/*0*/ value: kotlin.String)
public final val value: kotlin.String
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
}

View File

@@ -0,0 +1,42 @@
// !DIAGNOSTICS: -DEPRECATION -TOPLEVEL_TYPEALIASES_ONLY
fun test(`_`: Int) {
<!UNDERSCORE_USAGE_WITHOUT_BACKTICKS!>_<!> + 1
`_` + 1
}
fun `__`() {}
fun testCall() {
<!UNDERSCORE_USAGE_WITHOUT_BACKTICKS!>__<!>()
`__`()
}
val testCallableRef = ::<!UNDERSCORE_USAGE_WITHOUT_BACKTICKS!>__<!>
val testCallableRef2 = ::`__`
object Host {
val `_` = 42
object `__` {
val bar = 4
}
}
val testQualified = Host.<!UNDERSCORE_USAGE_WITHOUT_BACKTICKS!>_<!>
val testQualified2 = Host.`_`
object `___` {
val test = 42
}
val testQualifier = <!UNDERSCORE_USAGE_WITHOUT_BACKTICKS!>___<!>.test
val testQualifier2 = `___`.test
val testQualifier3 = Host.<!UNDERSCORE_USAGE_WITHOUT_BACKTICKS!>__<!>.bar
val testQualifier4 = Host.`__`.bar
fun testCallableRefLHSValue(`_`: Any) = <!UNDERSCORE_USAGE_WITHOUT_BACKTICKS!>_<!>::toString
fun testCallableRefLHSValue2(`_`: Any) = `_`::toString
val testCallableRefLHSObject = <!UNDERSCORE_USAGE_WITHOUT_BACKTICKS!>___<!>::toString
val testCallableRefLHSObject2 = `___`::toString

View File

@@ -0,0 +1,41 @@
package
public val testCallableRef: kotlin.reflect.KFunction0<kotlin.Unit>
public val testCallableRef2: kotlin.reflect.KFunction0<kotlin.Unit>
public val testCallableRefLHSObject: kotlin.reflect.KFunction0<kotlin.String>
public val testCallableRefLHSObject2: kotlin.reflect.KFunction0<kotlin.String>
public val testQualified: kotlin.Int = 42
public val testQualified2: kotlin.Int = 42
public val testQualifier: kotlin.Int = 42
public val testQualifier2: kotlin.Int = 42
public val testQualifier3: kotlin.Int = 4
public val testQualifier4: kotlin.Int = 4
public fun __(): kotlin.Unit
public fun test(/*0*/ _: kotlin.Int): kotlin.Unit
public fun testCall(): kotlin.Unit
public fun testCallableRefLHSValue(/*0*/ _: kotlin.Any): kotlin.reflect.KFunction0<kotlin.String>
public fun testCallableRefLHSValue2(/*0*/ _: kotlin.Any): kotlin.reflect.KFunction0<kotlin.String>
public object Host {
private constructor Host()
public final val _: kotlin.Int = 42
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
public object __ {
private constructor __()
public final val bar: kotlin.Int = 4
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
}
public object ___ {
private constructor ___()
public final val test: kotlin.Int = 42
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}

View File

@@ -0,0 +1,11 @@
class `___` {
class `____`
}
val testCallableRefLHSType = <!UNDERSCORE_USAGE_WITHOUT_BACKTICKS!>___<!>::toString
val testCallableRefLHSType2 = `___`::toString
val testClassLiteralLHSType = <!UNDERSCORE_USAGE_WITHOUT_BACKTICKS!>___<!>::class
val testClassLiteralLHSType2 = `___`::class
val tesLHSTypeFQN = `___`.<!UNDERSCORE_USAGE_WITHOUT_BACKTICKS!>____<!>::class

View File

@@ -0,0 +1,21 @@
package
public val tesLHSTypeFQN: kotlin.reflect.KClass<___.____>
public val testCallableRefLHSType: kotlin.reflect.KFunction1<___, kotlin.String>
public val testCallableRefLHSType2: kotlin.reflect.KFunction1<___, kotlin.String>
public val testClassLiteralLHSType: kotlin.reflect.KClass<___>
public val testClassLiteralLHSType2: kotlin.reflect.KClass<___>
public final class ___ {
public constructor ___()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
public final class ____ {
public constructor ____()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
}

View File

@@ -0,0 +1,12 @@
// !DIAGNOSTICS: -DEPRECATION -TOPLEVEL_TYPEALIASES_ONLY
class `_`<`__`> {
fun testTypeArgument(x: List<<!UNDERSCORE_USAGE_WITHOUT_BACKTICKS!>__<!>>) = x
fun testTypeArgument2(x: List<`__`>) = x
}
fun <!UNDERSCORE_USAGE_WITHOUT_BACKTICKS!>_<!><Any>.testTypeConstructor() {}
fun `_`<Any>.testTypeConstructor2() {}
val testConstructor = <!UNDERSCORE_USAGE_WITHOUT_BACKTICKS!>_<!><Any>()
val testConstructor2 = `_`<Any>()

View File

@@ -0,0 +1,15 @@
package
public val testConstructor: _<kotlin.Any>
public val testConstructor2: _<kotlin.Any>
public fun _<kotlin.Any>.testTypeConstructor(): kotlin.Unit
public fun _<kotlin.Any>.testTypeConstructor2(): kotlin.Unit
public final class _</*0*/ __> {
public constructor _</*0*/ __>()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final fun testTypeArgument(/*0*/ x: kotlin.collections.List<__>): kotlin.collections.List<__>
public final fun testTypeArgument2(/*0*/ x: kotlin.collections.List<__>): kotlin.collections.List<__>
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}

View File

@@ -0,0 +1,6 @@
object Host {
val `____` = { -> }
fun testFunTypeVal() {
<!UNDERSCORE_USAGE_WITHOUT_BACKTICKS!>____<!>()
}
}

View File

@@ -0,0 +1,10 @@
package
public object Host {
private constructor Host()
public final val ____: () -> kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final fun testFunTypeVal(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}

View File

@@ -38,11 +38,11 @@ fun test() {
val (<!REDECLARATION!>`_`<!>, z) = A()
foo(_, z)
foo(<!UNDERSCORE_USAGE_WITHOUT_BACKTICKS!>_<!>, z)
val (_, <!NAME_SHADOWING, REDECLARATION!>`_`<!>) = A()
foo(<!TYPE_MISMATCH!>_<!>, y)
foo(<!UNDERSCORE_USAGE_WITHOUT_BACKTICKS, TYPE_MISMATCH!>_<!>, y)
val (<!UNUSED_VARIABLE!>unused<!>, _) = A()
}

View File

@@ -0,0 +1,29 @@
// !LANGUAGE: +MultiPlatformProjects
// !DIAGNOSTICS: -UNSUPPORTED
// MODULE: m1-common
// FILE: common.kt
header class Foo {
constructor(p: Any)
fun f1(s: String): Int
fun f2(s: List<String>?): MutableMap<Boolean?, Foo>
fun <T : Set<Number>> f3(t: T): T?
}
// MODULE: m2-js(m1-common)
// FILE: js.kt
// TODO: do not suppress UNSUPPORTED once JS files in multi-platform tests are analyzed with JS analyzer facade
impl class Foo {
impl constructor(p: dynamic) {}
impl fun f1(s: dynamic): dynamic = null!!
impl fun f2(s: dynamic): MutableMap<Boolean?, Foo> = null!!
impl fun <T : Set<Number>> f3(t: T): dynamic = null!!
}

View File

@@ -0,0 +1,26 @@
// -- Module: <m1-common> --
package
public final header class Foo {
public constructor Foo(/*0*/ p: kotlin.Any)
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final header fun f1(/*0*/ s: kotlin.String): kotlin.Int
public final header fun f2(/*0*/ s: kotlin.collections.List<kotlin.String>?): kotlin.collections.MutableMap<kotlin.Boolean?, Foo>
public final header fun </*0*/ T : kotlin.collections.Set<kotlin.Number>> f3(/*0*/ t: T): T?
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
// -- Module: <m2-js> --
package
public final impl class Foo {
public constructor Foo(/*0*/ p: dynamic)
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final impl fun f1(/*0*/ s: dynamic): dynamic
public final impl fun f2(/*0*/ s: dynamic): kotlin.collections.MutableMap<kotlin.Boolean?, Foo>
public final impl fun </*0*/ T : kotlin.collections.Set<kotlin.Number>> f3(/*0*/ t: T): dynamic
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}

View File

@@ -0,0 +1,32 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
header class Foo {
constructor(p: Any)
fun f1(s: String): Int
fun f2(s: List<String>?): MutableMap<Boolean?, Foo>
fun <T : Set<Number>> f3(t: T): T?
}
// MODULE: m2-jvm(m1-common)
// FILE: FooImpl.java
import java.util.*;
public class FooImpl {
public FooImpl(Object p) {}
public final int f1(String s) { return 0; }
public final Map<Boolean, FooImpl> f2(List<String> s) { return null; }
public final <T extends Set<Number>> T f3(T t) { return null; }
}
// FILE: jvm.kt
impl typealias Foo = FooImpl

View File

@@ -0,0 +1,27 @@
// -- Module: <m1-common> --
package
public final header class Foo {
public constructor Foo(/*0*/ p: kotlin.Any)
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final header fun f1(/*0*/ s: kotlin.String): kotlin.Int
public final header fun f2(/*0*/ s: kotlin.collections.List<kotlin.String>?): kotlin.collections.MutableMap<kotlin.Boolean?, Foo>
public final header fun </*0*/ T : kotlin.collections.Set<kotlin.Number>> f3(/*0*/ t: T): T?
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
// -- Module: <m2-jvm> --
package
public open class FooImpl {
public constructor FooImpl(/*0*/ p: kotlin.Any!)
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final fun f1(/*0*/ s: kotlin.String!): kotlin.Int
public final fun f2(/*0*/ s: kotlin.collections.(Mutable)List<kotlin.String!>!): kotlin.collections.(Mutable)Map<kotlin.Boolean!, FooImpl!>!
public final fun </*0*/ T : kotlin.collections.(Mutable)Set<kotlin.Number!>!> f3(/*0*/ t: T!): T!
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public typealias Foo = FooImpl

View File

@@ -0,0 +1,18 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
header class Foo {
fun foo(i: Int, d: Double, f: Float): Unit
}
// MODULE: m2-jvm(m1-common)
// FILE: FooImpl.java
public class FooImpl {
public final void foo(int d, double i, float f) {}
}
// FILE: jvm.kt
impl typealias Foo = FooImpl

View File

@@ -0,0 +1,23 @@
// -- Module: <m1-common> --
package
public final header class Foo {
public constructor Foo()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final header fun foo(/*0*/ i: kotlin.Int, /*1*/ d: kotlin.Double, /*2*/ f: kotlin.Float): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
// -- Module: <m2-jvm> --
package
public open class FooImpl {
public constructor FooImpl()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final fun foo(/*0*/ d: kotlin.Int, /*1*/ i: kotlin.Double, /*2*/ f: kotlin.Float): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public typealias Foo = FooImpl

View File

@@ -0,0 +1,36 @@
// !LANGUAGE: +MultiPlatformProjects
// MODULE: m1-common
// FILE: common.kt
header class Foo(zzz: Int) {
constructor(aaa: Boolean)
fun f1(xxx: String): String
}
header fun f2(xxx: Int)
fun testCommon() {
Foo(<!NAMED_ARGUMENTS_NOT_ALLOWED!>zzz<!> = 0)
val f = Foo(<!NAMED_ARGUMENTS_NOT_ALLOWED!>aaa<!> = true)
f.f1(<!NAMED_ARGUMENTS_NOT_ALLOWED!>xxx<!> = "")
f2(xxx = 42)
}
// MODULE: m2-jvm(m1-common)
// FILE: jvm.kt
impl class Foo(val aaa: Boolean) {
impl constructor(zzz: Int) : this(zzz == 0)
impl fun f1(xxx: String) = xxx
}
impl fun f2(xxx: Int) {}
fun testPlatform() {
Foo(zzz = 0)
val f = Foo(aaa = true)
f.f1(xxx = "")
f2(xxx = 42)
}

View File

@@ -0,0 +1,32 @@
// -- Module: <m1-common> --
package
public header fun f2(/*0*/ xxx: kotlin.Int): kotlin.Unit
public fun testCommon(): kotlin.Unit
public final header class Foo {
public constructor Foo(/*0*/ aaa: kotlin.Boolean)
public constructor Foo(/*0*/ zzz: kotlin.Int)
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final header fun f1(/*0*/ xxx: kotlin.String): kotlin.String
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
// -- Module: <m2-jvm> --
package
public impl fun f2(/*0*/ xxx: kotlin.Int): kotlin.Unit
public fun testCommon(): kotlin.Unit
public fun testPlatform(): kotlin.Unit
public final impl class Foo {
public constructor Foo(/*0*/ aaa: kotlin.Boolean)
public constructor Foo(/*0*/ zzz: kotlin.Int)
public final val aaa: kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final impl fun f1(/*0*/ xxx: kotlin.String): kotlin.String
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}

View File

@@ -6,7 +6,8 @@ Output:
Exit code: COMPILATION_ERROR
Output:
compiler/testData/multiplatform/classScopes/constructorIncorrectSignature/common.kt:1:14: error: header declaration 'Foo' has no implementation in module
The following declaration is incompatible because some members are not implemented.
The following declaration is incompatible because some members are not implemented:
public final impl class Foo
No implementations are found for members listed below:
public constructor Foo(s: String)
@@ -22,4 +23,3 @@ impl class Foo {
compiler/testData/multiplatform/classScopes/constructorIncorrectSignature/jvm.kt:2:5: error: modifier 'impl' is only applicable to members that are initially declared in platform-independent code
impl constructor(s: Array<String>)
^

View File

@@ -6,7 +6,8 @@ Output:
Exit code: COMPILATION_ERROR
Output:
compiler/testData/multiplatform/classScopes/functionIncorrectSignature/common.kt:1:14: error: header declaration 'Foo' has no implementation in module
The following declaration is incompatible because some members are not implemented.
The following declaration is incompatible because some members are not implemented:
public final impl class Foo
No implementations are found for members listed below:
public final header fun function(b: ByteArray): Int
@@ -22,4 +23,3 @@ impl class Foo {
compiler/testData/multiplatform/classScopes/functionIncorrectSignature/jvm.kt:2:5: error: modifier 'impl' is only applicable to members that are initially declared in platform-independent code
impl fun function(b: ByteArray): Long = b.size.toLong()
^

View File

@@ -6,7 +6,8 @@ Output:
Exit code: COMPILATION_ERROR
Output:
compiler/testData/multiplatform/classScopes/missingConstructor/common.kt:1:14: error: header declaration 'Foo' has no implementation in module
The following declaration is incompatible because some members are not implemented.
The following declaration is incompatible because some members are not implemented:
public final impl class Foo
No implementations are found for members listed below:
public constructor Foo(s: String)
@@ -19,4 +20,3 @@ header class Foo {
compiler/testData/multiplatform/classScopes/missingConstructor/jvm.kt:1:1: error: modifier 'impl' is only applicable to members that are initially declared in platform-independent code
impl class Foo
^

View File

@@ -6,7 +6,8 @@ Output:
Exit code: COMPILATION_ERROR
Output:
compiler/testData/multiplatform/classScopes/missingFunction/common.kt:1:14: error: header declaration 'Foo' has no implementation in module
The following declaration is incompatible because some members are not implemented.
The following declaration is incompatible because some members are not implemented:
public final impl class Foo
No implementations are found for members listed below:
public final header fun function(s: String): Unit
@@ -16,4 +17,3 @@ header class Foo {
compiler/testData/multiplatform/classScopes/missingFunction/jvm.kt:1:1: error: modifier 'impl' is only applicable to members that are initially declared in platform-independent code
impl class Foo
^

View File

@@ -0,0 +1,7 @@
package test
header fun stringToByteArray(str: String): ByteArray
header var prop: String
fun ttt() {}

View File

@@ -0,0 +1,5 @@
package test
impl fun stringToByteArray(str: String): ByteArray = byteArrayOf()
impl var prop: String = ""

View File

@@ -0,0 +1,7 @@
package test
fun bar() {
stringToByteArray("foo bar baz")
prop
prop = ""
}

View File

@@ -0,0 +1,11 @@
-- Common --
Exit code: OK
Output:
-- JVM --
Exit code: OK
Output:
-- JVM (2) --
Exit code: OK
Output:

View File

@@ -130,10 +130,10 @@ abstract class BaseDiagnosticsTest : KotlinMultiFileTestWithJava<TestModule, Tes
val dynamicCallDescriptors: List<DeclarationDescriptor> = ArrayList()
init {
this.whatDiagnosticsToConsider = parseDiagnosticFilterDirective(directives)
this.declareCheckType = CHECK_TYPE_DIRECTIVE in directives
this.whatDiagnosticsToConsider = parseDiagnosticFilterDirective(directives, declareCheckType)
this.customLanguageVersionSettings = parseLanguageVersionSettings(directives)
this.checkLazyLog = CHECK_LAZY_LOG_DIRECTIVE in directives || CHECK_LAZY_LOG_DEFAULT
this.declareCheckType = CHECK_TYPE_DIRECTIVE in directives
this.declareFlexibleType = EXPLICIT_FLEXIBLE_TYPES_DIRECTIVE in directives
this.markDynamicCalls = MARK_DYNAMIC_CALLS_DIRECTIVE in directives
if (fileName.endsWith(".java")) {
@@ -358,18 +358,26 @@ abstract class BaseDiagnosticsTest : KotlinMultiFileTestWithJava<TestModule, Tes
return values
}
private fun parseDiagnosticFilterDirective(directiveMap: Map<String, String>): Condition<Diagnostic> {
private fun parseDiagnosticFilterDirective(directiveMap: Map<String, String>, allowUnderscoreUsage: Boolean): Condition<Diagnostic> {
val directives = directiveMap[DIAGNOSTICS_DIRECTIVE]
val initialCondition =
if (allowUnderscoreUsage)
Condition<Diagnostic> { it.factory.name != "UNDERSCORE_USAGE_WITHOUT_BACKTICKS" }
else
Conditions.alwaysTrue()
if (directives == null) {
// If "!API_VERSION" is present, disable the NEWER_VERSION_IN_SINCE_KOTLIN diagnostic.
// Otherwise it would be reported in any non-trivial test on the @SinceKotlin value.
if (API_VERSION_DIRECTIVE in directiveMap) {
return Condition { diagnostic -> diagnostic.factory !== Errors.NEWER_VERSION_IN_SINCE_KOTLIN }
return Conditions.and(initialCondition, Condition {
diagnostic -> diagnostic.factory !== Errors.NEWER_VERSION_IN_SINCE_KOTLIN
})
}
return Conditions.alwaysTrue()
return initialCondition
}
var condition = Conditions.alwaysTrue<Diagnostic>()
var condition = initialCondition
val matcher = DIAGNOSTICS_PATTERN.matcher(directives)
if (!matcher.find()) {
Assert.fail("Wrong syntax in the '// !$DIAGNOSTICS_DIRECTIVE: ...' directive:\n" +

View File

@@ -56,6 +56,11 @@ public class ForTestCompileRuntime {
return assertExists(new File("dist/kotlinc/lib/kotlin-script-runtime.jar"));
}
@NotNull
public static File runtimeSourcesJarForTests() {
return assertExists(new File("dist/kotlinc/lib/kotlin-runtime-sources.jar"));
}
// TODO: Do not use these classes, remove them after stdlib tests are merged in the same build as the compiler
@NotNull
@Deprecated

View File

@@ -33,7 +33,7 @@ import java.util.regex.Pattern;
@RunWith(JUnit3RunnerWithInners.class)
public class CompilerLightClassTestGenerated extends AbstractCompilerLightClassTest {
public void testAllFilesPresentInLightClasses() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/asJava/lightClasses"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true, "local");
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/asJava/lightClasses"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true, "local", "ideRegression");
}
@TestMetadata("AnnotationClass.kt")
@@ -42,6 +42,12 @@ public class CompilerLightClassTestGenerated extends AbstractCompilerLightClassT
doTest(fileName);
}
@TestMetadata("Delegation.kt")
public void testDelegation() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/asJava/lightClasses/Delegation.kt");
doTest(fileName);
}
@TestMetadata("DeprecatedEnumEntry.kt")
public void testDeprecatedEnumEntry() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/asJava/lightClasses/DeprecatedEnumEntry.kt");
@@ -60,6 +66,12 @@ public class CompilerLightClassTestGenerated extends AbstractCompilerLightClassT
doTest(fileName);
}
@TestMetadata("HiddenDeprecated.kt")
public void testHiddenDeprecated() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/asJava/lightClasses/HiddenDeprecated.kt");
doTest(fileName);
}
@TestMetadata("JvmNameOnMember.kt")
public void testJvmNameOnMember() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/asJava/lightClasses/JvmNameOnMember.kt");
@@ -84,6 +96,12 @@ public class CompilerLightClassTestGenerated extends AbstractCompilerLightClassT
doTest(fileName);
}
@TestMetadata("VarArgs.kt")
public void testVarArgs() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/asJava/lightClasses/VarArgs.kt");
doTest(fileName);
}
@TestMetadata("compiler/testData/asJava/lightClasses/compilationErrors")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -98,6 +116,12 @@ public class CompilerLightClassTestGenerated extends AbstractCompilerLightClassT
doTest(fileName);
}
@TestMetadata("PrivateInTrait.kt")
public void testPrivateInTrait() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/asJava/lightClasses/compilationErrors/PrivateInTrait.kt");
doTest(fileName);
}
@TestMetadata("SameName.kt")
public void testSameName() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/asJava/lightClasses/compilationErrors/SameName.kt");
@@ -110,6 +134,12 @@ public class CompilerLightClassTestGenerated extends AbstractCompilerLightClassT
doTest(fileName);
}
@TestMetadata("TraitClassObjectField.kt")
public void testTraitClassObjectField() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/asJava/lightClasses/compilationErrors/TraitClassObjectField.kt");
doTest(fileName);
}
@TestMetadata("WrongAnnotations.kt")
public void testWrongAnnotations() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/asJava/lightClasses/compilationErrors/WrongAnnotations.kt");
@@ -263,12 +293,6 @@ public class CompilerLightClassTestGenerated extends AbstractCompilerLightClassT
doTest(fileName);
}
@TestMetadata("PrivateInTrait.NoCompile.kt")
public void testPrivateInTrait_NoCompile() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/asJava/lightClasses/nullabilityAnnotations/PrivateInTrait.NoCompile.kt");
doTest(fileName);
}
@TestMetadata("Synthetic.kt")
public void testSynthetic() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/asJava/lightClasses/nullabilityAnnotations/Synthetic.kt");
@@ -281,12 +305,6 @@ public class CompilerLightClassTestGenerated extends AbstractCompilerLightClassT
doTest(fileName);
}
@TestMetadata("TraitClassObjectField.NoCompile.kt")
public void testTraitClassObjectField_NoCompile() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/asJava/lightClasses/nullabilityAnnotations/TraitClassObjectField.NoCompile.kt");
doTest(fileName);
}
@TestMetadata("UnitAsGenericArgument.kt")
public void testUnitAsGenericArgument() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/asJava/lightClasses/nullabilityAnnotations/UnitAsGenericArgument.kt");

View File

@@ -764,6 +764,36 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("UnderscoreUsageInAnnotation.kt")
public void testUnderscoreUsageInAnnotation() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/UnderscoreUsageInAnnotation.kt");
doTest(fileName);
}
@TestMetadata("UnderscoreUsageInCall.kt")
public void testUnderscoreUsageInCall() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/UnderscoreUsageInCall.kt");
doTest(fileName);
}
@TestMetadata("UnderscoreUsageInCallableRefTypeLHS.kt")
public void testUnderscoreUsageInCallableRefTypeLHS() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/UnderscoreUsageInCallableRefTypeLHS.kt");
doTest(fileName);
}
@TestMetadata("UnderscoreUsageInType.kt")
public void testUnderscoreUsageInType() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/UnderscoreUsageInType.kt");
doTest(fileName);
}
@TestMetadata("UnderscoreUsageInVariableAsFunctionCall.kt")
public void testUnderscoreUsageInVariableAsFunctionCall() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/UnderscoreUsageInVariableAsFunctionCall.kt");
doTest(fileName);
}
@TestMetadata("UnitByDefaultForFunctionTypes.kt")
public void testUnitByDefaultForFunctionTypes() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/UnitByDefaultForFunctionTypes.kt");
@@ -13102,6 +13132,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("implDynamic.kt")
public void testImplDynamic() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/multiplatform/implDynamic.kt");
doTest(fileName);
}
@TestMetadata("implFakeOverride.kt")
public void testImplFakeOverride() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/multiplatform/implFakeOverride.kt");
@@ -13114,6 +13150,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("namedArguments.kt")
public void testNamedArguments() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/multiplatform/namedArguments.kt");
doTest(fileName);
}
@TestMetadata("compiler/testData/diagnostics/tests/multiplatform/enum")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -13237,6 +13279,27 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
}
}
@TestMetadata("compiler/testData/diagnostics/tests/multiplatform/java")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Java extends AbstractDiagnosticsTest {
public void testAllFilesPresentInJava() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/java"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("flexibleTypes.kt")
public void testFlexibleTypes() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/multiplatform/java/flexibleTypes.kt");
doTest(fileName);
}
@TestMetadata("parameterNames.kt")
public void testParameterNames() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/multiplatform/java/parameterNames.kt");
doTest(fileName);
}
}
@TestMetadata("compiler/testData/diagnostics/tests/multiplatform/topLevelFun")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)

View File

@@ -32,27 +32,36 @@ abstract class AbstractMultiPlatformIntegrationTest : KtUsefulTestCase() {
val commonSrc = File(root, "common.kt")
val jsSrc = File(root, "js.kt")
val jvmSrc = File(root, "jvm.kt")
// TODO: consider inventing a more clever scheme
val jvm2Src = File(root, "jvm2.kt")
val tmpdir = KotlinTestUtils.tmpDir(getTestName(true))
val commonDest = File(tmpdir, "common")
val jvmDest = File(tmpdir, "jvm")
val jsDest = File(File(tmpdir, "js"), "output.js")
val commonDest = File(tmpdir, "common").absolutePath
val jvmDest = File(tmpdir, "jvm").absolutePath
val jsDest = File(File(tmpdir, "js"), "output.js").absolutePath
val jvm2Dest = File(tmpdir, "jvm2").absolutePath
val result = buildString {
appendln("-- Common --")
appendln(K2MetadataCompiler().compile(listOf(commonSrc), "-d", commonDest.absolutePath))
appendln(K2MetadataCompiler().compile(listOf(commonSrc), "-d", commonDest))
if (jvmSrc.exists()) {
appendln()
appendln("-- JVM --")
append(K2JVMCompiler().compileBothWays(commonSrc, jvmSrc, "-d", jvmDest.absolutePath))
appendln(K2JVMCompiler().compileBothWays(commonSrc, jvmSrc, "-d", jvmDest))
}
if (jsSrc.exists()) {
appendln()
appendln("-- JS --")
append(K2JSCompiler().compileBothWays(commonSrc, jsSrc, "-output", jsDest.absolutePath))
appendln(K2JSCompiler().compileBothWays(commonSrc, jsSrc, "-output", jsDest))
}
if (jvm2Src.exists()) {
appendln()
appendln("-- JVM (2) --")
appendln(K2JVMCompiler().compile(listOf(jvm2Src), "-d", jvm2Dest, "-cp", listOf(commonDest, jvmDest).joinToString(File.pathSeparator)))
}
}
@@ -60,8 +69,8 @@ abstract class AbstractMultiPlatformIntegrationTest : KtUsefulTestCase() {
}
private fun CLICompiler<*>.compileBothWays(commonSource: File, platformSource: File, vararg additionalArguments: String): String {
val platformFirst = compile(listOf(platformSource, commonSource), *additionalArguments).trimTrailingWhitespacesAndAddNewlineAtEOF()
val commonFirst = compile(listOf(commonSource, platformSource), *additionalArguments).trimTrailingWhitespacesAndAddNewlineAtEOF()
val platformFirst = compile(listOf(platformSource, commonSource), *additionalArguments)
val commonFirst = compile(listOf(commonSource, platformSource), *additionalArguments)
if (platformFirst != commonFirst) {
assertEquals(
"Compilation results are different when compiling [platform-specific, common] compared to when compiling [common, platform-specific]",
@@ -80,5 +89,5 @@ abstract class AbstractMultiPlatformIntegrationTest : KtUsefulTestCase() {
appendln("Exit code: $exitCode")
appendln("Output:")
appendln(output)
}.trim()
}.trimTrailingWhitespacesAndAddNewlineAtEOF().trimEnd('\r', '\n')
}

View File

@@ -170,4 +170,20 @@ public class MultiPlatformIntegrationTestGenerated extends AbstractMultiPlatform
}
@TestMetadata("compiler/testData/multiplatform/regressions")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Regressions extends AbstractMultiPlatformIntegrationTest {
public void testAllFilesPresentInRegressions() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/multiplatform/regressions"), Pattern.compile("^([^\\.]+)$"), TargetBackend.ANY, true);
}
@TestMetadata("kt17001")
public void testKt17001() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/multiplatform/regressions/kt17001/");
doTest(fileName);
}
}
}

View File

@@ -33,7 +33,7 @@ class JsMetadataVersion(vararg numbers: Int) : BinaryVersion(*numbers) {
companion object {
@JvmField
val INSTANCE = JsMetadataVersion(1, 0, 0)
val INSTANCE = JsMetadataVersion(1, 0, 1)
@JvmField
val INVALID_VERSION = JsMetadataVersion()

View File

@@ -29,7 +29,7 @@ class JvmMetadataVersion(vararg numbers: Int) : BinaryVersion(*numbers) {
companion object {
@JvmField
val INSTANCE = JvmMetadataVersion(1, 1, 5)
val INSTANCE = JvmMetadataVersion(1, 1, 6)
@JvmField
val INVALID_VERSION = JvmMetadataVersion()

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