Compare commits

...

146 Commits

Author SHA1 Message Date
Ilya Matveev
be773a0565 Gradle, native: Support watchOS and tvOS in CocoaPods plugin
Issue #KT-34329 fixed
2019-10-22 16:07:04 +03:00
Leonid Startsev
8fb5ccc7cf Provide a diagnostic when @Serializable annotation is missing on enum.
It is required when enum members contain some special annotations which should be recorded in descriptor.
Due to some recursive/lazy resolve problems, compiler plugin frontend can't infer @Serializable on enum automatically, therefore, we ask a user to explicitly provide it.

Also fix ir tests
2019-10-22 14:57:44 +03:00
Leonid Startsev
b997f32834 Associate serializers added via @UseSerializers by argument class, not type
Use class instead of type because MyType<T> and MyType<Int> are different types, therefore map lookup was failing.

Fixes https://github.com/Kotlin/kotlinx.serialization/issues/533
2019-10-22 14:57:44 +03:00
Leonid Startsev
294617793a Support sealed, generic and abstract polymorphic inheritors in sealed class serialization 2019-10-22 14:57:44 +03:00
Leonid Startsev
23bcc3939f Sealed classes serialization 2019-10-22 14:57:44 +03:00
Leonid Startsev
133ad1090e Custom-serializable enums for IR 2019-10-22 14:57:44 +03:00
Leonid Startsev
62019adbfa Custom-serializable enums for JS 2019-10-22 14:57:43 +03:00
Leonid Startsev
bbc549742b Custom-serializable enums for JVM 2019-10-22 14:57:43 +03:00
Leonid Startsev
a3998d87fb Remove redundant additional check for @Polymorphic annotation 2019-10-22 14:57:43 +03:00
Leonid Startsev
026046e48c Object serialization for JVM, JS and Native 2019-10-22 14:57:43 +03:00
Ilya Goncharov
58221ca078 [Gradle, JS] Fix for wildcard npm dependency version
#KT-34460 fixed

(cherry picked from commit 6ddc05a5a8)
2019-10-22 14:39:37 +03:00
Ilya Goncharov
b8b251bff9 [Gradle, JS] Add test on success installation of duplicated dependencies
(cherry picked from commit e17b9097df)
2019-10-22 14:39:37 +03:00
Ilya Goncharov
1ba1660870 [Gradle, JS] Resolve devDependencies and dependencies modules clash
(cherry picked from commit bdd6186a07)
2019-10-22 14:39:36 +03:00
Andrey Uskov
2140a7c2be Fix actualisation of common source sets when HMPP is disabled
#KT-34256 Fixed
#KT-34402 Fixed

(cherry picked from commit 40bb48e19b)
2019-10-22 13:26:55 +03:00
Andrey Uskov
1277ceafb8 Do not build metadata dependency tree for platform source sets
(cherry picked from commit a60cbef5d2)
2019-10-22 13:26:50 +03:00
Andrey Uskov
8ab6c8cfac Do not create deep copy for MPP project is model is not a proxy
(cherry picked from commit 74f4a1357f)
2019-10-22 13:26:44 +03:00
Andrey Uskov
85271eeb1c Improved performance non-MPP projects import
#KT-32960 Fixed

(cherry picked from commit f567df283e)
2019-10-22 13:26:39 +03:00
Ilya Goncharov
b731cee2b1 [Gradle, JS] Add args instead of full override
(cherry picked from commit 1b929cd93e)
2019-10-22 12:56:19 +03:00
Ilya Goncharov
9c9450ceb3 [Gradle, JS] Set cli args for yarn install
(cherry picked from commit ee49c96650)
2019-10-22 12:56:19 +03:00
nikita.movshin
08c58d3184 Add changelog for 1.3.60 EAP 2 2019-10-22 01:21:38 +03:00
Mikhael Bogdanov
23b380c382 Initializer default values in 'tailrec' method in proper order
#KT-31540 Fixed

(cherry picked from commit c78dbaf6b3)
2019-10-21 16:35:12 +02:00
Mikhael Bogdanov
e8dfcaca6f Convert TailRecursionCodegen.java to Kotlin
(cherry picked from commit 077092d619)
2019-10-21 16:35:02 +02:00
Mikhael Bogdanov
aa79948dba Rename .java to .kt
(cherry picked from commit 2eda7cb4b0)
2019-10-21 16:34:52 +02:00
Denis Zharkov
ee96a0902d Temporary disable assertion in bridges generation
^KT-34431 Fixed
^KT-34507 Open
2019-10-21 16:05:44 +03:00
Jim Sproch
eeff8f489b Make useIR available from Gradle KotlinJvmOptions
(cherry picked from commit 383239aff6)
2019-10-21 13:23:52 +03:00
nikita.movshin
755940007d Update K/N version 2019-10-17 21:38:58 +03:00
Andrey Uskov
d424354c78 Work-around for importing intermediate android source sets
Fixed failure on import fully actualized intermediate source sets with K2Metadata compiler arguments (Android plugin expects compiler arguments of another type)

(cherry picked from commit 866ab51ce5)
2019-10-17 12:53:13 +03:00
Dmitry Gridin
cbf8d117b8 RemoveRedundantQualifierInspection: fix false positive for enum/object
#KT-34113 Fixed
#KT-32965 Fixed
#KT-33991 Fixed
#KT-33597 Fixed

(cherry picked from commit 696b832a9c)
2019-10-17 16:15:26 +07:00
Vladimir Dolzhenko
2c937ec570 Keep attachments of cause exception in KotlinExceptionWithAttachments and provide elements in attachments in case of errors during kotlin idea resolution
Relates to EA-210942, EA-209622 etc

(cherry picked from commit 30b98aaeb7)
2019-10-17 10:54:23 +02:00
Steven Schäfer
fa0e7c2961 JVM: Handle inline class equality in when statement with declaration
#KT-34268 Fixed

(cherry picked from commit 4878c7967a)
2019-10-16 23:45:29 +02:00
Anton Yalyshev
c316438285 Bump FUS Collectors versions after last changes for proper data fetching
(cherry picked from commit 1e921647fe)
2019-10-16 17:13:18 +03:00
Mikhael Bogdanov
f29b26a95f Report diagnostic on virtual tailrec function
#KT-18541 Fixed

(cherry picked from commit adae629258)
2019-10-16 15:38:24 +02:00
Alexander Gorshenev
8a83046d37 Broght back a condition lost during a refactoring 2019-10-16 15:51:17 +03:00
Roman Artemev
1f3db03a48 [KLIB] Fix explicitlyExported mode
- Refactor deserialization pipeline
 - Fix K/N test
2019-10-16 15:51:17 +03:00
Roman Artemev
098212e2e4 [KLIB] Correctly restore top level property order during deserialization - Add test - Fix KT-34273 2019-10-16 15:51:17 +03:00
Roman Artemev
2dd49cb0ba [Psi2Ir] Fix IrText test generation 2019-10-16 15:51:17 +03:00
Dmitry Gridin
dc696ea816 ShortenReferences: shouldn't analyze root prefix elements & should get rid of them at end
Relates to #KT-33937

(cherry picked from commit 8161403e69)
2019-10-16 19:12:01 +07:00
Dmitry Gridin
c97a8d11f2 delayedRequestsWaitingSet: performDelayedRefactoringRequests should commit all documents before refactoring
#KT-34365 Fixed

(cherry picked from commit d9faaddcca)
2019-10-16 19:11:12 +07:00
Dmitry Gridin
05c03d5b2e delayedRequestsWaitingSet: cleanup code
(cherry picked from commit 72eee17bff)
2019-10-16 19:11:11 +07:00
Andrey Uskov
25676ceda7 Fix creation of common source roots if android plugin is involved
#KT-34237 Fixed
2019-10-14 17:17:12 +03:00
Nicolay Mitropolsky
7abdab0c09 Uast: a workaround for getting parent for KotlinUAnonymousClass
when it is used in field initialisation

(cherry picked from commit f6e0e5b80d)
2019-10-14 14:54:59 +03:00
Nikolay Krasko
9a053f6928 Extend compatiblity to 201 upcoming release 2019-10-14 13:20:22 +03:00
Yan Zhulanow
f2527dfdf4 Run configurations: Fix compatibility with 2018.3
(cherry picked from commit 6b2b66e8e3)
2019-10-14 01:03:02 +09:00
Ivan Gavrilovic
5ab98732c8 KT-33503: Avoid analyzing module-info.class in KAPT classpath
When analyzing classpath changes for incremental KAPT, avoid
analyzing module-info.class files.

Test: ClasspathAnalyzerTest
(cherry picked from commit fbde7e47e9)
2019-10-14 01:03:01 +09:00
Yan Zhulanow
79d467c595 kapt: Fix compilation in 'compile' running mode (KT-33800)
(cherry picked from commit a4c8ccee06)
2019-10-14 01:03:01 +09:00
Yan Zhulanow
d8ab61273a Fix EA-209316: Allow null JDI values in captured value data
(cherry picked from commit 66758472c7)
2019-10-14 01:03:00 +09:00
Yan Zhulanow
81f7e48abb Fix EA-126019: Handle 'null' PsiType as nullable Any in "Create" actions
(cherry picked from commit d153aa87a8)
2019-10-14 01:03:00 +09:00
Yan Zhulanow
4422c43815 Make KotlinFacetSettingsProvider.getInstance() nullable
A module may not have a KotlinFacet.
It isn't correct to throw an exception in that case.

(cherry picked from commit 44b7a5cc36)
2019-10-14 01:02:59 +09:00
Yan Zhulanow
bdc93e451d Implement class/method run configurations for MPP projects
(cherry picked from commit f408c249f1)
2019-10-13 15:31:29 +09:00
Yan Zhulanow
83a4fcf18d Generify Gradle importing tests so they can be used in the Ultimate repo
(cherry picked from commit 0a8f15c745)
2019-10-13 15:31:24 +09:00
Yan Zhulanow
4c8d304e68 Disable alternative locations for new MPP as alternative locations aren't supported in Gradle
(cherry picked from commit 82c88f9cc4)
2019-10-13 15:31:19 +09:00
Yan Zhulanow
85d8a9f35d Implement test icon provider for 'native' platform
(cherry picked from commit 8f4063b36c)
2019-10-13 15:31:16 +09:00
Yan Zhulanow
4406dad9e6 Pill: Disable Pill for benchmarks module
(cherry picked from commit c19d62af73)
2019-10-13 15:31:13 +09:00
Yan Zhulanow
77ec036006 Pill: Add IDEA Ultimate run configuration
(cherry picked from commit 339ba499fb)
2019-10-13 15:31:08 +09:00
Ilya Kirillov
af0b1fe5b4 New J2K: fix SOE in inference processing for star-projection as type argument
#KT-33942 fixed
#KT-33941 fixed

(cherry picked from commit 1ec620b753)
2019-10-12 15:32:26 +03:00
Ilya Kirillov
dfc6106e57 New J2K: make post-processing aware of other files which are being converted
Before post-processing was able to handle only one converting file at once
So, some conversions (like (field, getter, setter) to Kotlin property)
was not able to work when converting class hierarchy was split into
multiple files.
Also, inferring nullability for a set of files was broken

#KT-19569 fixed
#KT-34266 fixed
#KT-32518 fixed

(cherry picked from commit b350515237)
2019-10-12 15:32:25 +03:00
Ilya Kirillov
5f296d162b New J2K: add multi-file conversion tests from old j2k
(cherry picked from commit 999918d499)
2019-10-12 15:32:24 +03:00
Ilya Kirillov
4491299d58 New J2K: introduce external code processing for new J2K
It will update usages from files not in conversion scope to a valid ones:
1. When converting (field, getter, setter) triple from Java to a Kotlin property,
   it will:
      1. Update every usage of getter/setter in Java/Kotlin code to a usage of actual property
      2. If property is used in Java directly then will add @JvmField to it
2. When converting static method or static field without getter and setter, which has Java usages then add @JvmStatic to it

#KT-34164 fixed

(cherry picked from commit f951ed9dba)
2019-10-12 15:32:23 +03:00
Ilya Kirillov
9276902ef0 New J2K: fix expose internal/private type errors
(cherry picked from commit 7535c2f249)
2019-10-12 15:32:22 +03:00
Ilya Kirillov
fb1e768a52 New J2K: do not allow field and method declarations to be internal
For internal members new names are generated,
So, references to them from Java will be broken

(cherry picked from commit d0f0b9e355)
2019-10-12 15:32:21 +03:00
Toshiaki Kameyama
2cdab841e5 KT-30643 J2K: wrong position of TYPE_USE annotation (#2543)
New J2K: fix wrong position of TYPE_USE annotation

#KT-30643 Fixed

(cherry picked from commit 4da7d11364)
2019-10-12 15:32:20 +03:00
Toshiaki Kameyama
14b6017089 New J2K: convert Integer.MAX_VALUE to Int.MAX_VALUE
#KT-7940 Fixed

(cherry picked from commit eda4206428)
2019-10-12 15:32:19 +03:00
Ilya Kirillov
73fa7c3b0e New J2K: handle correctly short names which are imported by default in kotlin (like List or Result)
Kotlin default import inserter was unable to correctly insert such imports

#KT-34165 fixed

(cherry picked from commit f950a0246c)
2019-10-12 15:32:18 +03:00
Ilya Kirillov
1c5cbc2449 New J2K: add hack for incorrect comment parsing in J2K (KT-16845)
#KT-33825 fixed

(cherry picked from commit 81341e3fd3)
2019-10-12 15:32:18 +03:00
Alexey Trilis
6f74f230bb Generate Kotlin/JS stdlib dependencies via dukat 2019-10-12 01:45:40 +02:00
Sergey Igushkin
c0d3bc5218 Cache PropertiesProvider, read the local.properties file lazily
Issue #KT-33980 Fixed

(cherry picked from commit c13f55f0ad)
2019-10-11 21:35:53 +03:00
Sergey Igushkin
5dea8e86a8 Fix requiresVisibilityOf in the Gradle plugin (KT-34312)
* Fix adding new items (which was untested, as the logic was only tested
 by unit tests)

* Exclude the source set's dependsOn transitive closure from the
requiresVisibilityOf checks (i.e. these source sets are considered
visible)

* Fix minor issues in the `UnsatisfiedSourceSetVisibilityException`
message

* Add `requiresVisibilityOf` to integration tests

Issue #KT-34312 Fixed

(cherry picked from commit d0604ffde8)
2019-10-11 21:35:38 +03:00
Kirill Shmakov
c021ca6264 Add Native Debug plugin advertising 2019-10-11 19:26:49 +03:00
Ilya Chernikov
2097d6de71 Implement samWithReceiver support for scripts when ...
it configured from script compilation configuration
#KT-34294 fixed
2019-10-11 17:49:19 +02:00
Ilya Chernikov
5cd1961b7e Instruct platform code to use NIO2 always
since we're not always use jna (means that we can get warnings about missing jna libs)
and according to the IDEA team, NIO2 works well enough to rely on it
2019-10-11 17:49:17 +02:00
Ilya Chernikov
df676de30e [minor] Fix file pattern matching test and converting paths to universal separator on calling the walking function 2019-10-11 17:49:16 +02:00
Ilya Matveev
2f1a90678d Fat frameworks: Run tests only on MacOS 2019-10-11 18:31:34 +03:00
Ilya Matveev
8761d1c621 Fat frameworks: Support for watchOS and tvOS
Issue #KT-34259 fixed
2019-10-11 18:31:33 +03:00
Ilya Matveev
b76b3d8fab Gradle, native: Disable watchOS x64
Currently a 64-bit simulator for watchOS is not available so
we disable this target.
2019-10-11 18:31:31 +03:00
Ilya Matveev
30e12119a6 Fat frameworks: Add tests 2019-10-11 18:31:30 +03:00
Ilya Matveev
aac5475d93 Fat frameworks: Don't add simulators into CFBundleSupportedPlatforms
Issue #KT-32223 fixed
2019-10-11 18:31:28 +03:00
Ilya Goncharov
0a64fdc40f [Gradle, JS] Not consider mocha default arguments 2019-10-11 17:52:51 +03:00
Ilya Goncharov
2d7936c98b [Gradle, JS] Deprecate useNodeJs for compatibility 2019-10-11 17:52:51 +03:00
Ilya Goncharov
c715b42961 [Gradle, JS] Remove redundant NodeJs runner 2019-10-11 17:52:51 +03:00
Ilya Goncharov
aa2f552f02 [Gradle, JS] Detect adapter automatically, not depends on JasmineLike 2019-10-11 17:52:51 +03:00
Ilya Goncharov
d2f5d87d41 [Gradle, JS] Remove copypaste for karma and nodejs test adapters 2019-10-11 17:52:51 +03:00
Ilya Goncharov
9d9f3f17aa [Gradle, JS] useMocha by default 2019-10-11 17:52:51 +03:00
Ilya Goncharov
55150bfacc [Gradle, JS] Return result of testing function
- It is useful for async testing (Promise returning)
2019-10-11 17:52:51 +03:00
Ilya Goncharov
1e5050e5f3 [Gradle, JS] Remove redundant related with JS test run 2019-10-11 17:52:50 +03:00
Ilya Goncharov
07ab3b89b7 [Gradle, JS] Only one sender of team city stdOut messages
- NodeJS and Browser tests should use one code to send TeamCity messages
2019-10-11 17:52:50 +03:00
Ilya Goncharov
253077bdf4 Use team city messages for mocha test output 2019-10-11 17:52:50 +03:00
Ilya Goncharov
9f15055b0e Migrate filtering adapter on mocha's initial adapter 2019-10-11 17:52:50 +03:00
Ilya Matveev
e7a794b814 Gradle, native: Add a DSL shortcut for iOS, watchsOS and tvOS
This patch adds a group of shortcut DSL methods allowing a user to
create simulator and device targets for Apple platforms along with
corresponding common source set(s) in one command. iOS, tvOS and
watchOS targets are supported.

Issue #KT-33856 fixed
2019-10-11 17:43:47 +03:00
Leonid Startsev
1005f1f473 Do not add synthetic deserialization constructor if .deserialize method is customized
Otherwise, there was an added descriptor without generated IR on Native

(cherry picked from commit d8ad0ec43a)
2019-10-11 14:36:57 +03:00
Leonid Startsev
4866c7ccfe Fix failing tests after 6d905157 2019-10-11 14:36:40 +03:00
Leonid Startsev
efcf136813 Don't skip LazyIR declarations during serialization
Skipping it would break kotlinx-serialization compiler plugin, because it emits lazy ir for now.

This commit is intended for 1.3.60 branch. In master, compiler plugins would be rewritten to emit correct IR.
2019-10-11 14:27:08 +03:00
Ilya Goncharov
2437a8e43a Fix license information for js modules
(cherry picked from commit 18b287def5)
2019-10-11 12:25:27 +03:00
Ilya Chernikov
2f42c88180 Fix filename pattern building under Windows
(cherry picked from commit 9bf46cf435)
2019-10-11 08:15:10 +02:00
Ilya Chernikov
7a7c7c5f6e Add a property for resolving via classloader in JSR-223 2019-10-10 17:39:01 +02:00
Ilya Chernikov
47bf4d3474 Add resolving from classloader to REPL pipeline 2019-10-10 17:38:59 +02:00
Ilya Chernikov
a8599875b5 Implement resolve top-level functions and props from classloader
#KT-33892 fixed
2019-10-10 17:38:58 +02:00
Ilya Chernikov
0f78a45008 Use default scripting host configuration if not provided 2019-10-10 17:38:57 +02:00
Ilya Goncharov
b230cdbcb0 Commonization of condition for linking node packages
(cherry picked from commit bf0b4f6878)
2019-10-10 12:25:13 +03:00
Ilya Goncharov
3f1927887f Remove NpmSimpleLinker
- Now only Yarn is responsible to link modules

(cherry picked from commit bcbc408892)
2019-10-10 12:25:12 +03:00
Ilya Goncharov
bf8ccbc396 Remain only license files
(cherry picked from commit 48e2e1f0c1)
2019-10-10 11:45:50 +03:00
Ilya Goncharov
e5c0d4440a Migrate on copyfiles
(cherry picked from commit 8c2ae4f91a)
2019-10-10 11:45:50 +03:00
Ilya Goncharov
ba1e0c8c50 Add similarity with kotlin-test-js-runner
(cherry picked from commit 896271cd87)
2019-10-10 11:45:50 +03:00
Ilya Goncharov
ef46414012 Remove webpack protocol for processing stacktrace
(cherry picked from commit 8ef28446cc)
2019-10-10 11:45:50 +03:00
Ilya Goncharov
02c522db47 Simplify progress procentage
(cherry picked from commit f4ba132327)
2019-10-10 11:45:50 +03:00
Ilya Goncharov
afaa730d7f Windows source-map-loading with absolute paths
(cherry picked from commit 7e5c51e6aa)
2019-10-10 11:45:50 +03:00
Ilya Goncharov
a4899235f0 Temp ignore tests on missing source file
#KT-32319 fixed

(cherry picked from commit b2fb81e9cc)
2019-10-10 11:45:50 +03:00
Ilya Goncharov
8561ff4f83 Fix webpack delimiter and add test on short path in stack trace
(cherry picked from commit 6688df8f6a)
2019-10-10 11:45:49 +03:00
Ilya Goncharov
81f3106918 Source-map-loader resolves relative paths into absolute even
- Now event sources with content in source map should be resolved with absolute path

(cherry picked from commit f7ba1c56e2)
2019-10-10 11:45:49 +03:00
Ilya Goncharov
fc0b7b16e1 Add tests for source-map-loader
(cherry picked from commit f3db846bce)
2019-10-10 11:45:49 +03:00
Ilya Goncharov
e8617a154c Add patched kotlin-source-map-loader
(cherry picked from commit e8efe5407d)
2019-10-10 11:45:49 +03:00
Ilya Goncharov
5f4c2405cc Fix test logging for Windows
(cherry picked from commit d2c2128aad)
2019-10-10 11:45:49 +03:00
Ilya Goncharov
2c1ab9fc0b Add typings field for DtsResolver
#KT-33549 fixed

(cherry picked from commit 1f5a760ac8)
2019-10-10 11:45:49 +03:00
Ilya Goncharov
e8239aece9 Add tests for processing karma stack traces
(cherry picked from commit 58e9b756f1)
2019-10-10 11:45:49 +03:00
Pavel Kirpichenkov
456a03cb5b Fix capturing of outer type parameters for classes declared inside init block 2019-10-10 11:13:40 +03:00
Abduqodiri Qurbonzoda
a8effec213 Fix Iterable, Sequence and String index overflow in windowed
(cherry picked from commit e54b405fe4)
2019-10-10 04:36:28 +03:00
Pavel Kirpichenkov
46fef9d71c Minor: fix typo in diagnostic message 2019-10-09 20:33:29 +03:00
Leonid Startsev
6d905157b3 Supply JVM and JS platforms when compile from CLI
To be able to check descriptor's platform in frontend during plugin processing.

This is needed for serialization plugin because some synthesized descriptors (annotation interface implementation) must be JVM-only (or the Native compilation fails).

(cherry picked from commit 395d595b22)
2019-10-09 14:20:32 +03:00
victor.petukhov
5f12ba992f Use new -Xinline-classes compiler flag in the corresponding IDEA intention 2019-10-09 12:23:37 +03:00
Kirill Shmakov
cc8eec91fd Advance 193 bunch to 193.4099
(cherry picked from commit 2a99687a95)
2019-10-09 12:06:39 +03:00
Ilya Chernikov
5e4bfe09db Drop TestCaseWithTempDir usage from scripting compiler plugin tests
fighting with flaky tests
2019-10-09 10:40:34 +02:00
Ilya Chernikov
574715616e [minor] Fix URL conversion to the file
possibly fixes the exception from https://stackoverflow.com/questions/57727150/kotlin-script-engine-with-spring-boot-self-running-war
2019-10-09 10:40:33 +02:00
Ilya Chernikov
f1f6963607 [minor] fix source root creation from imported scripts:
make the usages of KotlinSourceRoot consistent everywhere
2019-10-09 10:40:32 +02:00
Dmitry Gridin
cfc8721cde CreateExpect: shouldn't generate expect declaration from actual function with private, lateinit or const
#KT-33930 Fixed

(cherry picked from commit eaa07dac17)
2019-10-09 13:57:05 +07:00
Dmitry Gridin
d5d3e9a58b DescriptorRenderer: shouldn't render private modifier by default
#KT-31587 Fixed

(cherry picked from commit 9da6dcf840)
2019-10-09 13:57:04 +07:00
Dmitry Gridin
8a8e42a1fe CreateExpect: shouldn't generate expect declaration from actual function with default implementation from interface
#KT-32737 Fixed

(cherry picked from commit 847295bf1c)
2019-10-09 13:57:04 +07:00
Toshiaki Kameyama
e17f3edd3c Add quickfix to change object to class
#KT-33586 Fixed

(cherry picked from commit d86e87d35e)
2019-10-09 13:56:29 +07:00
Toshiaki Kameyama
b3ccda2f8d Convert to anonymous object: fix wrong replacement when SAM is nested interface
#KT-33660 Fixed

(cherry picked from commit 6a329210cb)
2019-10-09 13:56:28 +07:00
Toshiaki Kameyama
759141545a Change parameter type quick fix: don't use qualified name
#KT-32012 Fixed

(cherry picked from commit ac7e955d3e)
2019-10-09 13:55:49 +07:00
Toshiaki Kameyama
6c71264718 Add "Remove redundant label" quick fix for REDUNDANT_LABEL_WARNING
#KT-26431 Fixed

(cherry picked from commit b2d2165342)
2019-10-09 13:55:09 +07:00
nikita.movshin
f4c170f156 Add changelog for 1.3.60 EAP1 2019-10-08 17:21:24 +03:00
nikita.movshin
2597ac278d Update K/N 2019-10-08 10:46:28 +03:00
Alexander Gorshenev
ae4d8447c6 Use MessageCollector.NONE as a dummy logger collector for js library resolver 2019-10-07 18:28:08 +03:00
Alexander Gorshenev
77a325b664 Attached library resolver to messge collector 2019-10-07 18:28:07 +03:00
Alexander Gorshenev
1fa392cdcd A couple of fixes for js library resolver 2019-10-07 18:28:07 +03:00
Alexander Gorshenev
03896b1a02 Commonized FileRegistry with SourceFileMap for klib metadata 2019-10-07 18:28:06 +03:00
Alexander Gorshenev
5f397e27f8 The friend module identification has regressed recently 2019-10-07 18:28:06 +03:00
Vyacheslav Gerasimov
10a1d10100 Build: Fix maven dependencies for compiler daemon and util-klib-metadata artifacts 2019-10-07 15:14:46 +02:00
Nikolay Krasko
ca8cd19bff Move 193 version to the one we build against 2019-10-07 14:29:52 +03:00
Nikolay Krasko
8320337b05 Separate versions for 192 and 193 2019-10-07 14:19:16 +03:00
Anton Yalyshev
995b4637b8 Return older android.tools.build version, as we have problems with newer one 2019-10-07 12:51:55 +03:00
Anton Yalyshev
7bbe89fd60 Set JVM 1.8 for test source set as well #KT-34154 Fixed 2019-10-07 12:51:42 +03:00
Dmitriy Dolovov
ed2ca98e01 Fix KNPE after calling completion in native targeted filesIssue KT-34158 Fixed 2019-10-04 19:02:16 +03:00
Natalia Selezneva
7f403dc87f Add support for settings.gradle.kts configuring kotlin in project (KT-34114)
^KT-34114 Fixed
2019-10-03 16:04:33 +03:00
Igor Yakovlev
9fdd516582 Remove unnecessary fallback LigthClasses from UL 2019-10-03 15:35:00 +03:00
Igor Yakovlev
1f2df0f018 Revert commit and additional workaround to diagnostics problem
Another workaround of testClassObjectCopiedFieldObject test fix

Revert "Fix testClassObjectCopiedFieldObject test"

This reverts commit 8def1f07aa.
2019-10-03 15:34:53 +03:00
nikita.movshin
087ada6b4e Update K/N 2019-10-03 02:55:06 +03:00
779 changed files with 19273 additions and 19406 deletions

1
.gitignore vendored
View File

@@ -52,4 +52,5 @@ kotlin-ultimate/
node_modules/
.rpt2_cache/
libraries/tools/kotlin-test-js-runner/lib/
libraries/tools/kotlin-source-map-loader/lib/
local.properties

File diff suppressed because it is too large Load Diff

View File

@@ -24,7 +24,6 @@ apply(plugin = "kotlinx.benchmark")
plugins {
java
kotlin("jvm")
id("jps-compatible")
}
repositories {

View File

@@ -169,7 +169,7 @@ extra["versions.trove4j"] = "1.0.20181211"
extra["versions.ktor-network"] = "1.0.1"
if (!project.hasProperty("versions.kotlin-native")) {
extra["versions.kotlin-native"] = "1.3.60-dev-12485"
extra["versions.kotlin-native"] = "1.3.60-eap-13081"
}
val isTeamcityBuild = project.kotlinBuildProperties.isTeamcityBuild
@@ -527,6 +527,7 @@ tasks {
dependsOn(":kotlin-script-util:test")
dependsOn(":kotlin-scripting-compiler:test")
dependsOn(":kotlin-scripting-common:test")
dependsOn(":kotlin-scripting-jvm:test")
dependsOn(":kotlin-scripting-jvm-host-test:test")
dependsOn(":kotlin-scripting-jsr223-test:test")
dependsOn(":kotlin-scripting-jvm-host-test:embeddableTest")

View File

@@ -0,0 +1,41 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="[Pill] IDEA Ultimate" type="Application" factoryName="Application" singleton="true">
<log_file alias="idea.log" path="$PROJECT_DIR$/ideaSDK/system-idea/log/idea.log" />
<option name="MAIN_CLASS_NAME" value="com.intellij.idea.Main" />
<module name="kotlin-ultimate.ultimate.ultimate-runner" />
<option name="VM_PARAMETERS" value="-Xmx1250m -XX:ReservedCodeCacheSize=240m -XX:+HeapDumpOnOutOfMemoryError -ea -Didea.is.internal=true -Didea.debug.mode=true -Didea.system.path=$PROJECT_DIR$/local/ideaSandbox -Didea.config.path=$PROJECT_DIR$/local/ideaSandbox/config -Dapple.laf.useScreenMenuBar=true -Dapple.awt.graphics.UseQuartz=true -Dsun.io.useCanonCaches=false -Dplugin.path=$PROJECT_DIR$/out/artifacts/Kotlin $ADDITIONAL_IDEA_ARGS$" />
<option name="WORKING_DIRECTORY" value="file://$IDEA_HOME_PATH$" />
<RunnerSettings RunnerId="Debug">
<option name="DEBUG_PORT" value="" />
<option name="TRANSPORT" value="0" />
<option name="LOCAL" value="true" />
</RunnerSettings>
<RunnerSettings RunnerId="JavaRebel">
<option name="bootstrapPath" />
<option name="jrebelArgs" value="" />
<option name="loggingEnabled" value="false" />
<option name="useBootstrapDefaults" value="true" />
</RunnerSettings>
<RunnerSettings RunnerId="JavaRebel Debug">
<option name="bootstrapPath" />
<option name="debugPort" value="" />
<option name="jrebelArgs" value="" />
<option name="loggingEnabled" value="false" />
<option name="transport" value="0" />
<option name="useBootstrapDefaults" value="true" />
<option name="DEBUG_PORT" value="" />
<option name="TRANSPORT" value="0" />
<option name="LOCAL" value="true" />
</RunnerSettings>
<RunnerSettings RunnerId="Profile " />
<RunnerSettings RunnerId="Run" />
<ConfigurationWrapper RunnerId="Debug" />
<ConfigurationWrapper RunnerId="Profile " />
<ConfigurationWrapper RunnerId="Run" />
<method>
<option name="BuildArtifacts" enabled="true">
<artifact name="KotlinPlugin" />
</option>
</method>
</configuration>
</component>

View File

@@ -3297,7 +3297,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
else if (opToken == KtTokens.EQEQ || opToken == KtTokens.EXCLEQ ||
opToken == KtTokens.EQEQEQ || opToken == KtTokens.EXCLEQEQEQ) {
return generateEquals(
expression.getLeft(), expression.getRight(), opToken, null,
expression.getLeft(), expression.getRight(), opToken, null, null,
bindingContext.get(BindingContext.PRIMITIVE_NUMERIC_COMPARISON_INFO, expression)
);
}
@@ -3372,6 +3372,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
@Nullable KtExpression right,
@NotNull IElementType opToken,
@Nullable StackValue pregeneratedSubject,
@Nullable KotlinType subjectKotlinType,
@Nullable PrimitiveNumericComparisonInfo primitiveNumericComparisonInfo
) {
if (left == null || right == null) {
@@ -3382,7 +3383,7 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
});
}
KotlinType leftKotlinType = kotlinType(left);
KotlinType leftKotlinType = (subjectKotlinType != null) ? subjectKotlinType : kotlinType(left);
KotlinType rightKotlinType = kotlinType(right);
boolean leftIsInlineClass = leftKotlinType != null && InlineClassesUtilsKt.isInlineClassType(leftKotlinType);
boolean rightIsInlineClass = rightKotlinType != null && InlineClassesUtilsKt.isInlineClassType(rightKotlinType);
@@ -4892,10 +4893,10 @@ The "returned" value of try expression with no finally is either the last expres
return generateIsCheck(match, expression.getTypeReference(), expression.isNegated());
}
private StackValue generateExpressionMatch(StackValue expressionToMatch, KtExpression subjectExpression, KtExpression patternExpression) {
private StackValue generateExpressionMatch(StackValue expressionToMatch, KtExpression subjectExpression, KotlinType subjectKotlinType, KtExpression patternExpression) {
if (expressionToMatch != null) {
return generateEquals(
subjectExpression, patternExpression, KtTokens.EQEQ, expressionToMatch,
subjectExpression, patternExpression, KtTokens.EQEQ, expressionToMatch, subjectKotlinType,
bindingContext.get(BindingContext.PRIMITIVE_NUMERIC_COMPARISON_INFO, patternExpression)
);
}
@@ -4996,6 +4997,7 @@ The "returned" value of try expression with no finally is either the last expres
else {
subjectLocal = -1;
subjectType = Type.VOID_TYPE;
subjectKotlinType = null;
}
Label begin = new Label();
@@ -5015,7 +5017,7 @@ The "returned" value of try expression with no finally is either the last expres
if (!whenEntry.isElse()) {
KtWhenCondition[] conditions = whenEntry.getConditions();
for (int i = 0; i < conditions.length; i++) {
StackValue conditionValue = generateWhenCondition(subjectExpression, subjectType, subjectLocal, conditions[i]);
StackValue conditionValue = generateWhenCondition(subjectExpression, subjectType, subjectKotlinType, subjectLocal, conditions[i]);
BranchedValue.Companion.condJump(conditionValue, nextCondition, true, v);
if (i < conditions.length - 1) {
v.goTo(thisEntry);
@@ -5069,7 +5071,7 @@ The "returned" value of try expression with no finally is either the last expres
}
}
private StackValue generateWhenCondition(KtExpression subjectExpression, Type subjectType, int subjectLocal, KtWhenCondition condition) {
private StackValue generateWhenCondition(KtExpression subjectExpression, Type subjectType, KotlinType subjectKotlinType, int subjectLocal, KtWhenCondition condition) {
if (condition instanceof KtWhenConditionInRange) {
KtWhenConditionInRange conditionInRange = (KtWhenConditionInRange) condition;
return generateIn(StackValue.local(subjectLocal, subjectType),
@@ -5083,7 +5085,7 @@ The "returned" value of try expression with no finally is either the last expres
}
else if (condition instanceof KtWhenConditionWithExpression) {
KtExpression patternExpression = ((KtWhenConditionWithExpression) condition).getExpression();
return generateExpressionMatch(match, subjectExpression, patternExpression);
return generateExpressionMatch(match, subjectExpression, subjectKotlinType, patternExpression);
}
else {
throw new UnsupportedOperationException("unsupported kind of when condition");

View File

@@ -1,158 +0,0 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.codegen;
import com.google.common.collect.Lists;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.cfg.TailRecursionKind;
import org.jetbrains.kotlin.codegen.context.MethodContext;
import org.jetbrains.kotlin.codegen.coroutines.CoroutineCodegenUtilKt;
import org.jetbrains.kotlin.codegen.state.GenerationState;
import org.jetbrains.kotlin.descriptors.CallableDescriptor;
import org.jetbrains.kotlin.descriptors.FunctionDescriptor;
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor;
import org.jetbrains.kotlin.psi.KtExpression;
import org.jetbrains.kotlin.psi.KtSimpleNameExpression;
import org.jetbrains.kotlin.psi.ValueArgument;
import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt;
import org.jetbrains.kotlin.resolve.calls.model.*;
import org.jetbrains.org.objectweb.asm.Type;
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
import java.util.List;
import static org.jetbrains.kotlin.resolve.BindingContext.TAIL_RECURSION_CALL;
public class TailRecursionCodegen {
@NotNull
private final MethodContext context;
@NotNull
private final ExpressionCodegen codegen;
@NotNull
private final InstructionAdapter v;
@NotNull
private final GenerationState state;
public TailRecursionCodegen(
@NotNull MethodContext context,
@NotNull ExpressionCodegen codegen,
@NotNull InstructionAdapter v,
@NotNull GenerationState state
) {
this.context = context;
this.codegen = codegen;
this.v = v;
this.state = state;
}
public boolean isTailRecursion(@NotNull ResolvedCall<?> resolvedCall) {
TailRecursionKind status = state.getBindingContext().get(TAIL_RECURSION_CALL, resolvedCall.getCall());
return status != null && status.isDoGenerateTailRecursion();
}
public void generateTailRecursion(ResolvedCall<?> resolvedCall) {
CallableDescriptor fd = CoroutineCodegenUtilKt.unwrapInitialDescriptorForSuspendFunction(resolvedCall.getResultingDescriptor());
assert fd instanceof FunctionDescriptor : "Resolved call doesn't refer to the function descriptor: " + fd;
CallableMethod callable = (CallableMethod) codegen.resolveToCallable((FunctionDescriptor) fd, false, resolvedCall);
List<ResolvedValueArgument> arguments = resolvedCall.getValueArgumentsByIndex();
if (arguments == null) {
throw new IllegalStateException("Failed to arrange value arguments by index: " + fd);
}
if (((FunctionDescriptor) fd).isSuspend()) {
AsmUtil.pop(v, callable.getValueParameters().get(callable.getValueParameters().size() - 1).getAsmType());
}
assignParameterValues(fd, callable, arguments);
if (callable.getExtensionReceiverType() != null) {
if (resolvedCall.getExtensionReceiver() != fd.getExtensionReceiverParameter().getValue()) {
StackValue expression = context.getReceiverExpression(codegen.typeMapper);
expression.store(StackValue.onStack(callable.getExtensionReceiverType()), v, true);
}
else {
AsmUtil.pop(v, callable.getExtensionReceiverType());
}
}
if (callable.getDispatchReceiverType() != null) {
AsmUtil.pop(v, callable.getDispatchReceiverType());
}
v.goTo(context.getMethodStartLabel());
}
private void assignParameterValues(
CallableDescriptor fd,
CallableMethod callableMethod,
List<ResolvedValueArgument> valueArguments
) {
List<Type> types = callableMethod.getValueParameterTypes();
for (ValueParameterDescriptor parameterDescriptor : Lists.reverse(fd.getValueParameters())) {
ResolvedValueArgument arg = valueArguments.get(parameterDescriptor.getIndex());
Type type = types.get(parameterDescriptor.getIndex());
if (arg instanceof ExpressionValueArgument) {
ExpressionValueArgument ev = (ExpressionValueArgument) arg;
ValueArgument argument = ev.getValueArgument();
KtExpression argumentExpression = argument == null ? null : argument.getArgumentExpression();
if (argumentExpression instanceof KtSimpleNameExpression) {
ResolvedCall<?> resolvedCall = CallUtilKt.getResolvedCall(argumentExpression, state.getBindingContext());
if (resolvedCall != null && resolvedCall.getResultingDescriptor().equals(parameterDescriptor.getOriginal())) {
// do nothing: we shouldn't store argument to itself again
AsmUtil.pop(v, type);
continue;
}
}
//assign the parameter below
}
else if (arg instanceof DefaultValueArgument) {
AsmUtil.pop(v, type);
DefaultParameterValueLoader.DEFAULT.genValue(parameterDescriptor, codegen).put(type, v);
}
else if (arg instanceof VarargValueArgument) {
// assign the parameter below
}
else {
throw new UnsupportedOperationException("Unknown argument type: " + arg + " in " + fd);
}
store(parameterDescriptor, type);
}
}
private void store(ValueParameterDescriptor parameterDescriptor, Type type) {
int index = getParameterVariableIndex(parameterDescriptor);
v.store(index, type);
}
private int getParameterVariableIndex(ValueParameterDescriptor parameterDescriptor) {
int index = codegen.lookupLocalIndex(parameterDescriptor);
if (index == -1) {
// in the case of a generic function recursively calling itself, the parameters on the call site are substituted
index = codegen.lookupLocalIndex(parameterDescriptor.getOriginal());
}
if (index == -1) {
throw new IllegalStateException("Failed to obtain parameter index: " + parameterDescriptor);
}
return index;
}
}

View File

@@ -0,0 +1,152 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.codegen
import org.jetbrains.kotlin.codegen.context.MethodContext
import org.jetbrains.kotlin.codegen.coroutines.*
import org.jetbrains.kotlin.codegen.state.GenerationState
import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor
import org.jetbrains.kotlin.psi.KtSimpleNameExpression
import org.jetbrains.kotlin.resolve.calls.callUtil.*
import org.jetbrains.kotlin.resolve.calls.model.*
import org.jetbrains.org.objectweb.asm.Type
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
import org.jetbrains.kotlin.resolve.BindingContext.TAIL_RECURSION_CALL
class TailRecursionCodegen(
private val context: MethodContext,
private val codegen: ExpressionCodegen,
private val v: InstructionAdapter,
private val state: GenerationState
) {
fun isTailRecursion(resolvedCall: ResolvedCall<*>): Boolean {
val status = state.bindingContext.get(TAIL_RECURSION_CALL, resolvedCall.call)
return status != null && status.isDoGenerateTailRecursion
}
fun generateTailRecursion(resolvedCall: ResolvedCall<*>) {
val fd = resolvedCall.resultingDescriptor.unwrapInitialDescriptorForSuspendFunction().let {
it as? FunctionDescriptor
?: error("Resolved call doesn't refer to the function descriptor: $it")
}
val callable = codegen.resolveToCallable(fd, false, resolvedCall) as CallableMethod
val arguments = resolvedCall.valueArgumentsByIndex ?: throw IllegalStateException("Failed to arrange value arguments by index: $fd")
if (fd.isSuspend) {
AsmUtil.pop(v, callable.getValueParameters().last().asmType)
}
assignParameterValues(fd, callable, arguments)
if (callable.extensionReceiverType != null) {
if (resolvedCall.extensionReceiver != fd.extensionReceiverParameter!!.value) {
val expression = context.getReceiverExpression(codegen.typeMapper)
expression.store(StackValue.onStack(callable.extensionReceiverType), v, true)
} else {
AsmUtil.pop(v, callable.extensionReceiverType)
}
}
if (callable.dispatchReceiverType != null) {
AsmUtil.pop(v, callable.dispatchReceiverType)
}
v.goTo(context.methodStartLabel)
}
private fun assignParameterValues(
fd: CallableDescriptor,
callableMethod: CallableMethod,
valueArguments: List<ResolvedValueArgument>
) {
val properDefaultInitialization =
state.languageVersionSettings.supportsFeature(LanguageFeature.ProperComputationOrderOfTailrecDefaultParameters)
val types = callableMethod.valueParameterTypes
loop@ for (parameterDescriptor in fd.valueParameters.asReversed()) {
val arg = valueArguments[parameterDescriptor.index]
val type = types[parameterDescriptor.index]
when (arg) {
is ExpressionValueArgument -> {
val argumentExpression = arg.valueArgument?.getArgumentExpression()
if (argumentExpression is KtSimpleNameExpression) {
val resolvedCall = argumentExpression.getResolvedCall(state.bindingContext)
if (resolvedCall?.resultingDescriptor == parameterDescriptor.original) {
// do nothing: we shouldn't store argument to itself again
AsmUtil.pop(v, type)
continue@loop
}
}
//assign the parameter below
}
is DefaultValueArgument -> {
AsmUtil.pop(v, type)
if (properDefaultInitialization) {
//Initialization in proper order is performed in loop below
continue@loop
} else {
DefaultParameterValueLoader.DEFAULT.genValue(parameterDescriptor, codegen).put(type, v)
}
}
is VarargValueArgument -> {
// assign the parameter below
}
else -> throw UnsupportedOperationException("Unknown argument type: $arg in $fd")
}
store(parameterDescriptor, type)
}
if (properDefaultInitialization) {
for (parameterDescriptor in fd.valueParameters) {
val arg = valueArguments[parameterDescriptor.index]
val type = types[parameterDescriptor.index]
if (arg is DefaultValueArgument) {
DefaultParameterValueLoader.DEFAULT.genValue(parameterDescriptor, codegen).put(type, v)
store(parameterDescriptor, type)
}
}
}
}
private fun store(parameterDescriptor: ValueParameterDescriptor, type: Type) {
val index = getParameterVariableIndex(parameterDescriptor)
v.store(index, type)
}
private fun getParameterVariableIndex(parameterDescriptor: ValueParameterDescriptor): Int {
var index = codegen.lookupLocalIndex(parameterDescriptor)
if (index == -1) {
// in the case of a generic function recursively calling itself, the parameters on the call site are substituted
index = codegen.lookupLocalIndex(parameterDescriptor.original)
}
if (index == -1) {
throw IllegalStateException("Failed to obtain parameter index: $parameterDescriptor")
}
return index
}
}

View File

@@ -161,9 +161,10 @@ private fun <Signature> findSuperImplementationForStubDelegation(
// Implementation in super-class already has proper signature
if (signatureByDescriptor(function) == signatureByDescriptor(implementation.descriptor)) return null
assert(function.modality == Modality.OPEN) {
"Should generate stubs only for non-abstract built-ins, but ${function.name} is ${function.modality}"
}
// TODO: Enable the assertion once KT-34507 is fixed
// assert(function.modality == Modality.OPEN) {
// "Should generate stubs only for non-abstract built-ins, but ${function.name} is ${function.modality}"
// }
return implementation.descriptor
}

View File

@@ -72,6 +72,7 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
// Advanced options
@GradleOption(DefaultValues.BooleanFalseDefault::class)
@Argument(value = "-Xuse-ir", description = "Use the IR backend")
var useIR: Boolean by FreezableVar(false)

View File

@@ -19,13 +19,11 @@ package org.jetbrains.kotlin.cli.common.environment
import com.intellij.openapi.util.SystemInfo
fun setIdeaIoUseFallback() {
if (SystemInfo.isWindows) {
val properties = System.getProperties()
val properties = System.getProperties()
properties.setProperty("idea.io.use.nio2", java.lang.Boolean.TRUE.toString())
properties.setProperty("idea.io.use.nio2", java.lang.Boolean.TRUE.toString())
if (!(SystemInfo.isJavaVersionAtLeast(1, 7, 0) && "1.7.0-ea" != SystemInfo.JAVA_VERSION)) {
properties.setProperty("idea.io.use.fallback", java.lang.Boolean.TRUE.toString())
}
if (!(SystemInfo.isJavaVersionAtLeast(1, 7, 0) && "1.7.0-ea" != SystemInfo.JAVA_VERSION)) {
properties.setProperty("idea.io.use.fallback", java.lang.Boolean.TRUE.toString())
}
}

View File

@@ -15,6 +15,7 @@ import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments
import org.jetbrains.kotlin.cli.common.arguments.K2JsArgumentConstants
import org.jetbrains.kotlin.cli.common.config.addKotlinSourceRoot
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.*
import org.jetbrains.kotlin.cli.common.messages.GroupingMessageCollector
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
import org.jetbrains.kotlin.cli.common.messages.MessageUtil
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
@@ -28,19 +29,18 @@ 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
import org.jetbrains.kotlin.ir.backend.js.*
import org.jetbrains.kotlin.ir.backend.js.compile
import org.jetbrains.kotlin.ir.backend.js.generateKLib
import org.jetbrains.kotlin.ir.backend.js.jsPhases
import org.jetbrains.kotlin.ir.backend.js.jsResolveLibraries
import org.jetbrains.kotlin.js.config.EcmaVersion
import org.jetbrains.kotlin.js.config.JSConfigurationKeys
import org.jetbrains.kotlin.js.config.JsConfig
import org.jetbrains.kotlin.js.config.SourceMapSourceEmbedding
import org.jetbrains.kotlin.library.resolver.impl.libraryResolver
import org.jetbrains.kotlin.library.KotlinLibrary
import org.jetbrains.kotlin.library.KotlinLibrarySearchPathResolver
import org.jetbrains.kotlin.library.UnresolvedLibrary
import org.jetbrains.kotlin.library.toUnresolvedLibraries
import org.jetbrains.kotlin.metadata.deserialization.BinaryVersion
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.serialization.js.ModuleKind
import org.jetbrains.kotlin.util.Logger
import org.jetbrains.kotlin.utils.JsMetadataVersion
import org.jetbrains.kotlin.utils.KotlinPaths
import org.jetbrains.kotlin.utils.join
@@ -142,21 +142,15 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
// TODO: Handle non-empty main call arguments
val mainCallArguments = if (K2JsArgumentConstants.NO_CALL == arguments.main) null else emptyList<String>()
val unresolvedLibraries = libraries.toUnresolvedLibraries
// Configure resolver to only understands absolute path libraries.
val libraryResolver = KotlinLibrarySearchPathResolver<KotlinLibrary>(
repositories = emptyList(),
directLibs = libraries,
distributionKlib = null,
localKotlinDir = null,
skipCurrentDir = true
// TODO: pass logger attached to message collector here.
).libraryResolver()
val resolvedLibraries = libraryResolver.resolveWithDependencies(unresolvedLibraries, true, true, true)
val friendDependencies = resolvedLibraries.getFullList()
.filter {
it.moduleName in friendLibraries
}
val resolvedLibraries = jsResolveLibraries(
libraries,
messageCollectorLogger(configuration[CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY] ?: error("Could not find message collector"))
)
val friendAbsolutePaths = friendLibraries.map { File(it).absolutePath }
val friendDependencies = resolvedLibraries.getFullList().filter {
it.libraryFile.absolutePath in friendAbsolutePaths
}
val produceKind = produceMap[arguments.irProduceOnly]
if (produceKind == null) {
@@ -345,3 +339,14 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
}
}
}
fun messageCollectorLogger(collector: MessageCollector) = object : Logger {
override fun warning(message: String)= collector.report(STRONG_WARNING, message)
override fun error(message: String) = collector.report(ERROR, message)
override fun log(message: String) = collector.report(LOGGING, message)
override fun fatal(message: String): Nothing {
collector.report(ERROR, message)
(collector as? GroupingMessageCollector)?.flush()
kotlin.error(message)
}
}

View File

@@ -25,14 +25,11 @@ import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.LOGGING
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
import org.jetbrains.kotlin.cli.jvm.index.JavaRoot
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.load.kotlin.PackagePartProvider
import org.jetbrains.kotlin.load.kotlin.JvmPackagePartProviderBase
import org.jetbrains.kotlin.load.kotlin.loadModuleMapping
import org.jetbrains.kotlin.metadata.jvm.deserialization.JvmMetadataVersion
import org.jetbrains.kotlin.metadata.jvm.deserialization.ModuleMapping
import org.jetbrains.kotlin.metadata.jvm.deserialization.PackageParts
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.resolve.CompilerDeserializationConfiguration
import org.jetbrains.kotlin.serialization.deserialization.MetadataPartProvider
import java.io.ByteArrayOutputStream
import java.io.EOFException
import java.io.PrintStream
@@ -40,49 +37,10 @@ import java.io.PrintStream
class JvmPackagePartProvider(
languageVersionSettings: LanguageVersionSettings,
private val scope: GlobalSearchScope
) : PackagePartProvider, MetadataPartProvider {
private data class ModuleMappingInfo(val root: VirtualFile, val mapping: ModuleMapping, val name: String)
) : JvmPackagePartProviderBase<VirtualFile>() {
private val deserializationConfiguration = CompilerDeserializationConfiguration(languageVersionSettings)
private val loadedModules: MutableList<ModuleMappingInfo> = SmartList()
override fun findPackageParts(packageFqName: String): List<String> {
val rootToPackageParts = getPackageParts(packageFqName)
if (rootToPackageParts.isEmpty()) return emptyList()
val result = linkedSetOf<String>()
val visitedMultifileFacades = linkedSetOf<String>()
for ((_, packageParts) in rootToPackageParts) {
for (name in packageParts.parts) {
val facadeName = packageParts.getMultifileFacadeName(name)
if (facadeName == null || facadeName !in visitedMultifileFacades) {
result.add(name)
}
}
packageParts.parts.mapNotNullTo(visitedMultifileFacades, packageParts::getMultifileFacadeName)
}
return result.toList()
}
override fun findMetadataPackageParts(packageFqName: String): List<String> =
getPackageParts(packageFqName).values.flatMap(PackageParts::metadataParts).distinct()
@Synchronized
private fun getPackageParts(packageFqName: String): Map<VirtualFile, PackageParts> {
val result = mutableMapOf<VirtualFile, PackageParts>()
for ((root, mapping) in loadedModules) {
val newParts = mapping.findPackageParts(packageFqName) ?: continue
result[root]?.let { parts -> parts += newParts } ?: result.put(root, newParts)
}
return result
}
override fun getAnnotationsOnBinaryModule(moduleName: String): List<ClassId> {
return loadedModules.mapNotNull { (_, mapping, name) ->
if (name == moduleName) mapping.moduleData.annotations.map(ClassId::fromString) else null
}.flatten()
}
override val loadedModules: MutableList<ModuleMappingInfo<VirtualFile>> = SmartList()
fun addRoots(roots: List<JavaRoot>, messageCollector: MessageCollector) {
for ((root, type) in roots) {
@@ -93,29 +51,40 @@ class JvmPackagePartProvider(
for (moduleFile in metaInf.children) {
if (!moduleFile.name.endsWith(ModuleMapping.MAPPING_FILE_EXT)) continue
try {
val mapping = ModuleMapping.loadModuleMapping(
moduleFile.contentsToByteArray(), moduleFile.toString(), deserializationConfiguration
) { incompatibleVersion ->
messageCollector.report(
ERROR,
"Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is " +
"$incompatibleVersion, expected version is ${JvmMetadataVersion.INSTANCE}.",
CompilerMessageLocation.create(moduleFile.path)
)
}
loadedModules.add(ModuleMappingInfo(root, mapping, moduleFile.nameWithoutExtension))
} catch (e: EOFException) {
messageCollector.report(
ERROR, "Error occurred when reading the module: ${e.message}", CompilerMessageLocation.create(moduleFile.path)
)
messageCollector.report(
LOGGING,
String(ByteArrayOutputStream().also { e.printStackTrace(PrintStream(it)) }.toByteArray()),
CompilerMessageLocation.create(moduleFile.path)
)
tryLoadModuleMapping(
{ moduleFile.contentsToByteArray() }, moduleFile.toString(), moduleFile.path,
deserializationConfiguration, messageCollector
)?.let {
loadedModules.add(ModuleMappingInfo(root, it, moduleFile.nameWithoutExtension))
}
}
}
}
}
fun tryLoadModuleMapping(
getModuleBytes: () -> ByteArray,
debugName: String,
modulePath: String,
deserializationConfiguration: CompilerDeserializationConfiguration,
messageCollector: MessageCollector
): ModuleMapping? = try {
ModuleMapping.loadModuleMapping(getModuleBytes(), debugName, deserializationConfiguration) { incompatibleVersion ->
messageCollector.report(
ERROR,
"Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is " +
"$incompatibleVersion, expected version is ${JvmMetadataVersion.INSTANCE}.",
CompilerMessageLocation.create(modulePath)
)
}
} catch (e: EOFException) {
messageCollector.report(
ERROR, "Error occurred when reading the module: ${e.message}", CompilerMessageLocation.create(modulePath)
)
messageCollector.report(
LOGGING,
String(ByteArrayOutputStream().also { e.printStackTrace(PrintStream(it)) }.toByteArray()),
CompilerMessageLocation.create(modulePath)
)
null
}

View File

@@ -55,6 +55,7 @@ import org.jetbrains.kotlin.load.kotlin.incremental.IncrementalPackageFragmentPr
import org.jetbrains.kotlin.load.kotlin.incremental.IncrementalPackagePartProvider
import org.jetbrains.kotlin.modules.TargetId
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.platform.TargetPlatform
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.resolve.*
@@ -125,7 +126,11 @@ object TopDownAnalyzerFacadeForJVM {
targetEnvironment: TargetEnvironment = CompilerEnvironment,
sourceModuleSearchScope: GlobalSearchScope = newModuleSearchScope(project, files)
): ComponentProvider {
val moduleContext = createModuleContext(project, configuration)
val jvmTarget = configuration.get(JVMConfigurationKeys.JVM_TARGET, JvmTarget.DEFAULT)
val languageVersionSettings = configuration.languageVersionSettings
val jvmPlatform = JvmPlatforms.jvmPlatformByTargetVersion(jvmTarget)
val moduleContext = createModuleContext(project, configuration, jvmPlatform)
val storageManager = moduleContext.storageManager
val module = moduleContext.module
@@ -140,9 +145,6 @@ object TopDownAnalyzerFacadeForJVM {
val sourceScope = if (separateModules) sourceModuleSearchScope else GlobalSearchScope.allScope(project)
val moduleClassResolver = SourceOrBinaryModuleClassResolver(sourceScope)
val jvmTarget = configuration.get(JVMConfigurationKeys.JVM_TARGET, JvmTarget.DEFAULT)
val languageVersionSettings = configuration.languageVersionSettings
val fallbackBuiltIns = JvmBuiltIns(storageManager, JvmBuiltIns.Kind.FALLBACK).apply {
initialize(builtInsModule, languageVersionSettings)
}.builtInsModule
@@ -161,14 +163,14 @@ object TopDownAnalyzerFacadeForJVM {
val dependencyModule = if (separateModules) {
val dependenciesContext = ContextForNewModule(
moduleContext, Name.special("<dependencies of ${configuration.getNotNull(CommonConfigurationKeys.MODULE_NAME)}>"),
module.builtIns, null
module.builtIns, jvmPlatform
)
// Scope for the dependency module contains everything except files present in the scope for the source module
val dependencyScope = GlobalSearchScope.notScope(sourceScope)
val dependenciesContainer = createContainerForLazyResolveWithJava(
JvmPlatforms.jvmPlatformByTargetVersion(jvmTarget),
jvmPlatform,
dependenciesContext, trace, DeclarationProviderFactory.EMPTY, dependencyScope, moduleClassResolver,
targetEnvironment, lookupTracker, expectActualTracker,
packagePartProvider(dependencyScope), languageVersionSettings,
@@ -200,7 +202,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 = createContainerForLazyResolveWithJava(
JvmPlatforms.jvmPlatformByTargetVersion(jvmTarget),
jvmPlatform,
moduleContext, trace, declarationProviderFactory(storageManager, files), sourceScope, moduleClassResolver,
targetEnvironment, lookupTracker, expectActualTracker,
partProvider, languageVersionSettings,
@@ -275,11 +277,11 @@ object TopDownAnalyzerFacadeForJVM {
}
}
private fun createModuleContext(project: Project, configuration: CompilerConfiguration): MutableModuleContext {
private fun createModuleContext(project: Project, configuration: CompilerConfiguration, platform: TargetPlatform?): MutableModuleContext {
val projectContext = ProjectContext(project, "TopDownAnalyzer for JVM")
val builtIns = JvmBuiltIns(projectContext.storageManager, JvmBuiltIns.Kind.FROM_DEPENDENCIES)
return ContextForNewModule(
projectContext, Name.special("<${configuration.getNotNull(CommonConfigurationKeys.MODULE_NAME)}>"), builtIns, null
projectContext, Name.special("<${configuration.getNotNull(CommonConfigurationKeys.MODULE_NAME)}>"), builtIns, platform
).apply {
builtIns.builtInsModule = module
}

View File

@@ -17,13 +17,14 @@ jvmTarget = "1.8"
val ktorExcludesForDaemon : List<Pair<String, String>> by rootProject.extra
dependencies {
compile(project(":compiler:cli"))
compile(project(":compiler:cli-js"))
compile(project(":daemon-common-new"))
compile(project(":compiler:incremental-compilation-impl"))
compile(commonDep("org.fusesource.jansi", "jansi"))
compile(commonDep("org.jline", "jline"))
compileOnly(project(":compiler:cli"))
compileOnly(project(":compiler:cli-js"))
compileOnly(project(":compiler:incremental-compilation-impl"))
compileOnly(project(":daemon-common-new"))
compileOnly(intellijCoreDep()) { includeJars("intellij-core") }
compileOnly(intellijDep()) { includeJars("trove4j") }

View File

@@ -469,6 +469,11 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok
runTest("compiler/testData/diagnostics/tests/ProjectionsInSupertypes.kt");
}
@TestMetadata("properDefaultInitializationInTailrec.kt")
public void testProperDefaultInitializationInTailrec() throws Exception {
runTest("compiler/testData/diagnostics/tests/properDefaultInitializationInTailrec.kt");
}
@TestMetadata("Properties.kt")
public void testProperties() throws Exception {
runTest("compiler/testData/diagnostics/tests/Properties.kt");
@@ -609,6 +614,16 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok
runTest("compiler/testData/diagnostics/tests/SyntaxErrorInTestHighlightingEof.kt");
}
@TestMetadata("tailRecOnVirtualMember.kt")
public void testTailRecOnVirtualMember() throws Exception {
runTest("compiler/testData/diagnostics/tests/tailRecOnVirtualMember.kt");
}
@TestMetadata("tailRecOnVirtualMemberError.kt")
public void testTailRecOnVirtualMemberError() throws Exception {
runTest("compiler/testData/diagnostics/tests/tailRecOnVirtualMemberError.kt");
}
@TestMetadata("tailRecOverridden.kt")
public void testTailRecOverridden() throws Exception {
runTest("compiler/testData/diagnostics/tests/tailRecOverridden.kt");
@@ -679,6 +694,11 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok
runTest("compiler/testData/diagnostics/tests/UnitValue.kt");
}
@TestMetadata("unproperDefaultInitializationInTailrec.kt")
public void testUnproperDefaultInitializationInTailrec() throws Exception {
runTest("compiler/testData/diagnostics/tests/unproperDefaultInitializationInTailrec.kt");
}
@TestMetadata("Unresolved.kt")
public void testUnresolved() throws Exception {
runTest("compiler/testData/diagnostics/tests/Unresolved.kt");

View File

@@ -0,0 +1,55 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.resolve.jvm.checkers
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.psi.KtConstantExpression
import org.jetbrains.kotlin.psi.KtDeclaration
import org.jetbrains.kotlin.psi.KtNamedFunction
import org.jetbrains.kotlin.psi.KtParameter
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
import org.jetbrains.kotlin.resolve.checkers.DeclarationChecker
import org.jetbrains.kotlin.resolve.checkers.DeclarationCheckerContext
import org.jetbrains.kotlin.resolve.constants.evaluate.ConstantExpressionEvaluator
import org.jetbrains.kotlin.resolve.descriptorUtil.module
import org.jetbrains.kotlin.resolve.jvm.diagnostics.ErrorsJvm
import org.jetbrains.kotlin.resolve.jvm.getCompileTimeConstant
import org.jetbrains.kotlin.types.typeUtil.isPrimitiveNumberOrNullableType
object DefaultCheckerInTailrec : DeclarationChecker {
override fun check(declaration: KtDeclaration, descriptor: DeclarationDescriptor, context: DeclarationCheckerContext) {
if (declaration !is KtNamedFunction || descriptor !is FunctionDescriptor || !descriptor.isTailrec) return
if (context.languageVersionSettings.supportsFeature(LanguageFeature.ProperComputationOrderOfTailrecDefaultParameters)) return
val defaultValues = descriptor.valueParameters.filter { it.declaresDefaultValue() }.filter {
val parameterDeclaration = DescriptorToSourceUtils.descriptorToDeclaration(it)
if (parameterDeclaration is KtParameter) {
parameterDeclaration.defaultValue?.let {
getCompileTimeConstant(
it,
context.trace.bindingContext,
false,
context.languageVersionSettings.supportsFeature(LanguageFeature.InlineConstVals)
)?.let { const ->
val type = const.getType(descriptor.module)
return@filter !(KotlinBuiltIns.isPrimitiveTypeOrNullablePrimitiveType(type) ||
KotlinBuiltIns.isStringOrNullableString(type))
}
}
}
true
}
if (defaultValues.size > 1) {
context.trace.report(ErrorsJvm.TAILREC_WITH_DEFAULTS.on(declaration))
}
}
}

View File

@@ -151,6 +151,7 @@ public class DefaultErrorMessagesJvm implements DefaultErrorMessages.Extension {
"See https://youtrack.jetbrains.com/issue/KT-18053 for more details";
MAP.put(CONCURRENT_HASH_MAP_CONTAINS_OPERATOR, MESSAGE_FOR_CONCURRENT_HASH_MAP_CONTAINS);
MAP.put(CONCURRENT_HASH_MAP_CONTAINS_OPERATOR_ERROR, MESSAGE_FOR_CONCURRENT_HASH_MAP_CONTAINS);
MAP.put(TAILREC_WITH_DEFAULTS, "Computation order of non-constant default arguments in tail-recursive functions will change in 1.4. See KT-31540 for more details");
}
@NotNull

View File

@@ -10,10 +10,7 @@ import org.jetbrains.kotlin.descriptors.CallableDescriptor;
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
import org.jetbrains.kotlin.diagnostics.*;
import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.psi.KtAnnotationEntry;
import org.jetbrains.kotlin.psi.KtDeclaration;
import org.jetbrains.kotlin.psi.KtElement;
import org.jetbrains.kotlin.psi.KtExpression;
import org.jetbrains.kotlin.psi.*;
import org.jetbrains.kotlin.types.KotlinType;
import static org.jetbrains.kotlin.diagnostics.PositioningStrategies.*;
@@ -135,6 +132,8 @@ public interface ErrorsJvm {
DiagnosticFactory0<PsiElement> CONCURRENT_HASH_MAP_CONTAINS_OPERATOR = DiagnosticFactory0.create(WARNING);
DiagnosticFactory0<PsiElement> CONCURRENT_HASH_MAP_CONTAINS_OPERATOR_ERROR = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<KtNamedFunction> TAILREC_WITH_DEFAULTS = DiagnosticFactory0.create(WARNING, DECLARATION_SIGNATURE);
@SuppressWarnings("UnusedDeclaration")
Object _initializer = new Object() {
{

View File

@@ -32,7 +32,7 @@ import org.jetbrains.kotlin.resolve.scopes.LexicalScope
import org.jetbrains.kotlin.resolve.scopes.utils.memberScopeAsImportingScope
open class PartialAnalysisHandlerExtension : AnalysisHandlerExtension {
protected open val analyzePartially: Boolean
open val analyzePartially: Boolean
get() = true
override fun doAnalysis(

View File

@@ -38,7 +38,8 @@ object JvmPlatformConfigurator : PlatformConfiguratorBase(
JvmAnnotationsTargetNonExistentAccessorChecker(),
BadInheritedJavaSignaturesChecker,
JvmMultifileClassStateChecker,
SynchronizedOnInlineMethodChecker
SynchronizedOnInlineMethodChecker,
DefaultCheckerInTailrec
),
additionalCallCheckers = listOf(

View File

@@ -585,6 +585,8 @@ public interface Errors {
DiagnosticFactory0<KtParameter> VALUE_PARAMETER_WITH_NO_TYPE_ANNOTATION = DiagnosticFactory0.create(ERROR);
DiagnosticFactory0<KtNamedFunction> NO_TAIL_CALLS_FOUND = DiagnosticFactory0.create(WARNING, DECLARATION_SIGNATURE);
DiagnosticFactory0<KtNamedFunction> TAILREC_ON_VIRTUAL_MEMBER = DiagnosticFactory0.create(WARNING, DECLARATION_SIGNATURE);
DiagnosticFactory0<KtNamedFunction> TAILREC_ON_VIRTUAL_MEMBER_ERROR = DiagnosticFactory0.create(ERROR, DECLARATION_SIGNATURE);
DiagnosticFactory0<KtParameter>
ANONYMOUS_FUNCTION_PARAMETER_WITH_DEFAULT_VALUE = DiagnosticFactory0.create(ERROR, PARAMETER_DEFAULT_VALUE);

View File

@@ -203,7 +203,7 @@ public class DefaultErrorMessages {
MAP.put(SPREAD_OF_LAMBDA_OR_CALLABLE_REFERENCE, "The spread operator (*foo) cannot be applied to lambda argument or callable reference");
MAP.put(MANY_LAMBDA_EXPRESSION_ARGUMENTS, "Only one lambda expression is allowed outside a parenthesized argument list");
MAP.put(UNEXPECTED_TRAILING_LAMBDA_ON_A_NEW_LINE, "Expression is treated a trailing lambda argument; consider separating it from call with semicolon");
MAP.put(UNEXPECTED_TRAILING_LAMBDA_ON_A_NEW_LINE, "Expression is treated as a trailing lambda argument; consider separating it from call with semicolon");
MAP.put(PROPERTY_WITH_NO_TYPE_NO_INITIALIZER, "This property must either have a type annotation, be initialized or be delegated");
MAP.put(VARIABLE_WITH_NO_TYPE_NO_INITIALIZER, "This variable must either have a type annotation or be initialized");
@@ -619,6 +619,9 @@ public class DefaultErrorMessages {
MAP.put(ILLEGAL_SELECTOR, "The expression cannot be a selector (occur after a dot)");
MAP.put(NO_TAIL_CALLS_FOUND, "A function is marked as tail-recursive but no tail calls are found");
MAP.put(TAILREC_ON_VIRTUAL_MEMBER, "Tailrec on open members is deprecated");
MAP.put(TAILREC_ON_VIRTUAL_MEMBER_ERROR, "Tailrec is not allowed on open members");
MAP.put(VALUE_PARAMETER_WITH_NO_TYPE_ANNOTATION, "A type annotation is required on a value parameter");
MAP.put(BREAK_OR_CONTINUE_OUTSIDE_A_LOOP, "'break' and 'continue' are only allowed inside a loop");
MAP.put(BREAK_OR_CONTINUE_IN_WHEN, "'break' and 'continue' are not allowed in 'when' statements. Consider using labels to continue/break from the outer loop");

View File

@@ -31,7 +31,8 @@ private val DEFAULT_DECLARATION_CHECKERS = listOf(
AnnotationClassTargetAndRetentionChecker(),
ReservedMembersAndConstructsForInlineClass(),
ResultClassInReturnTypeChecker(),
LocalVariableTypeParametersChecker()
LocalVariableTypeParametersChecker(),
TailrecFunctionChecker
)
private val DEFAULT_CALL_CHECKERS = listOf(

View File

@@ -0,0 +1,28 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.resolve.checkers
import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.psi.KtDeclaration
import org.jetbrains.kotlin.psi.KtNamedFunction
import org.jetbrains.kotlin.resolve.isEffectivelyFinal
object TailrecFunctionChecker : DeclarationChecker {
override fun check(declaration: KtDeclaration, descriptor: DeclarationDescriptor, context: DeclarationCheckerContext) {
if (declaration !is KtNamedFunction || descriptor !is FunctionDescriptor || !descriptor.isTailrec) return
if (descriptor.isEffectivelyFinal(false)) return
if (!context.languageVersionSettings.supportsFeature(LanguageFeature.ProhibitTailrecOnVirtualMember)) {
context.trace.report(Errors.TAILREC_ON_VIRTUAL_MEMBER.on(declaration))
} else {
context.trace.report(Errors.TAILREC_ON_VIRTUAL_MEMBER_ERROR.on(declaration))
}
}
}

View File

@@ -28,6 +28,7 @@ import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.BindingTrace
import org.jetbrains.kotlin.resolve.calls.components.hasDefaultValue
import org.jetbrains.kotlin.resolve.descriptorUtil.declaresOrInheritsDefaultValue
import org.jetbrains.kotlin.resolve.isEffectivelyFinal
class InlineAnalyzerExtension(
private val reasonableInlineRules: Iterable<ReasonableInlineRule>,
@@ -159,7 +160,8 @@ class InlineAnalyzerExtension(
}
}
if (callableDescriptor.isEffectivelyFinal()) {
//TODO: actually it should be isEffectivelyFinal(false), but looks like it requires committee decision: KT-34372)
if (callableDescriptor.isEffectivelyFinal(true)) {
if (overridesAnything) {
trace.report(Errors.OVERRIDE_BY_INLINE.on(functionOrProperty))
}
@@ -168,12 +170,6 @@ class InlineAnalyzerExtension(
trace.report(Errors.DECLARATION_CANT_BE_INLINED.on(functionOrProperty))
}
private fun CallableMemberDescriptor.isEffectivelyFinal(): Boolean =
modality == Modality.FINAL ||
containingDeclaration.let { containingDeclaration ->
containingDeclaration is ClassDescriptor && containingDeclaration.modality == Modality.FINAL
}
private fun checkHasInlinableAndNullability(functionDescriptor: FunctionDescriptor, function: KtFunction, trace: BindingTrace) {
var hasInlineArgs = false
function.valueParameters.zip(functionDescriptor.valueParameters).forEach { (parameter, descriptor) ->

View File

@@ -5,7 +5,10 @@
package org.jetbrains.kotlin.resolve
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.types.DeferredType
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.typeUtil.contains
@@ -24,3 +27,11 @@ fun FunctionDescriptor.isFunctionForExpectTypeFromCastFeature(): Boolean {
return true
}
internal fun CallableMemberDescriptor.isEffectivelyFinal(ignoreEnumClassFinality: Boolean): Boolean =
modality == Modality.FINAL ||
containingDeclaration.let { parent ->
(ignoreEnumClassFinality || !DescriptorUtils.isEnumClass(parent)) &&
parent is ClassDescriptor && parent.modality == Modality.FINAL
}

View File

@@ -105,7 +105,10 @@ class DeclarationTable(
}
}
if (this is IrLazyDeclarationBase) return false
// Currently this check is skipped because LazyIr
// can be generated by kotlinx-serialization compiler plugin
// if (this is IrLazyDeclarationBase) return false
if (parent is IrPackageFragment) return true

View File

@@ -1325,7 +1325,6 @@ open class IrFileSerializer(
file.declarations
.filterIsInstance<IrProperty>()
.filter { it.backingField?.initializer != null && !it.isConst }
.filter { it.visibility.let { it == Visibilities.PUBLIC || it == Visibilities.INTERNAL } }
.forEach { proto.addExplicitlyExportedToCompiler(serializeIrSymbol(it.backingField!!.symbol)) }
// TODO: Konan specific

View File

@@ -59,50 +59,62 @@ abstract class KotlinIrLinker(
) : DescriptorUniqIdAware, IrDeserializer {
sealed class DeserializationState {
sealed class DeserializationState<T> {
val deserializedSymbols = mutableMapOf<UniqId, IrSymbol>()
val reachableTopLevels = mutableSetOf<UniqId>()
val deserializedTopLevels = mutableSetOf<UniqId>()
operator fun contains(key: UniqId) = key in deserializedSymbols
operator fun get(key: UniqId): IrSymbol = deserializedSymbols[key] ?: error("No deserialized symbol found for $key")
abstract fun addUniqID(key: UniqId)
protected open fun peekReachableKey(): UniqId? = reachableTopLevels.firstOrNull()
abstract fun processPendingDeclaration(processor: (T) -> Unit)
class ModuleDeserializationState(val module: IrModuleDeserializer): DeserializationState<IrModuleDeserializer.IrDeserializerForFile>() {
private val filesWithPendingTopLevels = mutableSetOf<IrModuleDeserializer.IrDeserializerForFile>()
fun enqueueFile(fileDeserializer: IrModuleDeserializer.IrDeserializerForFile) {
filesWithPendingTopLevels.add(fileDeserializer)
module.enqueueModule()
}
class ModuleDeserializationState(val module: IrModuleDeserializer): DeserializationState() {
override fun addUniqID(key: UniqId) {
module.addModuleReachableTopLevel(key)
val fileDeserializer = module.moduleReversedFileIndex[key] ?: error("No file found for key $key")
fileDeserializer.fileLocalDeserializationState.addUniqID(key)
enqueueFile(fileDeserializer)
}
override fun processPendingDeclaration(processor: (IrModuleDeserializer.IrDeserializerForFile) -> Unit) {
while (filesWithPendingTopLevels.isNotEmpty()) {
val pendingDeserializer = filesWithPendingTopLevels.first()
processor(pendingDeserializer)
filesWithPendingTopLevels.remove(pendingDeserializer)
}
}
}
class SimpleDeserializationState: DeserializationState() {
class SimpleDeserializationState: DeserializationState<UniqId>() {
private val reachableTopLevels = mutableSetOf<UniqId>()
override fun addUniqID(key: UniqId) {
reachableTopLevels.add(key)
}
override fun peekReachableKey(): UniqId {
return reachableTopLevels.firstOrNull() ?: error("Expecting non-empty set")
}
}
override fun processPendingDeclaration(processor: (UniqId) -> Unit) {
while (reachableTopLevels.isNotEmpty()) {
val reachableKey = reachableTopLevels.first()
fun processPendingDeclaration(processor: (UniqId) -> Unit) {
do {
if (deserializedSymbols[reachableKey]?.isBound == true) {
reachableTopLevels.remove(reachableKey)
continue
}
val reachableKey = peekReachableKey() ?: return
processor(reachableKey)
if (deserializedSymbols[reachableKey]?.isBound == true) {
reachableTopLevels.remove(reachableKey)
deserializedTopLevels.add(reachableKey)
continue
}
processor(reachableKey)
reachableTopLevels.remove(reachableKey)
deserializedTopLevels.add(reachableKey)
} while (reachableTopLevels.isNotEmpty())
}
}
}
@@ -127,7 +139,7 @@ abstract class KotlinIrLinker(
protected val moduleResolvedForwardDeclarations = mutableMapOf<UniqId, UniqId>()
private val moduleDeserializationState = DeserializationState.ModuleDeserializationState(this)
private val moduleReversedFileIndex = mutableMapOf<UniqId, IrDeserializerForFile>()
val moduleReversedFileIndex = mutableMapOf<UniqId, IrDeserializerForFile>()
private val moduleDependencies by lazy {
moduleDescriptor.allDependencyModules.filter { it != moduleDescriptor }.map { deserializersForModules[it]!! }
}
@@ -135,7 +147,7 @@ abstract class KotlinIrLinker(
// This is a heavy initializer
val module = deserializeIrModuleHeader()
inner class IrDeserializerForFile(private var annotationsProto: ProtoAnnotations?, private val fileIndex: Int, onlyHeaders: Boolean) :
inner class IrDeserializerForFile(private var annotationsProto: ProtoAnnotations?, private var fordcedDeclarations: List<UniqId>?, private val fileIndex: Int, onlyHeaders: Boolean) :
IrFileDeserializer(logger, builtIns, symbolTable) {
private var fileLoops = mutableMapOf<Int, IrLoopBase>()
@@ -285,7 +297,7 @@ abstract class KotlinIrLinker(
return moduleDependencies.firstOrNull { key in it.moduleReversedFileIndex }
}
private fun getStateForID(key: UniqId): DeserializationState {
private fun getStateForID(key: UniqId): DeserializationState<*> {
if (key.isLocal) return fileLocalDeserializationState
if (isGlobalUniqID(key)) return globalDeserializationState
return getModuleForTopLevelId(key)?.moduleDeserializationState ?: handleNoModuleDeserializerFound(key)
@@ -315,7 +327,7 @@ abstract class KotlinIrLinker(
resolvedForwardDeclarations[key]?.let {
val fdState = getStateForID(it)
fdState.addUniqID(it)
if (it !in fdState) fdState.addUniqID(it)
}
referenceDeserializedSymbol(proto, descriptor)
@@ -381,17 +393,18 @@ abstract class KotlinIrLinker(
}
}
fun deserializeFileAnnotationsIfFirstUse() {
fun deserializeFileImplicitDataIfFirstUse() {
annotationsProto?.let {
file.annotations.addAll(deserializeAnnotations(it))
annotationsProto = null
}
fordcedDeclarations?.let {
it.forEach { fileLocalDeserializationState.addUniqID(it) }
fordcedDeclarations = null
}
}
fun deserializeFileTopLevelDeclaration(key: UniqId) {
fileLocalDeserializationState.addUniqID(key)
fun deserializeAllFileReachableTopLevel() {
fileLocalDeserializationState.processPendingDeclaration {
val declaration = deserializeDeclaration(it)
file.declarations.add(declaration)
@@ -405,7 +418,10 @@ abstract class KotlinIrLinker(
val fileEntry = NaiveSourceBasedFileEntryImpl(fileName, fileProto.fileEntry.lineStartOffsetsList.toIntArray())
val fileDeserializer = IrDeserializerForFile(fileProto.annotations, fileIndex, !deserializationStrategy.needBodies)
val explicitlyExported = mutableListOf<UniqId>()
val fileDeserializer =
IrDeserializerForFile(fileProto.annotations, explicitlyExported, fileIndex, !deserializationStrategy.needBodies)
val fqName = fileDeserializer.deserializeFqName(fileProto.fqName)
@@ -417,24 +433,25 @@ abstract class KotlinIrLinker(
fileDeserializer.file = file
fileToDeserializerMap[file] = fileDeserializer
fileProto.declarationIdList.forEach {
val uniqId = it.uniqId()
assert(uniqId.isPublic)
moduleReversedFileIndex.getOrPut(uniqId) { fileDeserializer }
val fileUniqIdIndex = fileProto.declarationIdList.map { UniqId(it.index, it.isLocal) }
fileUniqIdIndex.forEach {
moduleReversedFileIndex.getOrPut(it) { fileDeserializer }
}
val forceLoadedIds = deserializationStrategy.run {
when {
theWholeWorld -> fileProto.declarationIdList
explicitlyExported -> fileProto.explicitlyExportedToCompilerList.map {
fileDeserializer.loadSymbolData(it.index).topLevelUniqId
}
else -> emptyList()
fileProto.explicitlyExportedToCompilerList.mapTo(explicitlyExported) {
fileDeserializer.loadSymbolData(it.index).topLevelUniqId.uniqId()
}
if (deserializationStrategy.theWholeWorld) {
for (id in fileUniqIdIndex) {
assert(id.isPublic)
moduleDeserializationState.addUniqID(id)
}
} else if (deserializationStrategy.explicitlyExported) {
moduleDeserializationState.enqueueFile(fileDeserializer)
}
forceLoadedIds.forEach { moduleDeserializationState.addUniqID(it.uniqId().also { i -> assert(i.isPublic) }) }
return file
}
@@ -447,25 +464,23 @@ abstract class KotlinIrLinker(
files.add(deserializeIrFile(ProtoFile.parseFrom(readFile(moduleDescriptor, i), newInstance()), i))
}
return IrModuleFragmentImpl(moduleDescriptor, builtIns, files)
}
fun deserializeAllModuleReachableTopLevels() {
moduleDeserializationState.processPendingDeclaration {
val fileDeserializer = moduleReversedFileIndex[it]
?: error("No file deserializer for key $it")
fileDeserializer.deserializeFileTopLevelDeclaration(it)
fileDeserializer.deserializeFileAnnotationsIfFirstUse()
moduleDeserializationState.processPendingDeclaration { fileDeserializer ->
fileDeserializer.deserializeFileImplicitDataIfFirstUse()
fileDeserializer.deserializeAllFileReachableTopLevel()
}
}
fun addModuleReachableTopLevel(topLevelKey: UniqId) {
moduleDeserializationState.reachableTopLevels.add(topLevelKey)
fun enqueueModule() {
modulesWithReachableTopLevels.add(this)
}
fun addModuleReachableTopLevel(key: UniqId) {
moduleDeserializationState.addUniqID(key)
}
}
protected abstract val descriptorReferenceDeserializer: DescriptorReferenceDeserializer
@@ -499,7 +514,7 @@ abstract class KotlinIrLinker(
protected abstract fun readFileCount(moduleDescriptor: ModuleDescriptor): Int
protected abstract fun checkAccessibility(declarationDescriptor: DeclarationDescriptor): Boolean
protected open fun handleNoModuleDeserializerFound(key: UniqId): DeserializationState {
protected open fun handleNoModuleDeserializerFound(key: UniqId): DeserializationState<*> {
error("Deserializer for declaration $key is not found")
}
@@ -522,7 +537,6 @@ abstract class KotlinIrLinker(
"Locally accessible declarations should not be accessed here $topLevelDescriptor"
}
if (topLevelDescriptor !is DeserializedClassDescriptor && topLevelDescriptor !is DeserializedCallableMemberDescriptor) {
return null
}
@@ -589,7 +603,7 @@ abstract class KotlinIrLinker(
}
}
private fun deserializeIrModuleHeader(
fun deserializeIrModuleHeader(
moduleDescriptor: ModuleDescriptor,
deserializationStrategy: DeserializationStrategy = DeserializationStrategy.ONLY_REFERENCED
): IrModuleFragment {

View File

@@ -12,8 +12,13 @@ import org.jetbrains.kotlin.descriptors.MemberDescriptor
import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor
import org.jetbrains.kotlin.resolve.checkers.ExpectedActualDeclarationChecker
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.library.KotlinLibrary
import org.jetbrains.kotlin.library.metadata.KlibMetadataPackageFragment
import org.jetbrains.kotlin.library.metadata.KlibMetadataProtoBuf
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.OverridingUtil
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedPropertyDescriptor
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedSimpleFunctionDescriptor
internal val DeclarationDescriptor.isExpectMember: Boolean
get() = this is MemberDescriptor && this.isExpect
@@ -49,3 +54,23 @@ internal fun <T : CallableMemberDescriptor> T.resolveFakeOverrideMaybeAbstract()
// This is Native specific. Try to eliminate.
val ModuleDescriptor.isForwardDeclarationModule get() =
name == Name.special("<forward declarations>")
private fun sourceByIndex(descriptor: CallableMemberDescriptor, index: Int): SourceFile {
val fragment = descriptor.findPackage() as KlibMetadataPackageFragment
return fragment.fileRegistry.sourceFile(index)
}
fun CallableMemberDescriptor.findSourceFile(): SourceFile {
val source = this.source.containingFile
if (source != SourceFile.NO_SOURCE_FILE)
return source
return when {
this is DeserializedSimpleFunctionDescriptor && proto.hasExtension(KlibMetadataProtoBuf.functionFile) ->
sourceByIndex(
this, proto.getExtension(KlibMetadataProtoBuf.functionFile))
this is DeserializedPropertyDescriptor && proto.hasExtension(KlibMetadataProtoBuf.propertyFile) ->
sourceByIndex(
this, proto.getExtension(KlibMetadataProtoBuf.propertyFile))
else -> TODO()
}
}

View File

@@ -3,7 +3,7 @@
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.ir.backend.js.lower.serialization.metadata
package org.jetbrains.kotlin.backend.common.serialization.metadata
import org.jetbrains.kotlin.library.metadata.KlibMetadataPackageFragment
import org.jetbrains.kotlin.psi.KtFile

View File

@@ -1,41 +0,0 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.ir.backend.js.lower.serialization.metadata
import org.jetbrains.kotlin.backend.common.serialization.metadata.extractFileId
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.DeclarationDescriptorWithSource
import org.jetbrains.kotlin.library.metadata.KlibMetadataPackageFragment
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.source.PsiSourceFile
class KlibMetadataFileRegistry {
private val fileIdsImpl = mutableMapOf<KlibFileMetadata, Int>()
fun lookup(file: KlibFileMetadata) = fileIdsImpl.getOrPut(file) { fileIdsImpl.size }
val fileIds: Map<KlibFileMetadata, Int>
get() = fileIdsImpl
fun getFileId(descriptor: DeclarationDescriptor): Int? {
if (!DescriptorUtils.isTopLevelDeclaration(descriptor) || descriptor !is DeclarationDescriptorWithSource) return null
val fileId = descriptor.extractFileId()
if (fileId != null) {
(descriptor.containingDeclaration as? KlibMetadataPackageFragment)?.let { packageFragment ->
return this.lookup(KotlinDeserializedFileMetadata(packageFragment, fileId))
}
}
val file = descriptor.source.containingFile as? PsiSourceFile ?: return null
val psiFile = file.psiFile
return (psiFile as? KtFile)?.let { this.lookup(KotlinPsiFileMetadata(it)) }
}
}

View File

@@ -11,8 +11,7 @@ import org.jetbrains.kotlin.config.AnalysisFlags
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
import org.jetbrains.kotlin.ir.backend.js.lower.serialization.metadata.KlibMetadataFileRegistry
import org.jetbrains.kotlin.ir.backend.js.lower.serialization.metadata.KotlinPsiFileMetadata
import org.jetbrains.kotlin.library.metadata.KlibMetadataFileRegistry
import org.jetbrains.kotlin.library.metadata.KlibMetadataProtoBuf
import org.jetbrains.kotlin.metadata.ProtoBuf
import org.jetbrains.kotlin.metadata.deserialization.BinaryVersion
@@ -35,7 +34,6 @@ abstract class KlibMetadataSerializer(
val metadataVersion: BinaryVersion,
val descriptorTable: DescriptorTable
) {
val fileRegistry = KlibMetadataFileRegistry()
lateinit var serializerContext: SerializerContext
@@ -57,7 +55,7 @@ abstract class KlibMetadataSerializer(
languageVersionSettings,
metadataVersion,
::declarationTableHandler,
{descriptor -> fileRegistry.getFileId(descriptor) } ,
{descriptor: DeclarationDescriptorWithSource -> fileRegistry.assign(descriptor.source.containingFile) } ,
KlibMetadataStringTable()
)
return SerializerContext(
@@ -82,10 +80,6 @@ abstract class KlibMetadataSerializer(
val (stringTableProto, nameTableProto) = serializerExtension.stringTable.buildProto()
// TODO: we place files table to each and every fragment.
// Need to refactor it out sonehow.
val files = serializeFiles(fileRegistry, bindingContext, AnnotationSerializer(serializerExtension.stringTable))
return ProtoBuf.PackageFragment.newBuilder()
.setPackage(packageProto)
.addAllClass_(classesProto.map { it.first })
@@ -95,7 +89,6 @@ abstract class KlibMetadataSerializer(
classesProto.forEach {
packageFragment.addExtension(KlibMetadataProtoBuf.className, it.second )
}
packageFragment.setExtension(KlibMetadataProtoBuf.packageFragmentFiles, files)
packageFragment.setExtension(KlibMetadataProtoBuf.isEmpty, isEmpty)
packageFragment.setExtension(KlibMetadataProtoBuf.fqName, fqName.asString())
}
@@ -224,32 +217,17 @@ abstract class KlibMetadataSerializer(
}
private fun serializeFiles(
fileRegistry: KlibMetadataFileRegistry,
bindingContext: BindingContext,
serializer: AnnotationSerializer
): KlibMetadataProtoBuf.Files {
val filesProto = KlibMetadataProtoBuf.Files.newBuilder()
for ((file, id) in fileRegistry.fileIds.entries.sortedBy { it.value }) {
header: KlibMetadataProtoBuf.Header.Builder,
fileRegistry: KlibMetadataFileRegistry
) {
fileRegistry.filesAndClear().map { it.name ?: "" }.forEach {
val fileProto = KlibMetadataProtoBuf.File.newBuilder()
if (id != filesProto.fileCount) {
fileProto.id = id
}
val annotations = when (file) {
is KotlinPsiFileMetadata -> file.ktFile.annotationEntries.map { bindingContext[BindingContext.ANNOTATION, it]!! }
//is KotlinDeserializedFileMetadata -> file.packageFragment.fileMap[file.fileId]!!.annotations
else -> TODO("support other file types")
}
for (annotation in annotations.filterOutSourceAnnotations()) {
fileProto.addAnnotation(serializer.serializeAnnotation(annotation))
}
val name = when (file) {
is KotlinPsiFileMetadata -> file.ktFile.getName()
else -> TODO("support other file types")
}
fileProto.name = name
filesProto.addFile(fileProto)
.setName(it)
.build()
header.addFile(fileProto)
}
return filesProto.build()
}
protected fun getPackagesFqNames(module: ModuleDescriptor): Set<FqName> {
@@ -296,6 +274,9 @@ abstract class KlibMetadataSerializer(
emptyPackages.forEach {
header.addEmptyPackage(it)
}
serializeFiles(header, fileRegistry)
return header.build()
}

View File

@@ -22,7 +22,7 @@ class KlibMetadataSerializerExtension(
private val languageVersionSettings: LanguageVersionSettings,
override val metadataVersion: BinaryVersion,
val declarationTableHandler: (DeclarationDescriptor) -> KlibMetadataProtoBuf.DescriptorUniqId?,
val descriptorFileId: (DeclarationDescriptor) -> Int?,
val descriptorFileId: (DeclarationDescriptorWithSource) -> Int?,
override val stringTable: StringTableImpl
) : KotlinSerializerExtensionBase(KlibMetadataSerializerProtocol) {
override fun shouldUseTypeTable(): Boolean = true

View File

@@ -12,7 +12,7 @@ dependencies {
testCompile(intellijCoreDep()) { includeJars("intellij-core") }
testCompile(project(":compiler:frontend"))
testCompile(project(":compiler:cli"))
testCompile(project(":compiler:cli-js"))
testCompile(project(":compiler:util"))
testRuntime(project(":kotlin-reflect"))

View File

@@ -10,6 +10,7 @@ import com.intellij.openapi.vfs.VfsUtilCore
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.backend.common.LoggingContext
import org.jetbrains.kotlin.backend.common.serialization.DescriptorTable
import org.jetbrains.kotlin.backend.common.serialization.DeserializationStrategy
import org.jetbrains.kotlin.backend.common.serialization.metadata.DynamicTypeDeserializer
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.config.CommonConfigurationKeys
@@ -41,6 +42,7 @@ import org.jetbrains.kotlin.library.impl.buildKoltinLibrary
import org.jetbrains.kotlin.library.impl.createKotlinLibrary
import org.jetbrains.kotlin.library.resolver.KotlinLibraryResolveResult
import org.jetbrains.kotlin.library.resolver.TopologicalLibraryOrder
import org.jetbrains.kotlin.library.resolver.impl.libraryResolver
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus
import org.jetbrains.kotlin.psi.KtFile
@@ -51,6 +53,7 @@ import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.BindingContextUtils
import org.jetbrains.kotlin.storage.LockBasedStorageManager
import org.jetbrains.kotlin.storage.StorageManager
import org.jetbrains.kotlin.util.Logger
import org.jetbrains.kotlin.utils.DFS
import java.io.File
import org.jetbrains.kotlin.konan.file.File as KFile
@@ -80,6 +83,29 @@ private val CompilerConfiguration.metadataVersion
class KotlinFileSerializedData(val metadata: ByteArray, val irData: SerializedIrFile)
// TODO: This is a temporary set of library resolver policies for js compiler.
fun jsResolveLibraries(libraries: List<String>, logger: Logger): KotlinLibraryResolveResult {
val unresolvedLibraries = libraries.map { UnresolvedLibrary(it ,null) }
val libraryAbsolutePaths = libraries.map{ File(it).absolutePath }
// Configure the resolver to only work with absolute paths for now.
val libraryResolver = KotlinLibrarySearchPathResolver<KotlinLibrary>(
repositories = emptyList(),
directLibs = libraryAbsolutePaths,
distributionKlib = null,
localKotlinDir = null,
skipCurrentDir = false,
logger = logger
).libraryResolver()
val resolvedLibraries =
libraryResolver.resolveWithDependencies(
unresolvedLibraries = unresolvedLibraries,
noStdLib = true,
noDefaultLibs = true,
noEndorsedLibs = true
)
return resolvedLibraries
}
fun generateKLib(
project: Project,
files: List<KtFile>,

View File

@@ -1,76 +0,0 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.ir.backend.js.lower.serialization.metadata
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.descriptors.SourceFile
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
import org.jetbrains.kotlin.library.metadata.KlibMetadataProtoBuf
import org.jetbrains.kotlin.metadata.ProtoBuf
import org.jetbrains.kotlin.metadata.deserialization.NameResolverImpl
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.serialization.deserialization.*
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
import org.jetbrains.kotlin.storage.StorageManager
import org.jetbrains.kotlin.storage.getValue
class JsKlibMetadataPackageFragment(
fqName: FqName,
storageManager: StorageManager,
module: ModuleDescriptor,
proto: ProtoBuf.PackageFragment,
header: KlibMetadataProtoBuf.Header,
metadataVersion: JsKlibMetadataVersion,
configuration: DeserializationConfiguration
) : DeserializedPackageFragmentImpl(
fqName, storageManager, module, proto, metadataVersion, JsContainerSource(fqName, header, configuration)
) {
val fileMap: Map<Int, FileHolder> =
proto.getExtension(KlibMetadataProtoBuf.packageFragmentFiles).fileList.withIndex().associate { (index, file) ->
(if (file.hasId()) file.id else index) to FileHolder(file.annotationList)
}
private lateinit var annotationDeserializer: AnnotationDeserializer
override fun initialize(components: DeserializationComponents) {
super.initialize(components)
this.annotationDeserializer = AnnotationDeserializer(components.moduleDescriptor, components.notFoundClasses)
}
inner class FileHolder(private val annotationsProto: List<ProtoBuf.Annotation>) {
val annotations: List<AnnotationDescriptor> by storageManager.createLazyValue {
annotationsProto.map { annotationDeserializer.deserializeAnnotation(it, nameResolver) }
}
}
class JsContainerSource(
private val fqName: FqName,
header: KlibMetadataProtoBuf.Header,
configuration: DeserializationConfiguration
) : DeserializedContainerSource {
val annotations: List<ClassId> =
if (header.annotationCount == 0) emptyList()
else NameResolverImpl(header.strings, header.qualifiedNames).let { nameResolver ->
// TODO: read arguments of module annotations
header.annotationList.map { annotation -> nameResolver.getClassId(annotation.id) }
}
// TODO
override fun getContainingFile(): SourceFile = SourceFile.NO_SOURCE_FILE
// This is null because we look for incompatible libraries in dependencies in the beginning of the compilation anyway,
// and refuse to compile against them completely
override val incompatibility: IncompatibleVersionErrorData<*>?
get() = null
override val isPreReleaseInvisible: Boolean =
configuration.reportErrorsOnPreReleaseDependencies && (header.flags and 1) != 0
override val presentableString: String
get() = "Package '$fqName'"
}
}

View File

@@ -9,15 +9,13 @@ import com.intellij.openapi.Disposable
import com.intellij.openapi.vfs.StandardFileSystems
import com.intellij.openapi.vfs.VirtualFileManager
import com.intellij.psi.PsiManager
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
import org.jetbrains.kotlin.cli.js.messageCollectorLogger
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import org.jetbrains.kotlin.config.*
import org.jetbrains.kotlin.js.config.JSConfigurationKeys
import org.jetbrains.kotlin.library.KotlinLibrary
import org.jetbrains.kotlin.library.KotlinLibrarySearchPathResolver
import org.jetbrains.kotlin.library.UnresolvedLibrary
import org.jetbrains.kotlin.library.resolver.KotlinLibraryResolveResult
import org.jetbrains.kotlin.library.resolver.impl.libraryResolver
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.resolve.multiplatform.isCommonSource
import org.jetbrains.kotlin.serialization.js.ModuleKind
@@ -117,18 +115,9 @@ fun main(args: Array<String>) {
error("Please set path to .klm file: `-o some/dir/module-name.klm`")
}
val dependencyAbsolutePaths = dependencies.map{ File(it).absolutePath }
val unresolvedLibraries = dependencies.map { UnresolvedLibrary(it, null) }
// Configure the resolver to only understand absolute path libraries.
val libraryResolver = KotlinLibrarySearchPathResolver<KotlinLibrary>(
repositories = emptyList(),
directLibs = dependencyAbsolutePaths,
distributionKlib = null,
localKotlinDir = null,
skipCurrentDir = true
// TODO: pass logger attached to message collector here.
).libraryResolver()
val resolvedLibraries = libraryResolver.resolveWithDependencies(unresolvedLibraries, true, true, true)
val resolvedLibraries = jsResolveLibraries(
dependencies, messageCollectorLogger(MessageCollector.NONE)
)
buildKLib(File(outputPath).absolutePath, listOfKtFilesFrom(inputFiles), outputPath, resolvedLibraries, listOfKtFilesFrom(commonSources))
}

View File

@@ -170,7 +170,7 @@ private class ClassFilterForClassOrObject(private val classOrObject: KtClassOrOb
if (classOrObject === processingClassOrObject) return true
// process all children
if (classOrObject.isAncestor(processingClassOrObject, true) || processingClassOrObject.isAncestor(classOrObject, true)) {
if (classOrObject.isAncestor(processingClassOrObject, true)) {
return true
}
@@ -196,8 +196,9 @@ private class ClassFilterForClassOrObject(private val classOrObject: KtClassOrOb
return false
}
override fun shouldGenerateClass(processingClassOrObject: KtClassOrObject) =
shouldGenerateClassMembers(processingClassOrObject)
override fun shouldGenerateClass(processingClassOrObject: KtClassOrObject)
// generate outer classes but not their members
= shouldGenerateClassMembers(processingClassOrObject) || processingClassOrObject.isAncestor(classOrObject, true)
override fun shouldGenerateScript(script: KtScript) = PsiTreeUtil.isAncestor(script, classOrObject, false)
override fun shouldGenerateCodeFragment(script: KtCodeFragment) = false

View File

@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.asJava.builder.InvalidLightClassDataHolder
import org.jetbrains.kotlin.asJava.builder.LightClassDataProviderForFileFacade
import org.jetbrains.kotlin.asJava.classes.KtLightClassForFacade
import org.jetbrains.kotlin.asJava.classes.KtLightClassForSourceDeclaration
import org.jetbrains.kotlin.asJava.classes.getOutermostClassOrObject
import org.jetbrains.kotlin.diagnostics.Diagnostic
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory.cast
@@ -49,7 +50,8 @@ fun getJvmSignatureDiagnostics(element: PsiElement, otherDiagnostics: Diagnostic
}
fun getDiagnosticsForClass(ktClassOrObject: KtClassOrObject): Diagnostics {
val lightClassDataHolder = KtLightClassForSourceDeclaration.getLightClassDataHolder(ktClassOrObject)
val outermostClass = getOutermostClassOrObject(ktClassOrObject)
val lightClassDataHolder = KtLightClassForSourceDeclaration.getLightClassDataHolder(outermostClass)
if (lightClassDataHolder is InvalidLightClassDataHolder) {
return Diagnostics.EMPTY
}

View File

@@ -472,6 +472,8 @@ class KtPsiFactory @JvmOverloads constructor(private val project: Project, val m
return file.importDirectives
}
fun createClassKeyword(): PsiElement = createClass("class A").getClassKeyword()!!
fun createPrimaryConstructor(text: String = ""): KtPrimaryConstructor {
return createClass(if (text.isNotEmpty()) "class A $text" else "class A()").primaryConstructor!!
}

View File

@@ -0,0 +1,15 @@
class Queue<T>(override val size: Int) : Collection<T> {
override fun contains(element: T): Boolean = TODO()
override fun containsAll(elements: Collection<T>): Boolean = TODO()
override fun isEmpty(): Boolean = TODO()
override fun iterator(): Iterator<T> = TODO()
fun remove(v: T): Any = v as Any
}
fun box(): String {
return Queue<String>(1).remove("OK") as String
}

View File

@@ -1,5 +1,5 @@
// !LANGUAGE: +ProperComputationOrderOfTailrecDefaultParameters
// DONT_RUN_GENERATED_CODE: JS
// IGNORE_BACKEND: JVM
var counter = 0
fun inc() = counter++

View File

@@ -1,3 +1,5 @@
// !LANGUAGE: +ProperComputationOrderOfTailrecDefaultParameters
// Flag above doesn't matter cause 1 default value is passed explicitly in tail recursion call
// DONT_RUN_GENERATED_CODE: JS
var counter = 0

View File

@@ -0,0 +1,17 @@
// !LANGUAGE: -ProperComputationOrderOfTailrecDefaultParameters
// TARGET_BACKEND: JVM
// IGNORE_BACKEND: JVM_IR
var counter = 0
fun calc(counter: Int) = if (counter % 2 == 0) "K" else "O"
<!TAILREC_WITH_DEFAULTS!>tailrec fun test(x: Int, y: String = calc(counter++), z: String = calc(counter++)): String<!> {
if (x > 0)
return y + z
return test(x + 1)
}
fun box(): String {
return test(0)
}

View File

@@ -0,0 +1,6 @@
package
public var counter: kotlin.Int
public fun box(): kotlin.String
public fun calc(/*0*/ counter: kotlin.Int): kotlin.String
public tailrec fun test(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.String = ..., /*2*/ z: kotlin.String = ...): kotlin.String

View File

@@ -0,0 +1,9 @@
// WITH_RUNTIME
// KJS_WITH_FULL_RUNTIME
fun box(): String {
return when(val foo = 42UL) {
42UL -> "OK"
else -> "Fail"
}
}

View File

@@ -0,0 +1,15 @@
// MODULE: lib
// FILE: lib.kt
// KT-34273
class Foo(val str: String)
private val foo1 = Foo("OK")
val foo2 = foo1
// MODULE: main(lib)
// FILE: main.kt
fun box(): String = foo2.str

View File

@@ -0,0 +1,24 @@
// IGNORE_BACKEND: JVM, JVM_IR
// MODULE: lib1
// FILE: lib1.kt
// KT-34273
var foo = "Fail"
// MODULE: lib2(lib1)
// FILE: lib2.kt
private val bar = run {
foo = "OK"
42
}
// MODULE: main(lib1, lib2)
// FILE: main.kt
// TODO: the proper behaviour of this test is still open design issue
// K/N & K/JS used to go like this when JVM fails
fun box(): String = foo

View File

@@ -0,0 +1,18 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE
class Outer<T> (val v: T) {
val prop: Any?
init {
class Inner(val v: T) {
override fun toString() = v.toString()
}
val value: Inner = Inner(v)
prop = value
}
}
fun box(): String {
return Outer("OK").prop.toString()
}

View File

@@ -0,0 +1,39 @@
//!LANGUAGE: +ProperComputationOrderOfTailrecDefaultParameters
import kotlin.reflect.KClass
fun withEffects(): String = "OK"
const val Z = "123"
enum class EnumA {
A
}
tailrec fun foo(i: Int = 1, c: Char = '2', s: String = "1234", b: Boolean = true, d: Double = 1.0, l: Long = 1L, y: String = withEffects()) {
foo(i, c, s, b, d, l, y)
}
tailrec fun foo2(x: Int = 1, y: String = withEffects(), z: String = Z) {
foo2(x, y, z)
}
tailrec fun foo3(y: String = withEffects()) {
foo3(y)
}
tailrec fun foo4(x: String = withEffects(), y: String = withEffects()) {
foo4(x, y)
}
tailrec fun foo5(x: String = withEffects(), y: String = withEffects(), z: String = withEffects()) {
foo5(x, y, z)
}
tailrec fun foo6(x: String = withEffects(), y: EnumA = EnumA.A) {
foo6(x, y)
}
tailrec fun foo7(x: String = withEffects(), y: KClass<out EnumA> = EnumA.A::class) {
foo7(x, y)
}

View File

@@ -0,0 +1,30 @@
package
public const val Z: kotlin.String = "123"
public tailrec fun foo(/*0*/ i: kotlin.Int = ..., /*1*/ c: kotlin.Char = ..., /*2*/ s: kotlin.String = ..., /*3*/ b: kotlin.Boolean = ..., /*4*/ d: kotlin.Double = ..., /*5*/ l: kotlin.Long = ..., /*6*/ y: kotlin.String = ...): kotlin.Unit
public tailrec fun foo2(/*0*/ x: kotlin.Int = ..., /*1*/ y: kotlin.String = ..., /*2*/ z: kotlin.String = ...): kotlin.Unit
public tailrec fun foo3(/*0*/ y: kotlin.String = ...): kotlin.Unit
public tailrec fun foo4(/*0*/ x: kotlin.String = ..., /*1*/ y: kotlin.String = ...): kotlin.Unit
public tailrec fun foo5(/*0*/ x: kotlin.String = ..., /*1*/ y: kotlin.String = ..., /*2*/ z: kotlin.String = ...): kotlin.Unit
public tailrec fun foo6(/*0*/ x: kotlin.String = ..., /*1*/ y: EnumA = ...): kotlin.Unit
public tailrec fun foo7(/*0*/ x: kotlin.String = ..., /*1*/ y: kotlin.reflect.KClass<out EnumA> = ...): kotlin.Unit
public fun withEffects(): kotlin.String
public final enum class EnumA : kotlin.Enum<EnumA> {
enum entry A
private constructor EnumA()
public final override /*1*/ /*fake_override*/ val name: kotlin.String
public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int
protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: EnumA): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit
public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class<EnumA!>!
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
// Static members
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): EnumA
public final /*synthesized*/ fun values(): kotlin.Array<EnumA>
}

View File

@@ -0,0 +1,171 @@
//!LANGUAGE: -ProhibitTailrecOnVirtualMember
open class A {
<!TAILREC_ON_VIRTUAL_MEMBER!>tailrec open fun foo(x: Int)<!> {
foo(x)
}
<!TAILREC_ON_VIRTUAL_MEMBER!>internal tailrec open fun bar(y: Int)<!> {
bar(y)
}
<!TAILREC_ON_VIRTUAL_MEMBER!>protected tailrec open fun baz(y: Int)<!> {
baz(y)
}
private tailrec fun boo(y: Int) {
boo(y)
}
internal tailrec fun baa(y: Int) {
baa(y)
}
}
open class B : A() {
final tailrec override fun foo(x: Int) {
foo(x)
}
final tailrec override fun bar(y: Int) {
bar(y)
}
final tailrec override fun baz(y: Int) {
baz(y)
}
}
open class C : A() {
<!TAILREC_ON_VIRTUAL_MEMBER!>tailrec override fun foo(x: Int)<!> {
foo(x)
}
<!TAILREC_ON_VIRTUAL_MEMBER!>tailrec override fun bar(y: Int)<!> {
bar(y)
}
<!TAILREC_ON_VIRTUAL_MEMBER!>tailrec override fun baz(y: Int)<!> {
baz(y)
}
}
object D : A() {
tailrec override fun foo(x: Int) {
foo(x)
}
tailrec override fun bar(y: Int) {
bar(y - 1)
}
tailrec override fun baz(y: Int) {
baz(y)
}
}
sealed class E : A() {
<!TAILREC_ON_VIRTUAL_MEMBER!>tailrec override fun foo(x: Int)<!> {
foo(x)
}
<!TAILREC_ON_VIRTUAL_MEMBER!>tailrec override fun bar(y: Int)<!> {
bar(y)
}
<!TAILREC_ON_VIRTUAL_MEMBER!>tailrec override fun baz(y: Int)<!> {
baz(y)
}
class E1 : E() {
tailrec override fun foo(x: Int) {
foo(x)
}
tailrec override fun bar(y: Int) {
bar(y)
}
tailrec override fun baz(y: Int) {
baz(y)
}
}
}
enum class F {
F0,
F1() {
tailrec override fun foo(x: Int) {
foo(x)
}
tailrec override fun bar(y: Int) {
bar(y)
}
tailrec override fun baz(y: Int) {
baz(y)
}
};
<!TAILREC_ON_VIRTUAL_MEMBER!>tailrec open fun foo(x: Int)<!> {
foo(x)
}
<!TAILREC_ON_VIRTUAL_MEMBER!>internal tailrec open fun bar(y: Int)<!> {
bar(y)
}
<!TAILREC_ON_VIRTUAL_MEMBER!>protected tailrec open fun baz(y: Int)<!> {
baz(y)
}
private tailrec fun boo(y: Int) {
boo(y)
}
internal tailrec fun baa(y: Int) {
baa(y)
}
}
enum class G {
G1;
<!TAILREC_ON_VIRTUAL_MEMBER!>tailrec open fun foo(x: Int)<!> {
foo(x)
}
<!TAILREC_ON_VIRTUAL_MEMBER!>internal tailrec open fun bar(y: Int)<!> {
bar(y)
}
<!TAILREC_ON_VIRTUAL_MEMBER!>protected tailrec open fun baz(y: Int)<!> {
baz(y)
}
private tailrec fun boo(y: Int) {
boo(y)
}
internal tailrec fun baa(y: Int) {
baa(y)
}
}
val z = object : A() {
tailrec override fun foo(x: Int) {
foo(x)
}
tailrec override fun bar(y: Int) {
bar(y)
}
tailrec override fun baz(y: Int) {
baz(y)
}
}

View File

@@ -0,0 +1,125 @@
package
public val z: A
public open class A {
public constructor A()
internal final tailrec fun baa(/*0*/ y: kotlin.Int): kotlin.Unit
internal open tailrec fun bar(/*0*/ y: kotlin.Int): kotlin.Unit
protected open tailrec fun baz(/*0*/ y: kotlin.Int): kotlin.Unit
private final tailrec fun boo(/*0*/ y: kotlin.Int): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open tailrec fun foo(/*0*/ x: kotlin.Int): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public open class B : A {
public constructor B()
internal final override /*1*/ tailrec /*fake_override*/ fun baa(/*0*/ y: kotlin.Int): kotlin.Unit
internal final override /*1*/ tailrec fun bar(/*0*/ y: kotlin.Int): kotlin.Unit
protected final override /*1*/ tailrec fun baz(/*0*/ y: kotlin.Int): kotlin.Unit
invisible_fake final override /*1*/ tailrec /*fake_override*/ fun boo(/*0*/ y: kotlin.Int): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final override /*1*/ tailrec fun foo(/*0*/ x: kotlin.Int): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public open class C : A {
public constructor C()
internal final override /*1*/ tailrec /*fake_override*/ fun baa(/*0*/ y: kotlin.Int): kotlin.Unit
internal open override /*1*/ tailrec fun bar(/*0*/ y: kotlin.Int): kotlin.Unit
protected open override /*1*/ tailrec fun baz(/*0*/ y: kotlin.Int): kotlin.Unit
invisible_fake final override /*1*/ tailrec /*fake_override*/ fun boo(/*0*/ y: kotlin.Int): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ tailrec fun foo(/*0*/ x: kotlin.Int): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public object D : A {
private constructor D()
internal final override /*1*/ tailrec /*fake_override*/ fun baa(/*0*/ y: kotlin.Int): kotlin.Unit
internal open override /*1*/ tailrec fun bar(/*0*/ y: kotlin.Int): kotlin.Unit
protected open override /*1*/ tailrec fun baz(/*0*/ y: kotlin.Int): kotlin.Unit
invisible_fake final override /*1*/ tailrec /*fake_override*/ fun boo(/*0*/ y: kotlin.Int): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ tailrec fun foo(/*0*/ x: kotlin.Int): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public sealed class E : A {
private constructor E()
internal final override /*1*/ tailrec /*fake_override*/ fun baa(/*0*/ y: kotlin.Int): kotlin.Unit
internal open override /*1*/ tailrec fun bar(/*0*/ y: kotlin.Int): kotlin.Unit
protected open override /*1*/ tailrec fun baz(/*0*/ y: kotlin.Int): kotlin.Unit
invisible_fake final override /*1*/ tailrec /*fake_override*/ fun boo(/*0*/ y: kotlin.Int): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ tailrec fun foo(/*0*/ x: kotlin.Int): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
public final class E1 : E {
public constructor E1()
internal final override /*1*/ tailrec /*fake_override*/ fun baa(/*0*/ y: kotlin.Int): kotlin.Unit
internal open override /*1*/ tailrec fun bar(/*0*/ y: kotlin.Int): kotlin.Unit
protected open override /*1*/ tailrec fun baz(/*0*/ y: kotlin.Int): kotlin.Unit
invisible_fake final override /*1*/ tailrec /*fake_override*/ fun boo(/*0*/ y: kotlin.Int): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ tailrec fun foo(/*0*/ x: kotlin.Int): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
}
public final enum class F : kotlin.Enum<F> {
enum entry F0
enum entry F1
private constructor F()
public final override /*1*/ /*fake_override*/ val name: kotlin.String
public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int
internal final tailrec fun baa(/*0*/ y: kotlin.Int): kotlin.Unit
internal open tailrec fun bar(/*0*/ y: kotlin.Int): kotlin.Unit
protected open tailrec fun baz(/*0*/ y: kotlin.Int): kotlin.Unit
private final tailrec fun boo(/*0*/ y: kotlin.Int): kotlin.Unit
protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: F): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit
public open tailrec fun foo(/*0*/ x: kotlin.Int): kotlin.Unit
public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class<F!>!
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
// Static members
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): F
public final /*synthesized*/ fun values(): kotlin.Array<F>
}
public final enum class G : kotlin.Enum<G> {
enum entry G1
private constructor G()
public final override /*1*/ /*fake_override*/ val name: kotlin.String
public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int
internal final tailrec fun baa(/*0*/ y: kotlin.Int): kotlin.Unit
internal open tailrec fun bar(/*0*/ y: kotlin.Int): kotlin.Unit
protected open tailrec fun baz(/*0*/ y: kotlin.Int): kotlin.Unit
private final tailrec fun boo(/*0*/ y: kotlin.Int): kotlin.Unit
protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: G): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit
public open tailrec fun foo(/*0*/ x: kotlin.Int): kotlin.Unit
public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class<G!>!
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
// Static members
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): G
public final /*synthesized*/ fun values(): kotlin.Array<G>
}

View File

@@ -0,0 +1,170 @@
//!LANGUAGE: +ProhibitTailrecOnVirtualMember
open class A {
<!TAILREC_ON_VIRTUAL_MEMBER_ERROR!>tailrec open fun foo(x: Int)<!> {
foo(x)
}
<!TAILREC_ON_VIRTUAL_MEMBER_ERROR!>internal tailrec open fun bar(y: Int)<!> {
bar(y)
}
<!TAILREC_ON_VIRTUAL_MEMBER_ERROR!>protected tailrec open fun baz(y: Int)<!> {
baz(y)
}
private tailrec fun boo(y: Int) {
boo(y)
}
internal tailrec fun baa(y: Int) {
baa(y)
}
}
open class B : A() {
final tailrec override fun foo(x: Int) {
foo(x)
}
final tailrec override fun bar(y: Int) {
bar(y)
}
final tailrec override fun baz(y: Int) {
baz(y)
}
}
open class C : A() {
<!TAILREC_ON_VIRTUAL_MEMBER_ERROR!>tailrec override fun foo(x: Int)<!> {
foo(x)
}
<!TAILREC_ON_VIRTUAL_MEMBER_ERROR!>tailrec override fun bar(y: Int)<!> {
bar(y)
}
<!TAILREC_ON_VIRTUAL_MEMBER_ERROR!>tailrec override fun baz(y: Int)<!> {
baz(y)
}
}
object D : A() {
tailrec override fun foo(x: Int) {
foo(x)
}
tailrec override fun bar(y: Int) {
bar(y - 1)
}
tailrec override fun baz(y: Int) {
baz(y)
}
}
sealed class E : A() {
<!TAILREC_ON_VIRTUAL_MEMBER_ERROR!>tailrec override fun foo(x: Int)<!> {
foo(x)
}
<!TAILREC_ON_VIRTUAL_MEMBER_ERROR!>tailrec override fun bar(y: Int)<!> {
bar(y)
}
<!TAILREC_ON_VIRTUAL_MEMBER_ERROR!>tailrec override fun baz(y: Int)<!> {
baz(y)
}
class E1 : E() {
tailrec override fun foo(x: Int) {
foo(x)
}
tailrec override fun bar(y: Int) {
bar(y)
}
tailrec override fun baz(y: Int) {
baz(y)
}
}
}
enum class F {
F0,
F1() {
tailrec override fun foo(x: Int) {
foo(x)
}
tailrec override fun bar(y: Int) {
bar(y)
}
tailrec override fun baz(y: Int) {
baz(y)
}
};
<!TAILREC_ON_VIRTUAL_MEMBER_ERROR!>tailrec open fun foo(x: Int)<!> {
foo(x)
}
<!TAILREC_ON_VIRTUAL_MEMBER_ERROR!>internal tailrec open fun bar(y: Int)<!> {
bar(y)
}
<!TAILREC_ON_VIRTUAL_MEMBER_ERROR!>protected tailrec open fun baz(y: Int)<!> {
baz(y)
}
private tailrec fun boo(y: Int) {
boo(y)
}
internal tailrec fun baa(y: Int) {
baa(y)
}
}
enum class G {
G1;
<!TAILREC_ON_VIRTUAL_MEMBER_ERROR!>tailrec open fun foo(x: Int)<!> {
foo(x)
}
<!TAILREC_ON_VIRTUAL_MEMBER_ERROR!>internal tailrec open fun bar(y: Int)<!> {
bar(y)
}
<!TAILREC_ON_VIRTUAL_MEMBER_ERROR!>protected tailrec open fun baz(y: Int)<!> {
baz(y)
}
private tailrec fun boo(y: Int) {
boo(y)
}
internal tailrec fun baa(y: Int) {
baa(y)
}
}
val z = object : A() {
tailrec override fun foo(x: Int) {
foo(x)
}
tailrec override fun bar(y: Int) {
bar(y)
}
tailrec override fun baz(y: Int) {
baz(y)
}
}

View File

@@ -0,0 +1,125 @@
package
public val z: A
public open class A {
public constructor A()
internal final tailrec fun baa(/*0*/ y: kotlin.Int): kotlin.Unit
internal open tailrec fun bar(/*0*/ y: kotlin.Int): kotlin.Unit
protected open tailrec fun baz(/*0*/ y: kotlin.Int): kotlin.Unit
private final tailrec fun boo(/*0*/ y: kotlin.Int): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open tailrec fun foo(/*0*/ x: kotlin.Int): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public open class B : A {
public constructor B()
internal final override /*1*/ tailrec /*fake_override*/ fun baa(/*0*/ y: kotlin.Int): kotlin.Unit
internal final override /*1*/ tailrec fun bar(/*0*/ y: kotlin.Int): kotlin.Unit
protected final override /*1*/ tailrec fun baz(/*0*/ y: kotlin.Int): kotlin.Unit
invisible_fake final override /*1*/ tailrec /*fake_override*/ fun boo(/*0*/ y: kotlin.Int): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final override /*1*/ tailrec fun foo(/*0*/ x: kotlin.Int): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public open class C : A {
public constructor C()
internal final override /*1*/ tailrec /*fake_override*/ fun baa(/*0*/ y: kotlin.Int): kotlin.Unit
internal open override /*1*/ tailrec fun bar(/*0*/ y: kotlin.Int): kotlin.Unit
protected open override /*1*/ tailrec fun baz(/*0*/ y: kotlin.Int): kotlin.Unit
invisible_fake final override /*1*/ tailrec /*fake_override*/ fun boo(/*0*/ y: kotlin.Int): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ tailrec fun foo(/*0*/ x: kotlin.Int): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public object D : A {
private constructor D()
internal final override /*1*/ tailrec /*fake_override*/ fun baa(/*0*/ y: kotlin.Int): kotlin.Unit
internal open override /*1*/ tailrec fun bar(/*0*/ y: kotlin.Int): kotlin.Unit
protected open override /*1*/ tailrec fun baz(/*0*/ y: kotlin.Int): kotlin.Unit
invisible_fake final override /*1*/ tailrec /*fake_override*/ fun boo(/*0*/ y: kotlin.Int): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ tailrec fun foo(/*0*/ x: kotlin.Int): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public sealed class E : A {
private constructor E()
internal final override /*1*/ tailrec /*fake_override*/ fun baa(/*0*/ y: kotlin.Int): kotlin.Unit
internal open override /*1*/ tailrec fun bar(/*0*/ y: kotlin.Int): kotlin.Unit
protected open override /*1*/ tailrec fun baz(/*0*/ y: kotlin.Int): kotlin.Unit
invisible_fake final override /*1*/ tailrec /*fake_override*/ fun boo(/*0*/ y: kotlin.Int): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ tailrec fun foo(/*0*/ x: kotlin.Int): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
public final class E1 : E {
public constructor E1()
internal final override /*1*/ tailrec /*fake_override*/ fun baa(/*0*/ y: kotlin.Int): kotlin.Unit
internal open override /*1*/ tailrec fun bar(/*0*/ y: kotlin.Int): kotlin.Unit
protected open override /*1*/ tailrec fun baz(/*0*/ y: kotlin.Int): kotlin.Unit
invisible_fake final override /*1*/ tailrec /*fake_override*/ fun boo(/*0*/ y: kotlin.Int): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ tailrec fun foo(/*0*/ x: kotlin.Int): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
}
public final enum class F : kotlin.Enum<F> {
enum entry F0
enum entry F1
private constructor F()
public final override /*1*/ /*fake_override*/ val name: kotlin.String
public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int
internal final tailrec fun baa(/*0*/ y: kotlin.Int): kotlin.Unit
internal open tailrec fun bar(/*0*/ y: kotlin.Int): kotlin.Unit
protected open tailrec fun baz(/*0*/ y: kotlin.Int): kotlin.Unit
private final tailrec fun boo(/*0*/ y: kotlin.Int): kotlin.Unit
protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: F): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit
public open tailrec fun foo(/*0*/ x: kotlin.Int): kotlin.Unit
public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class<F!>!
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
// Static members
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): F
public final /*synthesized*/ fun values(): kotlin.Array<F>
}
public final enum class G : kotlin.Enum<G> {
enum entry G1
private constructor G()
public final override /*1*/ /*fake_override*/ val name: kotlin.String
public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int
internal final tailrec fun baa(/*0*/ y: kotlin.Int): kotlin.Unit
internal open tailrec fun bar(/*0*/ y: kotlin.Int): kotlin.Unit
protected open tailrec fun baz(/*0*/ y: kotlin.Int): kotlin.Unit
private final tailrec fun boo(/*0*/ y: kotlin.Int): kotlin.Unit
protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: G): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit
public open tailrec fun foo(/*0*/ x: kotlin.Int): kotlin.Unit
public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class<G!>!
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
// Static members
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): G
public final /*synthesized*/ fun values(): kotlin.Array<G>
}

View File

@@ -0,0 +1,39 @@
//!LANGUAGE: -ProperComputationOrderOfTailrecDefaultParameters
import kotlin.reflect.KClass
fun withEffects(): String = "OK"
const val Z = "123"
enum class EnumA {
A
}
tailrec fun foo(i: Int = 1, c: Char = '2', s: String = "1234", b: Boolean = true, d: Double = 1.0, l: Long = 1L, y: String = withEffects()) {
foo(i, c, s, b, d, l, y)
}
tailrec fun foo2(x: Int = 1, y: String = withEffects(), z: String = Z) {
foo2(x, y, z)
}
tailrec fun foo3(y: String = withEffects()) {
foo3(y)
}
<!TAILREC_WITH_DEFAULTS!>tailrec fun foo4(x: String = withEffects(), y: String = withEffects())<!> {
foo4(x, y)
}
<!TAILREC_WITH_DEFAULTS!>tailrec fun foo5(x: String = withEffects(), y: String = withEffects(), z: String = withEffects())<!> {
foo5(x, y, z)
}
<!TAILREC_WITH_DEFAULTS!>tailrec fun foo6(x: String = withEffects(), y: EnumA = EnumA.A)<!> {
foo6(x, y)
}
<!TAILREC_WITH_DEFAULTS!>tailrec fun foo7(x: String = withEffects(), y: KClass<out EnumA> = EnumA.A::class)<!> {
foo7(x, y)
}

View File

@@ -0,0 +1,30 @@
package
public const val Z: kotlin.String = "123"
public tailrec fun foo(/*0*/ i: kotlin.Int = ..., /*1*/ c: kotlin.Char = ..., /*2*/ s: kotlin.String = ..., /*3*/ b: kotlin.Boolean = ..., /*4*/ d: kotlin.Double = ..., /*5*/ l: kotlin.Long = ..., /*6*/ y: kotlin.String = ...): kotlin.Unit
public tailrec fun foo2(/*0*/ x: kotlin.Int = ..., /*1*/ y: kotlin.String = ..., /*2*/ z: kotlin.String = ...): kotlin.Unit
public tailrec fun foo3(/*0*/ y: kotlin.String = ...): kotlin.Unit
public tailrec fun foo4(/*0*/ x: kotlin.String = ..., /*1*/ y: kotlin.String = ...): kotlin.Unit
public tailrec fun foo5(/*0*/ x: kotlin.String = ..., /*1*/ y: kotlin.String = ..., /*2*/ z: kotlin.String = ...): kotlin.Unit
public tailrec fun foo6(/*0*/ x: kotlin.String = ..., /*1*/ y: EnumA = ...): kotlin.Unit
public tailrec fun foo7(/*0*/ x: kotlin.String = ..., /*1*/ y: kotlin.reflect.KClass<out EnumA> = ...): kotlin.Unit
public fun withEffects(): kotlin.String
public final enum class EnumA : kotlin.Enum<EnumA> {
enum entry A
private constructor EnumA()
public final override /*1*/ /*fake_override*/ val name: kotlin.String
public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int
protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any
public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: EnumA): kotlin.Int
public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit
public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class<EnumA!>!
public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
// Static members
public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): EnumA
public final /*synthesized*/ fun values(): kotlin.Array<EnumA>
}

View File

@@ -5,73 +5,73 @@ Output:
-- JVM --
Exit code: COMPILATION_ERROR
Output:
compiler/testData/multiplatform/incompatibleCallables/common.kt:1:12: error: expected function 'f1' has no actual declaration in module
compiler/testData/multiplatform/incompatibleCallables/common.kt:1:12: error: expected function 'f1' has no actual declaration in module for JVM
The following declaration is incompatible because return type is different:
public actual fun f1(): String
expect fun f1()
^
compiler/testData/multiplatform/incompatibleCallables/common.kt:5:14: error: expected function 'f3' has no actual declaration in module
compiler/testData/multiplatform/incompatibleCallables/common.kt:5:14: error: expected function 'f3' has no actual declaration in module for JVM
The following declaration is incompatible because parameter types are different:
public actual fun f3(name: Double): Unit
expect fun f3(name: String)
^
compiler/testData/multiplatform/incompatibleCallables/common.kt:6:24: error: expected function 'f3ext' has no actual declaration in module
compiler/testData/multiplatform/incompatibleCallables/common.kt:6:24: error: expected function 'f3ext' has no actual declaration in module for JVM
The following declaration is incompatible because parameter types are different:
public actual fun Double.f3ext(): Unit
expect fun String.f3ext()
^
compiler/testData/multiplatform/incompatibleCallables/common.kt:8:14: error: expected function 'f4' has no actual declaration in module
compiler/testData/multiplatform/incompatibleCallables/common.kt:8:14: error: expected function 'f4' has no actual declaration in module for JVM
The following declaration is incompatible because parameter shapes are different (extension vs non-extension):
public actual fun String.f4(): Unit
expect fun f4(name: String)
^
compiler/testData/multiplatform/incompatibleCallables/common.kt:10:12: error: expected function 'f5' has no actual declaration in module
compiler/testData/multiplatform/incompatibleCallables/common.kt:10:12: error: expected function 'f5' has no actual declaration in module for JVM
The following declaration is incompatible because parameter shapes are different (extension vs non-extension):
public actual fun f5(name: String): Unit
expect fun String.f5()
^
compiler/testData/multiplatform/incompatibleCallables/common.kt:12:14: error: expected function 'f6' has no actual declaration in module
compiler/testData/multiplatform/incompatibleCallables/common.kt:12:14: error: expected function 'f6' has no actual declaration in module for JVM
The following declaration is incompatible because number of value parameters is different:
public actual fun f6(p2: Int): Unit
expect fun f6(p1: String, p2: Int)
^
compiler/testData/multiplatform/incompatibleCallables/common.kt:14:12: error: expected function 'f7' has no actual declaration in module
compiler/testData/multiplatform/incompatibleCallables/common.kt:14:12: error: expected function 'f7' has no actual declaration in module for JVM
The following declaration is incompatible because number of type parameters is different:
public actual fun <K, V> f7(): Unit
expect fun <T> f7()
^
compiler/testData/multiplatform/incompatibleCallables/common.kt:19:12: error: expected function 'f11' has no actual declaration in module
compiler/testData/multiplatform/incompatibleCallables/common.kt:19:12: error: expected function 'f11' has no actual declaration in module for JVM
The following declaration is incompatible because upper bounds of type parameters are different:
public actual fun <T : Annotation> f11(): Unit
expect fun <T : Number> f11()
^
compiler/testData/multiplatform/incompatibleCallables/common.kt:20:12: error: expected function 'f12' has no actual declaration in module
compiler/testData/multiplatform/incompatibleCallables/common.kt:20:12: error: expected function 'f12' has no actual declaration in module for JVM
The following declaration is incompatible because upper bounds of type parameters are different:
public actual fun <U : MutableList<out String>> f12(): Unit
expect fun <U : MutableList<String>> f12()
^
compiler/testData/multiplatform/incompatibleCallables/common.kt:21:12: error: expected function 'f13' has no actual declaration in module
compiler/testData/multiplatform/incompatibleCallables/common.kt:21:12: error: expected function 'f13' has no actual declaration in module for JVM
The following declaration is incompatible because upper bounds of type parameters are different:
public actual fun <A, B : Comparable<B>> f13(): Unit
expect fun <A, B : Comparable<A>> f13()
^
compiler/testData/multiplatform/incompatibleCallables/common.kt:32:15: error: expected function 'f21' has no actual declaration in module
compiler/testData/multiplatform/incompatibleCallables/common.kt:32:15: error: expected function 'f21' has no actual declaration in module for JVM
The following declaration is incompatible because parameter types are different:
public actual fun f21(c: Unit.() -> Unit): Unit
expect fun f21(c: suspend Unit.() -> Unit)
^
compiler/testData/multiplatform/incompatibleCallables/common.kt:33:15: error: expected function 'f22' has no actual declaration in module
compiler/testData/multiplatform/incompatibleCallables/common.kt:33:15: error: expected function 'f22' has no actual declaration in module for JVM
The following declaration is incompatible because parameter types are different:
public actual fun f22(c: suspend Unit.() -> Unit): Unit

View File

@@ -5,19 +5,19 @@ Output:
-- JVM --
Exit code: COMPILATION_ERROR
Output:
compiler/testData/multiplatform/incompatibleClasses/common.kt:14:16: error: expected class 'C1' has no actual declaration in module
compiler/testData/multiplatform/incompatibleClasses/common.kt:14:16: error: expected class 'C1' has no actual declaration in module for JVM
The following declaration is incompatible because number of type parameters is different:
public final actual class C1<A, Extra>
expect class C1<A>
^
compiler/testData/multiplatform/incompatibleClasses/common.kt:16:16: error: expected class 'C3' has no actual declaration in module
compiler/testData/multiplatform/incompatibleClasses/common.kt:16:16: error: expected class 'C3' has no actual declaration in module for JVM
The following declaration is incompatible because upper bounds of type parameters are different:
public final actual class C3<D, E : D?>
expect class C3<D, E : D>
^
compiler/testData/multiplatform/incompatibleClasses/common.kt:18:16: error: expected class 'C4' has no actual declaration in module
compiler/testData/multiplatform/incompatibleClasses/common.kt:18:16: error: expected class 'C4' has no actual declaration in module for JVM
The following declaration is incompatible because upper bounds of type parameters are different:
public actual typealias C4<F> = C4Impl<F>

View File

@@ -5,7 +5,7 @@ Output:
-- JVM --
Exit code: COMPILATION_ERROR
Output:
compiler/testData/multiplatform/missingOverload/common.kt:7:13: error: expected function 'g' has no actual declaration in module
compiler/testData/multiplatform/missingOverload/common.kt:7:13: error: expected function 'g' has no actual declaration in module for JVM
The following declaration is incompatible because parameter types are different:
public actual fun g(a: Any): Unit

View File

@@ -26,7 +26,7 @@ fun useInSignature(a: A) = a.toString()
compiler/testData/multiplatform/optionalExpectationIncorrectUse/common.kt:9:1: error: this annotation is not applicable to target 'class'
@OptionalExpectation
^
compiler/testData/multiplatform/optionalExpectationIncorrectUse/common.kt:10:14: error: expected class 'NotAnAnnotationClass' has no actual declaration in module
compiler/testData/multiplatform/optionalExpectationIncorrectUse/common.kt:10:14: error: expected class 'NotAnAnnotationClass' has no actual declaration in module for JVM
expect class NotAnAnnotationClass
^
compiler/testData/multiplatform/optionalExpectationIncorrectUse/common.kt:12:1: error: '@OptionalExpectation' can only be used on an expected annotation class

View File

@@ -471,6 +471,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
runTest("compiler/testData/diagnostics/tests/ProjectionsInSupertypes.kt");
}
@TestMetadata("properDefaultInitializationInTailrec.kt")
public void testProperDefaultInitializationInTailrec() throws Exception {
runTest("compiler/testData/diagnostics/tests/properDefaultInitializationInTailrec.kt");
}
@TestMetadata("Properties.kt")
public void testProperties() throws Exception {
runTest("compiler/testData/diagnostics/tests/Properties.kt");
@@ -611,6 +616,16 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
runTest("compiler/testData/diagnostics/tests/SyntaxErrorInTestHighlightingEof.kt");
}
@TestMetadata("tailRecOnVirtualMember.kt")
public void testTailRecOnVirtualMember() throws Exception {
runTest("compiler/testData/diagnostics/tests/tailRecOnVirtualMember.kt");
}
@TestMetadata("tailRecOnVirtualMemberError.kt")
public void testTailRecOnVirtualMemberError() throws Exception {
runTest("compiler/testData/diagnostics/tests/tailRecOnVirtualMemberError.kt");
}
@TestMetadata("tailRecOverridden.kt")
public void testTailRecOverridden() throws Exception {
runTest("compiler/testData/diagnostics/tests/tailRecOverridden.kt");
@@ -681,6 +696,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
runTest("compiler/testData/diagnostics/tests/UnitValue.kt");
}
@TestMetadata("unproperDefaultInitializationInTailrec.kt")
public void testUnproperDefaultInitializationInTailrec() throws Exception {
runTest("compiler/testData/diagnostics/tests/unproperDefaultInitializationInTailrec.kt");
}
@TestMetadata("Unresolved.kt")
public void testUnresolved() throws Exception {
runTest("compiler/testData/diagnostics/tests/Unresolved.kt");
@@ -24004,6 +24024,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgsWithSideEffects2.kt");
}
@TestMetadata("defaultArgsWithSideEffectsOld.kt")
public void testDefaultArgsWithSideEffectsOld() throws Exception {
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgsWithSideEffectsOld.kt");
}
@TestMetadata("extensionTailCall.kt")
public void testExtensionTailCall() throws Exception {
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/extensionTailCall.kt");

View File

@@ -471,6 +471,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
runTest("compiler/testData/diagnostics/tests/ProjectionsInSupertypes.kt");
}
@TestMetadata("properDefaultInitializationInTailrec.kt")
public void testProperDefaultInitializationInTailrec() throws Exception {
runTest("compiler/testData/diagnostics/tests/properDefaultInitializationInTailrec.kt");
}
@TestMetadata("Properties.kt")
public void testProperties() throws Exception {
runTest("compiler/testData/diagnostics/tests/Properties.kt");
@@ -611,6 +616,16 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
runTest("compiler/testData/diagnostics/tests/SyntaxErrorInTestHighlightingEof.kt");
}
@TestMetadata("tailRecOnVirtualMember.kt")
public void testTailRecOnVirtualMember() throws Exception {
runTest("compiler/testData/diagnostics/tests/tailRecOnVirtualMember.kt");
}
@TestMetadata("tailRecOnVirtualMemberError.kt")
public void testTailRecOnVirtualMemberError() throws Exception {
runTest("compiler/testData/diagnostics/tests/tailRecOnVirtualMemberError.kt");
}
@TestMetadata("tailRecOverridden.kt")
public void testTailRecOverridden() throws Exception {
runTest("compiler/testData/diagnostics/tests/tailRecOverridden.kt");
@@ -681,6 +696,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
runTest("compiler/testData/diagnostics/tests/UnitValue.kt");
}
@TestMetadata("unproperDefaultInitializationInTailrec.kt")
public void testUnproperDefaultInitializationInTailrec() throws Exception {
runTest("compiler/testData/diagnostics/tests/unproperDefaultInitializationInTailrec.kt");
}
@TestMetadata("Unresolved.kt")
public void testUnresolved() throws Exception {
runTest("compiler/testData/diagnostics/tests/Unresolved.kt");
@@ -23924,6 +23944,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgsWithSideEffects2.kt");
}
@TestMetadata("defaultArgsWithSideEffectsOld.kt")
public void testDefaultArgsWithSideEffectsOld() throws Exception {
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgsWithSideEffectsOld.kt");
}
@TestMetadata("extensionTailCall.kt")
public void testExtensionTailCall() throws Exception {
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/extensionTailCall.kt");

View File

@@ -4453,6 +4453,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/collections/removeAtInt.kt");
}
@TestMetadata("removeClash.kt")
public void testRemoveClash() throws Exception {
runTest("compiler/testData/codegen/box/collections/removeClash.kt");
}
@TestMetadata("strList.kt")
public void testStrList() throws Exception {
runTest("compiler/testData/codegen/box/collections/strList.kt");
@@ -9998,6 +10003,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgsWithSideEffects2.kt");
}
@TestMetadata("defaultArgsWithSideEffectsOld.kt")
public void testDefaultArgsWithSideEffectsOld() throws Exception {
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgsWithSideEffectsOld.kt");
}
@TestMetadata("extensionTailCall.kt")
public void testExtensionTailCall() throws Exception {
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/extensionTailCall.kt");
@@ -12750,6 +12760,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/inlineClasses/kt28920_javaPrimitiveType.kt");
}
@TestMetadata("kt34268.kt")
public void testKt34268() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/kt34268.kt");
}
@TestMetadata("mangledDefaultParameterFunction.kt")
public void testMangledDefaultParameterFunction() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/mangledDefaultParameterFunction.kt");
@@ -18303,6 +18318,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/properties/genericPropertyMultiModule.kt");
}
@TestMetadata("initOrderMultiModule.kt")
public void testInitOrderMultiModule() throws Exception {
runTest("compiler/testData/codegen/box/properties/initOrderMultiModule.kt");
}
@TestMetadata("javaPropertyBoxedGetter.kt")
public void testJavaPropertyBoxedGetter() throws Exception {
runTest("compiler/testData/codegen/box/properties/javaPropertyBoxedGetter.kt");
@@ -18513,6 +18533,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/properties/protectedJavaPropertyInCompanion.kt");
}
@TestMetadata("sideEffectInTopLevelInitializerMultiModule.kt")
public void testSideEffectInTopLevelInitializerMultiModule() throws Exception {
runTest("compiler/testData/codegen/box/properties/sideEffectInTopLevelInitializerMultiModule.kt");
}
@TestMetadata("substituteJavaSuperField.kt")
public void testSubstituteJavaSuperField() throws Exception {
runTest("compiler/testData/codegen/box/properties/substituteJavaSuperField.kt");
@@ -22997,6 +23022,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/regressions/kt2318.kt");
}
@TestMetadata("kt24913.kt")
public void testKt24913() throws Exception {
runTest("compiler/testData/codegen/box/regressions/kt24913.kt");
}
@TestMetadata("Kt2495Test.kt")
public void testKt2495Test() throws Exception {
runTest("compiler/testData/codegen/box/regressions/Kt2495Test.kt");

View File

@@ -4453,6 +4453,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/collections/removeAtInt.kt");
}
@TestMetadata("removeClash.kt")
public void testRemoveClash() throws Exception {
runTest("compiler/testData/codegen/box/collections/removeClash.kt");
}
@TestMetadata("strList.kt")
public void testStrList() throws Exception {
runTest("compiler/testData/codegen/box/collections/strList.kt");
@@ -9965,11 +9970,6 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class TailRecursion extends AbstractLightAnalysisModeTest {
@TestMetadata("defaultArgsWithSideEffects.kt")
public void ignoreDefaultArgsWithSideEffects() throws Exception {
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgsWithSideEffects.kt");
}
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath);
}
@@ -9993,11 +9993,21 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgsOverridden.kt");
}
@TestMetadata("defaultArgsWithSideEffects.kt")
public void testDefaultArgsWithSideEffects() throws Exception {
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgsWithSideEffects.kt");
}
@TestMetadata("defaultArgsWithSideEffects2.kt")
public void testDefaultArgsWithSideEffects2() throws Exception {
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgsWithSideEffects2.kt");
}
@TestMetadata("defaultArgsWithSideEffectsOld.kt")
public void testDefaultArgsWithSideEffectsOld() throws Exception {
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgsWithSideEffectsOld.kt");
}
@TestMetadata("extensionTailCall.kt")
public void testExtensionTailCall() throws Exception {
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/extensionTailCall.kt");
@@ -12755,6 +12765,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/inlineClasses/kt28920_javaPrimitiveType.kt");
}
@TestMetadata("kt34268.kt")
public void testKt34268() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/kt34268.kt");
}
@TestMetadata("mangledDefaultParameterFunction.kt")
public void testMangledDefaultParameterFunction() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/mangledDefaultParameterFunction.kt");
@@ -18303,6 +18318,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/properties/genericPropertyMultiModule.kt");
}
@TestMetadata("initOrderMultiModule.kt")
public void testInitOrderMultiModule() throws Exception {
runTest("compiler/testData/codegen/box/properties/initOrderMultiModule.kt");
}
@TestMetadata("javaPropertyBoxedGetter.kt")
public void testJavaPropertyBoxedGetter() throws Exception {
runTest("compiler/testData/codegen/box/properties/javaPropertyBoxedGetter.kt");
@@ -18513,6 +18533,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/properties/protectedJavaPropertyInCompanion.kt");
}
@TestMetadata("sideEffectInTopLevelInitializerMultiModule.kt")
public void testSideEffectInTopLevelInitializerMultiModule() throws Exception {
runTest("compiler/testData/codegen/box/properties/sideEffectInTopLevelInitializerMultiModule.kt");
}
@TestMetadata("substituteJavaSuperField.kt")
public void testSubstituteJavaSuperField() throws Exception {
runTest("compiler/testData/codegen/box/properties/substituteJavaSuperField.kt");
@@ -22997,6 +23022,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/regressions/kt2318.kt");
}
@TestMetadata("kt24913.kt")
public void testKt24913() throws Exception {
runTest("compiler/testData/codegen/box/regressions/kt24913.kt");
}
@TestMetadata("Kt2495Test.kt")
public void testKt2495Test() throws Exception {
runTest("compiler/testData/codegen/box/regressions/Kt2495Test.kt");

View File

@@ -4423,6 +4423,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/collections/removeAtInt.kt");
}
@TestMetadata("removeClash.kt")
public void testRemoveClash() throws Exception {
runTest("compiler/testData/codegen/box/collections/removeClash.kt");
}
@TestMetadata("strList.kt")
public void testStrList() throws Exception {
runTest("compiler/testData/codegen/box/collections/strList.kt");
@@ -8883,6 +8888,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgsWithSideEffects2.kt");
}
@TestMetadata("defaultArgsWithSideEffectsOld.kt")
public void testDefaultArgsWithSideEffectsOld() throws Exception {
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/defaultArgsWithSideEffectsOld.kt");
}
@TestMetadata("extensionTailCall.kt")
public void testExtensionTailCall() throws Exception {
runTest("compiler/testData/codegen/box/diagnostics/functions/tailRecursion/extensionTailCall.kt");
@@ -11635,6 +11645,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/inlineClasses/kt28920_javaPrimitiveType.kt");
}
@TestMetadata("kt34268.kt")
public void testKt34268() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/kt34268.kt");
}
@TestMetadata("mangledDefaultParameterFunction.kt")
public void testMangledDefaultParameterFunction() throws Exception {
runTest("compiler/testData/codegen/box/inlineClasses/mangledDefaultParameterFunction.kt");
@@ -17188,6 +17203,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/properties/genericPropertyMultiModule.kt");
}
@TestMetadata("initOrderMultiModule.kt")
public void testInitOrderMultiModule() throws Exception {
runTest("compiler/testData/codegen/box/properties/initOrderMultiModule.kt");
}
@TestMetadata("javaPropertyBoxedGetter.kt")
public void testJavaPropertyBoxedGetter() throws Exception {
runTest("compiler/testData/codegen/box/properties/javaPropertyBoxedGetter.kt");
@@ -17398,6 +17418,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/properties/protectedJavaPropertyInCompanion.kt");
}
@TestMetadata("sideEffectInTopLevelInitializerMultiModule.kt")
public void testSideEffectInTopLevelInitializerMultiModule() throws Exception {
runTest("compiler/testData/codegen/box/properties/sideEffectInTopLevelInitializerMultiModule.kt");
}
@TestMetadata("substituteJavaSuperField.kt")
public void testSubstituteJavaSuperField() throws Exception {
runTest("compiler/testData/codegen/box/properties/substituteJavaSuperField.kt");
@@ -21897,6 +21922,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/regressions/kt2318.kt");
}
@TestMetadata("kt24913.kt")
public void testKt24913() throws Exception {
runTest("compiler/testData/codegen/box/regressions/kt24913.kt");
}
@TestMetadata("Kt2495Test.kt")
public void testKt2495Test() throws Exception {
runTest("compiler/testData/codegen/box/regressions/Kt2495Test.kt");

View File

@@ -192,7 +192,7 @@ fun main(args: Array<String>) {
}
testClass<AbstractIrJsTextTestCase> {
model("ir/irJsText")
model("ir/irJsText", pattern = "^(.+)\\.kt(s)?\$")
}
testClass<AbstractIrCfgTestCase> {

View File

@@ -26,7 +26,7 @@ public class IrJsTextTestCaseGenerated extends AbstractIrJsTextTestCase {
}
public void testAllFilesPresentInIrJsText() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/ir/irJsText"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/ir/irJsText"), Pattern.compile("^(.+)\\.kt(s)?$"), TargetBackend.ANY, true);
}
@TestMetadata("compiler/testData/ir/irJsText/dynamic")
@@ -38,7 +38,7 @@ public class IrJsTextTestCaseGenerated extends AbstractIrJsTextTestCase {
}
public void testAllFilesPresentInDynamic() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/ir/irJsText/dynamic"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/ir/irJsText/dynamic"), Pattern.compile("^(.+)\\.kt(s)?$"), TargetBackend.ANY, true);
}
@TestMetadata("dynamicAndMembersOfAny.kt")
@@ -161,7 +161,7 @@ public class IrJsTextTestCaseGenerated extends AbstractIrJsTextTestCase {
}
public void testAllFilesPresentInNative() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/ir/irJsText/native"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/ir/irJsText/native"), Pattern.compile("^(.+)\\.kt(s)?$"), TargetBackend.ANY, true);
}
@TestMetadata("nativeNativeKotlin.kt")
@@ -169,4 +169,32 @@ public class IrJsTextTestCaseGenerated extends AbstractIrJsTextTestCase {
runTest("compiler/testData/ir/irJsText/native/nativeNativeKotlin.kt");
}
}
@TestMetadata("compiler/testData/ir/irJsText/scripting")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Scripting extends AbstractIrJsTextTestCase {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
}
public void testAllFilesPresentInScripting() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/ir/irJsText/scripting"), Pattern.compile("^(.+)\\.kt(s)?$"), TargetBackend.ANY, true);
}
@TestMetadata("arrayAssignment.kts")
public void testArrayAssignment() throws Exception {
runTest("compiler/testData/ir/irJsText/scripting/arrayAssignment.kts");
}
@TestMetadata("fun.kts")
public void testFun() throws Exception {
runTest("compiler/testData/ir/irJsText/scripting/fun.kts");
}
@TestMetadata("safeCalls.kts")
public void testSafeCalls() throws Exception {
runTest("compiler/testData/ir/irJsText/scripting/safeCalls.kts");
}
}
}

View File

@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.js.facade.MainCallParameters
import org.jetbrains.kotlin.js.facade.TranslationResult
import org.jetbrains.kotlin.js.resolve.JsPlatformAnalyzerServices
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.platform.js.JsPlatforms
import org.jetbrains.kotlin.resolve.BindingTraceContext
import org.jetbrains.kotlin.serialization.AbstractVersionRequirementTest
import org.jetbrains.kotlin.test.ConfigurationKind
@@ -78,7 +79,7 @@ class JsVersionRequirementTest : AbstractVersionRequirementTest() {
val config = JsConfig(environment.project, environment.configuration)
return ContextForNewModule(
ProjectContext(environment.project, "ProjectContext"),
Name.special("<test>"), JsPlatformAnalyzerServices.builtIns, null
Name.special("<test>"), JsPlatformAnalyzerServices.builtIns, JsPlatforms.defaultJsPlatform
).apply {
setDependencies(listOf(module) + config.moduleDescriptors + module.builtIns.builtInsModule)
}

View File

@@ -6,10 +6,11 @@ plugins {
description = "Common klib metadata reader and writer"
dependencies {
compileOnly(project(":compiler:frontend"))
compileOnly(project(":core:deserialization"))
compileOnly(project(":compiler:serialization"))
compile(kotlinStdlib())
compile(project(":compiler:frontend"))
compile(project(":core:deserialization"))
compile(project(":compiler:serialization"))
compile(project(":kotlin-util-io"))
compile(project(":kotlin-util-klib"))
}

View File

@@ -33,6 +33,7 @@ message Header {
repeated org.jetbrains.kotlin.metadata.Annotation annotation = 6;
repeated string package_fragment_name = 7;
repeated string empty_package = 8;
repeated File file = 9;
// TODO: Unused.
// TODO: We need to have backend specific extension for versionings.
@@ -42,14 +43,7 @@ message Header {
}
message File {
// If absent, id is the index of the file in the Files.file list
optional int32 id = 1;
required string name = 2;
repeated org.jetbrains.kotlin.metadata.Annotation annotation = 3;
}
message Files {
repeated File file = 1;
required string name = 1;
}
message DescriptorUniqId {
@@ -92,6 +86,10 @@ extend org.jetbrains.kotlin.metadata.EnumEntry {
optional DescriptorUniqId enum_entry_uniq_id = 172;
}
extend org.jetbrains.kotlin.metadata.ValueParameter {
repeated org.jetbrains.kotlin.metadata.Annotation parameter_annotation = 170;
}
extend org.jetbrains.kotlin.metadata.Type {
repeated org.jetbrains.kotlin.metadata.Annotation type_annotation = 170;
}
@@ -102,7 +100,7 @@ extend org.jetbrains.kotlin.metadata.TypeParameter {
}
extend org.jetbrains.kotlin.metadata.PackageFragment {
optional Files package_fragment_files = 170;
repeated int32 package_fragment_files = 170;
optional bool is_empty = 172;
optional string fq_name = 173;
// id in StringTable

View File

@@ -1,26 +1,13 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the LICENSE file.
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.backend.common.serialization.metadata
package org.jetbrains.kotlin.library.metadata
import org.jetbrains.kotlin.descriptors.SourceFile
import org.jetbrains.kotlin.library.KotlinLibrary
private class DeserializedSourceFile(
val name_: String, val index: Int, val library: KotlinLibrary) : SourceFile {
override fun getName(): String? = name_
override fun equals(other: Any?): Boolean {
return other is DeserializedSourceFile && library == other.library && index == other.index
}
override fun hashCode(): Int {
return library.hashCode() xor index
}
}
class SourceFileMap {
class KlibMetadataFileRegistry {
private val sourceToIndex = mutableMapOf<SourceFile, Int>()
private val indexToSource = mutableMapOf<Int, SourceFile>()
@@ -37,7 +24,7 @@ class SourceFileMap {
}
fun sourceFile(index: Int): SourceFile =
indexToSource[index] ?: throw Error("Unknown file for $index")
indexToSource[index] ?: throw Error("Unknown file for $index")
fun filesAndClear() =
sourceToIndex.keys.sortedBy {
@@ -51,4 +38,18 @@ class SourceFileMap {
sourceToIndex.clear()
indexToSource.clear()
}
}
class DeserializedSourceFile(
val name_: String, val index: Int, val library: KotlinLibrary
) : SourceFile {
override fun getName(): String? = name_
override fun equals(other: Any?): Boolean {
return other is DeserializedSourceFile && library == other.library && index == other.index
}
override fun hashCode(): Int {
return library.hashCode() xor index
}
}

View File

@@ -19,6 +19,16 @@ import org.jetbrains.kotlin.serialization.deserialization.getClassId
import org.jetbrains.kotlin.serialization.deserialization.getName
import org.jetbrains.kotlin.storage.StorageManager
private val KotlinLibrary.fileSources: KlibMetadataFileRegistry get() {
val result = KlibMetadataFileRegistry()
val proto = parseModuleHeader(moduleHeaderData)
proto.fileList.forEachIndexed { index, it ->
result.provide(it.name, index, this)
}
return result
}
class KlibMetadataPackageFragment(
fqName: FqName,
private val library: KotlinLibrary,
@@ -28,6 +38,10 @@ class KlibMetadataPackageFragment(
private val partName: String
) : DeserializedPackageFragment(fqName, storageManager, module) {
val fileRegistry: KlibMetadataFileRegistry by lazy {
library.fileSources
}
lateinit var components: DeserializationComponents
override fun initialize(components: DeserializationComponents) {

View File

@@ -5,7 +5,8 @@
package org.jetbrains.kotlin.serialization.konan.impl
import org.jetbrains.kotlin.backend.common.serialization.metadata.*
import org.jetbrains.kotlin.backend.common.serialization.metadata.KlibMetadataDeserializedPackageFragmentsFactory
import org.jetbrains.kotlin.backend.common.serialization.metadata.KlibMetadataModuleDescriptorFactory
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.builtins.functions.functionInterfacePackageFragmentProvider
import org.jetbrains.kotlin.config.LanguageVersionSettings
@@ -28,15 +29,14 @@ import org.jetbrains.kotlin.resolve.CompilerDeserializationConfiguration
import org.jetbrains.kotlin.serialization.deserialization.*
import org.jetbrains.kotlin.storage.StorageManager
val ModuleDescriptorImpl.isStdlibModule
get() = (this.klibModuleOrigin as? DeserializedKlibModuleOrigin)
?.library?.unresolvedDependencies?.isEmpty() ?: false
private val ModuleDescriptorImpl.isStdlibModule
get() = (this.klibModuleOrigin as? DeserializedKlibModuleOrigin)?.library?.unresolvedDependencies?.isEmpty() ?: false
class KlibMetadataModuleDescriptorFactoryImpl(
override val descriptorFactory: KlibModuleDescriptorFactory,
override val packageFragmentsFactory: KlibMetadataDeserializedPackageFragmentsFactory,
override val flexibleTypeDeserializer: FlexibleTypeDeserializer
): KlibMetadataModuleDescriptorFactory {
) : KlibMetadataModuleDescriptorFactory {
override fun createDescriptorOptionalBuiltIns(
library: KotlinLibrary,
@@ -89,11 +89,13 @@ class KlibMetadataModuleDescriptorFactoryImpl(
): PackageFragmentProvider {
val deserializedPackageFragments = packageFragmentsFactory.createDeserializedPackageFragments(
library, packageFragmentNames, moduleDescriptor, packageAccessHandler, storageManager)
library, packageFragmentNames, moduleDescriptor, packageAccessHandler, storageManager
)
// TODO: this is native specific. Move to a child class.
val syntheticPackageFragments = packageFragmentsFactory.createSyntheticPackageFragments(
library, deserializedPackageFragments, moduleDescriptor)
library, deserializedPackageFragments, moduleDescriptor
)
val provider = PackageFragmentProviderImpl(deserializedPackageFragments + syntheticPackageFragments)
@@ -119,21 +121,22 @@ class KlibMetadataModuleDescriptorFactoryImpl(
emptyList(),
notFoundClasses,
ContractDeserializerImpl(configuration, storageManager),
extensionRegistryLite = KlibMetadataSerializerProtocol.extensionRegistry)
extensionRegistryLite = KlibMetadataSerializerProtocol.extensionRegistry
)
for (packageFragment in deserializedPackageFragments) {
packageFragment.initialize(components)
}
return compositePackageFragmentAddend ?.let {
return compositePackageFragmentAddend?.let {
CompositePackageFragmentProvider(listOf(it, provider))
} ?: provider
}
fun createForwardDeclarationHackPackagePartProvider(
storageManager: StorageManager,
module: ModuleDescriptorImpl
): PackageFragmentProviderImpl {
storageManager: StorageManager,
module: ModuleDescriptorImpl
): PackageFragmentProviderImpl {
fun createPackage(fqName: FqName, supertypeName: String, classKind: ClassKind) =
ForwardDeclarationsPackageFragmentDescriptor(
storageManager,

View File

@@ -22,7 +22,7 @@ fun String.parseKonanAbiVersion(): KotlinAbiVersion {
data class KotlinAbiVersion(val version: Int) {
companion object {
val CURRENT = KotlinAbiVersion(16)
val CURRENT = KotlinAbiVersion(17)
}
override fun toString() = "$version"
}

View File

@@ -107,6 +107,8 @@ enum class LanguageFeature(
NonParenthesizedAnnotationsOnFunctionalTypes(KOTLIN_1_4),
UseGetterNameForPropertyAnnotationsMethodOnJvm(KOTLIN_1_4),
AllowBreakAndContinueInsideWhen(KOTLIN_1_4),
ProhibitTailrecOnVirtualMember(KOTLIN_1_4, kind = BUG_FIX),
ProperComputationOrderOfTailrecDefaultParameters(KOTLIN_1_4),
ProperVisibilityForCompanionObjectInstanceField(sinceVersion = null, kind = BUG_FIX),
// Temporarily disabled, see KT-27084/KT-22379

View File

@@ -13,7 +13,11 @@ open class KotlinExceptionWithAttachments : RuntimeException, ExceptionWithAttac
constructor(message: String) : super(message)
constructor(message: String?, cause: Throwable?) : super(message, cause)
constructor(message: String?, cause: Throwable?) : super(message, cause) {
if (cause is KotlinExceptionWithAttachments) {
attachments.addAll(cause.attachments)
}
}
override fun getAttachments(): Array<Attachment> = attachments.toTypedArray()

View File

@@ -0,0 +1,54 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.load.kotlin
import org.jetbrains.kotlin.metadata.jvm.deserialization.ModuleMapping
import org.jetbrains.kotlin.metadata.jvm.deserialization.PackageParts
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.serialization.deserialization.MetadataPartProvider
abstract class JvmPackagePartProviderBase<MappingsKey> : PackagePartProvider, MetadataPartProvider {
protected data class ModuleMappingInfo<MappingsKey>(val key: MappingsKey, val mapping: ModuleMapping, val name: String)
protected abstract val loadedModules: MutableList<ModuleMappingInfo<MappingsKey>>
override fun findPackageParts(packageFqName: String): List<String> {
val rootToPackageParts: Collection<PackageParts> = getPackageParts(packageFqName)
if (rootToPackageParts.isEmpty()) return emptyList()
val result = linkedSetOf<String>()
val visitedMultifileFacades = linkedSetOf<String>()
for (packageParts in rootToPackageParts) {
for (name in packageParts.parts) {
val facadeName = packageParts.getMultifileFacadeName(name)
if (facadeName == null || facadeName !in visitedMultifileFacades) {
result.add(name)
}
}
packageParts.parts.mapNotNullTo(visitedMultifileFacades, packageParts::getMultifileFacadeName)
}
return result.toList()
}
override fun findMetadataPackageParts(packageFqName: String): List<String> =
getPackageParts(packageFqName).flatMap(PackageParts::metadataParts).distinct()
private fun getPackageParts(packageFqName: String): Collection<PackageParts> {
val result = mutableMapOf<MappingsKey, PackageParts>()
for ((root, mapping) in loadedModules) {
val newParts = mapping.findPackageParts(packageFqName) ?: continue
result[root]?.let { parts -> parts += newParts } ?: result.put(root, newParts)
}
return result.values
}
override fun getAnnotationsOnBinaryModule(moduleName: String): List<ClassId> {
return loadedModules.mapNotNull { (_, mapping, name) ->
if (name == moduleName) mapping.moduleData.annotations.map(ClassId::fromString) else null
}.flatten()
}
}

View File

@@ -106,14 +106,15 @@ fun makeLazyJavaPackageFragmentFromClassLoaderProvider(
notFoundClasses: NotFoundClasses,
reflectKotlinClassFinder: KotlinClassFinder,
deserializedDescriptorResolver: DeserializedDescriptorResolver,
singleModuleClassResolver: ModuleClassResolver
singleModuleClassResolver: ModuleClassResolver,
packagePartProvider: PackagePartProvider = PackagePartProvider.Empty
): LazyJavaPackageFragmentProvider {
val annotationTypeQualifierResolver = AnnotationTypeQualifierResolver(storageManager, Jsr305State.DISABLED)
val javaResolverComponents = JavaResolverComponents(
storageManager, ReflectJavaClassFinder(classLoader), reflectKotlinClassFinder, deserializedDescriptorResolver,
SignaturePropagator.DO_NOTHING, RuntimeErrorReporter, JavaResolverCache.EMPTY,
JavaPropertyInitializerEvaluator.DoNothing, SamConversionResolver.Empty, RuntimeSourceElementFactory,
singleModuleClassResolver, PackagePartProvider.Empty, SupertypeLoopChecker.EMPTY, LookupTracker.DO_NOTHING, module,
singleModuleClassResolver, packagePartProvider, SupertypeLoopChecker.EMPTY, LookupTracker.DO_NOTHING, module,
ReflectionTypes(module, notFoundClasses), annotationTypeQualifierResolver,
SignatureEnhancement(annotationTypeQualifierResolver, Jsr305State.DISABLED),
JavaClassesTracker.Default, JavaResolverSettings.Default, NewKotlinTypeChecker.Default

View File

@@ -30,7 +30,9 @@ fun ClassifierDescriptorWithTypeParameters.computeConstructorTypeParameters(): L
val parametersFromContainingFunctions =
parents.takeWhile { it is CallableDescriptor }
.flatMap { (it as CallableDescriptor).typeParameters.asSequence() }.toList()
.filter { it !is ConstructorDescriptor }
.flatMap { (it as CallableDescriptor).typeParameters.asSequence() }
.toList()
val containingClassTypeConstructorParameters = parents.firstIsInstanceOrNull<ClassDescriptor>()?.typeConstructor?.parameters.orEmpty()
if (parametersFromContainingFunctions.isEmpty() && containingClassTypeConstructorParameters.isEmpty()) return declaredTypeParameters

View File

@@ -723,7 +723,8 @@ internal class DescriptorRendererImpl(
private fun renderConstructor(constructor: ConstructorDescriptor, builder: StringBuilder) {
builder.renderAnnotations(constructor)
val visibilityRendered = renderVisibility(constructor.visibility, builder)
val visibilityRendered = (options.renderDefaultVisibility || constructor.constructedClass.modality != Modality.SEALED)
&& renderVisibility(constructor.visibility, builder)
renderMemberKind(constructor, builder)
val constructorKeywordRendered = renderConstructorKeyword || !constructor.isPrimary || visibilityRendered

View File

@@ -139,6 +139,7 @@ import org.jetbrains.kotlin.kapt.cli.test.AbstractArgumentParsingTest
import org.jetbrains.kotlin.kapt.cli.test.AbstractKaptToolIntegrationTest
import org.jetbrains.kotlin.kapt3.test.AbstractClassFileToSourceStubConverterTest
import org.jetbrains.kotlin.kapt3.test.AbstractKotlinKaptContextTest
import org.jetbrains.kotlin.nj2k.AbstractNewJavaToKotlinConverterMultiFileTest
import org.jetbrains.kotlin.nj2k.AbstractNewJavaToKotlinConverterSingleFileTest
import org.jetbrains.kotlin.nj2k.AbstractNewJavaToKotlinCopyPasteConversionTest
import org.jetbrains.kotlin.nj2k.AbstractTextNewJavaToKotlinCopyPasteConversionTest
@@ -1076,6 +1077,9 @@ fun main(args: Array<String>) {
testClass<AbstractTextNewJavaToKotlinCopyPasteConversionTest> {
model("copyPastePlainText", pattern = """^([^\.]+)\.txt$""")
}
testClass<AbstractNewJavaToKotlinConverterMultiFileTest> {
model("multiFile", extension = null, recursive = false)
}
}
testGroup("jps-plugin/jps-tests/test", "jps-plugin/testData") {

View File

@@ -149,6 +149,7 @@ import org.jetbrains.kotlin.kapt.cli.test.AbstractArgumentParsingTest
import org.jetbrains.kotlin.kapt.cli.test.AbstractKaptToolIntegrationTest
import org.jetbrains.kotlin.kapt3.test.AbstractClassFileToSourceStubConverterTest
import org.jetbrains.kotlin.kapt3.test.AbstractKotlinKaptContextTest
import org.jetbrains.kotlin.nj2k.AbstractNewJavaToKotlinConverterMultiFileTest
import org.jetbrains.kotlin.nj2k.AbstractNewJavaToKotlinConverterSingleFileTest
import org.jetbrains.kotlin.nj2k.AbstractNewJavaToKotlinCopyPasteConversionTest
import org.jetbrains.kotlin.nj2k.AbstractTextNewJavaToKotlinCopyPasteConversionTest
@@ -1011,6 +1012,9 @@ fun main(args: Array<String>) {
testClass<AbstractTextNewJavaToKotlinCopyPasteConversionTest> {
model("copyPastePlainText", pattern = """^([^\.]+)\.txt$""")
}
testClass<AbstractNewJavaToKotlinConverterMultiFileTest> {
model("multiFile", extension = null, recursive = false)
}
}
testGroup("jps-plugin/jps-tests/test", "jps-plugin/testData") {

View File

@@ -141,6 +141,7 @@ import org.jetbrains.kotlin.kapt.cli.test.AbstractArgumentParsingTest
import org.jetbrains.kotlin.kapt.cli.test.AbstractKaptToolIntegrationTest
import org.jetbrains.kotlin.kapt3.test.AbstractClassFileToSourceStubConverterTest
import org.jetbrains.kotlin.kapt3.test.AbstractKotlinKaptContextTest
import org.jetbrains.kotlin.nj2k.AbstractNewJavaToKotlinConverterMultiFileTest
import org.jetbrains.kotlin.nj2k.AbstractNewJavaToKotlinConverterSingleFileTest
import org.jetbrains.kotlin.nj2k.AbstractNewJavaToKotlinCopyPasteConversionTest
import org.jetbrains.kotlin.nj2k.AbstractTextNewJavaToKotlinCopyPasteConversionTest
@@ -983,6 +984,9 @@ fun main(args: Array<String>) {
testClass<AbstractTextNewJavaToKotlinCopyPasteConversionTest> {
model("copyPastePlainText", pattern = """^([^\.]+)\.txt$""")
}
testClass<AbstractNewJavaToKotlinConverterMultiFileTest> {
model("multiFile", extension = null, recursive = false)
}
}
/* There is no jps in AS

View File

@@ -141,6 +141,7 @@ import org.jetbrains.kotlin.kapt.cli.test.AbstractArgumentParsingTest
import org.jetbrains.kotlin.kapt.cli.test.AbstractKaptToolIntegrationTest
import org.jetbrains.kotlin.kapt3.test.AbstractClassFileToSourceStubConverterTest
import org.jetbrains.kotlin.kapt3.test.AbstractKotlinKaptContextTest
import org.jetbrains.kotlin.nj2k.AbstractNewJavaToKotlinConverterMultiFileTest
import org.jetbrains.kotlin.nj2k.AbstractNewJavaToKotlinConverterSingleFileTest
import org.jetbrains.kotlin.nj2k.AbstractNewJavaToKotlinCopyPasteConversionTest
import org.jetbrains.kotlin.nj2k.AbstractTextNewJavaToKotlinCopyPasteConversionTest
@@ -979,6 +980,9 @@ fun main(args: Array<String>) {
testClass<AbstractTextNewJavaToKotlinCopyPasteConversionTest> {
model("copyPastePlainText", pattern = """^([^\.]+)\.txt$""")
}
testClass<AbstractNewJavaToKotlinConverterMultiFileTest> {
model("multiFile", extension = null, recursive = false)
}
}
/* There is no jps in AS

View File

@@ -141,6 +141,7 @@ import org.jetbrains.kotlin.kapt.cli.test.AbstractArgumentParsingTest
import org.jetbrains.kotlin.kapt.cli.test.AbstractKaptToolIntegrationTest
import org.jetbrains.kotlin.kapt3.test.AbstractClassFileToSourceStubConverterTest
import org.jetbrains.kotlin.kapt3.test.AbstractKotlinKaptContextTest
import org.jetbrains.kotlin.nj2k.AbstractNewJavaToKotlinConverterMultiFileTest
import org.jetbrains.kotlin.nj2k.AbstractNewJavaToKotlinConverterSingleFileTest
import org.jetbrains.kotlin.nj2k.AbstractNewJavaToKotlinCopyPasteConversionTest
import org.jetbrains.kotlin.nj2k.AbstractTextNewJavaToKotlinCopyPasteConversionTest
@@ -979,6 +980,9 @@ fun main(args: Array<String>) {
testClass<AbstractTextNewJavaToKotlinCopyPasteConversionTest> {
model("copyPastePlainText", pattern = """^([^\.]+)\.txt$""")
}
testClass<AbstractNewJavaToKotlinConverterMultiFileTest> {
model("multiFile", extension = null, recursive = false)
}
}
/* There is no jps in AS

View File

@@ -51,6 +51,7 @@ val mirroredUrls = listOf(
"https://jetbrains.bintray.com/test-discovery",
"https://jetbrains.bintray.com/wormhole",
"https://jitpack.io",
"https://kotlin.bintray.com/dukat",
"https://kotlin.bintray.com/kotlin-dependencies",
"https://oss.sonatype.org/content/repositories/releases",
"https://oss.sonatype.org/content/repositories/snapshots",

View File

@@ -1,4 +1,4 @@
versions.intellijSdk=193.3793.14-EAP-SNAPSHOT
versions.intellijSdk=193.4099.13-EAP-SNAPSHOT
versions.androidBuildTools=r23.0.1
versions.idea.NodeJS=181.3494.12
versions.jar.asm-all=7.0.1

View File

@@ -62,16 +62,20 @@ import java.util.concurrent.ConcurrentMap
class IDELightClassGenerationSupport(private val project: Project) : LightClassGenerationSupport() {
private inner class KtUltraLightSupportImpl(private val element: KtElement, private val module: Module) : KtUltraLightSupport {
private inner class KtUltraLightSupportImpl(private val element: KtElement) : KtUltraLightSupport {
private val module = ModuleUtilCore.findModuleForPsiElement(element)
override val isReleasedCoroutine
get() = module.languageVersionSettings.supportsFeature(LanguageFeature.ReleaseCoroutines)
get() = module?.languageVersionSettings?.supportsFeature(LanguageFeature.ReleaseCoroutines) ?: true
private fun KtDeclaration.mayBeModifiedByCompilerPlugins(): Boolean {
val facet = KotlinFacet.get(module)
val pluginClasspaths = facet?.configuration?.settings?.compilerArguments?.pluginClasspaths
if (pluginClasspaths.isNullOrEmpty()) return false
module?.let {
val facet = KotlinFacet.get(it)
val pluginClasspaths = facet?.configuration?.settings?.compilerArguments?.pluginClasspaths
if (pluginClasspaths.isNullOrEmpty()) return false
}
val resolvedDescriptor = lazy(LazyThreadSafetyMode.NONE) {
resolveToDescriptorIfAny(
@@ -157,8 +161,7 @@ class IDELightClassGenerationSupport(private val project: Project) : LightClassG
if (files.any { it.isScript() }) return null
val filesToSupports: List<Pair<KtFile, KtUltraLightSupport>> = files.map {
val module = ModuleUtilCore.findModuleForPsiElement(it) ?: return null
it to KtUltraLightSupportImpl(it, module)
it to KtUltraLightSupportImpl(it)
}
return KtUltraLightClassForFacade(
@@ -178,9 +181,7 @@ class IDELightClassGenerationSupport(private val project: Project) : LightClassG
return null
}
val module = ModuleUtilCore.findModuleForPsiElement(element) ?: return null
return KtUltraLightSupportImpl(element, module).let { support ->
return KtUltraLightSupportImpl(element).let { support ->
when {
element is KtObjectDeclaration && element.isObjectLiteral() ->
KtUltraLightClassForAnonymousDeclaration(element, support)

View File

@@ -118,6 +118,9 @@ private class KotlinIdeaResolutionException(
appendln("---------------------------------------------")
append(creationPlace.description())
})
for (element in resolvingWhat.elements.withIndex()) {
withAttachment("element${element.index}.kt", element.value.text)
}
}
}
@@ -142,7 +145,7 @@ private class CreationPlace(
}
private class ResolvingWhat(
private val elements: Collection<PsiElement> = emptyList(),
val elements: Collection<PsiElement> = emptyList(),
private val bodyResolveMode: BodyResolveMode? = null,
private val serviceClass: Class<*>? = null,
private val moduleDescriptor: ModuleDescriptor? = null

View File

@@ -16,19 +16,16 @@
package org.jetbrains.kotlin.idea.codeInsight.shorten
import com.intellij.openapi.project.Project
import com.intellij.psi.SmartPsiElementPointer
import com.intellij.openapi.util.Key
import com.intellij.openapi.application.ApplicationManager
import com.intellij.psi.SmartPointerManager
import com.intellij.openapi.diagnostic.Logger
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiMember
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.Key
import com.intellij.psi.*
import org.jetbrains.kotlin.asJava.unwrapped
import org.jetbrains.kotlin.idea.caches.resolve.util.getJavaMemberDescriptor
import org.jetbrains.kotlin.idea.caches.resolve.unsafeResolveToDescriptor
import org.jetbrains.kotlin.idea.core.ShortenReferences.Options
import org.jetbrains.kotlin.idea.caches.resolve.util.getJavaMemberDescriptor
import org.jetbrains.kotlin.idea.core.ShortenReferences
import org.jetbrains.kotlin.idea.core.ShortenReferences.Options
import org.jetbrains.kotlin.idea.util.ImportInsertHelper
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.createSmartPointer
@@ -40,8 +37,8 @@ interface DelayedRefactoringRequest
class ShorteningRequest(val pointer: SmartPsiElementPointer<KtElement>, val options: Options) : DelayedRefactoringRequest
class ImportRequest(
val elementToImportPointer: SmartPsiElementPointer<PsiElement>,
val filePointer: SmartPsiElementPointer<KtFile>
val elementToImportPointer: SmartPsiElementPointer<PsiElement>,
val filePointer: SmartPsiElementPointer<KtFile>
) : DelayedRefactoringRequest
private var Project.delayedRefactoringRequests: MutableSet<DelayedRefactoringRequest>?
@@ -90,6 +87,7 @@ fun addDelayedImportRequest(elementToImport: PsiElement, file: KtFile) {
fun performDelayedRefactoringRequests(project: Project) {
project.delayedRefactoringRequests?.let { requests ->
project.delayedRefactoringRequests = null
PsiDocumentManager.getInstance(project).commitAllDocuments()
val shorteningRequests = ArrayList<ShorteningRequest>()
val importRequests = ArrayList<ImportRequest>()
@@ -103,7 +101,7 @@ fun performDelayedRefactoringRequests(project: Project) {
val elementToOptions = shorteningRequests.mapNotNull { req -> req.pointer.element?.let { it to req.options } }.toMap()
val elements = elementToOptions.keys
//TODO: this is not correct because it should not shorten deep into the elements!
ShortenReferences({ elementToOptions[it] ?: Options.DEFAULT }).process(elements)
ShortenReferences { elementToOptions[it] ?: Options.DEFAULT }.process(elements)
val importInsertHelper = ImportInsertHelper.getInstance(project)
@@ -127,7 +125,7 @@ private val LOG = Logger.getInstance(Project::class.java.canonicalName)
fun prepareDelayedRequests(project: Project) {
val requests = project.delayedRefactoringRequests
if (project.ensureNoRefactoringRequestsBeforeRefactoring && requests != null && !requests.isEmpty()) {
if (project.ensureNoRefactoringRequestsBeforeRefactoring && requests != null && requests.isNotEmpty()) {
LOG.warn("Waiting set for reference shortening is not empty")
project.delayedRefactoringRequests = null
}
@@ -137,7 +135,7 @@ var KtElement.isToBeShortened: Boolean? by CopyablePsiUserDataProperty(Key.creat
fun KtElement.addToBeShortenedDescendantsToWaitingSet() {
forEachDescendantOfType<KtElement> {
if (it.isToBeShortened ?: false) {
if (it.isToBeShortened == true) {
it.isToBeShortened = null
it.addToShorteningWaitSet()
}

View File

@@ -62,7 +62,7 @@ object IDELanguageSettingsProvider : LanguageSettingsProvider {
private fun computeJsr305State(project: Project): Jsr305State? {
var result: Jsr305State? = null
for (module in ModuleManager.getInstance(project).modules) {
val settings = KotlinFacetSettingsProvider.getInstance(project).getSettings(module) ?: continue
val settings = KotlinFacetSettingsProvider.getInstance(project)?.getSettings(module) ?: continue
val compilerArguments = settings.mergedCompilerArguments as? K2JVMCompilerArguments ?: continue
result = Jsr305Parser(MessageCollector.NONE).parse(

View File

@@ -92,7 +92,8 @@ private fun Iterable<String>.addReleaseVersionIfNecessary(shouldAdd: Boolean): I
if (shouldAdd) this + VersionView.RELEASED_VERSION.versionString else this
fun getRuntimeLibraryVersion(module: Module): String? {
val targetPlatform = KotlinFacetSettingsProvider.getInstance(module.project).getInitializedSettings(module).targetPlatform
val settingsProvider = KotlinFacetSettingsProvider.getInstance(module.project) ?: return null
val targetPlatform = settingsProvider.getInitializedSettings(module).targetPlatform
val versions = getRuntimeLibraryVersions(module, null, targetPlatform.orDefault().idePlatformKind)
return versions.toSet().singleOrNull()
}

View File

@@ -58,11 +58,11 @@ val KtElement.builtIns: KotlinBuiltIns
var KtFile.forcedTargetPlatform: TargetPlatform? by UserDataProperty(Key.create("FORCED_TARGET_PLATFORM"))
fun Module.getAndCacheLanguageLevelByDependencies(): LanguageVersion {
val facetSettings = KotlinFacetSettingsProvider.getInstance(project).getInitializedSettings(this)
val languageLevel = getLibraryLanguageLevel(this, null, facetSettings.targetPlatform?.idePlatformKind)
val facetSettings = KotlinFacetSettingsProvider.getInstance(project)?.getInitializedSettings(this)
val languageLevel = getLibraryLanguageLevel(this, null, facetSettings?.targetPlatform?.idePlatformKind)
// Preserve inferred version in facet/project settings
if (facetSettings.useProjectSettings) {
if (facetSettings == null || facetSettings.useProjectSettings) {
KotlinCommonCompilerArgumentsHolder.getInstance(project).update {
if (languageVersion == null) {
languageVersion = languageLevel.versionString
@@ -96,7 +96,8 @@ fun Module.getAndCacheLanguageLevelByDependencies(): LanguageVersion {
fun Module.getStableName(): Name {
// Here we check ideal situation: we have a facet, and it has 'moduleName' argument.
// This should be the case for the most environments
val arguments = KotlinFacetSettingsProvider.getInstance(project).getInitializedSettings(this).mergedCompilerArguments
val settingsProvider = KotlinFacetSettingsProvider.getInstance(project)
val arguments = settingsProvider?.getInitializedSettings(this)?.mergedCompilerArguments
val explicitNameFromArguments = when (arguments) {
is K2JVMCompilerArguments -> arguments.moduleName
is K2JSCompilerArguments -> arguments.outputFile?.let { FileUtil.getNameWithoutExtension(File(it)) }
@@ -179,25 +180,35 @@ private fun Module.createCachedValueForLanguageVersionSettings(): CachedValue<La
}
private fun Module.shouldUseProjectLanguageVersionSettings(): Boolean {
val facetSettingsProvider = KotlinFacetSettingsProvider.getInstance(project)
val facetSettingsProvider = KotlinFacetSettingsProvider.getInstance(project) ?: return true
return facetSettingsProvider.getSettings(this) == null || facetSettingsProvider.getInitializedSettings(this).useProjectSettings
}
private fun Module.computeLanguageVersionSettings(): LanguageVersionSettings {
if (shouldUseProjectLanguageVersionSettings()) return project.getLanguageVersionSettings()
val facetSettings = KotlinFacetSettingsProvider.getInstance(project).getInitializedSettings(this)
val languageVersion = facetSettings.languageLevel ?: getAndCacheLanguageLevelByDependencies()
val apiVersion = facetSettings.apiLevel ?: languageVersion
val facetSettings = KotlinFacetSettingsProvider.getInstance(project)?.getInitializedSettings(this)
val languageFeatures = facetSettings.mergedCompilerArguments?.configureLanguageFeatures(MessageCollector.NONE)?.apply {
val languageVersion: LanguageVersion
val apiVersion: LanguageVersion
if (facetSettings != null) {
languageVersion = facetSettings.languageLevel ?: getAndCacheLanguageLevelByDependencies()
apiVersion = facetSettings.apiLevel ?: languageVersion
} else {
languageVersion = getAndCacheLanguageLevelByDependencies()
apiVersion = languageVersion
}
val languageFeatures = facetSettings?.mergedCompilerArguments?.configureLanguageFeatures(MessageCollector.NONE)?.apply {
configureCoroutinesSupport(facetSettings.coroutineSupport, languageVersion)
configureMultiplatformSupport(facetSettings.targetPlatform?.idePlatformKind, this@computeLanguageVersionSettings)
configureNewInferenceSupportInIDE(project)
}.orEmpty()
val analysisFlags = facetSettings
.mergedCompilerArguments
?.mergedCompilerArguments
?.configureAnalysisFlags(MessageCollector.NONE)
?.apply { initIDESpecificAnalysisSettings(project) }
.orEmpty()
@@ -218,10 +229,10 @@ private fun MutableMap<AnalysisFlag<*>, Any>.initIDESpecificAnalysisSettings(pro
}
val Module.platform: TargetPlatform?
get() = KotlinFacetSettingsProvider.getInstance(project).getInitializedSettings(this).targetPlatform ?: project.platform
get() = KotlinFacetSettingsProvider.getInstance(project)?.getInitializedSettings(this)?.targetPlatform ?: project.platform
val Module.isHMPPEnabled: Boolean
get() = KotlinFacetSettingsProvider.getInstance(project).getInitializedSettings(this).isHmppEnabled
get() = KotlinFacetSettingsProvider.getInstance(project)?.getInitializedSettings(this)?.isHmppEnabled ?: false
// FIXME(dsavvinov): this logic is clearly wrong in MPP environment; review and fix
val Project.platform: TargetPlatform?

View File

@@ -226,7 +226,9 @@ class ShortenReferences(val options: (KtElement) -> Options = { Options.DEFAULT
failedToImportDescriptors.add(descriptor)
}
}
if (!anyChange) processors.forEach { it.removeRootPrefixes() }
}
if (!anyChange) break
}
@@ -249,6 +251,7 @@ class ShortenReferences(val options: (KtElement) -> Options = { Options.DEFAULT
var options: Options = Options.DEFAULT
private val elementsToAnalyze = ArrayList<ElementToAnalyze<TElement>>()
private val elementsWithRootPrefix = mutableListOf<SmartPsiElementPointer<TElement>>()
private var level = 0
@@ -265,7 +268,10 @@ class ShortenReferences(val options: (KtElement) -> Options = { Options.DEFAULT
* Should be invoked by implementors when visiting the PSI tree for those elements that can potentially be shortened
*/
protected fun addQualifiedElementToAnalyze(element: TElement) {
elementsToAnalyze.add(ElementToAnalyze(element, level))
if (element.isRootPrefix())
elementsWithRootPrefix += element.createSmartPointer()
else
elementsToAnalyze += ElementToAnalyze(element, level)
}
override fun visitElement(element: PsiElement) {
@@ -275,6 +281,7 @@ class ShortenReferences(val options: (KtElement) -> Options = { Options.DEFAULT
}
fun getElementsToAnalyze(): List<ElementToAnalyze<TElement>> = elementsToAnalyze
fun getElementsWithRootPrefix(): Collection<SmartPsiElementPointer<TElement>> = elementsWithRootPrefix
}
private abstract class ShorteningProcessor<TElement : KtElement>(
@@ -362,6 +369,13 @@ class ShortenReferences(val options: (KtElement) -> Options = { Options.DEFAULT
}
}
fun removeRootPrefixes() {
for (pointer in collectElementsVisitor.getElementsWithRootPrefix()) {
val element = pointer.element ?: continue
shortenElement(element, Options.DEFAULT)
}
}
fun getDescriptorsToImport(): Set<DeclarationDescriptor> = descriptorsToImport
}
@@ -393,40 +407,31 @@ class ShortenReferences(val options: (KtElement) -> Options = { Options.DEFAULT
}
override fun analyzeQualifiedElement(element: KtUserType, bindingContext: BindingContext): AnalyzeQualifiedElementResult {
fun eval(element: KtUserType, bindingContext: BindingContext): AnalyzeQualifiedElementResult {
if (element.qualifier == null) return AnalyzeQualifiedElementResult.Skip
val referenceExpression = element.referenceExpression ?: return AnalyzeQualifiedElementResult.Skip
if (element.qualifier == null) return AnalyzeQualifiedElementResult.Skip
val referenceExpression = element.referenceExpression ?: return AnalyzeQualifiedElementResult.Skip
val target = referenceExpression.targets(bindingContext).singleOrNull()
?: return AnalyzeQualifiedElementResult.Skip
val target = referenceExpression.targets(bindingContext).singleOrNull()
?: return AnalyzeQualifiedElementResult.Skip
val scope = element.getResolutionScope(bindingContext, resolutionFacade)
val name = target.name
val scope = element.getResolutionScope(bindingContext, resolutionFacade)
val name = target.name
val targetByName: DeclarationDescriptor?
val isDeprecated: Boolean
val targetByName: DeclarationDescriptor?
val isDeprecated: Boolean
if (target is ClassifierDescriptor) {
val classifierWithDeprecation = scope.findFirstClassifierWithDeprecationStatus(name, NoLookupLocation.FROM_IDE)
targetByName = classifierWithDeprecation?.descriptor
isDeprecated = classifierWithDeprecation?.isDeprecated ?: false
} else {
targetByName = scope.findPackage(name)
isDeprecated = false
}
val canShortenNow = targetByName?.asString() == target.asString() && !isDeprecated
return if (canShortenNow) AnalyzeQualifiedElementResult.ShortenNow else AnalyzeQualifiedElementResult.ImportDescriptors(
listOfNotNull(target)
)
if (target is ClassifierDescriptor) {
val classifierWithDeprecation = scope.findFirstClassifierWithDeprecationStatus(name, NoLookupLocation.FROM_IDE)
targetByName = classifierWithDeprecation?.descriptor
isDeprecated = classifierWithDeprecation?.isDeprecated ?: false
} else {
targetByName = scope.findPackage(name)
isDeprecated = false
}
val result = eval(element, bindingContext)
if (result is AnalyzeQualifiedElementResult.Skip &&
element.qualifier?.text == ROOT_PREFIX_FOR_IDE_RESOLUTION_MODE
) return AnalyzeQualifiedElementResult.ShortenNow
return result
val canShortenNow = targetByName?.asString() == target.asString() && !isDeprecated
return if (canShortenNow) AnalyzeQualifiedElementResult.ShortenNow else AnalyzeQualifiedElementResult.ImportDescriptors(
listOfNotNull(target)
)
}
override fun shortenElement(element: KtUserType, options: Options): KtElement {
@@ -487,8 +492,6 @@ class ShortenReferences(val options: (KtElement) -> Options = { Options.DEFAULT
element: KtDotQualifiedExpression,
bindingContext: BindingContext
): AnalyzeQualifiedElementResult {
if (element.receiverExpression.text == ROOT_PREFIX_FOR_IDE_RESOLUTION_MODE) return AnalyzeQualifiedElementResult.ShortenNow
if (PsiTreeUtil.getParentOfType(
element,
KtImportDirective::class.java, KtPackageDirective::class.java
@@ -746,3 +749,9 @@ class ShortenReferences(val options: (KtElement) -> Options = { Options.DEFAULT
}
}
}
private fun PsiElement.isRootPrefix(): Boolean = when (this) {
is KtDotQualifiedExpression -> receiverExpression.text == ROOT_PREFIX_FOR_IDE_RESOLUTION_MODE
is KtUserType -> qualifier?.text == ROOT_PREFIX_FOR_IDE_RESOLUTION_MODE
else -> false
}

View File

@@ -35,5 +35,5 @@ class IDESettingsFUSCollector : ProjectUsagesCollector() {
}
override fun getGroupId() = "kotlin.ide.settings"
override fun getVersion(): Int = 1
override fun getVersion(): Int = 2
}

View File

@@ -27,6 +27,7 @@ import com.intellij.openapi.roots.ModifiableModelsProvider
import com.intellij.openapi.roots.ModifiableRootModel
import com.intellij.openapi.vfs.LocalFileSystem
import com.intellij.openapi.vfs.VfsUtil.createDirectoryIfMissing
import com.intellij.psi.PsiFile
import org.jetbrains.kotlin.idea.KotlinIcons
import org.jetbrains.kotlin.idea.formatter.KotlinStyleGuideCodeStyle
import org.jetbrains.kotlin.idea.formatter.ProjectCodeStyleImporter
@@ -156,7 +157,7 @@ abstract class GradleKotlinFrameworkSupportProvider(
KotlinFUSLogger.log(FUSEventGroups.NPWizards, this.javaClass.simpleName)
}
protected open fun updateSettingsScript(settingsBuilder: SettingsScriptBuilder, specifyPluginVersionIfNeeded: Boolean) {}
protected open fun updateSettingsScript(settingsBuilder: SettingsScriptBuilder<out PsiFile>, specifyPluginVersionIfNeeded: Boolean) {}
protected abstract fun getDependencies(sdk: Sdk?): List<String>
protected open fun getTestDependencies(): List<String> = listOf()

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