Compare commits

...

130 Commits

Author SHA1 Message Date
Ilya Chernikov
13f69878c2 Reading KOTLIN_HOME only once
may fix #KT-21145, or at least make it less flaky

(cherry picked from commit efc470d)
2017-12-28 09:46:52 +01:00
Ilya Chernikov
36e07f2d00 Add kotlin-compiler-client-embeddable to the plugin's lib since...
it's used in the `KotlinJsr223JvmScriptEngine4Idea`
Fixes #KT-18613

(cherry picked from commit 945da50)
2017-12-28 09:46:30 +01:00
Ilya Gorbunov
755de4564e Fix Volatile usages in common and JS code
(cherry picked from commit 042f81f23b)
2017-12-28 02:18:16 +03:00
Ilya Gorbunov
4c25ab2f12 JS: Move declaration to match their packages in JVM and Common stdlib
Mostly internal, but also two public annotations

(cherry picked from commit a33a3867b8)
2017-12-28 02:18:14 +03:00
Ilya Gorbunov
e499f24528 Do not compile SynchronizedLazyImpl for platforms other than JVM
(cherry picked from commit d2eb8b4a3f)
2017-12-28 02:18:12 +03:00
Ilya Gorbunov
d4b9933ce4 Improve expect declarations in kotlin.text
- Replace overloads with default parameters in expect declarations by suppressing errors
- Remove meaningless inline modifier

(cherry picked from commit b6595d661d)
2017-12-28 02:18:10 +03:00
Ilya Gorbunov
08d2e29459 Remove inheritance between LinkedHashSet/Map and HashSet/Map
(cherry picked from commit 824b506abe)
2017-12-28 02:18:08 +03:00
Ilya Gorbunov
763740a49b Make common ArrayList declaration not open and implementing RandomAccess
(cherry picked from commit c5c6eed170)
2017-12-28 02:18:06 +03:00
Ilya Gorbunov
0acd2b9698 Extract kotlin.collections expect classes into separate files
Add missing expect declarations for AbstractMutableMap/Set.

(cherry picked from commit fb13347864)
2017-12-28 02:18:04 +03:00
Ilya Gorbunov
4b6c3dfff1 Move expect declarations to the appropriate packages
So that they match actual declarations in Kotlin/JVM stdlib.

(cherry picked from commit 93ef16deaf)
2017-12-28 02:18:01 +03:00
Anton Bannykh
1d9254fd92 kotlin-test-js: pass test function result to test framework (e.g. Promise)
(cherry picked from commit 2df85ae4a9)
2017-12-27 20:00:41 +03:00
Anton Bannykh
efd90b7a36 JS: test kotlin-test as box tests, support nested, fix mpp
Support tests inside nested classes and companion objects (KT-21850
fixed).
Don't launch multiplatform tests twice (KT-21567 fixed).

(cherry picked from commit 79359b7bc2)
2017-12-27 20:00:31 +03:00
Anton Bannykh
9799c6150d Make :js:npm a separate project to avoid calling update_dependencies
(cherry picked from commit 3e0d83b7d1)
2017-12-27 17:36:18 +03:00
Ilya Gorbunov
792db1469c Add racing version of each Lazy test
Run several concurrent accesses to a lazy value
many times and validate invariants.

(cherry picked from commit f468990f97)
2017-12-27 17:08:41 +03:00
Ilya Gorbunov
5dcdce291c Improve stability of lazy test, make some tests take less time
(cherry picked from commit 4827aadcfd)
2017-12-27 17:08:41 +03:00
Ilya Gorbunov
3ca581876a Do not read volatile _value field second time it is already initialized
(cherry picked from commit 934b3cc54e)
2017-12-27 17:08:40 +03:00
Ilya Gorbunov
e63a0e3823 Make SafePublicationLazyImpl.initializer volatile
This establishes happens-before relation between nulling out the initializer and
checking whether it is null. This will prevent the subsequent _value reads
being reordered before the initializer reads.

#KT-21868 Fixed

(cherry picked from commit 5d62277fa5)
2017-12-27 17:08:40 +03:00
Ilya Gorbunov
5490746bdc Add pattern and options properties to common Regex
And add a test that accesses them and checks they work as expected.

(cherry picked from commit 10639eaf6a)
2017-12-27 17:08:40 +03:00
Ilya Gorbunov
5894c52d4c Replace Regex constructor-like functions with secondary constructors
Historically secondary constructors were not supported in Kotlin/JS, so they had to
be emulated with constructor-like top level functions, now they can be rewritten
as true secondary constructors.

#KT-22003 Fixed

(cherry picked from commit d9edc5f221)
2017-12-27 17:08:39 +03:00
Ilya Gorbunov
a000111a92 Tests: use helper function to assert compile-time and run-time type check
To cleanup warnings about useless cast or type check that is always true.

(cherry picked from commit 053f3b6ac0)
2017-12-27 17:08:39 +03:00
Ilya Gorbunov
6848ea630f Compile common stdlib tests against common stdlib
Declare platform-specific test utilities as expect.

(cherry picked from commit ecd42f14b3)
2017-12-27 17:08:39 +03:00
Chris Povirk
d202cf5314 Recognize Checker Framework declaration annotations.
We are migrating Guava to use these annotations rather than jsr305's
@Nullable. We can't use the Checker Framework's _@Nullable_ yet because
we promise compatibility with Java 7, which doesn't support type
annotations. This is related to but distinct from
https://youtrack.jetbrains.com/issue/KT-21408, which is about a
different jsr305 annotation we use, @ParametersAreNonnullByDefault.

I've also updated some docs to mention Kotlin's existing support for the
Checker Framework _@NonNull_.

(cherry picked from commit ac87ad422d)
2017-12-27 13:23:29 +01:00
Ilya Chernikov
6beee0c1ba Increment repl line generation on compilation error
fixes #KT-17921 and #KT-21141
Tests added to the JSR223 local eval example

(cherry picked from commit 953a485)
2017-12-26 19:32:29 +01:00
Ilya Chernikov
cf7b5fec05 Make JSR 223 examples compatible with embeddable compiler, strip ...
some dependencies.
Fixes #KT-17561 and related issues
Warning: API changed slightly

(cherry picked from commit 2d8e73f)
2017-12-26 19:31:57 +01:00
Nikolay Krasko
d1efa8e08c More nullability update in selectors for compatibility in 181 2017-12-26 17:40:19 +03:00
Nikolay Krasko
64a4e7b607 Use platform types to prepare for nullability check in 181 2017-12-26 17:40:18 +03:00
Joscha Alisch
7a47bc1c5d Select lambda after other args when it's outside argument list (KT-21214)
#KT-21214 Fixed
2017-12-26 13:23:14 +03:00
Toshiaki Kameyama
edc6d162f4 KT-21928 Structure view doesn't show default constructor 2017-12-26 13:22:59 +03:00
Nikolay Krasko
b007da5ac3 Consistency for replace string quick fix message
https://youtrack.jetbrains.com/issue/KT-21746#comment=27-2634335
2017-12-26 13:21:24 +03:00
Nikolay Krasko
579ea2e90a Fix smart step into to Kotlin SAM adapter (KT-21538)
#KT-21538 Fixed
2017-12-26 13:21:24 +03:00
Nikolay Krasko
93e0d9336b Don't show file root if it's same as the only declaration (KT-21200)
#KT-21200 Fixed
2017-12-26 13:21:24 +03:00
Sergey Igushkin
0923c40495 Fix unconditional warning in JS compilation with sourceMap disabled.
(cherry picked from commit 149b197)
2017-12-25 16:01:36 +03:00
Sergey Igushkin
def71307e3 Fix both moduleFile and destination passed to the compiler
when it is run not in daemon from Gradle; don't pass the destination in
such case.

Issue #KT-21637 Fixed

(cherry picked from commit 66d3c94)
2017-12-25 16:01:36 +03:00
Alexey Tsvetkov
9ba9ceeb64 Track changes in inline function when friend paths are disabled in JS 2017-12-22 18:38:39 +03:00
Alexey Tsvetkov
a23f96a2dd Replace testCancelLongKotlinCompilation with less flaky test 2017-12-22 18:38:36 +03:00
Alexey Tsvetkov
d595b7d398 Explicitly request rebuild when untracked java file is removed
Previously a rebuild was happenning because FileNotFoundException
was thrown when getting psiFile of removed file.
2017-12-22 18:38:33 +03:00
Alexey Tsvetkov
e7f93c6102 Include tests from incremental-compilation-impl in compiler tests 2017-12-22 18:38:30 +03:00
Alexey Tsvetkov
56881e7783 Turn off class redeclaration test for JS IC temporarily
So the tests could be run on TC.
Turn on after KT-19846 is fixed.
2017-12-22 18:38:27 +03:00
Alexey Tsvetkov
542e556577 Generate source maps in JS IC tests
#KT-21700 fixed
2017-12-22 18:38:24 +03:00
Alexey Tsvetkov
1bb538b044 Recompile only files from last iteration after compile error 2017-12-22 18:38:21 +03:00
Alexey Tsvetkov
15bd424aba Allow to edit non-JPS build logs in "Show difference" window for non-JPS IC tests 2017-12-22 18:38:18 +03:00
Alexey Tsvetkov
e44a4bb54c Add JS specific IC build log in test
JS IC compares proto using a source file path as a key,
so moving file causes recompilation of its usages
unlike JVM IC that uses a class file path as a key.
2017-12-22 18:38:15 +03:00
Alexey Tsvetkov
0e94bfd734 Fix IC test build log diverged from JPS
JPS marks dirty direct usages of removed classes since 172.* before a build.
Generic IC also marks dirty all subclasses and their usages.
That is necessary because a method from a removed class could be used
through a subclass.
JPS and generic IC logs diverged in 172 branch, but non-JPS tests
were not run on CI.
2017-12-22 18:38:12 +03:00
Alexey Tsvetkov
d317f789be Recompile inline function usages in JS when offset is changed
Otherwise source maps would differ after rebuild
2017-12-22 18:38:09 +03:00
Alexey Tsvetkov
058b40369c Recompile all subclasses of removed classes 2017-12-22 18:38:06 +03:00
Alexey Tsvetkov
7cbd83541a Unify processing of removed files for JS and JVM IC 2017-12-22 18:38:03 +03:00
Alexey Tsvetkov
e96abbebd1 Avoid processing incremental changes after first build for JVM 2017-12-22 18:38:00 +03:00
Alexey Tsvetkov
03046159b0 Make general IC logs similar to JPS IC logs 2017-12-22 18:37:56 +03:00
Alexey Tsvetkov
cd1c87bfef Compile actual and expected declarations together
#KT-20840 fixed
2017-12-22 18:37:50 +03:00
Alexey Tsvetkov
a951af8775 Fix stdlib usages in IC tests
* Use stdlib from dist
* Check that stdlib exists
* Don't add stdlib for JS, because compiler adds one by default
(stdlib would be read twice which is slow)
2017-12-22 18:37:47 +03:00
Alexey Tsvetkov
8c0a2da7aa Minor: remove unused variable 2017-12-22 18:37:44 +03:00
Alexey Tsvetkov
f3e4232649 Avoid computing source files changes in IC for Gradle 2017-12-22 18:37:40 +03:00
Alexey Tsvetkov
5f48a4484d Allow override removing temporary module files after build
For debug purposes
2017-12-22 18:37:36 +03:00
Alexey Tsvetkov
153e296a8e Allow customizing directory for temporary module files 2017-12-22 18:37:33 +03:00
Alexey Tsvetkov
3dd3403447 Avoid generating too long path for temp module file
#KT-21841 fixed
2017-12-22 18:37:30 +03:00
Alexey Tsvetkov
99cab8129e Do not set api version to language version when language version is null
#KT-21852 fixed
    #KT-21574 fixed
2017-12-22 18:37:26 +03:00
Dmitry Jemerov
414ea3dd2d Insert line break before elvis when converting if to elvis
This ensures correct indentation
2017-12-22 10:53:59 +01:00
Dmitry Jemerov
e6e4072b55 Add option for wrapping closing paren in multiline if conditions 2017-12-22 10:53:52 +01:00
Dmitry Jemerov
10d6f4eddb Add predefined code style for Kotlin style guide 2017-12-22 10:53:47 +01:00
Dmitry Jemerov
4a615262a9 Don't apply indent on Enter after modifier list
#KT-9562 Fixed
2017-12-22 10:53:40 +01:00
Dmitry Jemerov
9d38d341bc Correctly apply annotation wrap before modifier keyword
#KT-20314 Fixed
2017-12-22 10:53:29 +01:00
Dmitry Jemerov
01ecc145ed Apply indent of continuation call start to its children
#KT-15099 Fixed
2017-12-22 10:53:23 +01:00
Dmitry Jemerov
e017ef71d7 Force no line break after dot in chained calls
#KT-20362 Fixed
2017-12-22 10:53:18 +01:00
Dmitry Jemerov
25a88ab707 Line breaks in objects and lambdas don't trigger call paren wrapping
#KT-19727 Fixed
2017-12-22 10:53:11 +01:00
Dmitry Jemerov
51e964d579 Option to apply normal indent to children of 'if' expressions 2017-12-22 10:53:02 +01:00
Dmitry Jemerov
8988675ad4 Refactoring: extract 'continuationIf' method 2017-12-22 10:52:56 +01:00
Dmitry Jemerov
c3a7044405 Don't wrap parentheses in long argument list containing only object 2017-12-22 10:52:50 +01:00
Dmitry Jemerov
aea040bafa KotlinFormattingModelBuilder: J2K 2017-12-22 10:52:45 +01:00
Dmitry Jemerov
cf457ae2e3 KotlinFormattingModelBuilder: rename to .kt 2017-12-22 10:52:40 +01:00
Toshiaki Kameyama
f28c7bc937 Inspection to highlight usages of Collections.sort() and replace them with .sort() method from Kotlin stdlib
#KT-11023 Fixed
2017-12-22 10:52:25 +01:00
Toshiaki Kameyama
1023228335 KT-21698 Create interface shouldn't suggest to declare it inside a class which implements it 2017-12-22 10:52:04 +01:00
Dmitry Jemerov
e06adf2559 Regenerate test 2017-12-22 10:51:42 +01:00
Dmitry Jemerov
7fc586d4a5 Don't apply highlighting to zero-length elements
#KT-19820 Fixed
2017-12-22 10:51:32 +01:00
Dmitry Jemerov
dd2e9a0bdd Fix highlighting of TODO calls in lambdas
#KT-19915 Fixed
2017-12-22 10:51:25 +01:00
Dmitry Jemerov
a2976598f9 Apply rainbow highlighting in anonymous initializers
#KT-18839 Fixed
2017-12-22 10:51:19 +01:00
Dmitry Jemerov
82d23b7ee5 Don't show type hints for destructuring declarations with explicit type
#KT-21833 Fixed
2017-12-22 10:51:12 +01:00
Dmitry Jemerov
3f50ae8d8d Put argument name hint before spread element
#KT-21645 Fixed
2017-12-22 10:51:07 +01:00
Dmitry Jemerov
e1b1869441 Don't show argument name hints for dynamic calls.
Mark function descriptors created for dynamic calls as having
synthesized parameter names.

 #KT-21275 Fixed
2017-12-22 10:51:02 +01:00
Dmitry Jemerov
c5cfd05083 Add mapOf() to default parameter name hints blacklist
#KT-18829 Fixed
2017-12-22 10:50:56 +01:00
Dmitry Jemerov
ae3b331bb7 Add single-arg 'assert' method to parameter name hints blacklist
#KT-17965 Fixed
2017-12-22 10:50:50 +01:00
Dmitry Jemerov
2d7f46ef34 Don't show type hint for local variable initialized with object
#KT-17964 Fixed
2017-12-22 10:50:44 +01:00
Dmitry Jemerov
0222539d23 Don't show parameter name hints when calling Java methods with unknown
parameter names

 #KT-17843 Fixed
2017-12-22 10:50:38 +01:00
Dmitry Jemerov
af5211fcf2 Enable "Configure Kotlin plugin updates" with no open project
#KT-20380 Fixed
2017-12-22 10:50:31 +01:00
Dmitry Jemerov
4051934cbe Fix name of inspection description file 2017-12-22 10:50:24 +01:00
kenji tomita
399166d92d Use BodyResolveMode.PARTIAL and ProblemHighlightType.GENERIC_ERROR_OR_WARNING 2017-12-22 10:50:13 +01:00
kenji tomita
176d6fedfa code style inspection: to -> Pair function used not in infix form 2017-12-22 10:50:07 +01:00
Toshiaki Kameyama
b4c3e98955 KT-21770 Pasting into an interpolated string shouldn't escape $ 2017-12-22 10:49:18 +01:00
Toshiaki Kameyama
68712713c4 KT-17928 Support code folding for primary constructors 2017-12-22 10:49:13 +01:00
Dmitry Jemerov
149a40ba46 Add 'reformat' flag to DeprecatedSymbolUsageFixBase 2017-12-22 10:49:02 +01:00
Dmitry Jemerov
4e0f73520a Disallow formatting in KotlinQuickFix.isAvailable() 2017-12-22 10:48:50 +01:00
Dmitry Jemerov
d65a2f36f2 Check that add() method is in fact MutableCollection.add()
#KT-18881 Fixed
2017-12-22 10:48:36 +01:00
Dmitry Jemerov
bd2e69ddeb Don't suggest mapTo() transformation over range literals
#KT-18816 Fixed
2017-12-22 10:48:27 +01:00
Dmitry Jemerov
982bc8efa3 Don't generate .forEach { return } when converting loop to call chain
#KT-17161 Fixed
2017-12-22 10:48:17 +01:00
Dmitry Jemerov
59d15e1b00 Fix incorrect replacement with 'any' instead of 'all'
#KT-17730 Fixed
2017-12-22 10:48:07 +01:00
Dmitry Jemerov
e115d3d622 Delete unused class 2017-12-22 10:47:59 +01:00
Dmitry Jemerov
53e924ef6e Update EAP channel names in plugin update check dialog 2017-12-22 10:47:47 +01:00
Nicolay Mitropolsky
ab2b0538ed LightClassUtil.extractPropertyAccessors refactoring to fix KotlinShortNamesCacheTest.testGetMethodsByNameWithCustomPropertyAccessors test
After light classes caching the test started to fail.
 Also refer Simon Ogorodnik.

(cherry picked from commit 657123f)
2017-12-22 12:20:25 +03:00
Nicolay Mitropolsky
4a7eeb9ecb LightClassEqualsTest fix by creating lightclasses with createNoCache
(cherry picked from commit bb4d6d1)
2017-12-22 12:20:25 +03:00
Nicolay Mitropolsky
ad83c4ae22 *kapt3-idea* added to test-dependencies in *uast-kotlin*
(cherry picked from commit 4c5cf0f)
2017-12-22 12:20:25 +03:00
Mikhael Bogdanov
07c5845c38 Generate annotations in proper order in DefaultImpls
(cherry picked from commit ea5505f)
2017-12-22 10:06:55 +01:00
Mikhael Bogdanov
84d641af4a Generate proper java parameter names for DefaultImpls
#KT-21919 Fixed

(cherry picked from commit c9d0ab3)
2017-12-22 10:06:49 +01:00
Ilya Gorbunov
6c7837a848 Use empty array instead of presized for Collection.toArray
#KT-21918

(cherry picked from commit 94a0e50)
2017-12-22 05:15:23 +03:00
Sergey Igushkin
391d08bc9c Improve kapt arguments & javac options usability with Kotlin DSL
Issue #KT-21596 Fixed

(cherry picked from commit 710c726)
2017-12-21 18:50:41 +03:00
Alexey Sedunov
030c1fb21d Change Signature: Fix overrider search for suspend functions
#KT-21288 Fixed

(cherry picked from commit 0ab924a)
2017-12-21 18:46:22 +03:00
Alexey Sedunov
04a934e453 Kotlin Facet: Do not auto-advance version in imported projects
#KT-21879 Fixed

(cherry picked from commit b5bd594)
2017-12-21 18:46:22 +03:00
Alexey Sedunov
7253090595 Misc: Fix NPE on external project import
(cherry picked from commit 8854036)
2017-12-21 18:46:21 +03:00
Kirill
d4c5b12c66 Support callable references in "implicit this" inspection
Second part of #KT-21510

(cherry picked from commit 7842fa4)
2017-12-21 17:32:32 +03:00
Kirill
252a754758 Support callable references in "explicit this" inspection
So #KT-21510 Fixed

(cherry picked from commit 74e5a94)
2017-12-21 17:31:36 +03:00
Mikhail Glukhikh
b7d7241630 Inline handler: fix reference detection for properties
(cherry picked from commit 4173960)
2017-12-21 17:29:05 +03:00
Mikhail Glukhikh
b7d45f7ac7 Extract common class from two KotlinInline<...>Dialogs #KT-17212 Fixed
(cherry picked from commit ce441e2)
2017-12-21 17:28:43 +03:00
Mikhail Glukhikh
959e8ea851 Fix "fake JVM field" inspection test XML
(cherry picked from commit 484bf01)
2017-12-21 17:28:32 +03:00
Mikhael Bogdanov
108e1c2d1c Don't delete nested default lambda classes during inline transformation
(cherry picked from commit 50608d0)
2017-12-21 13:15:08 +01:00
Mikhael Bogdanov
1a6fb37c45 Provide test source mapping data for separate and non-separate compilation
Compilation in same module or in separate ones

(cherry picked from commit b65dcf2)
2017-12-21 13:15:04 +01:00
Mikhael Bogdanov
8f9b839a5c Copy nested objects of default lambda during inline
(cherry picked from commit f4f7c83)
2017-12-21 13:15:02 +01:00
Mikhael Bogdanov
d88617cdac Properly process default lambda source mapping
#KT-21827 Fixed

(cherry picked from commit 3513f1a)
2017-12-21 13:14:58 +01:00
Vyacheslav Gerasimov
1710bfd11d Add previous release to changelog 2017-12-20 18:29:41 +03:00
Pavel V. Talanov
d778febc6c Minor, JvmAnalyzerFacade: drop logging
Prevent log spam
2017-12-20 17:33:36 +03:00
Pavel V. Talanov
f77f8e552f ScriptDefinitionsManager: ignore reloadDefinitionsBy calls
If definitions are not loaded yet
2017-12-19 17:28:01 +03:00
Pavel V. Talanov
8a639609bb scriptTemplatesFromCompilerSettings: fix ScriptDefinitionsManager access
#KT-21545 Fixed
2017-12-19 17:27:59 +03:00
Vyacheslav Gerasimov
bee01ffe6e Add changelog for 1.2.20 2017-12-19 16:06:02 +03:00
Mikhail Glukhikh
834433251c Unused symbol: revert entry point check optimization to fix regression
E.g. JUnit 3 tests was highlighted as unused after it

(cherry picked from commit 4bff0fb)
2017-12-19 16:01:53 +03:00
Nicolay Mitropolsky
eea2612ce0 Fix for "safe delete" after caching added to light elements
(cherry picked from commit 4a6cc39)
2017-12-19 13:35:28 +03:00
Ilya Chernikov
86a0356a75 Do not log daemon connection errors as exceptions - may reduce number of ...
redundant report if the problem is corrected on retry

(cherry picked from commit 260fe36)
2017-12-18 17:05:30 +01:00
Ilya Chernikov
8b4cf7f02b Make daemon session retrieval more robust to the daemon failures
(cherry picked from commit f83dc0a)
2017-12-18 16:51:56 +01:00
Ilya Chernikov
e91a31cab2 Treat "daemon is dying" state as a case for fallback compilation strategy in jps
(cherry picked from commit 1101bb7)
2017-12-18 16:51:47 +01:00
Ilya Chernikov
c539b3602a Retry socket connection on connection errors, number of retries and...
retry interval are configurable via the system props

(cherry picked from commit 6e34f57)
2017-12-18 16:51:38 +01:00
Ilya Chernikov
2fd094bb89 Ignore connection error on the (optional) daemon.clearJarCache call
May fix issues with NoSuchObjectException and UnmarshalException - the
stacktraces often point to this place

(cherry picked from commit 1cd14f0)
2017-12-18 16:51:29 +01:00
Mikhail Glukhikh
f350761b76 Fix corner cases (override/script/null/etc.) in "might be const"
Related to KT-20644

(cherry picked from commit 0d64ab4)
2017-12-18 18:25:09 +03:00
Ilya Gorbunov
8cb29c688c Do not leak primitiveness of an array wrapped with asList
A primitive array wrapped in a List with asList had incorrect implementation of toArray method:
while it declares that an object array is returned, it returned a primitive array.
Therefore the methods such as `Collection.toTypedArray()` and its dependents
`ArrayList(collection)`, `Collection + Iterable` might behave incorrectly
having relied on `toTypedArray` returned an object array.

#KT-21828 Fixed

(cherry picked from commit d8cd926)
2017-12-18 16:03:23 +03:00
Sergey Igushkin
76cc5556ab Optimize embeddable JARs
Exclude the compiler dummy JAR from the resulting shadow JAR

(cherry picked from commit c55f08a)
2017-12-18 15:59:52 +03:00
513 changed files with 7679 additions and 5236 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -28,18 +28,20 @@ import java.io.File
/**
* Incremental cache common for JVM and JS
*/
abstract class IncrementalCacheCommon(workingDir: File) : BasicMapsOwner(workingDir) {
abstract class IncrementalCacheCommon<ClassName>(workingDir: File) : BasicMapsOwner(workingDir) {
companion object {
private val SUBTYPES = "subtypes"
private val SUPERTYPES = "supertypes"
private val CLASS_FQ_NAME_TO_SOURCE = "class-fq-name-to-source"
@JvmStatic protected val SOURCE_TO_CLASSES = "source-to-classes"
@JvmStatic protected val DIRTY_OUTPUT_CLASSES = "dirty-output-classes"
}
private val dependents = arrayListOf<IncrementalCacheCommon>()
fun addDependentCache(cache: IncrementalCacheCommon) {
private val dependents = arrayListOf<IncrementalCacheCommon<ClassName>>()
fun addDependentCache(cache: IncrementalCacheCommon<ClassName>) {
dependents.add(cache)
}
val thisWithDependentCaches: Iterable<IncrementalCacheCommon> by lazy {
val thisWithDependentCaches: Iterable<IncrementalCacheCommon<ClassName>> by lazy {
val result = arrayListOf(this)
result.addAll(dependents)
result
@@ -48,6 +50,8 @@ abstract class IncrementalCacheCommon(workingDir: File) : BasicMapsOwner(working
private val subtypesMap = registerMap(SubtypesMap(SUBTYPES.storageFile))
private val supertypesMap = registerMap(SupertypesMap(SUPERTYPES.storageFile))
protected val classFqNameToSourceMap = registerMap(ClassFqNameToSourceMap(CLASS_FQ_NAME_TO_SOURCE.storageFile))
internal abstract val sourceToClassesMap: AbstractSourceToOutputMap<ClassName>
internal abstract val dirtyOutputClassesMap: AbstractDirtyClassesMap<ClassName>
fun getSubtypesOf(className: FqName): Sequence<FqName> =
subtypesMap[className].asSequence()
@@ -55,7 +59,16 @@ abstract class IncrementalCacheCommon(workingDir: File) : BasicMapsOwner(working
fun getSourceFileIfClass(fqName: FqName): File? =
classFqNameToSourceMap[fqName]
abstract fun markDirty(removedAndCompiledSources: List<File>)
open fun markDirty(removedAndCompiledSources: List<File>) {
for (sourceFile in removedAndCompiledSources) {
val classes = sourceToClassesMap[sourceFile]
classes.forEach {
dirtyOutputClassesMap.markDirty(it)
}
sourceToClassesMap.clearOutputsForSource(sourceFile)
}
}
protected fun addToClassStorage(proto: ProtoBuf.Class, nameResolver: NameResolver, srcFile: File) {
val supertypes = proto.supertypes(TypeTable(proto.typeTable))
@@ -73,11 +86,19 @@ abstract class IncrementalCacheCommon(workingDir: File) : BasicMapsOwner(working
classFqNameToSourceMap[child] = srcFile
}
protected fun removeAllFromClassStorage(removedClasses: Collection<FqName>) {
abstract fun clearCacheForRemovedClasses(changesCollector: ChangesCollector)
protected fun removeAllFromClassStorage(removedClasses: Collection<FqName>, changesCollector: ChangesCollector) {
if (removedClasses.isEmpty()) return
val removedFqNames = removedClasses.toSet()
for (removedClass in removedFqNames) {
for (affectedClass in withSubtypes(removedClass, thisWithDependentCaches)) {
changesCollector.collectSignature(affectedClass, areSubclassesAffected = false)
}
}
for (cache in thisWithDependentCaches) {
val parentsFqNames = hashSetOf<FqName>()
val childrenFqNames = hashSetOf<FqName>()

View File

@@ -31,19 +31,20 @@ import java.io.DataInput
import java.io.DataOutput
import java.io.File
open class IncrementalJsCache(cachesDir: File) : IncrementalCacheCommon(cachesDir) {
open class IncrementalJsCache(cachesDir: File) : IncrementalCacheCommon<FqName>(cachesDir) {
companion object {
private val TRANSLATION_RESULT_MAP = "translation-result"
private val SOURCES_TO_CLASSES_FQNS = "sources-to-classes"
private val INLINE_FUNCTIONS = "inline-functions"
private val HEADER_FILE_NAME = "header.meta"
}
private val dirtySources = arrayListOf<File>()
override val sourceToClassesMap = registerMap(SourceToFqNameMap(SOURCE_TO_CLASSES.storageFile))
override val dirtyOutputClassesMap = registerMap(DirtyClassesFqNameMap(DIRTY_OUTPUT_CLASSES.storageFile))
private val translationResults = registerMap(TranslationResultMap(TRANSLATION_RESULT_MAP.storageFile))
private val sourcesToClasses = registerMap(SourceToClassesMap(SOURCES_TO_CLASSES_FQNS.storageFile))
private val inlineFunctions = registerMap(InlineFunctionsMap(INLINE_FUNCTIONS.storageFile))
private val dirtySources = hashSetOf<File>()
private val headerFile: File
get() = File(cachesDir, HEADER_FILE_NAME)
@@ -55,30 +56,23 @@ open class IncrementalJsCache(cachesDir: File) : IncrementalCacheCommon(cachesDi
}
override fun markDirty(removedAndCompiledSources: List<File>) {
super.markDirty(removedAndCompiledSources)
dirtySources.addAll(removedAndCompiledSources)
}
fun compareAndUpdate(incrementalResults: IncrementalResultsConsumerImpl, changesCollector: ChangesCollector) {
val translatedFiles = incrementalResults.packageParts
dirtySources.forEach {
if (it !in translatedFiles) {
translationResults.remove(it, changesCollector)
inlineFunctions.remove(it)
}
removeAllFromClassStorage(sourcesToClasses[it])
sourcesToClasses.clearOutputsForSource(it)
}
dirtySources.clear()
for ((srcFile, data) in translatedFiles) {
dirtySources.remove(srcFile)
val (binaryMetadata, binaryAst) = data
val oldProtoMap = translationResults[srcFile]?.metadata?.let { getProtoData(srcFile, it) } ?: emptyMap()
val newProtoMap = getProtoData(srcFile, binaryMetadata)
for (protoData in newProtoMap.values) {
for ((classId, protoData) in newProtoMap) {
registerOutputForFile(srcFile, classId.asSingleFqName())
if (protoData is ClassProtoData) {
addToClassStorage(protoData.proto, protoData.nameResolver, srcFile)
}
@@ -96,6 +90,21 @@ open class IncrementalJsCache(cachesDir: File) : IncrementalCacheCommon(cachesDi
}
}
private fun registerOutputForFile(srcFile: File, name: FqName) {
sourceToClassesMap.add(srcFile, name)
dirtyOutputClassesMap.notDirty(name)
}
override fun clearCacheForRemovedClasses(changesCollector: ChangesCollector) {
dirtySources.forEach {
translationResults.remove(it, changesCollector)
inlineFunctions.remove(it)
}
removeAllFromClassStorage(dirtyOutputClassesMap.getDirtyOutputClasses(), changesCollector)
dirtySources.clear()
dirtyOutputClassesMap.clean()
}
fun nonDirtyPackageParts(): Map<File, TranslationResultValue> =
hashMapOf<File, TranslationResultValue>().apply {
for (path in translationResults.keys()) {
@@ -107,25 +116,6 @@ open class IncrementalJsCache(cachesDir: File) : IncrementalCacheCommon(cachesDi
}
}
private class SourceToClassesMap(storageFile: File) : BasicStringMap<Collection<String>>(storageFile, PathStringDescriptor, StringCollectionExternalizer) {
fun clearOutputsForSource(sourceFile: File) {
remove(sourceFile.canonicalPath)
}
fun add(sourceFile: File, className: FqName) {
storage.append(sourceFile.canonicalPath, className.asString())
}
operator fun get(sourceFile: File): Collection<FqName> =
storage[sourceFile.canonicalPath].orEmpty().map { FqName(it) }
override fun dumpValue(value: Collection<String>) = value.dumpCollection()
private fun remove(path: String) {
storage.remove(path)
}
}
private object TranslationResultValueExternalizer : DataExternalizer<TranslationResultValue> {
override fun save(output: DataOutput, value: TranslationResultValue) {
output.writeInt(value.metadata.size)

View File

@@ -44,15 +44,13 @@ val KOTLIN_CACHE_DIRECTORY_NAME = "kotlin"
open class IncrementalJvmCache(
private val targetDataRoot: File,
targetOutputDir: File?
) : IncrementalCacheCommon(File(targetDataRoot, KOTLIN_CACHE_DIRECTORY_NAME)), IncrementalCache {
) : IncrementalCacheCommon<JvmClassName>(File(targetDataRoot, KOTLIN_CACHE_DIRECTORY_NAME)), IncrementalCache {
companion object {
private val PROTO_MAP = "proto"
private val CONSTANTS_MAP = "constants"
private val PACKAGE_PARTS = "package-parts"
private val MULTIFILE_CLASS_FACADES = "multifile-class-facades"
private val MULTIFILE_CLASS_PARTS = "multifile-class-parts"
private val SOURCE_TO_CLASSES = "source-to-classes"
private val DIRTY_OUTPUT_CLASSES = "dirty-output-classes"
private val INLINE_FUNCTIONS = "inline-functions"
private val INTERNAL_NAME_TO_SOURCE = "internal-name-to-source"
private val JAVA_SOURCES_PROTO_MAP = "java-sources-proto-map"
@@ -60,13 +58,14 @@ open class IncrementalJvmCache(
private val MODULE_MAPPING_FILE_NAME = "." + ModuleMapping.MAPPING_FILE_EXT
}
override val sourceToClassesMap = registerMap(SourceToJvmNameMap(SOURCE_TO_CLASSES.storageFile))
override val dirtyOutputClassesMap = registerMap(DirtyClassesJvmNameMap(DIRTY_OUTPUT_CLASSES.storageFile))
private val protoMap = registerMap(ProtoMap(PROTO_MAP.storageFile))
private val constantsMap = registerMap(ConstantsMap(CONSTANTS_MAP.storageFile))
private val packagePartMap = registerMap(PackagePartMap(PACKAGE_PARTS.storageFile))
private val multifileFacadeToParts = registerMap(MultifileClassFacadeMap(MULTIFILE_CLASS_FACADES.storageFile))
private val partToMultifileFacade = registerMap(MultifileClassPartMap(MULTIFILE_CLASS_PARTS.storageFile))
private val sourceToClassesMap = registerMap(SourceToClassesMap(SOURCE_TO_CLASSES.storageFile))
private val dirtyOutputClassesMap = registerMap(DirtyOutputClassesMap(DIRTY_OUTPUT_CLASSES.storageFile))
private val inlineFunctionsMap = registerMap(InlineFunctionsMap(INLINE_FUNCTIONS.storageFile))
// todo: try to use internal names only?
private val internalNameToSource = registerMap(InternalNameToSourcesMap(INTERNAL_NAME_TO_SOURCE.storageFile))
@@ -76,17 +75,6 @@ open class IncrementalJvmCache(
protected open fun debugLog(message: String) {}
override fun markDirty(removedAndCompiledSources: List<File>) {
for (sourceFile in removedAndCompiledSources) {
val classes = sourceToClassesMap[sourceFile]
classes.forEach {
dirtyOutputClassesMap.markDirty(it.internalName)
}
sourceToClassesMap.clearOutputsForSource(sourceFile)
}
}
fun isTrackedFile(file: File) = sourceToClassesMap.contains(file)
// used in gradle
@@ -98,7 +86,7 @@ open class IncrementalJvmCache(
internalNameToSource[internalName]
fun isMultifileFacade(className: JvmClassName): Boolean =
className.internalName in multifileFacadeToParts
className in multifileFacadeToParts
override fun getClassFilePath(internalClassName: String): String {
return toSystemIndependentName(File(outputDir, "$internalClassName.class").canonicalPath)
@@ -107,7 +95,7 @@ open class IncrementalJvmCache(
fun saveModuleMappingToCache(sourceFiles: Collection<File>, file: File) {
val jvmClassName = JvmClassName.byInternalName(MODULE_MAPPING_FILE_NAME)
protoMap.storeModuleMapping(jvmClassName, file.readBytes())
dirtyOutputClassesMap.notDirty(MODULE_MAPPING_FILE_NAME)
dirtyOutputClassesMap.notDirty(jvmClassName)
sourceFiles.forEach { sourceToClassesMap.add(it, jvmClassName) }
}
@@ -116,7 +104,7 @@ open class IncrementalJvmCache(
val kotlinClass: LocalFileKotlinClass = generatedClass.outputClass
val className = kotlinClass.className
dirtyOutputClassesMap.notDirty(className.internalName)
dirtyOutputClassesMap.notDirty(className)
sourceFiles.forEach {
sourceToClassesMap.add(it, className)
}
@@ -181,7 +169,7 @@ open class IncrementalJvmCache(
val (proto, nameResolver) = serializedJavaClass.toProtoData()
addToClassStorage(proto, nameResolver, source)
dirtyOutputClassesMap.notDirty(jvmClassName.internalName)
dirtyOutputClassesMap.notDirty(jvmClassName)
}
fun getObsoleteJavaClasses(): Collection<ClassId> =
@@ -192,31 +180,28 @@ open class IncrementalJvmCache(
fun isJavaClassToTrack(classId: ClassId): Boolean {
val jvmClassName = JvmClassName.byClassId(classId)
return dirtyOutputClassesMap.isDirty(jvmClassName.internalName) ||
javaSourcesProtoMap[jvmClassName.internalName] == null
return dirtyOutputClassesMap.isDirty(jvmClassName) ||
jvmClassName !in javaSourcesProtoMap
}
fun isJavaClassAlreadyInCache(classId: ClassId): Boolean {
val jvmClassName = JvmClassName.byClassId(classId)
return javaSourcesProtoMap[jvmClassName.internalName] != null
return jvmClassName in javaSourcesProtoMap
}
fun clearCacheForRemovedClasses(changesCollector: ChangesCollector) {
val dirtyClasses = dirtyOutputClassesMap
.getDirtyOutputClasses()
.map(JvmClassName::byInternalName)
.toList()
override fun clearCacheForRemovedClasses(changesCollector: ChangesCollector) {
val dirtyClasses = dirtyOutputClassesMap.getDirtyOutputClasses()
val facadesWithRemovedParts = hashMapOf<JvmClassName, MutableSet<String>>()
for (dirtyClass in dirtyClasses) {
val facade = partToMultifileFacade.get(dirtyClass.internalName) ?: continue
val facade = partToMultifileFacade.get(dirtyClass) ?: continue
val facadeClassName = JvmClassName.byInternalName(facade)
val removedParts = facadesWithRemovedParts.getOrPut(facadeClassName) { hashSetOf() }
removedParts.add(dirtyClass.internalName)
}
for ((facade, removedParts) in facadesWithRemovedParts.entries) {
val allParts = multifileFacadeToParts[facade.internalName] ?: continue
val allParts = multifileFacadeToParts[facade] ?: continue
val notRemovedParts = allParts.filter { it !in removedParts }
if (notRemovedParts.isEmpty()) {
@@ -238,16 +223,14 @@ open class IncrementalJvmCache(
javaSourcesProtoMap.remove(it, changesCollector)
}
removeAllFromClassStorage(dirtyClasses.map { it.fqNameForClassNameWithoutDollars })
removeAllFromClassStorage(dirtyClasses.map { it.fqNameForClassNameWithoutDollars }, changesCollector)
dirtyOutputClassesMap.clean()
}
override fun getObsoletePackageParts(): Collection<String> {
val obsoletePackageParts =
dirtyOutputClassesMap.getDirtyOutputClasses().filter { packagePartMap.isPackagePart(JvmClassName.byInternalName(it)) }
val obsoletePackageParts = dirtyOutputClassesMap.getDirtyOutputClasses().filter(packagePartMap::isPackagePart)
debugLog("Obsolete package parts: $obsoletePackageParts")
return obsoletePackageParts
return obsoletePackageParts.map { it.internalName }
}
override fun getPackagePartData(partInternalName: String): JvmPackagePartProto? {
@@ -267,8 +250,9 @@ open class IncrementalJvmCache(
}
override fun getStableMultifileFacadeParts(facadeInternalName: String): Collection<String>? {
val partNames = multifileFacadeToParts.get(facadeInternalName) ?: return null
return partNames.filter { !dirtyOutputClassesMap.isDirty(it) }
val jvmClassName = JvmClassName.byInternalName(facadeInternalName)
val partNames = multifileFacadeToParts[jvmClassName] ?: return null
return partNames.filter { !dirtyOutputClassesMap.isDirty(JvmClassName.byInternalName(it)) }
}
override fun getModuleMappingData(): ByteArray? {
@@ -351,7 +335,11 @@ open class IncrementalJvmCache(
changesCollector.collectProtoChanges(oldValue.toProtoData(), newData = null)
}
operator fun get(internalName: String) = storage[internalName]
operator fun get(className: JvmClassName): SerializedJavaClass? =
storage[className.internalName]
operator fun contains(className: JvmClassName): Boolean =
className.internalName in storage
override fun dumpValue(value: SerializedJavaClass): String =
java.lang.Long.toHexString(value.proto.toByteArray().md5())
@@ -419,13 +407,15 @@ open class IncrementalJvmCache(
}
private inner class MultifileClassFacadeMap(storageFile: File) : BasicStringMap<Collection<String>>(storageFile, StringCollectionExternalizer) {
operator fun set(facadeName: JvmClassName, partNames: Collection<String>) {
storage[facadeName.internalName] = partNames
operator fun set(className: JvmClassName, partNames: Collection<String>) {
storage[className.internalName] = partNames
}
operator fun get(internalName: String): Collection<String>? = storage[internalName]
operator fun get(className: JvmClassName): Collection<String>? =
storage[className.internalName]
operator fun contains(internalName: String): Boolean = internalName in storage
operator fun contains(className: JvmClassName): Boolean =
className.internalName in storage
fun remove(className: JvmClassName) {
storage.remove(className.internalName)
@@ -439,9 +429,8 @@ open class IncrementalJvmCache(
storage[partName] = facadeName
}
fun get(partName: String): String? {
return storage.get(partName)
}
fun get(partName: JvmClassName): String? =
storage[partName.internalName]
fun remove(className: JvmClassName) {
storage.remove(className.internalName)
@@ -450,27 +439,6 @@ open class IncrementalJvmCache(
override fun dumpValue(value: String): String = value
}
inner class SourceToClassesMap(storageFile: File) : BasicStringMap<Collection<String>>(storageFile, PathStringDescriptor, StringCollectionExternalizer) {
fun clearOutputsForSource(sourceFile: File) {
remove(sourceFile.absolutePath)
}
fun add(sourceFile: File, className: JvmClassName) {
storage.append(sourceFile.absolutePath, className.internalName)
}
fun contains(sourceFile: File) = sourceFile.absolutePath in storage
operator fun get(sourceFile: File): Collection<JvmClassName> =
storage[sourceFile.absolutePath].orEmpty().map { JvmClassName.byInternalName(it) }
override fun dumpValue(value: Collection<String>) = value.dumpCollection()
private fun remove(path: String) {
storage.remove(path)
}
}
inner class InternalNameToSourcesMap(storageFile: File) : BasicStringMap<Collection<String>>(storageFile, EnumeratorStringDescriptor(), PathCollectionExternalizer) {
operator fun set(internalName: String, sourceFiles: Iterable<File>) {
storage[internalName] = sourceFiles.map { it.canonicalPath }
@@ -492,24 +460,6 @@ open class IncrementalJvmCache(
addToClassStorage(proto, nameResolver, srcFile)
}
private inner class DirtyOutputClassesMap(storageFile: File) : BasicStringMap<Boolean>(storageFile, BooleanDataDescriptor.INSTANCE) {
fun markDirty(className: String) {
storage[className] = true
}
fun notDirty(className: String) {
storage.remove(className)
}
fun getDirtyOutputClasses(): Collection<String> =
storage.keys
fun isDirty(className: String): Boolean =
storage.contains(className)
override fun dumpValue(value: Boolean) = ""
}
private inner class InlineFunctionsMap(storageFile: File) : BasicStringMap<Map<String, Long>>(storageFile, StringToLongMapExternalizer) {
private fun getInlineFunctionsMap(header: KotlinClassHeader, bytes: ByteArray): Map<String, Long> {
val inlineFunctions = inlineFunctionsJvmNames(header)

View File

@@ -116,7 +116,7 @@ data class DirtyData(
)
fun ChangesCollector.getDirtyData(
caches: Iterable<IncrementalCacheCommon>,
caches: Iterable<IncrementalCacheCommon<*>>,
reporter: ICReporter
): DirtyData {
val dirtyLookupSymbols = HashSet<LookupSymbol>()
@@ -170,7 +170,7 @@ fun mapLookupSymbolsToFiles(
}
fun mapClassesFqNamesToFiles(
caches: Iterable<IncrementalCacheCommon>,
caches: Iterable<IncrementalCacheCommon<*>>,
classesFqNames: Iterable<FqName>,
reporter: ICReporter,
excludes: Set<File> = emptySet()
@@ -192,7 +192,7 @@ fun mapClassesFqNamesToFiles(
fun withSubtypes(
typeFqName: FqName,
caches: Iterable<IncrementalCacheCommon>
caches: Iterable<IncrementalCacheCommon<*>>
): Set<FqName> {
val types = LinkedList(listOf(typeFqName))
val subtypes = hashSetOf<FqName>()

View File

@@ -0,0 +1,46 @@
/*
* 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.incremental.storage
import com.intellij.util.io.BooleanDataDescriptor
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.resolve.jvm.JvmClassName
import java.io.File
internal class DirtyClassesJvmNameMap(storageFile: File) : AbstractDirtyClassesMap<JvmClassName>(JvmClassNameTransformer, storageFile)
internal class DirtyClassesFqNameMap(storageFile: File) : AbstractDirtyClassesMap<FqName>(FqNameTransformer, storageFile)
internal abstract class AbstractDirtyClassesMap<Name>(
private val nameTransformer: NameTransformer<Name>,
storageFile: File
) : BasicStringMap<Boolean>(storageFile, BooleanDataDescriptor.INSTANCE) {
fun markDirty(className: Name) {
storage[nameTransformer.asString(className)] = true
}
fun notDirty(className: Name) {
storage.remove(nameTransformer.asString(className))
}
fun getDirtyOutputClasses(): Collection<Name> =
storage.keys.map { nameTransformer.asName(it) }
fun isDirty(className: Name): Boolean =
storage.contains(nameTransformer.asString(className))
override fun dumpValue(value: Boolean) = ""
}

View File

@@ -0,0 +1,41 @@
/*
* 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.incremental.storage
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.resolve.jvm.JvmClassName
internal interface NameTransformer<Name> {
fun asString(name: Name): String
fun asName(string: String): Name
}
internal object FqNameTransformer : NameTransformer<FqName> {
override fun asString(name: FqName): String =
name.asString()
override fun asName(string: String): FqName =
FqName(string)
}
internal object JvmClassNameTransformer : NameTransformer<JvmClassName> {
override fun asString(name: JvmClassName): String =
name.internalName
override fun asName(string: String): JvmClassName =
JvmClassName.byInternalName(string)
}

View File

@@ -0,0 +1,51 @@
/*
* 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.incremental.storage
import org.jetbrains.kotlin.incremental.dumpCollection
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.resolve.jvm.JvmClassName
import java.io.File
internal class SourceToJvmNameMap(storageFile: File) : AbstractSourceToOutputMap<JvmClassName>(JvmClassNameTransformer, storageFile)
internal class SourceToFqNameMap(storageFile: File) : AbstractSourceToOutputMap<FqName>(FqNameTransformer, storageFile)
internal abstract class AbstractSourceToOutputMap<Name>(
private val nameTransformer: NameTransformer<Name>,
storageFile: File
) : BasicStringMap<Collection<String>>(storageFile, PathStringDescriptor, StringCollectionExternalizer) {
fun clearOutputsForSource(sourceFile: File) {
remove(sourceFile.absolutePath)
}
fun add(sourceFile: File, className: Name) {
storage.append(sourceFile.absolutePath, nameTransformer.asString(className))
}
fun contains(sourceFile: File): Boolean =
sourceFile.absolutePath in storage
operator fun get(sourceFile: File): Collection<Name> =
storage[sourceFile.absolutePath].orEmpty().map(nameTransformer::asName)
override fun dumpValue(value: Collection<String>) =
value.dumpCollection()
private fun remove(path: String) {
storage.remove(path)
}
}

View File

@@ -28,6 +28,9 @@ data class BuildLogFinder(
private const val GRADLE_LOG = "gradle-build.log"
private const val DATA_CONTAINER_LOG = "data-container-version-build.log"
private const val SIMPLE_LOG = "build.log"
fun isJpsLogFile(file: File): Boolean =
file.name.let { it == SIMPLE_LOG || it == DATA_CONTAINER_LOG }
}
fun findBuildLog(dir: File): File? {

View File

@@ -357,6 +357,7 @@ tasks {
dependsOn("scriptingTest")
dependsOn(":kotlin-build-common:test")
dependsOn(":compiler:incremental-compilation-impl:test")
}
"examplesTest" {

View File

@@ -1,10 +1,8 @@
@file:Suppress("unused") // usages in build scripts are not tracked properly
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.gradle.api.GradleException
import org.gradle.api.Project
import org.gradle.api.file.DuplicatesStrategy
import org.gradle.api.tasks.bundling.Zip
import org.gradle.jvm.tasks.Jar
import org.gradle.kotlin.dsl.task
import org.gradle.kotlin.dsl.*
@@ -104,23 +102,22 @@ fun Project.embeddableCompilerDummyForDependenciesRewriting(taskName: String = "
}
}
fun Project.rewriteDepsToShadedJar(originalJarTask: Jar, shadowJarTask: Zip, body: Jar.() -> Unit = {}): Jar {
val originalFiles by lazy {
val jarContents = zipTree(originalJarTask.outputs.files.singleFile).files
val basePath = jarContents.find { it.name == "MANIFEST.MF" }?.parentFile?.parentFile ?: throw GradleException("cannot determine the jar root dir")
jarContents.map { it.relativeTo(basePath).path }.toSet()
fun Project.rewriteDepsToShadedJar(originalJarTask: Jar, shadowJarTask: Jar, body: Jar.() -> Unit = {}): Jar {
originalJarTask.apply {
classifier = "original"
}
return task<Jar>("rewrittenDepsJar") {
originalJarTask.apply {
classifier = "original"
}
shadowJarTask.apply {
dependsOn(originalJarTask)
from(originalJarTask)// { include("**") }
classifier = "shadow"
}
dependsOn(shadowJarTask)
from(project.zipTree(shadowJarTask.outputs.files.singleFile)) { include { originalFiles.any { originalFile -> it.file.canonicalPath.endsWith(originalFile) } } }
val compilerDummyJarFile by lazy { configurations.getAt("compilerDummyJar").singleFile }
return shadowJarTask.apply {
dependsOn(originalJarTask)
from(originalJarTask)// { include("**") }
// When Gradle traverses the inputs, reject the shaded compiler JAR,
// which leads to the content of that JAR being excluded as well:
exclude { it.file == compilerDummyJarFile }
classifier = null
body()
}
}

View File

@@ -223,9 +223,8 @@ public class FunctionCodegen {
generateMethodAnnotations(functionDescriptor, asmMethod, mv);
JvmMethodSignature signature = typeMapper.mapSignatureSkipGeneric(functionDescriptor);
generateParameterAnnotations(functionDescriptor, mv, signature);
GenerateJava8ParameterNamesKt.generateParameterNames(functionDescriptor, mv, signature, state, (flags & ACC_SYNTHETIC) != 0);
generateParameterAnnotations(functionDescriptor, mv, jvmSignature);
GenerateJava8ParameterNamesKt.generateParameterNames(functionDescriptor, mv, jvmSignature, state, (flags & ACC_SYNTHETIC) != 0);
generateBridges(functionDescriptor);

View File

@@ -164,7 +164,7 @@ class DefaultLambda(
classReader.b,
invokeMethod.name,
invokeMethod.descriptor,
lambdaClassType)!!
lambdaClassType) ?: error("Can't find method '${invokeMethod.name}${invokeMethod.descriptor}' in '${classReader.className}'")
if (needReification) {
//nested classes could also require reification

View File

@@ -164,7 +164,9 @@ class MethodInliner(
result.merge(transformResult)
result.addChangedType(oldClassName, newClassName)
if (inliningContext.isInliningLambda && transformationInfo!!.canRemoveAfterTransformation()) {
if (inliningContext.isInliningLambda &&
inliningContext.lambdaInfo !is DefaultLambda && //never delete default lambda classes
transformationInfo!!.canRemoveAfterTransformation()) {
// this class is transformed and original not used so we should remove original one after inlining
result.addClassToRemove(oldClassName)
}
@@ -220,15 +222,20 @@ class MethodInliner(
setLambdaInlining(true)
val lambdaSMAP = info.node.classSMAP
val sourceMapper = if (inliningContext.classRegeneration && !inliningContext.isInliningLambda)
NestedSourceMapper(sourceMapper, lambdaSMAP.intervals, lambdaSMAP.sourceInfo)
else
InlineLambdaSourceMapper(sourceMapper.parent!!, info.node)
val childSourceMapper =
if (inliningContext.classRegeneration && !inliningContext.isInliningLambda)
NestedSourceMapper(sourceMapper, lambdaSMAP.intervals, lambdaSMAP.sourceInfo)
else if (info is DefaultLambda) {
NestedSourceMapper(sourceMapper.parent!!, lambdaSMAP.intervals, lambdaSMAP.sourceInfo)
}
else InlineLambdaSourceMapper(sourceMapper.parent!!, info.node)
val inliner = MethodInliner(
info.node.node, lambdaParameters, inliningContext.subInlineLambda(info),
newCapturedRemapper, true /*cause all calls in same module as lambda*/,
newCapturedRemapper,
if (info is DefaultLambda) isSameModule else true /*cause all nested objects in same module as lambda*/,
"Lambda inlining " + info.lambdaClassType.internalName,
sourceMapper, inlineCallSiteInfo, null
childSourceMapper, inlineCallSiteInfo, null
)
val varRemapper = LocalVarRemapper(lambdaParameters, valueParamShift)
@@ -242,7 +249,7 @@ class MethodInliner(
StackValue.onStack(info.invokeMethod.returnType).put(bridge.returnType, this)
setLambdaInlining(false)
addInlineMarker(this, false)
sourceMapper.endMapping()
childSourceMapper.endMapping()
inlineOnlySmapSkipper?.markCallSiteLineNumber(remappingMethodAdapter)
}
else if (isAnonymousConstructorCall(owner, name)) { //TODO add method

View File

@@ -51,7 +51,7 @@ open class DefaultValues(val defaultValue: String, val possibleValues: List<Stri
)
object JsSourceMapContentModes : DefaultValues(
"\"${K2JsArgumentConstants.SOURCE_MAP_SOURCE_CONTENT_INLINING}\"",
"null",
listOf(
K2JsArgumentConstants.SOURCE_MAP_SOURCE_CONTENT_NEVER,
K2JsArgumentConstants.SOURCE_MAP_SOURCE_CONTENT_ALWAYS,

View File

@@ -16,6 +16,7 @@
package org.jetbrains.kotlin.cli.common.arguments
import com.intellij.util.text.VersionComparatorUtil
import java.util.*
import kotlin.reflect.KClass
import kotlin.reflect.KMutableProperty1
@@ -98,4 +99,10 @@ fun <T : Any> collectProperties(kClass: KClass<T>, inheritedOnly: Boolean): List
return properties.filter {
it.visibility == KVisibility.PUBLIC && it.findAnnotation<Transient>() == null
}
}
fun CommonCompilerArguments.setApiVersionToLanguageVersionIfNeeded() {
if (languageVersion != null && VersionComparatorUtil.compare(languageVersion, apiVersion) < 0) {
apiVersion = languageVersion
}
}

View File

@@ -53,6 +53,7 @@ open class BasicReplStageHistory<T>(override val lock: ReentrantReadWriteLock =
lock.write {
val removed = map { it.id }
clear()
currentGeneration.incrementAndGet()
return removed
}
}
@@ -67,7 +68,10 @@ open class BasicReplStageHistory<T>(override val lock: ReentrantReadWriteLock =
currentGeneration.incrementAndGet()
removed
}
else emptyList()
else {
currentGeneration.incrementAndGet()
emptyList()
}
}
}
}

View File

@@ -35,7 +35,15 @@ class GenericReplCompilingEvaluator(val compiler: ReplCompiler,
val aggregatedState = state.asState(AggregatedReplStageState::class.java)
val compiled = compiler.compile(state, codeLine)
when (compiled) {
is ReplCompileResult.Error -> ReplEvalResult.Error.CompileTime(compiled.message, compiled.location)
is ReplCompileResult.Error -> {
aggregatedState.apply {
lock.write {
assert(state1.history.size == state2.history.size)
adjustHistories() // needed due to statefulness of AnalyzerEngine - in case of compilation errors the line name reuse leads to #KT-17921
}
}
ReplEvalResult.Error.CompileTime(compiled.message, compiled.location)
}
is ReplCompileResult.Incomplete -> ReplEvalResult.Incomplete()
is ReplCompileResult.CompiledClasses -> {
val result = eval(state, compiled, scriptArgs, invokeWrapper)
@@ -46,14 +54,7 @@ class GenericReplCompilingEvaluator(val compiler: ReplCompiler,
aggregatedState.apply {
lock.write {
if (state1.history.size > state2.history.size) {
if (state2.history.size == 0) {
state1.history.reset()
}
else {
state2.history.peek()?.let {
state1.history.resetTo(it.id)
}
}
adjustHistories()
assert(state1.history.size == state2.history.size)
}
}
@@ -91,3 +92,9 @@ class GenericReplCompilingEvaluator(val compiler: ReplCompiler,
evaluator.eval(state, compiledCode, scriptArgs ?: defaultScriptArgs, invokeWrapper)
}
}
private fun AggregatedReplStageState<*, *>.adjustHistories(): Iterable<ILineId>? =
state2.history.peek()?.let {
state1.history.resetTo(it.id)
}
?: state1.history.reset()

View File

@@ -44,6 +44,7 @@ import java.io.PrintStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import static org.jetbrains.kotlin.cli.common.ExitCode.*;
import static org.jetbrains.kotlin.cli.common.environment.UtilKt.setIdeaIoUseFallback;
@@ -239,11 +240,12 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> extends CLI
// do nothing
}
private static final String kotlinHomeEnvVar = System.getenv(KOTLIN_HOME_ENV_VAR);
@Nullable
private static KotlinPaths computeKotlinPaths(@NotNull MessageCollector messageCollector, @NotNull CommonCompilerArguments arguments) {
KotlinPaths paths;
String kotlinHomeProperty = System.getProperty(KOTLIN_HOME_PROPERTY);
String kotlinHomeEnvVar = System.getenv(KOTLIN_HOME_ENV_VAR);
File kotlinHome =
arguments.getKotlinHome() != null ? new File(arguments.getKotlinHome()) :
kotlinHomeProperty != null ? new File(kotlinHomeProperty) :

View File

@@ -45,6 +45,7 @@ import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles;
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment;
import org.jetbrains.kotlin.cli.jvm.plugins.PluginCliParser;
import org.jetbrains.kotlin.config.*;
import org.jetbrains.kotlin.incremental.components.ExpectActualTracker;
import org.jetbrains.kotlin.incremental.components.LookupTracker;
import org.jetbrains.kotlin.incremental.js.IncrementalDataProvider;
import org.jetbrains.kotlin.incremental.js.IncrementalResultsConsumer;
@@ -418,6 +419,11 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
configuration.put(CommonConfigurationKeys.LOOKUP_TRACKER, lookupTracker);
}
ExpectActualTracker expectActualTracker = services.get(ExpectActualTracker.class);
if (expectActualTracker != null) {
configuration.put(CommonConfigurationKeys.EXPECT_ACTUAL_TRACKER, expectActualTracker);
}
String sourceMapEmbedContentString = arguments.getSourceMapEmbedSources();
SourceMapSourceEmbedding sourceMapContentEmbedding = sourceMapEmbedContentString != null ?
sourceMapContentEmbeddingMap.get(sourceMapEmbedContentString) :

View File

@@ -42,6 +42,7 @@ import org.jetbrains.kotlin.cli.jvm.plugins.PluginCliParser
import org.jetbrains.kotlin.cli.jvm.repl.ReplFromTerminal
import org.jetbrains.kotlin.codegen.CompilationException
import org.jetbrains.kotlin.config.*
import org.jetbrains.kotlin.incremental.components.ExpectActualTracker
import org.jetbrains.kotlin.incremental.components.LookupTracker
import org.jetbrains.kotlin.javac.JavacWrapper
import org.jetbrains.kotlin.load.java.JavaClassesTracker
@@ -300,6 +301,10 @@ class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
configuration.put(CommonConfigurationKeys.LOOKUP_TRACKER, it)
}
services.get(ExpectActualTracker::class.java)?.let {
configuration.put(CommonConfigurationKeys.EXPECT_ACTUAL_TRACKER, it)
}
services.get(IncrementalCompilationComponents::class.java)?.let {
configuration.put(JVMConfigurationKeys.INCREMENTAL_COMPILATION_COMPONENTS, it)
}

View File

@@ -41,6 +41,7 @@ import org.jetbrains.kotlin.descriptors.impl.ModuleDependenciesImpl
import org.jetbrains.kotlin.frontend.java.di.createContainerForTopDownAnalyzerForJvm
import org.jetbrains.kotlin.frontend.java.di.initJvmBuiltInsForTopDownAnalysis
import org.jetbrains.kotlin.frontend.java.di.initialize
import org.jetbrains.kotlin.incremental.components.ExpectActualTracker
import org.jetbrains.kotlin.incremental.components.LookupTracker
import org.jetbrains.kotlin.javac.components.JavacBasedClassFinder
import org.jetbrains.kotlin.javac.components.JavacBasedSourceElementFactory
@@ -133,6 +134,7 @@ object TopDownAnalyzerFacadeForJVM {
val incrementalComponents = configuration.get(JVMConfigurationKeys.INCREMENTAL_COMPILATION_COMPONENTS)
val lookupTracker = configuration.get(CommonConfigurationKeys.LOOKUP_TRACKER) ?: LookupTracker.DO_NOTHING
val expectActualTracker = configuration.get(CommonConfigurationKeys.EXPECT_ACTUAL_TRACKER) ?: ExpectActualTracker.DoNothing
val targetIds = configuration.get(JVMConfigurationKeys.MODULES)?.map(::TargetId)
val separateModules = !configuration.getBoolean(JVMConfigurationKeys.USE_SINGLE_MODULE)
@@ -171,7 +173,7 @@ object TopDownAnalyzerFacadeForJVM {
val dependencyScope = GlobalSearchScope.notScope(sourceScope)
val dependenciesContainer = createContainerForTopDownAnalyzerForJvm(
dependenciesContext, trace, DeclarationProviderFactory.EMPTY, dependencyScope, lookupTracker,
dependenciesContext, trace, DeclarationProviderFactory.EMPTY, dependencyScope, lookupTracker, expectActualTracker,
packagePartProvider(dependencyScope), moduleClassResolver, jvmTarget, languageVersionSettings, configureJavaClassFinder
)
@@ -196,7 +198,7 @@ object TopDownAnalyzerFacadeForJVM {
// to be stored in CliLightClassGenerationSupport, and it better be the source one (otherwise light classes would not be found)
// TODO: get rid of duplicate invocation of CodeAnalyzerInitializer#initialize, or refactor CliLightClassGenerationSupport
val container = createContainerForTopDownAnalyzerForJvm(
moduleContext, trace, declarationProviderFactory(storageManager, files), sourceScope, lookupTracker,
moduleContext, trace, declarationProviderFactory(storageManager, files), sourceScope, lookupTracker, expectActualTracker,
partProvider, moduleClassResolver, jvmTarget, languageVersionSettings, configureJavaClassFinder,
javaClassTracker = configuration[JVMConfigurationKeys.JAVA_CLASSES_TRACKER]
).apply {

View File

@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.cli.jvm.repl
import com.intellij.openapi.Disposable
import com.intellij.openapi.util.Disposer
import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
import org.jetbrains.kotlin.cli.common.repl.*
@@ -46,6 +47,9 @@ open class GenericReplCompiler(disposable: Disposable,
messageCollector: MessageCollector
) : ReplCompiler {
constructor(scriptDefinition: KotlinScriptDefinition, compilerConfiguration: CompilerConfiguration, messageCollector: MessageCollector) :
this(Disposer.newDisposable(), scriptDefinition, compilerConfiguration, messageCollector)
private val checker = GenericReplChecker(disposable, scriptDefinition, compilerConfiguration, messageCollector)
override fun createState(lock: ReentrantReadWriteLock): IReplStageState<*> = GenericReplCompilerState(checker.environment, lock)

View File

@@ -92,13 +92,13 @@ private inline fun tryConnectToDaemon(port: Int, report: (DaemonReportCategory,
val daemon = LocateRegistry.getRegistry(LoopbackNetworkInterface.loopbackInetAddressName, port, LoopbackNetworkInterface.clientLoopbackSocketFactory)
?.lookup(COMPILER_SERVICE_RMI_NAME)
when (daemon) {
null -> report(DaemonReportCategory.EXCEPTION, "daemon not found")
null -> report(DaemonReportCategory.INFO, "daemon not found")
is CompileService -> return daemon
else -> report(DaemonReportCategory.EXCEPTION, "Unable to cast compiler service, actual class received: ${daemon::class.java.name}")
else -> report(DaemonReportCategory.INFO, "Unable to cast compiler service, actual class received: ${daemon::class.java.name}")
}
}
catch (e: Throwable) {
report(DaemonReportCategory.EXCEPTION, "cannot connect to registry: " + (e.cause?.message ?: e.message ?: "unknown error"))
report(DaemonReportCategory.INFO, "cannot connect to registry: " + (e.cause?.message ?: e.message ?: "unknown error"))
}
return null
}

View File

@@ -18,10 +18,7 @@ package org.jetbrains.kotlin.daemon.common
import java.io.IOException
import java.io.Serializable
import java.net.Inet6Address
import java.net.InetAddress
import java.net.ServerSocket
import java.net.Socket
import java.net.*
import java.rmi.RemoteException
import java.rmi.registry.LocateRegistry
import java.rmi.registry.Registry
@@ -33,6 +30,11 @@ import java.util.*
const val SOCKET_ANY_FREE_PORT = 0
const val JAVA_RMI_SERVER_HOSTNAME = "java.rmi.server.hostname"
const val DAEMON_RMI_SOCKET_BACKLOG_SIZE_PROPERTY = "kotlin.daemon.socket.backlog.size"
const val DAEMON_RMI_SOCKET_CONNECT_ATTEMPTS_PROPERTY = "kotlin.daemon.socket.connect.attempts"
const val DAEMON_RMI_SOCKET_CONNECT_INTERVAL_PROPERTY = "kotlin.daemon.socket.connect.interval"
const val DEFAULT_SERVER_SOCKET_BACKLOG_SIZE = 50
const val DEFAULT_SOCKET_CONNECT_ATTEMPTS = 3
const val DEFAULT_SOCKET_CONNECT_INTERVAL_MS = 10L
object LoopbackNetworkInterface {
@@ -41,7 +43,9 @@ object LoopbackNetworkInterface {
// size of the requests queue for daemon services, so far seems that we don't need any big numbers here
// but if we'll start getting "connection refused" errors, that could be the first place to try to fix it
val SERVER_SOCKET_BACKLOG_SIZE by lazy { System.getProperty(DAEMON_RMI_SOCKET_BACKLOG_SIZE_PROPERTY)?.toIntOrNull() ?: 50 }
val SERVER_SOCKET_BACKLOG_SIZE by lazy { System.getProperty(DAEMON_RMI_SOCKET_BACKLOG_SIZE_PROPERTY)?.toIntOrNull() ?: DEFAULT_SERVER_SOCKET_BACKLOG_SIZE }
val SOCKET_CONNECT_ATTEMPTS by lazy { System.getProperty(DAEMON_RMI_SOCKET_CONNECT_ATTEMPTS_PROPERTY)?.toIntOrNull() ?: DEFAULT_SOCKET_CONNECT_ATTEMPTS }
val SOCKET_CONNECT_INTERVAL_MS by lazy { System.getProperty(DAEMON_RMI_SOCKET_CONNECT_INTERVAL_PROPERTY)?.toLongOrNull() ?: DEFAULT_SOCKET_CONNECT_INTERVAL_MS }
val serverLoopbackSocketFactory by lazy { ServerLoopbackSocketFactory() }
val clientLoopbackSocketFactory by lazy { ClientLoopbackSocketFactory() }
@@ -75,7 +79,18 @@ object LoopbackNetworkInterface {
override fun hashCode(): Int = super.hashCode()
@Throws(IOException::class)
override fun createSocket(host: String, port: Int): Socket = Socket(InetAddress.getByName(null), port)
override fun createSocket(host: String, port: Int): Socket {
var attemptsLeft = SOCKET_CONNECT_ATTEMPTS
while (true) {
try {
return Socket(InetAddress.getByName(null), port)
}
catch (e: ConnectException) {
if (--attemptsLeft <= 0) throw e
}
Thread.sleep(SOCKET_CONNECT_INTERVAL_MS)
}
}
}
}

View File

@@ -453,8 +453,8 @@ class CompileServiceImpl(
workingDir,
enabled = true)
return IncrementalJsCompilerRunner(workingDir, versions, reporter)
.compile(allKotlinFiles, args, compilerMessageCollector, { changedFiles })
val compiler = IncrementalJsCompilerRunner(workingDir, versions, reporter)
return compiler.compile(allKotlinFiles, args, compilerMessageCollector, changedFiles)
}
private fun execIncrementalCompiler(
@@ -514,7 +514,7 @@ class CompileServiceImpl(
friendBuildHistoryFile = incrementalCompilationOptions.friendDifferenceFile,
usePreciseJavaTracking = incrementalCompilationOptions.usePreciseJavaTracking
)
return compiler.compile(allKotlinFiles, k2jvmArgs, compilerMessageCollector, { changedFiles })
return compiler.compile(allKotlinFiles, k2jvmArgs, compilerMessageCollector, changedFiles)
}
override fun leaseReplSession(

View File

@@ -29,6 +29,7 @@ import org.jetbrains.kotlin.contracts.ContractDeserializerImpl
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.descriptors.PackagePartProvider
import org.jetbrains.kotlin.frontend.di.configureModule
import org.jetbrains.kotlin.incremental.components.ExpectActualTracker
import org.jetbrains.kotlin.incremental.components.LookupTracker
import org.jetbrains.kotlin.load.java.AbstractJavaClassFinder
import org.jetbrains.kotlin.load.java.InternalFlexibleTypeTransformer
@@ -49,10 +50,12 @@ import org.jetbrains.kotlin.resolve.lazy.declarations.DeclarationProviderFactory
private fun StorageComponentContainer.configureJavaTopDownAnalysis(
moduleContentScope: GlobalSearchScope,
project: Project,
lookupTracker: LookupTracker
lookupTracker: LookupTracker,
expectActualTracker: ExpectActualTracker
) {
useInstance(moduleContentScope)
useInstance(lookupTracker)
useInstance(expectActualTracker)
useImpl<ResolveSession>()
useImpl<LazyTopDownAnalyzer>()
@@ -79,6 +82,7 @@ fun createContainerForLazyResolveWithJava(
moduleClassResolver: ModuleClassResolver,
targetEnvironment: TargetEnvironment,
lookupTracker: LookupTracker,
expectActualTracker: ExpectActualTracker,
packagePartProvider: PackagePartProvider,
jvmTarget: JvmTarget,
languageVersionSettings: LanguageVersionSettings,
@@ -87,7 +91,7 @@ fun createContainerForLazyResolveWithJava(
javaClassTracker: JavaClassesTracker? = null
): StorageComponentContainer = createContainer("LazyResolveWithJava", JvmPlatform) {
configureModule(moduleContext, JvmPlatform, jvmTarget, bindingTrace)
configureJavaTopDownAnalysis(moduleContentScope, moduleContext.project, lookupTracker)
configureJavaTopDownAnalysis(moduleContentScope, moduleContext.project, lookupTracker, expectActualTracker)
if (configureJavaClassFinder != null) {
configureJavaClassFinder()
@@ -127,6 +131,7 @@ fun createContainerForTopDownAnalyzerForJvm(
declarationProviderFactory: DeclarationProviderFactory,
moduleContentScope: GlobalSearchScope,
lookupTracker: LookupTracker,
expectActualTracker: ExpectActualTracker,
packagePartProvider: PackagePartProvider,
moduleClassResolver: ModuleClassResolver,
jvmTarget: JvmTarget,
@@ -135,7 +140,7 @@ fun createContainerForTopDownAnalyzerForJvm(
javaClassTracker: JavaClassesTracker? = null
): ComponentProvider = createContainerForLazyResolveWithJava(
moduleContext, bindingTrace, declarationProviderFactory, moduleContentScope, moduleClassResolver,
CompilerEnvironment, lookupTracker, packagePartProvider, jvmTarget, languageVersionSettings,
CompilerEnvironment, lookupTracker, expectActualTracker, packagePartProvider, jvmTarget, languageVersionSettings,
useBuiltInsProvider = true,
configureJavaClassFinder = configureJavaClassFinder,
javaClassTracker = javaClassTracker

View File

@@ -16,7 +16,6 @@
package org.jetbrains.kotlin.resolve.jvm
import com.intellij.openapi.diagnostic.Logger
import com.intellij.psi.search.GlobalSearchScope
import org.jetbrains.kotlin.analyzer.*
import org.jetbrains.kotlin.config.JvmTarget
@@ -26,6 +25,7 @@ import org.jetbrains.kotlin.descriptors.PackagePartProvider
import org.jetbrains.kotlin.descriptors.impl.CompositePackageFragmentProvider
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
import org.jetbrains.kotlin.frontend.java.di.createContainerForLazyResolveWithJava
import org.jetbrains.kotlin.incremental.components.ExpectActualTracker
import org.jetbrains.kotlin.incremental.components.LookupTracker
import org.jetbrains.kotlin.load.java.lazy.ModuleClassResolverImpl
import org.jetbrains.kotlin.load.java.structure.JavaClass
@@ -72,7 +72,6 @@ object JvmAnalyzerFacade : AnalyzerFacade() {
val resolverForReferencedModule = referencedClassModule?.let { resolverForProject.tryGetResolverForModule(it as M) }
val resolverForModule = resolverForReferencedModule ?: run {
LOG.warn("Java referenced $referencedClassModule from $moduleInfo\nReferenced class was: $javaClass\n")
// in case referenced class lies outside of our resolver, resolve the class as if it is inside our module
// this leads to java class being resolved several times
resolverForProject.resolverForModule(moduleInfo)
@@ -94,6 +93,7 @@ object JvmAnalyzerFacade : AnalyzerFacade() {
moduleClassResolver,
targetEnvironment,
lookupTracker,
ExpectActualTracker.DoNothing,
packagePartProvider,
jvmTarget,
languageVersionSettings,
@@ -120,6 +120,4 @@ object JvmAnalyzerFacade : AnalyzerFacade() {
override val targetPlatform: TargetPlatform
get() = JvmPlatform
private val LOG = Logger.getInstance(JvmAnalyzerFacade::class.java)
}

View File

@@ -34,6 +34,7 @@ import org.jetbrains.kotlin.descriptors.PackagePartProvider
import org.jetbrains.kotlin.descriptors.impl.CompositePackageFragmentProvider
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
import org.jetbrains.kotlin.frontend.di.configureModule
import org.jetbrains.kotlin.incremental.components.ExpectActualTracker
import org.jetbrains.kotlin.incremental.components.LookupTracker
import org.jetbrains.kotlin.load.kotlin.MetadataFinderFactory
import org.jetbrains.kotlin.name.Name
@@ -142,6 +143,7 @@ object CommonAnalyzerFacade : AnalyzerFacade() {
useInstance(moduleContentScope)
useInstance(LookupTracker.DO_NOTHING)
useInstance(ExpectActualTracker.DoNothing)
useImpl<ResolveSession>()
useImpl<LazyTopDownAnalyzer>()
useInstance(languageVersionSettings)

View File

@@ -16,6 +16,7 @@
package org.jetbrains.kotlin.config
import org.jetbrains.kotlin.incremental.components.ExpectActualTracker
import org.jetbrains.kotlin.incremental.components.LookupTracker
object CommonConfigurationKeys {
@@ -33,6 +34,9 @@ object CommonConfigurationKeys {
@JvmField
val LOOKUP_TRACKER = CompilerConfigurationKey.create<LookupTracker>("lookup tracker")
@JvmField
val EXPECT_ACTUAL_TRACKER = CompilerConfigurationKey.create<ExpectActualTracker>("expect actual tracker")
}
var CompilerConfiguration.languageVersionSettings: LanguageVersionSettings

View File

@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.container.useImpl
import org.jetbrains.kotlin.container.useInstance
import org.jetbrains.kotlin.context.ModuleContext
import org.jetbrains.kotlin.extensions.StorageComponentContainerContributor
import org.jetbrains.kotlin.incremental.components.ExpectActualTracker
import org.jetbrains.kotlin.incremental.components.LookupTracker
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.resolve.*
@@ -127,6 +128,7 @@ fun createContainerForLazyLocalClassifierAnalyzer(
useInstance(localClassDescriptorHolder)
useInstance(lookupTracker)
useInstance(ExpectActualTracker.DoNothing)
useImpl<LazyTopDownAnalyzer>()

View File

@@ -20,6 +20,7 @@ import com.intellij.injected.editor.VirtualFileWindow
import com.intellij.lang.ASTNode
import com.intellij.openapi.util.TextRange
import com.intellij.psi.*
import com.intellij.psi.impl.source.tree.TreeUtil
import com.intellij.psi.search.PsiSearchScopeUtil
import com.intellij.psi.search.SearchScope
import com.intellij.psi.util.PsiTreeUtil
@@ -400,3 +401,11 @@ fun ASTNode.siblings(forward: Boolean = true): Sequence<ASTNode> {
return generateSequence(treePrev) { it.treePrev }
}
}
fun ASTNode.leaves(forward: Boolean = true): Sequence<ASTNode> {
if (forward) {
return generateSequence(TreeUtil.nextLeaf(this)) { TreeUtil.nextLeaf(it) }
} else {
return generateSequence(TreeUtil.prevLeaf(this)) { TreeUtil.prevLeaf(it) }
}
}

View File

@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.config.LanguageVersionSettings;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory1;
import org.jetbrains.kotlin.extensions.DeclarationAttributeAltererExtension;
import org.jetbrains.kotlin.incremental.components.ExpectActualTracker;
import org.jetbrains.kotlin.lexer.KtKeywordToken;
import org.jetbrains.kotlin.lexer.KtModifierKeywordToken;
import org.jetbrains.kotlin.lexer.KtTokens;
@@ -280,7 +281,7 @@ public class ModifiersChecker {
@NotNull DeclarationDescriptor descriptor
) {
for (DeclarationChecker checker : declarationCheckers) {
checker.check(declaration, descriptor, trace, trace.getBindingContext(), languageVersionSettings);
checker.check(declaration, descriptor, trace, trace.getBindingContext(), languageVersionSettings, expectActualTracker);
}
OperatorModifierChecker.INSTANCE.check(declaration, descriptor, trace, languageVersionSettings);
PublishedApiUsageChecker.INSTANCE.check(declaration, descriptor, trace);
@@ -304,14 +305,19 @@ public class ModifiersChecker {
@NotNull
private final LanguageVersionSettings languageVersionSettings;
@NotNull
private final ExpectActualTracker expectActualTracker;
public ModifiersChecker(
@NotNull AnnotationChecker annotationChecker,
@NotNull Iterable<DeclarationChecker> declarationCheckers,
@NotNull LanguageVersionSettings languageVersionSettings
@NotNull LanguageVersionSettings languageVersionSettings,
@NotNull ExpectActualTracker expectActualTracker
) {
this.annotationChecker = annotationChecker;
this.declarationCheckers = declarationCheckers;
this.languageVersionSettings = languageVersionSettings;
this.expectActualTracker = expectActualTracker;
}
@NotNull

View File

@@ -136,6 +136,7 @@ class DynamicCallableDescriptors(storageManager: StorageManager, builtIns: Kotli
Modality.FINAL,
Visibilities.PUBLIC
)
functionDescriptor.setHasSynthesizedParameterNames(true)
return functionDescriptor
}

View File

@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.resolve.checkers
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
import org.jetbrains.kotlin.incremental.components.ExpectActualTracker
import org.jetbrains.kotlin.psi.KtDeclaration
import org.jetbrains.kotlin.resolve.BindingContext
@@ -29,7 +30,8 @@ interface DeclarationChecker {
descriptor: DeclarationDescriptor,
diagnosticHolder: DiagnosticSink,
bindingContext: BindingContext,
languageVersionSettings: LanguageVersionSettings
languageVersionSettings: LanguageVersionSettings,
expectActualTracker: ExpectActualTracker
)
}
@@ -38,7 +40,9 @@ interface SimpleDeclarationChecker : DeclarationChecker {
declaration: KtDeclaration,
descriptor: DeclarationDescriptor,
diagnosticHolder: DiagnosticSink,
bindingContext: BindingContext, languageVersionSettings: LanguageVersionSettings
bindingContext: BindingContext,
languageVersionSettings: LanguageVersionSettings,
expectActualTracker: ExpectActualTracker
) = check(declaration, descriptor, diagnosticHolder, bindingContext)
fun check(

View File

@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
import org.jetbrains.kotlin.diagnostics.Errors.DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE
import org.jetbrains.kotlin.incremental.components.ExpectActualTracker
import org.jetbrains.kotlin.psi.KtClassOrObject
import org.jetbrains.kotlin.psi.KtDeclaration
import org.jetbrains.kotlin.psi.KtDelegatedSuperTypeEntry
@@ -37,7 +38,8 @@ class DelegationChecker : DeclarationChecker {
descriptor: DeclarationDescriptor,
diagnosticHolder: DiagnosticSink,
bindingContext: BindingContext,
languageVersionSettings: LanguageVersionSettings
languageVersionSettings: LanguageVersionSettings,
expectActualTracker: ExpectActualTracker
) {
if (descriptor !is ClassDescriptor) return
if (declaration !is KtClassOrObject) return

View File

@@ -16,6 +16,7 @@
package org.jetbrains.kotlin.resolve.checkers
import com.intellij.openapi.vfs.VfsUtilCore
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.config.AnalysisFlag
import org.jetbrains.kotlin.config.LanguageFeature
@@ -23,6 +24,7 @@ import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.incremental.components.ExpectActualTracker
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.psi.KtConstructor
@@ -40,6 +42,7 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.module
import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
import org.jetbrains.kotlin.resolve.scopes.MemberScope
import org.jetbrains.kotlin.resolve.scopes.getDescriptorsFiltered
import org.jetbrains.kotlin.resolve.source.PsiSourceFile
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.TypeConstructor
import org.jetbrains.kotlin.types.TypeConstructorSubstitution
@@ -48,7 +51,9 @@ import org.jetbrains.kotlin.types.checker.NewKotlinTypeChecker
import org.jetbrains.kotlin.types.checker.TypeCheckerContext
import org.jetbrains.kotlin.types.typeUtil.asTypeProjection
import org.jetbrains.kotlin.utils.SmartList
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
import org.jetbrains.kotlin.utils.keysToMap
import java.io.File
object ExpectedActualDeclarationChecker : DeclarationChecker {
override fun check(
@@ -56,7 +61,8 @@ object ExpectedActualDeclarationChecker : DeclarationChecker {
descriptor: DeclarationDescriptor,
diagnosticHolder: DiagnosticSink,
bindingContext: BindingContext,
languageVersionSettings: LanguageVersionSettings
languageVersionSettings: LanguageVersionSettings,
expectActualTracker: ExpectActualTracker
) {
if (!languageVersionSettings.supportsFeature(LanguageFeature.MultiPlatformProjects)) return
@@ -64,7 +70,7 @@ object ExpectedActualDeclarationChecker : DeclarationChecker {
if (descriptor !is MemberDescriptor || DescriptorUtils.isEnumEntry(descriptor)) return
if (descriptor.isExpect) {
checkExpectedDeclarationHasActual(declaration, descriptor, diagnosticHolder, descriptor.module)
checkExpectedDeclarationHasActual(declaration, descriptor, diagnosticHolder, descriptor.module, expectActualTracker)
}
else {
val checkActual = !languageVersionSettings.getFlag(AnalysisFlag.multiPlatformDoNotCheckActual)
@@ -76,7 +82,8 @@ object ExpectedActualDeclarationChecker : DeclarationChecker {
reportOn: KtNamedDeclaration,
descriptor: MemberDescriptor,
diagnosticHolder: DiagnosticSink,
platformModule: ModuleDescriptor
platformModule: ModuleDescriptor,
expectActualTracker: ExpectActualTracker
) {
// Only look for top level actual members; class members will be handled as a part of that expected class
if (descriptor.containingDeclaration !is PackageFragmentDescriptor) return
@@ -96,8 +103,32 @@ object ExpectedActualDeclarationChecker : DeclarationChecker {
val incompatibility = compatibility as Map<Incompatible, Collection<MemberDescriptor>>
diagnosticHolder.report(Errors.NO_ACTUAL_FOR_EXPECT.on(reportOn, descriptor, platformModule, incompatibility))
}
else {
val actualMembers = compatibility.asSequence()
.filter { (compatibility, _) ->
compatibility is Compatible || (compatibility is Incompatible && compatibility.kind != Compatibility.IncompatibilityKind.STRONG)
}.flatMap { it.value.asSequence() }
expectActualTracker?.reportExpectActual(expected = descriptor, actualMembers = actualMembers)
}
}
private fun ExpectActualTracker.reportExpectActual(expected: MemberDescriptor, actualMembers: Sequence<MemberDescriptor>) {
if (this is ExpectActualTracker.DoNothing) return
val expectedFile = sourceFile(expected) ?: return
for (actual in actualMembers) {
val actualFile = sourceFile(actual) ?: continue
report(expectedFile = expectedFile, actualFile = actualFile)
}
}
private fun sourceFile(descriptor: MemberDescriptor): File? =
descriptor.source
.containingFile
.safeAs<PsiSourceFile>()
?.run { VfsUtilCore.virtualToIoFile(psiFile.virtualFile) }
fun Map<out Compatibility, Collection<MemberDescriptor>>.allStrongIncompatibilities(): Boolean =
this.keys.all { it is Incompatible && it.kind == Compatibility.IncompatibilityKind.STRONG }

View File

@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.incremental.components.ExpectActualTracker
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.psi.KtDeclaration
import org.jetbrains.kotlin.resolve.BindingContext
@@ -37,7 +38,8 @@ abstract class KotlinVersionStringAnnotationValueChecker(
descriptor: DeclarationDescriptor,
diagnosticHolder: DiagnosticSink,
bindingContext: BindingContext,
languageVersionSettings: LanguageVersionSettings
languageVersionSettings: LanguageVersionSettings,
expectActualTracker: ExpectActualTracker
) {
val annotation = descriptor.annotations.findAnnotation(annotationFqName) ?: return
val version = annotation.allValueArguments.values.singleOrNull()?.value as? String ?: return

View File

@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.descriptors.VariableDescriptor
import org.jetbrains.kotlin.descriptors.impl.FunctionExpressionDescriptor
import org.jetbrains.kotlin.diagnostics.DiagnosticSink
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.incremental.components.ExpectActualTracker
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.resolve.BindingContext
@@ -61,7 +62,8 @@ object UnderscoreChecker : DeclarationChecker {
descriptor: DeclarationDescriptor,
diagnosticHolder: DiagnosticSink,
bindingContext: BindingContext,
languageVersionSettings: LanguageVersionSettings
languageVersionSettings: LanguageVersionSettings,
expectActualTracker: ExpectActualTracker
) {
if (declaration is KtProperty && descriptor !is VariableDescriptor) return
if (declaration is KtCallableDeclaration) {

View File

@@ -0,0 +1,31 @@
/*
* 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.incremental
import org.jetbrains.kotlin.incremental.components.ExpectActualTracker
import java.io.File
internal class ExpectActualTrackerImpl : ExpectActualTracker {
private val expectToActual = hashMapOf<File, MutableSet<File>>()
val expectToActualMap: Map<File, Set<File>>
get() = expectToActual
override fun report(expectedFile: File, actualFile: File) {
expectToActual.getOrPut(expectedFile) { hashSetOf() }.add(actualFile)
}
}

View File

@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.incremental
import org.jetbrains.kotlin.incremental.storage.BasicMapsOwner
import java.io.File
abstract class IncrementalCachesManager<PlatformCache : IncrementalCacheCommon>(
abstract class IncrementalCachesManager<PlatformCache : IncrementalCacheCommon<*>>(
protected val cachesRootDir: File,
protected val reporter: ICReporter
) {

View File

@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.compilerRunner.OutputItemsCollectorImpl
import org.jetbrains.kotlin.compilerRunner.SimpleOutputItem
import org.jetbrains.kotlin.compilerRunner.toGeneratedFile
import org.jetbrains.kotlin.config.Services
import org.jetbrains.kotlin.incremental.components.ExpectActualTracker
import org.jetbrains.kotlin.incremental.components.LookupTracker
import org.jetbrains.kotlin.incremental.multiproject.ArtifactChangesProvider
import org.jetbrains.kotlin.incremental.multiproject.ChangesRegistry
@@ -54,10 +55,12 @@ abstract class IncrementalCompilerRunner<
protected abstract fun destinationDir(args: Args): File
fun compile(
allKotlinSources: List<File>,
allSourceFiles: List<File>,
args: Args,
messageCollector: MessageCollector,
getChangedFiles: (CacheManager)-> ChangedFiles
// when [providedChangedFiles] is not null, changes are provided by external system (e.g. Gradle)
// otherwise we track source files changes ourselves.
providedChangedFiles: ChangedFiles?
): ExitCode {
assert(isICEnabled()) { "Incremental compilation is not enabled" }
var caches = createCacheManager(args)
@@ -70,18 +73,20 @@ abstract class IncrementalCompilerRunner<
destinationDir(args).deleteRecursively()
caches = createCacheManager(args)
// todo more optimal fix
caches.inputsCache.sourceSnapshotMap.compareAndUpdate(allKotlinSources)
return compileIncrementally(args, caches, allKotlinSources, CompilationMode.Rebuild(), messageCollector)
if (providedChangedFiles == null) {
caches.inputsCache.sourceSnapshotMap.compareAndUpdate(allSourceFiles)
}
val allKotlinFiles = allSourceFiles.filter { it.isKotlinFile() }
return compileIncrementally(args, caches, allKotlinFiles, CompilationMode.Rebuild(), messageCollector)
}
return try {
val changedFiles = getChangedFiles(caches)
val changedFiles = providedChangedFiles ?: caches.inputsCache.sourceSnapshotMap.compareAndUpdate(allSourceFiles)
val compilationMode = sourcesToCompile(caches, changedFiles, args)
val exitCode = when (compilationMode) {
is CompilationMode.Incremental -> {
compileIncrementally(args, caches, allKotlinSources, compilationMode, messageCollector)
compileIncrementally(args, caches, allSourceFiles, compilationMode, messageCollector)
}
is CompilationMode.Rebuild -> {
rebuild { "Non-incremental compilation will be performed: ${compilationMode.reason}" }
@@ -113,7 +118,7 @@ abstract class IncrementalCompilerRunner<
}.filterTo(dirtyFiles, File::isKotlinFile)
if (dirtySourcesSinceLastTimeFile.exists()) {
val files = dirtySourcesSinceLastTimeFile.readLines().map(::File).filter(File::exists)
val files = dirtySourcesSinceLastTimeFile.readLines().map(::File)
if (files.isNotEmpty()) {
reporter.report { "Source files added since last compilation: ${reporter.pathsAsString(files)}" }
}
@@ -149,11 +154,13 @@ abstract class IncrementalCompilerRunner<
protected open fun makeServices(
args: Args,
lookupTracker: LookupTracker,
expectActualTracker: ExpectActualTracker,
caches: CacheManager,
compilationMode: CompilationMode
): Services.Builder =
Services.Builder().apply {
register(LookupTracker::class.java, lookupTracker)
register(ExpectActualTracker::class.java, expectActualTracker)
register(CompilationCanceledStatus::class.java, EmptyCompilationCanceledStatus)
}
@@ -185,22 +192,24 @@ abstract class IncrementalCompilerRunner<
val allSourcesToCompile = HashSet<File>()
var exitCode = ExitCode.OK
val allGeneratedFiles = hashSetOf<GeneratedFile>()
while (dirtySources.any() || runWithNoDirtyKotlinSources(caches)) {
val complementaryFiles = caches.inputsCache.clearComplementaryFilesMapping(dirtySources)
dirtySources.addAll(complementaryFiles)
caches.platformCache.markDirty(dirtySources)
caches.inputsCache.removeOutputForSourceFiles(dirtySources)
val lookupTracker = LookupTrackerImpl(LookupTracker.DO_NOTHING)
val expectActualTracker = ExpectActualTrackerImpl()
val (sourcesToCompile, removedKotlinSources) = dirtySources.partition(File::exists)
// todo: more optimal to save only last iteration, but it will require adding standalone-ic specific logs
// (because jps rebuilds all files from last build if it failed and gradle rebuilds everything)
allSourcesToCompile.addAll(sourcesToCompile)
val text = allSourcesToCompile.joinToString(separator = System.getProperty("line.separator")) { it.canonicalPath }
val text = dirtySources.joinToString(separator = System.getProperty("line.separator")) { it.canonicalPath }
dirtySourcesSinceLastTimeFile.writeText(text)
val services = makeServices(args, lookupTracker, caches, compilationMode).build()
val services = makeServices(args, lookupTracker, expectActualTracker, caches, compilationMode).build()
args.reportOutputFiles = true
val outputItemsCollector = OutputItemsCollectorImpl()
@@ -224,7 +233,7 @@ abstract class IncrementalCompilerRunner<
}
}
allGeneratedFiles.addAll(generatedFiles)
caches.inputsCache.registerComplementaryFiles(expectActualTracker)
caches.inputsCache.registerOutputForSourceFiles(generatedFiles)
caches.lookupCache.update(lookupTracker, sourcesToCompile, removedKotlinSources)
val changesCollector = ChangesCollector()

View File

@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.cli.common.messages.MessageCollector
import org.jetbrains.kotlin.cli.js.K2JSCompiler
import org.jetbrains.kotlin.config.IncrementalCompilation
import org.jetbrains.kotlin.config.Services
import org.jetbrains.kotlin.incremental.components.ExpectActualTracker
import org.jetbrains.kotlin.incremental.components.LookupTracker
import org.jetbrains.kotlin.incremental.js.*
import java.io.File
@@ -41,9 +42,7 @@ fun makeJsIncrementally(
withJsIC {
val compiler = IncrementalJsCompilerRunner(cachesDir, versions, reporter)
compiler.compile(allKotlinFiles, args, messageCollector) {
it.inputsCache.sourceSnapshotMap.compareAndUpdate(allKotlinFiles)
}
compiler.compile(allKotlinFiles, args, messageCollector, providedChangedFiles = null)
}
}
@@ -99,10 +98,11 @@ class IncrementalJsCompilerRunner(
override fun makeServices(
args: K2JSCompilerArguments,
lookupTracker: LookupTracker,
expectActualTracker: ExpectActualTracker,
caches: IncrementalJsCachesManager,
compilationMode: CompilationMode
): Services.Builder =
super.makeServices(args, lookupTracker, caches, compilationMode).apply {
super.makeServices(args, lookupTracker, expectActualTracker, caches, compilationMode).apply {
register(IncrementalResultsConsumer::class.java, IncrementalResultsConsumerImpl())
if (compilationMode is CompilationMode.Incremental) {
@@ -121,7 +121,8 @@ class IncrementalJsCompilerRunner(
val jsCache = caches.platformCache
jsCache.header = incrementalResults.headerMetadata
return jsCache.compareAndUpdate(incrementalResults, changesCollector)
jsCache.compareAndUpdate(incrementalResults, changesCollector)
jsCache.clearCacheForRemovedClasses(changesCollector)
}
override fun runCompiler(

View File

@@ -37,6 +37,7 @@ import org.jetbrains.kotlin.compilerRunner.ArgumentUtils
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.config.IncrementalCompilation
import org.jetbrains.kotlin.config.Services
import org.jetbrains.kotlin.incremental.components.ExpectActualTracker
import org.jetbrains.kotlin.incremental.components.LookupTracker
import org.jetbrains.kotlin.incremental.multiproject.ArtifactChangesProvider
import org.jetbrains.kotlin.incremental.multiproject.ChangesRegistry
@@ -63,7 +64,6 @@ fun makeIncrementally(
val rootsWalk = sourceRoots.asSequence().flatMap { it.walk() }
val files = rootsWalk.filter(File::isFile)
val sourceFiles = files.filter { it.extension.toLowerCase() in allExtensions }.toList()
val kotlinFiles = sourceFiles.filter { it.extension.toLowerCase() in kotlinExtensions }
withIC {
val compiler = IncrementalJvmCompilerRunner(
@@ -73,9 +73,7 @@ fun makeIncrementally(
// Use precise setting in case of non-Gradle build
usePreciseJavaTracking = true
)
compiler.compile(kotlinFiles, args, messageCollector) {
it.inputsCache.sourceSnapshotMap.compareAndUpdate(sourceFiles)
}
compiler.compile(sourceFiles, args, messageCollector, providedChangedFiles = null)
}
}
@@ -158,11 +156,11 @@ class IncrementalJvmCompilerRunner(
dirtyFiles.addAll(dirtyFilesFromFqNames)
}
val lastBuildInfo = BuildInfo.read(lastBuildInfoFile)
val lastBuildInfo = BuildInfo.read(lastBuildInfoFile) ?: return CompilationMode.Rebuild { "No information on previous build" }
reporter.report { "Last Kotlin Build info -- $lastBuildInfo" }
val changesFromFriend by lazy {
val myLastTS = lastBuildInfo?.startTS ?: return@lazy ChangesEither.Unknown()
val myLastTS = lastBuildInfo.startTS
val storage = friendBuildHistoryFile?.let { BuildDiffsStorage.readFromFile(it, reporter) } ?: return@lazy ChangesEither.Unknown()
val (prevDiffs, newDiffs) = storage.buildDiffs.partition { it.ts < myLastTS }
@@ -226,6 +224,12 @@ class IncrementalJvmCompilerRunner(
for (javaFile in javaFiles) {
if (!caches.platformCache.isTrackedFile(javaFile)) {
if (!javaFile.exists()) {
// todo: can we do this more optimal?
reporter.report { "Could not get changed for untracked removed java file $javaFile" }
return false
}
val psiFile = javaFile.psiFile()
if (psiFile !is PsiJavaFile) {
reporter.report { "[Precise Java tracking] Expected PsiJavaFile, got ${psiFile?.javaClass}" }
@@ -404,10 +408,11 @@ class IncrementalJvmCompilerRunner(
override fun makeServices(
args: K2JVMCompilerArguments,
lookupTracker: LookupTracker,
expectActualTracker: ExpectActualTracker,
caches: IncrementalJvmCachesManager,
compilationMode: CompilationMode
): Services.Builder =
super.makeServices(args, lookupTracker, caches, compilationMode).apply {
super.makeServices(args, lookupTracker, expectActualTracker, caches, compilationMode).apply {
val targetId = TargetId(args.moduleName!!, "java-production")
val targetToCache = mapOf(targetId to caches.platformCache)
val incrementalComponents = IncrementalCompilationComponentsImpl(targetToCache)

View File

@@ -23,20 +23,63 @@ import org.jetbrains.kotlin.incremental.storage.BasicMapsOwner
import org.jetbrains.kotlin.incremental.storage.BasicStringMap
import org.jetbrains.kotlin.incremental.storage.PathStringDescriptor
import org.jetbrains.kotlin.incremental.storage.StringCollectionExternalizer
import org.jetbrains.kotlin.modules.TargetId
import java.io.File
import java.util.*
import kotlin.collections.HashSet
class InputsCache(
workingDir: File,
private val reporter: ICReporter
) : BasicMapsOwner(workingDir) {
companion object {
private val SOURCE_TO_OUTPUT_FILES = "source-to-output"
private val SOURCE_SNAPSHOTS = "source-snapshot"
private val SOURCE_TO_OUTPUT_FILES = "source-to-output"
private val COMPLEMENTARY_FILES = "complementary-files"
}
internal val sourceToOutputMap = registerMap(SourceToOutputFilesMap(SOURCE_TO_OUTPUT_FILES.storageFile))
internal val sourceSnapshotMap = registerMap(FileSnapshotMap(SOURCE_SNAPSHOTS.storageFile))
private val sourceToOutputMap = registerMap(FilesMap(SOURCE_TO_OUTPUT_FILES.storageFile))
/**
* A file X is a complementary to a file Y if they contain corresponding expect/actual declarations.
* Complementary files should be compiled together during IC so the compiler does not complain
* about missing parts.
* TODO: provide a better solution (maintain an index of expect/actual declarations akin to IncrementalPackagePartProvider)
*/
private val complementaryFilesMap = registerMap(FilesMap(COMPLEMENTARY_FILES.storageFile))
fun clearComplementaryFilesMapping(dirtyFiles: Collection<File>): Collection<File> {
val complementaryFiles = HashSet<File>()
val filesQueue = ArrayDeque(dirtyFiles)
while (filesQueue.isNotEmpty()) {
val file = filesQueue.pollFirst()
complementaryFilesMap.remove(file).filterTo(filesQueue) { complementaryFiles.add(it) }
}
complementaryFiles.removeAll(dirtyFiles)
return complementaryFiles
}
internal fun registerComplementaryFiles(expectActualTracker: ExpectActualTrackerImpl) {
val actualToExpect = hashMapOf<File, MutableSet<File>>()
for ((expect, actuals) in expectActualTracker.expectToActualMap) {
for (actual in actuals) {
actualToExpect.getOrPut(actual) { hashSetOf() }.add(expect)
}
complementaryFilesMap[expect] = actuals
}
for ((actual, expects) in actualToExpect) {
complementaryFilesMap[actual] = expects
}
}
fun removeOutputForSourceFiles(sources: Iterable<File>) {
for (sourceFile in sources) {
sourceToOutputMap.remove(sourceFile).forEach { it ->
reporter.report { "Deleting $it on clearing cache for $sourceFile" }
it.delete()
}
}
}
// generatedFiles can contain multiple entries with the same source file
// for example Kapt3 IC will generate a .java stub and .class stub for each source file
@@ -53,29 +96,21 @@ class InputsCache(
sourceToOutputMap[source] = outputs
}
}
}
fun removeOutputForSourceFiles(sources: Iterable<File>) {
sources.forEach { sourceToOutputMap.remove(it) }
private class FilesMap(storageFile: File)
: BasicStringMap<Collection<String>>(storageFile, PathStringDescriptor, StringCollectionExternalizer) {
operator fun set(sourceFile: File, outputFiles: Collection<File>) {
storage[sourceFile.absolutePath] = outputFiles.map { it.absolutePath }
}
inner class SourceToOutputFilesMap(storageFile: File) : BasicStringMap<Collection<String>>(storageFile, PathStringDescriptor, StringCollectionExternalizer) {
operator fun set(sourceFile: File, outputFiles: Collection<File>) {
storage[sourceFile.absolutePath] = outputFiles.map { it.absolutePath }
}
operator fun get(sourceFile: File): Collection<File> =
storage[sourceFile.absolutePath].orEmpty().map(::File)
operator fun get(sourceFile: File): Collection<File> =
storage[sourceFile.absolutePath].orEmpty().map(::File)
override fun dumpValue(value: Collection<String>) =
value.dumpCollection()
override fun dumpValue(value: Collection<String>) = value.dumpCollection()
fun remove(file: File) {
// TODO: do it in the code that uses cache, since cache should not generally delete anything outside of it!
// but for a moment it is an easiest solution to implement
get(file).forEach {
reporter.report { "Deleting $it on clearing cache for $file" }
it.delete()
}
storage.remove(file.absolutePath)
}
}
fun remove(file: File): Collection<File> =
get(file).also { storage.remove(file.absolutePath) }
}

View File

@@ -16,6 +16,7 @@
package org.jetbrains.kotlin.incremental
import com.intellij.testFramework.UsefulTestCase
import com.intellij.util.containers.HashMap
import org.jetbrains.kotlin.TestWithWorkingDir
import org.jetbrains.kotlin.cli.common.ExitCode
@@ -23,9 +24,6 @@ import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
import org.jetbrains.kotlin.incremental.testingUtils.*
import org.jetbrains.kotlin.incremental.utils.TestCompilationResult
import org.junit.Assert
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
import java.io.File
abstract class AbstractIncrementalCompilerRunnerTestBase<Args : CommonCompilerArguments> : TestWithWorkingDir() {
@@ -83,7 +81,13 @@ abstract class AbstractIncrementalCompilerRunnerTestBase<Args : CommonCompilerAr
}
if (expectedSBWithoutErrors.toString() != actualSBWithoutErrors.toString()) {
Assert.assertEquals(expectedSB.toString(), actualSB.toString())
if (BuildLogFinder.isJpsLogFile(buildLogFile)) {
// JPS logs should be updated carefully, because standalone logs are a bit different (no removed classes, iterations, etc)
Assert.assertEquals(expectedSB.toString(), actualSB.toString())
}
else {
UsefulTestCase.assertSameLinesWithFile(buildLogFile.canonicalPath, actualSB.toString(), false)
}
}
// todo: also compare caches
@@ -110,20 +114,17 @@ abstract class AbstractIncrementalCompilerRunnerTestBase<Args : CommonCompilerAr
private fun stepLogAsString(step: Int, ktSources: Iterable<String>, errors: Collection<String>, includeErrors: Boolean = true): String {
val sb = StringBuilder()
sb.appendLine("<======= STEP $step =======>")
sb.appendLine()
sb.appendLine("Compiled kotlin sources:")
ktSources.toSet().toTypedArray().sortedArray().forEach { sb.appendLine(it) }
sb.appendLine("================ Step #$step =================")
sb.appendLine()
sb.appendLine("Compiling files:")
ktSources.toSet().toTypedArray().sortedArray().forEach { sb.appendLine(" $it") }
sb.appendLine("End of files")
sb.appendLine("Exit code: ${if (errors.isEmpty()) "OK" else "ABORT"}")
if (errors.isEmpty()) {
sb.appendLine("SUCCESS")
}
else {
sb.appendLine("FAILURE")
if (includeErrors) {
errors.filter(String::isNotEmpty).forEach { sb.appendLine(it) }
}
if (errors.isNotEmpty() && includeErrors) {
sb.appendLine("------------------------------------------")
sb.appendLine("COMPILATION FAILED")
errors.filter(String::isNotEmpty).forEach { sb.appendLine(it) }
}
return sb.toString()
@@ -136,6 +137,11 @@ abstract class AbstractIncrementalCompilerRunnerTestBase<Args : CommonCompilerAr
companion object {
@JvmStatic
protected val bootstrapKotlincLib: File = File("dependencies/bootstrap-compiler/Kotlin/kotlinc/lib")
private val distKotlincLib: File = File("dist/kotlinc/lib")
@JvmStatic
protected val kotlinStdlibJvm: File = File(distKotlincLib, "kotlin-stdlib.jar").also {
UsefulTestCase.assertExists(it)
}
}
}

View File

@@ -37,6 +37,6 @@ abstract class AbstractIncrementalJsCompilerRunnerTest : AbstractIncrementalComp
override fun createCompilerArguments(destinationDir: File, testDir: File): K2JSCompilerArguments =
K2JSCompilerArguments().apply {
outputFile = File(destinationDir, "${testDir.name}.js").path
libraries = File(bootstrapKotlincLib, "kotlin-stdlib-js.jar").path
sourceMap = true
}
}

View File

@@ -0,0 +1,27 @@
/*
* 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.incremental
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments
import java.io.File
abstract class AbstractIncrementalJsCompilerRunnerWithFriendModulesDisabledTest : AbstractIncrementalJsCompilerRunnerTest() {
override fun createCompilerArguments(destinationDir: File, testDir: File): K2JSCompilerArguments =
super.createCompilerArguments(destinationDir, testDir).apply {
friendModulesDisabled = true
}
}

View File

@@ -77,7 +77,7 @@ abstract class AbstractIncrementalJvmCompilerRunnerTest : AbstractIncrementalCom
private val compileClasspath =
listOf(
File(bootstrapKotlincLib, "kotlin-stdlib.jar"),
kotlinStdlibJvm,
KotlinTestUtils.getAnnotationsJar()
).joinToString(File.pathSeparator) { it.canonicalPath }
}

View File

@@ -0,0 +1,29 @@
/*
* 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.incremental
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
import java.io.File
abstract class AbstractIncrementalMultiplatformJsCompilerRunnerTest : AbstractIncrementalJsCompilerRunnerTest() {
override fun createCompilerArguments(destinationDir: File, testDir: File): K2JSCompilerArguments {
return super.createCompilerArguments(destinationDir, testDir).apply {
multiPlatform = true
}
}
}

View File

@@ -0,0 +1,28 @@
/*
* 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.incremental
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
import java.io.File
abstract class AbstractIncrementalMultiplatformJvmCompilerRunnerTest : AbstractIncrementalJvmCompilerRunnerTest() {
override fun createCompilerArguments(destinationDir: File, testDir: File): K2JVMCompilerArguments {
return super.createCompilerArguments(destinationDir, testDir).apply {
multiPlatform = true
}
}
}

View File

@@ -122,12 +122,6 @@ public class IncrementalJsCompilerRunnerTestGenerated extends AbstractIncrementa
doTest(fileName);
}
@TestMetadata("classRedeclaration")
public void testClassRedeclaration() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/classRedeclaration/");
doTest(fileName);
}
@TestMetadata("classSignatureChanged")
public void testClassSignatureChanged() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/classSignatureChanged/");
@@ -965,4 +959,28 @@ public class IncrementalJsCompilerRunnerTestGenerated extends AbstractIncrementa
doTest(fileName);
}
}
@TestMetadata("jps-plugin/testData/incremental/js")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Js extends AbstractIncrementalJsCompilerRunnerTest {
public void testAllFilesPresentInJs() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("jps-plugin/testData/incremental/js"), Pattern.compile("^([^\\.]+)$"), TargetBackend.ANY, true);
}
@TestMetadata("jps-plugin/testData/incremental/js/friendsModuleDisabled")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class FriendsModuleDisabled extends AbstractIncrementalJsCompilerRunnerTest {
public void testAllFilesPresentInFriendsModuleDisabled() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("jps-plugin/testData/incremental/js/friendsModuleDisabled"), Pattern.compile("^([^\\.]+)$"), TargetBackend.ANY, true);
}
@TestMetadata("internalInlineFunctionIsChanged")
public void testInternalInlineFunctionIsChanged() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/js/friendsModuleDisabled/internalInlineFunctionIsChanged/");
doTest(fileName);
}
}
}
}

View File

@@ -0,0 +1,44 @@
/*
* 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.incremental;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
import org.jetbrains.kotlin.test.KotlinTestUtils;
import org.jetbrains.kotlin.test.TargetBackend;
import org.jetbrains.kotlin.test.TestMetadata;
import org.junit.runner.RunWith;
import java.io.File;
import java.util.regex.Pattern;
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("jps-plugin/testData/incremental/js/friendsModuleDisabled")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public class IncrementalJsCompilerRunnerWithFriendModulesDisabledTestGenerated extends AbstractIncrementalJsCompilerRunnerWithFriendModulesDisabledTest {
public void testAllFilesPresentInFriendsModuleDisabled() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("jps-plugin/testData/incremental/js/friendsModuleDisabled"), Pattern.compile("^([^\\.]+)$"), TargetBackend.ANY, false);
}
@TestMetadata("internalInlineFunctionIsChanged")
public void testInternalInlineFunctionIsChanged() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/js/friendsModuleDisabled/internalInlineFunctionIsChanged/");
doTest(fileName);
}
}

View File

@@ -122,12 +122,6 @@ public class IncrementalJvmCompilerRunnerTestGenerated extends AbstractIncrement
doTest(fileName);
}
@TestMetadata("classRedeclaration")
public void testClassRedeclaration() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/classRedeclaration/");
doTest(fileName);
}
@TestMetadata("classSignatureChanged")
public void testClassSignatureChanged() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/pureKotlin/classSignatureChanged/");
@@ -1363,6 +1357,12 @@ public class IncrementalJvmCompilerRunnerTestGenerated extends AbstractIncrement
doTest(fileName);
}
@TestMetadata("classRedeclaration")
public void testClassRedeclaration() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/withJava/other/classRedeclaration/");
doTest(fileName);
}
@TestMetadata("classToPackageFacade")
public void testClassToPackageFacade() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/withJava/other/classToPackageFacade/");

View File

@@ -0,0 +1,50 @@
/*
* 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.incremental;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
import org.jetbrains.kotlin.test.KotlinTestUtils;
import org.jetbrains.kotlin.test.TargetBackend;
import org.jetbrains.kotlin.test.TestMetadata;
import org.junit.runner.RunWith;
import java.io.File;
import java.util.regex.Pattern;
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("jps-plugin/testData/incremental/multiplatform")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public class IncrementalMultiplatformJsCompilerRunnerTestGenerated extends AbstractIncrementalMultiplatformJsCompilerRunnerTest {
public void testAllFilesPresentInMultiplatform() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("jps-plugin/testData/incremental/multiplatform"), Pattern.compile("^([^\\.]+)$"), TargetBackend.ANY, true);
}
@TestMetadata("touchActual")
public void testTouchActual() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/multiplatform/touchActual/");
doTest(fileName);
}
@TestMetadata("touchExpect")
public void testTouchExpect() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/multiplatform/touchExpect/");
doTest(fileName);
}
}

View File

@@ -0,0 +1,50 @@
/*
* 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.incremental;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
import org.jetbrains.kotlin.test.KotlinTestUtils;
import org.jetbrains.kotlin.test.TargetBackend;
import org.jetbrains.kotlin.test.TestMetadata;
import org.junit.runner.RunWith;
import java.io.File;
import java.util.regex.Pattern;
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("jps-plugin/testData/incremental/multiplatform")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public class IncrementalMultiplatformJvmCompilerRunnerTestGenerated extends AbstractIncrementalMultiplatformJvmCompilerRunnerTest {
public void testAllFilesPresentInMultiplatform() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("jps-plugin/testData/incremental/multiplatform"), Pattern.compile("^([^\\.]+)$"), TargetBackend.ANY, true);
}
@TestMetadata("touchActual")
public void testTouchActual() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/multiplatform/touchActual/");
doTest(fileName);
}
@TestMetadata("touchExpect")
public void testTouchExpect() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/multiplatform/touchExpect/");
doTest(fileName);
}
}

View File

@@ -127,10 +127,10 @@ object LightClassUtil {
return getPsiMethodWrappers(declaration).firstOrNull()
}
private fun getPsiMethodWrappers(declaration: KtDeclaration): Sequence<PsiMethod> {
return getWrappingClasses(declaration).flatMap { it.methods.asSequence() }
.filter { method -> method is KtLightMethod && method.kotlinOrigin === declaration }
}
private fun getPsiMethodWrappers(declaration: KtDeclaration): Sequence<KtLightMethod> =
getWrappingClasses(declaration).flatMap { it.methods.asSequence() }
.filterIsInstance<KtLightMethod>()
.filter { it.kotlinOrigin === declaration }
private fun getWrappingClass(declaration: KtDeclaration): PsiClass? {
var declaration = declaration
@@ -191,33 +191,19 @@ object LightClassUtil {
private fun extractPropertyAccessors(
ktDeclaration: KtDeclaration,
specialGetter: PsiMethod?, specialSetter: PsiMethod?): PropertyAccessorsPsiMethods {
var getterWrapper = specialGetter
var setterWrapper = specialSetter
val additionalAccessors = arrayListOf<PsiMethod>()
for (wrapper in getPsiMethodWrappers(ktDeclaration)) {
if (wrapper !is KtLightMethod) continue
if (wrapper.isSetter) {
if (setterWrapper == null || setterWrapper === specialSetter) {
setterWrapper = wrapper
}
else {
additionalAccessors.add(wrapper)
}
}
else {
if (getterWrapper == null || getterWrapper === specialGetter) {
getterWrapper = wrapper
}
else {
additionalAccessors.add(wrapper)
}
}
}
val (setters, getters) = getPsiMethodWrappers(ktDeclaration).partition { it.isSetter }
val allGetters = listOfNotNull(specialGetter) + getters.filterNot { it == specialGetter }
val allSetters = listOfNotNull(specialSetter) + setters.filterNot { it == specialSetter }
val backingField = getLightClassBackingField(ktDeclaration)
return PropertyAccessorsPsiMethods(getterWrapper, setterWrapper, backingField, additionalAccessors)
val additionalAccessors = allGetters.drop(1) + allSetters.drop(1)
return PropertyAccessorsPsiMethods(
allGetters.firstOrNull(),
allSetters.firstOrNull(),
backingField,
additionalAccessors
)
}
fun buildLightTypeParameterList(

View File

@@ -339,7 +339,7 @@ abstract class KtLightClassForSourceDeclaration(protected val classOrObject: KtC
.create(createNoCache(classOrObject), OUT_OF_CODE_BLOCK_MODIFICATION_COUNT)
}
private fun createNoCache(classOrObject: KtClassOrObject): KtLightClassForSourceDeclaration? {
fun createNoCache(classOrObject: KtClassOrObject): KtLightClassForSourceDeclaration? {
if (classOrObject.hasExpectModifier()) {
return null
}

View File

@@ -0,0 +1,20 @@
// FULL_JDK
// WITH_REFLECT
// IGNORE_BACKEND: JS, NATIVE
annotation class Anno(val value: String)
interface Test {
fun foo(@Anno("OK") a: String) = "123"
}
fun box(): String {
val testMethod = Class.forName("Test\$DefaultImpls").declaredMethods.single()
//return (::test.parameters.single().annotations.single() as Simple).value
val receiverAnnotations = (testMethod.parameters[0]).annotations
if (receiverAnnotations.isNotEmpty()) return "fail: receiver parameter should not have any annotations, but: ${receiverAnnotations.joinToString()}"
val value2 = ((testMethod.parameters[1]).annotations.single() as Anno).value
return value2
}

View File

@@ -0,0 +1,17 @@
// NO_CHECK_LAMBDA_INLINING
// FILE: 1.kt
package test
inline fun test(p: String, s: () -> () -> String = { { p } }) =
s()
val same = test("O")
// FILE: 2.kt
import test.*
fun box(): String {
val inlined = test("K")
return same() + inlined()
}

View File

@@ -0,0 +1,17 @@
// NO_CHECK_LAMBDA_INLINING
// FILE: 1.kt
package test
inline fun test(p: String, s: () -> () -> () -> String = { { { p } } }) =
s()
val same = test("O")
// FILE: 2.kt
import test.*
fun box(): String {
val inlined = test("K")
return same()() + inlined()()
}

View File

@@ -0,0 +1,24 @@
// NO_CHECK_LAMBDA_INLINING
// FILE: 1.kt
package test
interface Call {
fun run(): String
}
inline fun test(p: String, s: () -> Call = {
object : Call {
override fun run() = p
} as Call
}) = s()
val same = test("O")
// FILE: 2.kt
import test.*
fun box(): String {
val inlined = test("K")
return same.run() + inlined.run()
}

View File

@@ -0,0 +1,18 @@
// NO_CHECK_LAMBDA_INLINING
// FILE: 1.kt
package test
inline fun test(s: () -> () -> String = { { "OK" } }) =
s()
val same = test()
// FILE: 2.kt
import test.*
fun box(): String {
val inlined = test()
if (same() != "OK") return "fail 1: ${same()}"
return inlined()
}

View File

@@ -0,0 +1,18 @@
// NO_CHECK_LAMBDA_INLINING
// FILE: 1.kt
package test
inline fun test(s: () -> () -> () -> String = { { { "OK" } } }) =
s()
val same = test()
// FILE: 2.kt
import test.*
fun box(): String {
val inlined = test()
if (same()() != "OK") return "fail 1: ${same()()}"
return inlined()()
}

View File

@@ -0,0 +1,25 @@
// NO_CHECK_LAMBDA_INLINING
// FILE: 1.kt
package test
interface Call {
fun run(): String
}
inline fun test(s: () -> Call = {
object : Call {
override fun run() = "OK"
} as Call
}) = s()
val same = test()
// FILE: 2.kt
import test.*
fun box(): String {
val inlined = test()
if (same.run() != "OK") return "fail 1: ${same.run()}"
return inlined.run()
}

View File

@@ -0,0 +1,15 @@
// FILE: 1.kt
// SKIP_INLINE_CHECK_IN: bar$default
package test
inline fun bar(f: () -> String = { "OK" }) = f()
// FILE: 2.kt
import test.*
// SKIP_INLINE_CHECK_IN: foo$default
inline fun foo(f: () -> String = { bar() }) = f()
fun box(): String {
return foo()
}

View File

@@ -0,0 +1,17 @@
// NO_CHECK_LAMBDA_INLINING
// FILE: 1.kt
package test
inline fun <T> test(p: T, s: () -> () -> T = { { p } }) =
s()
val same = test("O")
// FILE: 2.kt
import test.*
fun box(): String {
val inlined = test("K")
return same() + inlined()
}

View File

@@ -0,0 +1,42 @@
// FILE: 1.kt
// SKIP_INLINE_CHECK_IN: lParams$default
package test
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
inline fun lParams(initParams: () -> String = { "OK" }): String {
return initParams()
}
// FILE: 2.kt
import test.*
fun box(): String {
return run {
lParams()
}
}

View File

@@ -0,0 +1,202 @@
// FILE: 1.kt
// SKIP_INLINE_CHECK_IN: lParams$default
package test
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
inline fun kValue(crossinline s: () -> String) = { s() + "K" }()
inline fun lParams(initParams: () -> String = {
{ "" + kValue { "O" } }()
}): String {
val z = "body"
return initParams()
}
// FILE: 2.kt
import test.*
fun box(): String {
return lParams()
}
// FILE: 1.smap
SMAP
1.kt
Kotlin
*S Kotlin
*F
+ 1 1.kt
test/_1Kt
*L
1#1,38:1
34#1,2:39
*E
SMAP
1.kt
Kotlin
*S Kotlin
*F
+ 1 1.kt
test/_1Kt$lParams$1
*L
1#1,38:1
*E
SMAP
1.kt
Kotlin
*S Kotlin
*F
+ 1 1.kt
test/_1Kt$lParams$1$1
+ 2 1.kt
test/_1Kt
*L
1#1,38:1
29#2:39
*E
*S KotlinDebug
*F
+ 1 1.kt
test/_1Kt$lParams$1$1
*L
32#1:39
*E
SMAP
1.kt
Kotlin
*S Kotlin
*F
+ 1 1.kt
test/_1Kt$kValue$1
+ 2 1.kt
test/_1Kt$lParams$1$1
*L
1#1,38:1
32#2:39
*E
SMAP
1.kt
Kotlin
*S Kotlin
*F
+ 1 1.kt
test/_1Kt$kValue$1
*L
1#1,38:1
*E
// FILE: 2.smap-nonseparate-compilation
SMAP
2.kt
Kotlin
*S Kotlin
*F
+ 1 2.kt
_2Kt
+ 2 1.kt
test/_1Kt
+ 3 1.kt
test/_1Kt$lParams$1
*L
1#1,8:1
31#2,5:9
32#3:14
*E
*S KotlinDebug
*F
+ 1 2.kt
_2Kt
*L
5#1,5:9
5#1:14
*E
// FILE: 2.smap-separate-compilation
SMAP
2.kt
Kotlin
*S Kotlin
*F
+ 1 2.kt
_2Kt
+ 2 1.kt
test/_1Kt
+ 3 1.kt
test/_1Kt$lParams$1
*L
1#1,8:1
31#2,5:9
32#3:14
*E
*S KotlinDebug
*F
+ 1 2.kt
_2Kt
*L
5#1,5:9
5#1:14
*E
SMAP
1.kt
Kotlin
*S Kotlin
*F
+ 1 1.kt
test/_1Kt$lParams$1$1
+ 2 1.kt
test/_1Kt
*L
1#1,38:1
29#2:39
*E
*S KotlinDebug
*F
+ 1 1.kt
test/_1Kt$lParams$1$1
*L
32#1:39
*E
SMAP
1.kt
Kotlin
*S Kotlin
*F
+ 1 1.kt
test/_1Kt$kValue$1
+ 2 1.kt
test/_1Kt$lParams$1$1
*L
1#1,38:1
32#2:39
*E

View File

@@ -0,0 +1,108 @@
// FILE: 1.kt
// SKIP_INLINE_CHECK_IN: lParams$default
package test
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
inline fun kValue() = "K"
inline fun lParams(initParams: () -> String = {
"O" + kValue()
}): String {
val z = "body"
return initParams()
}
// FILE: 2.kt
import test.*
fun box(): String {
return run {
lParams()
}
}
// FILE: 1.smap
SMAP
1.kt
Kotlin
*S Kotlin
*F
+ 1 1.kt
test/_1Kt
*L
1#1,38:1
34#1,2:39
*E
SMAP
1.kt
Kotlin
*S Kotlin
*F
+ 1 1.kt
test/_1Kt$lParams$1
+ 2 1.kt
test/_1Kt
*L
1#1,38:1
29#2:39
*E
*S KotlinDebug
*F
+ 1 1.kt
test/_1Kt$lParams$1
*L
32#1:39
*E
// FILE: 2.smap
SMAP
2.kt
Kotlin
*S Kotlin
*F
+ 1 2.kt
_2Kt
+ 2 1.kt
test/_1Kt
+ 3 1.kt
test/_1Kt$lParams$1
*L
1#1,10:1
31#2,5:11
29#2:17
32#3:16
*E
*S KotlinDebug
*F
+ 1 2.kt
_2Kt
*L
5#1,5:11
5#1:17
5#1:16
*E

View File

@@ -0,0 +1,148 @@
// FILE: 1.kt
// SKIP_INLINE_CHECK_IN: lParams$default
package test
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
inline fun kValue() = "K"
inline fun lParams(initParams: () -> String = {
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
"O" + kValue()
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
}): String {
val z = "body"
return initParams()
}
// FILE: 2.kt
import test.*
fun box(): String {
return run {
lParams()
}
}
// FILE: 1.smap
SMAP
1.kt
Kotlin
*S Kotlin
*F
+ 1 1.kt
test/_1Kt
*L
1#1,74:1
70#1,2:75
*E
SMAP
1.kt
Kotlin
*S Kotlin
*F
+ 1 1.kt
test/_1Kt$lParams$1
+ 2 1.kt
test/_1Kt
*L
1#1,74:1
29#2:75
*E
*S KotlinDebug
*F
+ 1 1.kt
test/_1Kt$lParams$1
*L
50#1:75
*E
// FILE: 2.smap
SMAP
2.kt
Kotlin
*S Kotlin
*F
+ 1 2.kt
_2Kt
+ 2 1.kt
test/_1Kt
+ 3 1.kt
test/_1Kt$lParams$1
*L
1#1,10:1
31#2:11
70#2,2:12
29#2:15
50#3:14
68#3:16
*E
*S KotlinDebug
*F
+ 1 2.kt
_2Kt
*L
5#1:11
5#1,2:12
5#1:15
5#1:14
5#1:16
*E

View File

@@ -0,0 +1,174 @@
// FILE: 1.kt
// SKIP_INLINE_CHECK_IN: lParams$default
package test
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
inline fun kValue(crossinline s: () -> String) = { s() + "K" }()
inline fun lParams(initParams: () -> String = {
"" + kValue { "O" }
}): String {
val z = "body"
return initParams()
}
// FILE: 2.kt
import test.*
fun box(): String {
return lParams()
}
// FILE: 1.smap
SMAP
1.kt
Kotlin
*S Kotlin
*F
+ 1 1.kt
test/_1Kt
*L
1#1,38:1
34#1,2:39
*E
SMAP
1.kt
Kotlin
*S Kotlin
*F
+ 1 1.kt
test/_1Kt$lParams$1
+ 2 1.kt
test/_1Kt
*L
1#1,38:1
29#2:39
*E
*S KotlinDebug
*F
+ 1 1.kt
test/_1Kt$lParams$1
*L
32#1:39
*E
SMAP
1.kt
Kotlin
*S Kotlin
*F
+ 1 1.kt
test/_1Kt$kValue$1
+ 2 1.kt
test/_1Kt$lParams$1
*L
1#1,38:1
32#2:39
*E
SMAP
1.kt
Kotlin
*S Kotlin
*F
+ 1 1.kt
test/_1Kt$kValue$1
*L
1#1,38:1
*E
// FILE: 2.smap-nonseparate-compilation
SMAP
2.kt
Kotlin
*S Kotlin
*F
+ 1 2.kt
_2Kt
+ 2 1.kt
test/_1Kt
+ 3 1.kt
test/_1Kt$lParams$1
*L
1#1,8:1
31#2,5:9
29#2:15
32#3:14
*E
*S KotlinDebug
*F
+ 1 2.kt
_2Kt
*L
5#1,5:9
5#1:15
5#1:14
*E
// FILE: 2.smap-separate-compilation
SMAP
2.kt
Kotlin
*S Kotlin
*F
+ 1 2.kt
_2Kt
+ 2 1.kt
test/_1Kt
+ 3 1.kt
test/_1Kt$lParams$1
*L
1#1,8:1
31#2,5:9
29#2:15
32#3:14
*E
*S KotlinDebug
*F
+ 1 2.kt
_2Kt
*L
5#1,5:9
5#1:15
5#1:14
*E
SMAP
1.kt
Kotlin
*S Kotlin
*F
+ 1 1.kt
test/_1Kt$kValue$1
+ 2 1.kt
test/_1Kt$lParams$1
*L
1#1,38:1
32#2:39
*E

View File

@@ -0,0 +1,175 @@
// FILE: 1.kt
// SKIP_INLINE_CHECK_IN: lParams$default
package test
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
inline fun kValue(crossinline s: () -> String) = { s() + "K" }()
inline fun lParams(initParams: () -> String = {
"" + kValue { "O" }
}): String {
val z = "body"
return initParams()
}
// FILE: 2.kt
import test.*
fun box(): String {
return run {
lParams()
}
}
// FILE: 1.smap
SMAP
1.kt
Kotlin
*S Kotlin
*F
+ 1 1.kt
test/_1Kt
*L
1#1,38:1
34#1,2:39
*E
SMAP
1.kt
Kotlin
*S Kotlin
*F
+ 1 1.kt
test/_1Kt$lParams$1
+ 2 1.kt
test/_1Kt
*L
1#1,38:1
29#2:39
*E
*S KotlinDebug
*F
+ 1 1.kt
test/_1Kt$lParams$1
*L
32#1:39
*E
SMAP
1.kt
Kotlin
*S Kotlin
*F
+ 1 1.kt
test/_1Kt$kValue$1
+ 2 1.kt
test/_1Kt$lParams$1
*L
1#1,38:1
32#2:39
*E
SMAP
1.kt
Kotlin
*S Kotlin
*F
+ 1 1.kt
test/_1Kt$kValue$1
*L
1#1,38:1
*E
// FILE: 2.smap-nonseparate-compilation
SMAP
2.kt
Kotlin
*S Kotlin
*F
+ 1 2.kt
_2Kt
+ 2 1.kt
test/_1Kt
+ 3 1.kt
test/_1Kt$lParams$1
*L
1#1,10:1
31#2,5:11
29#2:17
32#3:16
*E
*S KotlinDebug
*F
+ 1 2.kt
_2Kt
*L
5#1,5:11
5#1:17
5#1:16
*E
// FILE: 2.smap-separate-compilation
SMAP
2.kt
Kotlin
*S Kotlin
*F
+ 1 2.kt
_2Kt
+ 2 1.kt
test/_1Kt
+ 3 1.kt
test/_1Kt$lParams$1
*L
1#1,10:1
31#2,5:11
29#2:17
32#3:16
*E
*S KotlinDebug
*F
+ 1 2.kt
_2Kt
*L
5#1,5:11
5#1:17
5#1:16
*E
SMAP
1.kt
Kotlin
*S Kotlin
*F
+ 1 1.kt
test/_1Kt$kValue$1
+ 2 1.kt
test/_1Kt$lParams$1
*L
1#1,38:1
32#2:39
*E

View File

@@ -0,0 +1,95 @@
// FILE: 1.kt
// SKIP_INLINE_CHECK_IN: lParams$default
package test
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
inline fun lParams(initParams: () -> String = {
"OK"
}): String {
val z = "body"
return initParams()
}
// FILE: 2.kt
import test.*
fun box(): String {
return run {
lParams()
}
}
// FILE: 1.smap
SMAP
1.kt
Kotlin
*S Kotlin
*F
+ 1 1.kt
test/_1Kt
*L
1#1,37:1
33#1,2:38
*E
SMAP
1.kt
Kotlin
*S Kotlin
*F
+ 1 1.kt
test/_1Kt$lParams$1
*L
1#1,37:1
*E
// FILE: 2.smap
SMAP
2.kt
Kotlin
*S Kotlin
*F
+ 1 2.kt
_2Kt
+ 2 1.kt
test/_1Kt
+ 3 1.kt
test/_1Kt$lParams$1
*L
1#1,10:1
30#2,5:11
31#3:16
*E
*S KotlinDebug
*F
+ 1 2.kt
_2Kt
*L
5#1,5:11
5#1:16
*E

View File

@@ -51,9 +51,12 @@ Kotlin
_2Kt
+ 2 1.kt
test/_1Kt
+ 3 1.kt
test/_1Kt$inlineFun$1
*L
1#1,9:1
6#2,2:10
6#3:12
*E
*S KotlinDebug
*F
@@ -61,4 +64,5 @@ test/_1Kt
_2Kt
*L
6#1,2:10
6#1:12
*E

View File

@@ -0,0 +1,93 @@
// FILE: 1.kt
// SKIP_INLINE_CHECK_IN: lParams$default
package test
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
//A lot of blank lines [Don't delete]
inline fun lParams(initParams: () -> String = {
"OK"
}): String {
val z = "body"
return initParams()
}
// FILE: 2.kt
import test.*
fun box(): String {
return lParams()
}
// FILE: 1.smap
SMAP
1.kt
Kotlin
*S Kotlin
*F
+ 1 1.kt
test/_1Kt
*L
1#1,37:1
33#1,2:38
*E
SMAP
1.kt
Kotlin
*S Kotlin
*F
+ 1 1.kt
test/_1Kt$lParams$1
*L
1#1,37:1
*E
// FILE: 2.smap
SMAP
2.kt
Kotlin
*S Kotlin
*F
+ 1 2.kt
_2Kt
+ 2 1.kt
test/_1Kt
+ 3 1.kt
test/_1Kt$lParams$1
*L
1#1,8:1
30#2,5:9
31#3:14
*E
*S KotlinDebug
*F
+ 1 2.kt
_2Kt
*L
5#1,5:9
5#1:14
*E

View File

@@ -0,0 +1,19 @@
// WITH_RUNTIME
// FULL_JDK
// KOTLIN_CONFIGURATION_FLAGS: +JVM.PARAMETERS_METADATA
interface Test {
fun test(OK: String) = "123"
}
fun box(): String {
val testMethod = Class.forName("Test\$DefaultImpls").declaredMethods.single()
val parameters = testMethod.getParameters()
if (!parameters[0].isSynthetic()) return "wrong modifier on receiver parameter: ${parameters[0].modifiers}"
if (parameters[1].modifiers != 0) return "wrong modifier on value parameter: ${parameters[1].modifiers}"
return parameters[1].name
}

View File

@@ -0,0 +1,20 @@
// TARGET_BACKEND: JVM
// FILE: A.kt
package test
inline fun test(s: () -> () -> String = { val z = "Outer"; { "OK" } }) =
s()
val same = test()
// FILE: B.kt
import test.*
fun box(): String {
val inlined = test()
if (same::class.java == inlined::class.java) return "fail 1 : ${same::class.java} == ${inlined::class.java}"
println (inlined::class.java)
return inlined()
}

View File

@@ -0,0 +1,20 @@
// TARGET_BACKEND: JVM
// FILE: A.kt
package test
inline fun test(s: () -> () -> () -> String = { val z = "Outer"; { { "OK" } } }) =
s()
val same = test()
// FILE: B.kt
import test.*
fun box(): String {
val inlined = test()
if (same::class.java == inlined::class.java) return "fail 1 : ${same::class.java} == ${inlined::class.java}"
if (same()::class.java == inlined()::class.java) return "fail 2 : ${same()::class.java} == ${inlined()::class.java}"
return inlined()()
}

View File

@@ -0,0 +1,33 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER
// FILE: A.java
import org.checkerframework.checker.nullness.compatqual.*;
public class A {
@NullableDecl public String field = null;
@NullableDecl
public String foo(@NonNullDecl String x, @NullableDecl CharSequence y) {
return "";
}
@NonNullDecl
public String bar() {
return "";
}
}
// FILE: main.kt
fun main(a: A) {
a.foo("", null)?.length
a.foo("", null)<!UNSAFE_CALL!>.<!>length
a.foo(<!NULL_FOR_NONNULL_TYPE!>null<!>, "")<!UNSAFE_CALL!>.<!>length
a.bar().length
a.bar()<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.length
a.field?.length
a.field<!UNSAFE_CALL!>.<!>length
}

View File

@@ -0,0 +1,13 @@
package
public fun main(/*0*/ a: A): kotlin.Unit
public open class A {
public constructor A()
@org.checkerframework.checker.nullness.compatqual.NullableDecl public final var field: kotlin.String?
@org.checkerframework.checker.nullness.compatqual.NonNullDecl public open fun bar(): kotlin.String
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
@org.checkerframework.checker.nullness.compatqual.NullableDecl public open fun foo(/*0*/ @org.checkerframework.checker.nullness.compatqual.NonNullDecl x: kotlin.String, /*1*/ @org.checkerframework.checker.nullness.compatqual.NullableDecl y: kotlin.CharSequence?): kotlin.String?
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}

View File

@@ -41,6 +41,7 @@ import org.jetbrains.kotlin.diagnostics.DiagnosticUtils
import org.jetbrains.kotlin.diagnostics.Errors.*
import org.jetbrains.kotlin.frontend.java.di.createContainerForTopDownAnalyzerForJvm
import org.jetbrains.kotlin.frontend.java.di.initJvmBuiltInsForTopDownAnalysis
import org.jetbrains.kotlin.incremental.components.ExpectActualTracker
import org.jetbrains.kotlin.incremental.components.LookupTracker
import org.jetbrains.kotlin.load.java.lazy.SingleModuleClassResolver
import org.jetbrains.kotlin.name.FqName
@@ -322,6 +323,7 @@ abstract class AbstractDiagnosticsTest : BaseDiagnosticsTest() {
FileBasedDeclarationProviderFactory(moduleContext.storageManager, files),
moduleContentScope,
LookupTracker.DO_NOTHING,
ExpectActualTracker.DoNothing,
environment.createPackagePartProvider(moduleContentScope),
moduleClassResolver,
JvmTarget.JVM_1_6,

View File

@@ -23,7 +23,7 @@ abstract class AbstractBlackBoxInlineCodegenTest : AbstractBlackBoxCodegenTest()
super.doMultiFileTest(wholeFile, files, javaFilesDir)
try {
InlineTestUtil.checkNoCallsToInline(initializedClassLoader.allGeneratedFiles.filterClassFiles(), myFiles.psiFiles)
SMAPTestUtil.checkSMAP(files, generateClassesInFile().getClassFiles())
SMAPTestUtil.checkSMAP(files, generateClassesInFile().getClassFiles(), false)
}
catch (e: Throwable) {
println(generateToText())

View File

@@ -25,7 +25,7 @@ abstract class AbstractCompileKotlinAgainstInlineKotlinTest : AbstractCompileKot
val allGeneratedFiles = factory1.asList() + factory2.asList()
val sourceFiles = factory1.inputFiles + factory2.inputFiles
InlineTestUtil.checkNoCallsToInline(allGeneratedFiles.filterClassFiles(), sourceFiles)
SMAPTestUtil.checkSMAP(files, allGeneratedFiles.filterClassFiles())
SMAPTestUtil.checkSMAP(files, allGeneratedFiles.filterClassFiles(), true)
}
catch (e: Throwable) {
println("FIRST:\n\n${factory1.createText()}\n\nSECOND:\n\n${factory2.createText()}")

View File

@@ -45,8 +45,8 @@ object SMAPTestUtil {
}
}
private fun extractSmapFromTestDataFile(file: CodegenTestCase.TestFile): SMAPAndFile? {
if (!file.name.endsWith(".smap")) return null
private fun extractSmapFromTestDataFile(file: CodegenTestCase.TestFile, separateCompilation: Boolean): SMAPAndFile? {
if (!checkExtension(file, separateCompilation)) return null
val content = buildString {
StringReader(file.content).forEachLine { line ->
@@ -60,10 +60,13 @@ object SMAPTestUtil {
return SMAPAndFile(if (content.isNotEmpty()) content else null, SMAPAndFile.getPath(file.name), "NOT_SORTED")
}
fun checkSMAP(inputFiles: List<CodegenTestCase.TestFile>, outputFiles: Iterable<OutputFile>) {
private fun checkExtension(file: CodegenTestCase.TestFile, separateCompilation: Boolean) =
file.name.run { endsWith(".smap") || if (separateCompilation) endsWith(".smap-separate-compilation") else endsWith(".smap-nonseparate-compilation") }
fun checkSMAP(inputFiles: List<CodegenTestCase.TestFile>, outputFiles: Iterable<OutputFile>, separateCompilation: Boolean) {
if (!GENERATE_SMAP) return
val sourceData = inputFiles.mapNotNull { extractSmapFromTestDataFile(it) }
val sourceData = inputFiles.mapNotNull { extractSmapFromTestDataFile(it, separateCompilation) }
val compiledSmaps = extractSMAPFromClasses(outputFiles)
val compiledData = compiledSmaps.groupBy {
it.sourceFile
@@ -73,7 +76,10 @@ object SMAPTestUtil {
}.associateBy { it.sourceFile }
for (source in sourceData) {
val ktFileName = "/" + source.sourceFile.replace(".smap", ".kt")
val ktFileName = "/" + source.sourceFile.
replace(".smap-nonseparate-compilation", ".kt").
replace(".smap-separate-compilation", ".kt").
replace(".smap", ".kt")
val data = compiledData[ktFileName]
Assert.assertEquals("Smap data differs for $ktFileName", normalize(source.smap), normalize(data?.smap))
}

View File

@@ -128,6 +128,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
doTest(fileName);
}
@TestMetadata("parameterAnnotationInDefaultImpls.kt")
public void testParameterAnnotationInDefaultImpls() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/annotations/parameterAnnotationInDefaultImpls.kt");
doTest(fileName);
}
@TestMetadata("parameterWithPrimitiveType.kt")
public void testParameterWithPrimitiveType() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/annotations/parameterWithPrimitiveType.kt");

View File

@@ -1147,12 +1147,60 @@ public class IrBlackBoxInlineCodegenTestGenerated extends AbstractIrBlackBoxInli
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("checkLambdaClassIsPresent.kt")
public void testCheckLambdaClassIsPresent() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/checkLambdaClassIsPresent.kt");
doTest(fileName);
}
@TestMetadata("checkLambdaClassesArePresent.kt")
public void testCheckLambdaClassesArePresent() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/checkLambdaClassesArePresent.kt");
doTest(fileName);
}
@TestMetadata("checkObjectClassIsPresent.kt")
public void testCheckObjectClassIsPresent() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/checkObjectClassIsPresent.kt");
doTest(fileName);
}
@TestMetadata("checkStaticLambdaClassIsPresent.kt")
public void testCheckStaticLambdaClassIsPresent() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/checkStaticLambdaClassIsPresent.kt");
doTest(fileName);
}
@TestMetadata("checkStaticLambdaClassesArePresent.kt")
public void testCheckStaticLambdaClassesArePresent() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/checkStaticLambdaClassesArePresent.kt");
doTest(fileName);
}
@TestMetadata("checkStaticObjectClassIsPresent.kt")
public void testCheckStaticObjectClassIsPresent() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/checkStaticObjectClassIsPresent.kt");
doTest(fileName);
}
@TestMetadata("defaultCallInDefaultLambda.kt")
public void testDefaultCallInDefaultLambda() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/defaultCallInDefaultLambda.kt");
doTest(fileName);
}
@TestMetadata("defaultLambdaInNoInline.kt")
public void testDefaultLambdaInNoInline() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/defaultLambdaInNoInline.kt");
doTest(fileName);
}
@TestMetadata("genericLambda.kt")
public void testGenericLambda() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/genericLambda.kt");
doTest(fileName);
}
@TestMetadata("instanceCapuredInClass.kt")
public void testInstanceCapuredInClass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/instanceCapuredInClass.kt");
@@ -1171,6 +1219,12 @@ public class IrBlackBoxInlineCodegenTestGenerated extends AbstractIrBlackBoxInli
doTest(fileName);
}
@TestMetadata("kt21827.kt")
public void testKt21827() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/kt21827.kt");
doTest(fileName);
}
@TestMetadata("noInline.kt")
public void testNoInline() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/noInline.kt");
@@ -2974,6 +3028,42 @@ public class IrBlackBoxInlineCodegenTestGenerated extends AbstractIrBlackBoxInli
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/smap/defaultLambda"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("defaultLambdaInAnonymous.kt")
public void testDefaultLambdaInAnonymous() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/defaultLambda/defaultLambdaInAnonymous.kt");
doTest(fileName);
}
@TestMetadata("inlinInDefault.kt")
public void testInlinInDefault() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/defaultLambda/inlinInDefault.kt");
doTest(fileName);
}
@TestMetadata("inlinInDefault2.kt")
public void testInlinInDefault2() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/defaultLambda/inlinInDefault2.kt");
doTest(fileName);
}
@TestMetadata("inlineAnonymousInDefault.kt")
public void testInlineAnonymousInDefault() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/defaultLambda/inlineAnonymousInDefault.kt");
doTest(fileName);
}
@TestMetadata("inlineAnonymousInDefault2.kt")
public void testInlineAnonymousInDefault2() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/defaultLambda/inlineAnonymousInDefault2.kt");
doTest(fileName);
}
@TestMetadata("kt21827.kt")
public void testKt21827() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/defaultLambda/kt21827.kt");
doTest(fileName);
}
@TestMetadata("nested.kt")
public void testNested() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/defaultLambda/nested.kt");
@@ -2985,6 +3075,12 @@ public class IrBlackBoxInlineCodegenTestGenerated extends AbstractIrBlackBoxInli
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/defaultLambda/simple.kt");
doTest(fileName);
}
@TestMetadata("simple2.kt")
public void testSimple2() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/defaultLambda/simple2.kt");
doTest(fileName);
}
}
@TestMetadata("compiler/testData/codegen/boxInline/smap/inlineOnly")

View File

@@ -1147,12 +1147,60 @@ public class IrCompileKotlinAgainstInlineKotlinTestGenerated extends AbstractIrC
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("checkLambdaClassIsPresent.kt")
public void testCheckLambdaClassIsPresent() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/checkLambdaClassIsPresent.kt");
doTest(fileName);
}
@TestMetadata("checkLambdaClassesArePresent.kt")
public void testCheckLambdaClassesArePresent() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/checkLambdaClassesArePresent.kt");
doTest(fileName);
}
@TestMetadata("checkObjectClassIsPresent.kt")
public void testCheckObjectClassIsPresent() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/checkObjectClassIsPresent.kt");
doTest(fileName);
}
@TestMetadata("checkStaticLambdaClassIsPresent.kt")
public void testCheckStaticLambdaClassIsPresent() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/checkStaticLambdaClassIsPresent.kt");
doTest(fileName);
}
@TestMetadata("checkStaticLambdaClassesArePresent.kt")
public void testCheckStaticLambdaClassesArePresent() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/checkStaticLambdaClassesArePresent.kt");
doTest(fileName);
}
@TestMetadata("checkStaticObjectClassIsPresent.kt")
public void testCheckStaticObjectClassIsPresent() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/checkStaticObjectClassIsPresent.kt");
doTest(fileName);
}
@TestMetadata("defaultCallInDefaultLambda.kt")
public void testDefaultCallInDefaultLambda() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/defaultCallInDefaultLambda.kt");
doTest(fileName);
}
@TestMetadata("defaultLambdaInNoInline.kt")
public void testDefaultLambdaInNoInline() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/defaultLambdaInNoInline.kt");
doTest(fileName);
}
@TestMetadata("genericLambda.kt")
public void testGenericLambda() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/genericLambda.kt");
doTest(fileName);
}
@TestMetadata("instanceCapuredInClass.kt")
public void testInstanceCapuredInClass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/instanceCapuredInClass.kt");
@@ -1171,6 +1219,12 @@ public class IrCompileKotlinAgainstInlineKotlinTestGenerated extends AbstractIrC
doTest(fileName);
}
@TestMetadata("kt21827.kt")
public void testKt21827() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/kt21827.kt");
doTest(fileName);
}
@TestMetadata("noInline.kt")
public void testNoInline() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/noInline.kt");
@@ -2974,6 +3028,42 @@ public class IrCompileKotlinAgainstInlineKotlinTestGenerated extends AbstractIrC
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/smap/defaultLambda"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("defaultLambdaInAnonymous.kt")
public void testDefaultLambdaInAnonymous() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/defaultLambda/defaultLambdaInAnonymous.kt");
doTest(fileName);
}
@TestMetadata("inlinInDefault.kt")
public void testInlinInDefault() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/defaultLambda/inlinInDefault.kt");
doTest(fileName);
}
@TestMetadata("inlinInDefault2.kt")
public void testInlinInDefault2() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/defaultLambda/inlinInDefault2.kt");
doTest(fileName);
}
@TestMetadata("inlineAnonymousInDefault.kt")
public void testInlineAnonymousInDefault() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/defaultLambda/inlineAnonymousInDefault.kt");
doTest(fileName);
}
@TestMetadata("inlineAnonymousInDefault2.kt")
public void testInlineAnonymousInDefault2() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/defaultLambda/inlineAnonymousInDefault2.kt");
doTest(fileName);
}
@TestMetadata("kt21827.kt")
public void testKt21827() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/defaultLambda/kt21827.kt");
doTest(fileName);
}
@TestMetadata("nested.kt")
public void testNested() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/defaultLambda/nested.kt");
@@ -2985,6 +3075,12 @@ public class IrCompileKotlinAgainstInlineKotlinTestGenerated extends AbstractIrC
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/defaultLambda/simple.kt");
doTest(fileName);
}
@TestMetadata("simple2.kt")
public void testSimple2() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/defaultLambda/simple2.kt");
doTest(fileName);
}
}
@TestMetadata("compiler/testData/codegen/boxInline/smap/inlineOnly")

View File

@@ -578,6 +578,12 @@ public class BlackBoxWithJava8CodegenTestGenerated extends AbstractBlackBoxCodeg
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/java8/box/parametersMetadata"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("defaultImpls.kt")
public void testDefaultImpls() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/java8/box/parametersMetadata/defaultImpls.kt");
doTest(fileName);
}
@TestMetadata("enum.kt")
public void testEnum() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/java8/box/parametersMetadata/enum.kt");

View File

@@ -48,6 +48,12 @@ public class ForeignAnnotationsNoAnnotationInClasspathTestGenerated extends Abst
doTest(fileName);
}
@TestMetadata("checkerFramework.kt")
public void testCheckerFramework() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/checkerFramework.kt");
doTest(fileName);
}
@TestMetadata("eclipse.kt")
public void testEclipse() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/eclipse.kt");

View File

@@ -48,6 +48,12 @@ public class ForeignAnnotationsNoAnnotationInClasspathWithFastClassReadingTestGe
doTest(fileName);
}
@TestMetadata("checkerFramework.kt")
public void testCheckerFramework() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/checkerFramework.kt");
doTest(fileName);
}
@TestMetadata("eclipse.kt")
public void testEclipse() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/eclipse.kt");

View File

@@ -48,6 +48,12 @@ public class ForeignAnnotationsTestGenerated extends AbstractForeignAnnotationsT
doTest(fileName);
}
@TestMetadata("checkerFramework.kt")
public void testCheckerFramework() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/checkerFramework.kt");
doTest(fileName);
}
@TestMetadata("eclipse.kt")
public void testEclipse() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/eclipse.kt");

View File

@@ -48,6 +48,12 @@ public class JavacForeignAnnotationsTestGenerated extends AbstractJavacForeignAn
doTest(fileName);
}
@TestMetadata("checkerFramework.kt")
public void testCheckerFramework() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/checkerFramework.kt");
doTest(fileName);
}
@TestMetadata("eclipse.kt")
public void testEclipse() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotations/tests/eclipse.kt");

View File

@@ -128,6 +128,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
doTest(fileName);
}
@TestMetadata("parameterAnnotationInDefaultImpls.kt")
public void testParameterAnnotationInDefaultImpls() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/annotations/parameterAnnotationInDefaultImpls.kt");
doTest(fileName);
}
@TestMetadata("parameterWithPrimitiveType.kt")
public void testParameterWithPrimitiveType() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/annotations/parameterWithPrimitiveType.kt");

View File

@@ -1147,12 +1147,60 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("checkLambdaClassIsPresent.kt")
public void testCheckLambdaClassIsPresent() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/checkLambdaClassIsPresent.kt");
doTest(fileName);
}
@TestMetadata("checkLambdaClassesArePresent.kt")
public void testCheckLambdaClassesArePresent() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/checkLambdaClassesArePresent.kt");
doTest(fileName);
}
@TestMetadata("checkObjectClassIsPresent.kt")
public void testCheckObjectClassIsPresent() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/checkObjectClassIsPresent.kt");
doTest(fileName);
}
@TestMetadata("checkStaticLambdaClassIsPresent.kt")
public void testCheckStaticLambdaClassIsPresent() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/checkStaticLambdaClassIsPresent.kt");
doTest(fileName);
}
@TestMetadata("checkStaticLambdaClassesArePresent.kt")
public void testCheckStaticLambdaClassesArePresent() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/checkStaticLambdaClassesArePresent.kt");
doTest(fileName);
}
@TestMetadata("checkStaticObjectClassIsPresent.kt")
public void testCheckStaticObjectClassIsPresent() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/checkStaticObjectClassIsPresent.kt");
doTest(fileName);
}
@TestMetadata("defaultCallInDefaultLambda.kt")
public void testDefaultCallInDefaultLambda() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/defaultCallInDefaultLambda.kt");
doTest(fileName);
}
@TestMetadata("defaultLambdaInNoInline.kt")
public void testDefaultLambdaInNoInline() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/defaultLambdaInNoInline.kt");
doTest(fileName);
}
@TestMetadata("genericLambda.kt")
public void testGenericLambda() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/genericLambda.kt");
doTest(fileName);
}
@TestMetadata("instanceCapuredInClass.kt")
public void testInstanceCapuredInClass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/instanceCapuredInClass.kt");
@@ -1171,6 +1219,12 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo
doTest(fileName);
}
@TestMetadata("kt21827.kt")
public void testKt21827() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/kt21827.kt");
doTest(fileName);
}
@TestMetadata("noInline.kt")
public void testNoInline() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/noInline.kt");
@@ -2974,6 +3028,42 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/smap/defaultLambda"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("defaultLambdaInAnonymous.kt")
public void testDefaultLambdaInAnonymous() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/defaultLambda/defaultLambdaInAnonymous.kt");
doTest(fileName);
}
@TestMetadata("inlinInDefault.kt")
public void testInlinInDefault() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/defaultLambda/inlinInDefault.kt");
doTest(fileName);
}
@TestMetadata("inlinInDefault2.kt")
public void testInlinInDefault2() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/defaultLambda/inlinInDefault2.kt");
doTest(fileName);
}
@TestMetadata("inlineAnonymousInDefault.kt")
public void testInlineAnonymousInDefault() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/defaultLambda/inlineAnonymousInDefault.kt");
doTest(fileName);
}
@TestMetadata("inlineAnonymousInDefault2.kt")
public void testInlineAnonymousInDefault2() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/defaultLambda/inlineAnonymousInDefault2.kt");
doTest(fileName);
}
@TestMetadata("kt21827.kt")
public void testKt21827() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/defaultLambda/kt21827.kt");
doTest(fileName);
}
@TestMetadata("nested.kt")
public void testNested() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/defaultLambda/nested.kt");
@@ -2985,6 +3075,12 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/defaultLambda/simple.kt");
doTest(fileName);
}
@TestMetadata("simple2.kt")
public void testSimple2() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/defaultLambda/simple2.kt");
doTest(fileName);
}
}
@TestMetadata("compiler/testData/codegen/boxInline/smap/inlineOnly")

View File

@@ -1147,12 +1147,60 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("checkLambdaClassIsPresent.kt")
public void testCheckLambdaClassIsPresent() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/checkLambdaClassIsPresent.kt");
doTest(fileName);
}
@TestMetadata("checkLambdaClassesArePresent.kt")
public void testCheckLambdaClassesArePresent() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/checkLambdaClassesArePresent.kt");
doTest(fileName);
}
@TestMetadata("checkObjectClassIsPresent.kt")
public void testCheckObjectClassIsPresent() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/checkObjectClassIsPresent.kt");
doTest(fileName);
}
@TestMetadata("checkStaticLambdaClassIsPresent.kt")
public void testCheckStaticLambdaClassIsPresent() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/checkStaticLambdaClassIsPresent.kt");
doTest(fileName);
}
@TestMetadata("checkStaticLambdaClassesArePresent.kt")
public void testCheckStaticLambdaClassesArePresent() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/checkStaticLambdaClassesArePresent.kt");
doTest(fileName);
}
@TestMetadata("checkStaticObjectClassIsPresent.kt")
public void testCheckStaticObjectClassIsPresent() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/checkStaticObjectClassIsPresent.kt");
doTest(fileName);
}
@TestMetadata("defaultCallInDefaultLambda.kt")
public void testDefaultCallInDefaultLambda() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/defaultCallInDefaultLambda.kt");
doTest(fileName);
}
@TestMetadata("defaultLambdaInNoInline.kt")
public void testDefaultLambdaInNoInline() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/defaultLambdaInNoInline.kt");
doTest(fileName);
}
@TestMetadata("genericLambda.kt")
public void testGenericLambda() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/genericLambda.kt");
doTest(fileName);
}
@TestMetadata("instanceCapuredInClass.kt")
public void testInstanceCapuredInClass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/instanceCapuredInClass.kt");
@@ -1171,6 +1219,12 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi
doTest(fileName);
}
@TestMetadata("kt21827.kt")
public void testKt21827() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/kt21827.kt");
doTest(fileName);
}
@TestMetadata("noInline.kt")
public void testNoInline() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/defaultValues/lambdaInlining/noInline.kt");
@@ -2974,6 +3028,42 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxInline/smap/defaultLambda"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("defaultLambdaInAnonymous.kt")
public void testDefaultLambdaInAnonymous() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/defaultLambda/defaultLambdaInAnonymous.kt");
doTest(fileName);
}
@TestMetadata("inlinInDefault.kt")
public void testInlinInDefault() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/defaultLambda/inlinInDefault.kt");
doTest(fileName);
}
@TestMetadata("inlinInDefault2.kt")
public void testInlinInDefault2() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/defaultLambda/inlinInDefault2.kt");
doTest(fileName);
}
@TestMetadata("inlineAnonymousInDefault.kt")
public void testInlineAnonymousInDefault() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/defaultLambda/inlineAnonymousInDefault.kt");
doTest(fileName);
}
@TestMetadata("inlineAnonymousInDefault2.kt")
public void testInlineAnonymousInDefault2() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/defaultLambda/inlineAnonymousInDefault2.kt");
doTest(fileName);
}
@TestMetadata("kt21827.kt")
public void testKt21827() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/defaultLambda/kt21827.kt");
doTest(fileName);
}
@TestMetadata("nested.kt")
public void testNested() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/defaultLambda/nested.kt");
@@ -2985,6 +3075,12 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/defaultLambda/simple.kt");
doTest(fileName);
}
@TestMetadata("simple2.kt")
public void testSimple2() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxInline/smap/defaultLambda/simple2.kt");
doTest(fileName);
}
}
@TestMetadata("compiler/testData/codegen/boxInline/smap/inlineOnly")

View File

@@ -102,6 +102,18 @@ public class CompileKotlinAgainstKotlinTestGenerated extends AbstractCompileKotl
doTest(fileName);
}
@TestMetadata("defaultLambdaRegeneration.kt")
public void testDefaultLambdaRegeneration() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/compileKotlinAgainstKotlin/defaultLambdaRegeneration.kt");
doTest(fileName);
}
@TestMetadata("defaultLambdaRegeneration2.kt")
public void testDefaultLambdaRegeneration2() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/compileKotlinAgainstKotlin/defaultLambdaRegeneration2.kt");
doTest(fileName);
}
@TestMetadata("doublyNestedClass.kt")
public void testDoublyNestedClass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/compileKotlinAgainstKotlin/doublyNestedClass.kt");

View File

@@ -140,6 +140,12 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
doTest(fileName);
}
@TestMetadata("parameterAnnotationInDefaultImpls.kt")
public void testParameterAnnotationInDefaultImpls() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/annotations/parameterAnnotationInDefaultImpls.kt");
doTest(fileName);
}
@TestMetadata("parameterWithPrimitiveType.kt")
public void testParameterWithPrimitiveType() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/annotations/parameterWithPrimitiveType.kt");

View File

@@ -1,59 +0,0 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.utils;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.io.URLUtil;
import org.jetbrains.annotations.NotNull;
import java.net.MalformedURLException;
import java.net.URL;
/*
* This code is essentially copied from IntelliJ IDEA's VfsUtil, and slightly restructured
*/
public class KotlinVfsUtil {
private static final String FILE = "file";
private static final String JAR = "jar";
private static final String PROTOCOL_DELIMITER = ":";
@NotNull
public static String convertFromUrl(@NotNull URL url) throws MalformedURLException {
String protocol = url.getProtocol();
String path = url.getPath();
if (JAR.equals(protocol)) {
if (StringUtil.startsWithConcatenationOf(path, FILE, PROTOCOL_DELIMITER)) {
URL subURL = new URL(path);
path = subURL.getPath();
}
else {
throw new MalformedURLException("Can't parse url: " + url.toExternalForm());
}
}
if (SystemInfo.isWindows || SystemInfo.isOS2) {
while (path.length() > 0 && path.charAt(0) == '/') {
path = path.substring(1, path.length());
}
}
path = URLUtil.unescapePercentSequences(path);
return protocol + "://" + path;
}
private KotlinVfsUtil() {}
}

View File

@@ -24,6 +24,7 @@ val NULLABLE_ANNOTATIONS = listOf(
FqName("com.android.annotations.Nullable"),
FqName("org.eclipse.jdt.annotation.Nullable"),
FqName("org.checkerframework.checker.nullness.qual.Nullable"),
FqName("org.checkerframework.checker.nullness.compatqual.NullableDecl"),
FqName("javax.annotation.Nullable"),
FqName("javax.annotation.CheckForNull"),
FqName("edu.umd.cs.findbugs.annotations.CheckForNull"),
@@ -42,6 +43,7 @@ val NOT_NULL_ANNOTATIONS = listOf(
FqName("com.android.annotations.NonNull"),
FqName("org.eclipse.jdt.annotation.NonNull"),
FqName("org.checkerframework.checker.nullness.qual.NonNull"),
FqName("org.checkerframework.checker.nullness.compatqual.NonNullDecl"),
FqName("lombok.NonNull"),
FqName("io.reactivex.annotations.NonNull")
)

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