Commit Graph

119 Commits

Author SHA1 Message Date
Mikhail Zarechenskiy
6d4d244c28 Generate function from Any for inline classes same as for data classes
#KT-24873 Fixed
 #KT-25293 Fixed
 #KT-25299 Fixed
2018-08-06 10:56:01 +03:00
Mikhail Zarechenskiy
043ce1cb27 Support secondary constructors for inline classes
#KT-25614 Fixed
 #KT-25246 Fixed

 KT-25599 Will be fixed after recompilation of unsigned classes
2018-08-06 10:55:57 +03:00
Ilmir Usmanov
dc3b230b55 Do not generate continuation's setLabel and getLabel methods in 1.3
Also, do not call them.
 #KT-25521: Fixed
2018-07-25 15:35:18 +03:00
Dmitry Petrov
acf0bb349c Update testData for restricted expression annotations retention 2018-07-20 10:39:51 +03:00
Ilmir Usmanov
6ba2baa9da Deserialize constructors and properties with version requirement 1.3
if they have suspend function type in their descriptors.
Also, review fixes.

 #KT-25256: Fixed
2018-07-11 14:20:46 +03:00
Ilmir Usmanov
c460593b7d Forbid coroutines in language version is 1.3 and api version is less 2018-07-11 14:20:45 +03:00
Denis Zharkov
0b3048f60a Replace trivial usages of suspendCoroutineOrReturn in tests
This is necessary since suspendCoroutineOrReturn gets removed in 1.3
2018-07-09 15:27:19 +03:00
Denis Zharkov
820506d9c6 Fix tests after new Continuation API support
#KT-24863 Fixed
2018-07-09 15:27:19 +03:00
Alexander Udalov
1951d38f40 Retain optional expected annotations when compiling platform code
After this change, optional expected annotations will be compiled to
physical class files on JVM, and stored to metadata on other platforms,
to allow their usages from dependent platform modules. For example:

    @OptionalExpectation
    expect annotation class A

When compiling this code on JVM, A.class will be produced as if the
class A did neither have the 'expect' modifier, nor had it been
annotated with OptionalExpectation. Note that if there's no actual
annotation class for A, then usages (which can only be usages as
annotation entries) are simply skipped.

Class A will be public from Kotlin's point of view (since it should
be possible to use it in Kotlin sources), but _package-private_ in Java
to disallow its usages outside of the declaring module.

 #KT-18882 Fixed
 #KT-24617 Fixed
2018-06-26 10:23:55 +02:00
Ilmir Usmanov
de7aa23119 Make private inline suspend functions effectively inline-only 2018-06-13 15:08:26 +03:00
Ilmir Usmanov
8a5ae16947 Generate separate methods for inline and noinline uses of inline suspend functions
Previously, inline suspend functions were effectively inline only,
but ordinary inline functions can be used as noinline.
To fix the issue, I generate two functions: one for inline with suffix
$$forInline and without state machine; and the other one without any
suffix and state machine for direct calls.
This change does not affect effectively inline only suspend functions,
i.e. functions with reified generics, annotated with @InlineOnly
annotation and functions with crossinline parameters.
 #KT-20219: Fixed
2018-06-13 15:08:19 +03:00
Alexander Udalov
bf3419c3bd Introduce OptionalExpectation for annotations missing on some platforms
This commits adds a new annotation OptionalExpectation to the standard
library, which is experimental. To enable its usage, either pass
'-Xuse-experimental=kotlin.ExperimentalMultiplatform' as a compiler
argument, or '-Xuse-experimental=kotlin.Experimental' and also annotate
each usage with `@UseExperimental(ExperimentalMultiplatform::class)`

 #KT-18882 Fixed
2018-05-24 13:14:51 +02:00
Mikhail Zarechenskiy
6a120d2f85 Require presence of public primary constructor for inline class 2018-05-07 15:25:38 +03:00
Mikhael Bogdanov
8834ea74f2 Revert "Don't generate reified inline function as privates"
This reverts commit 56859f7
2018-05-07 14:14:07 +02:00
Mikhael Bogdanov
56859f7b87 Don't generate reified inline function as privates
#KT-18563 Fixed
2018-05-07 12:49:31 +02:00
Ilmir Usmanov
5e4ce4f880 Remove coroutineContext from kotlin.coroutines.experimental.intrinsics package
#KT-22400: Fixed
2018-05-07 10:28:54 +03:00
Ilmir Usmanov
f60787d57c Move coroutines to kotlin.coroutines package: tests
Introduce COMMON_COROUTINES_TEST directive.
Every test with this directive is run twice: one time with
language version 1.2 and kotlin.coroutines.experimental package
and the other time with language version 1.3 and kotlin.coroutines
package. Each run is a separate method: with suffixes _1_2 and _1_3
respectively.
However, since codegen of release coroutines is not supported in JS
backend, we generate only one method: with suffix _1_2.
 #KT-23362
2018-04-23 21:51:59 +03:00
Ilmir Usmanov
2cfe387bab Move coroutines to kotlin.coroutines package: compiler
Generate continuation type as kotlin.coroutines.Continuaion. This code will
fail at runtime since there is no stdlib backing this change yet.
However, in order to generate compatible stdlib we need a compiler, which
generates continuation type as kotlin.coroutines.Continuation.
Thus, firstly we support the change in the compiler, make it bootstrap
compiler and only then change stdlib and tests accordingly.
 #KT-23362
2018-04-10 22:51:46 +03:00
Ilmir Usmanov
eb3b9032d6 Add synthetic flag to generated private suspend functions
Private suspend functions need to be generated as package-local, since
they are called from their continuations.
However, this means that they can be called from Java, which breaks
their private visibility.
Adding synthetic to them fixes the issue.
 #KT-17584: Fixed
2018-04-10 17:25:12 +03:00
Ilmir Usmanov
eb81c205c7 Replace CHECKCAST kotlin/Unit with ARETURN for tail call optimization
Sometimes instead of {POP, GETSTATIC Unit.INSTANCE, ARETURN} sequence
the codegen emits {CHECKCAST Unit, ARETURN} sequence, which breaks tail
call optimization. By replacing CHECKCAST with ARETURN we eliminate
this issue.

 #KT-19790: Fixed
2018-04-03 20:04:18 +03:00
Ilmir Usmanov
bd7ad8c9d5 Raise deprecation level to ERROR of coroutineContext
inside kotlin.coroutines.experimental.intrinsics package
 #KT-22400
2018-03-22 22:12:27 +03:00
Ilmir Usmanov
07ec704228 Fix modifiers generation for companion objects
when language verion is 1.3

 #KT-23002: Fixed
2018-03-01 20:03:26 +03:00
Mikhail Zarechenskiy
30c79ffadc Support generating computable properties inside inline classes 2018-02-09 04:57:20 +03:00
Mikhail Zarechenskiy
70cd1cfcdf Fix generation of companion object inside inline classes 2018-02-09 04:56:45 +03:00
Mikhail Zarechenskiy
e1d3b21201 Skip bridge methods generation for inline classes 2018-02-09 04:56:43 +03:00
Mikhail Zarechenskiy
1ac4e9755a Generate synthetic unbox method for each wrapper of inline class 2018-02-09 02:08:11 +03:00
Mikhail Zarechenskiy
a59917b6f8 Generate synthetic box method for each erased inline class 2018-02-09 02:08:10 +03:00
Mikhail Zarechenskiy
9d05fac771 Don't generate backing field for erased inline class 2018-02-09 02:08:09 +03:00
Mikhael Bogdanov
0954d1ab1b Don't generate hash in sam wrapper class name
#KT-17091 Fixed
2018-02-08 10:11:48 +01:00
Ilmir Usmanov
18c03f94f8 Move coroutineContext to correct package
from kotlin.coroutines.experimental.instrinsics to kotlin.coroutines.experimental

 #KT-22400
2018-02-01 13:18:32 +03:00
Ilmir Usmanov
f4ad5182b8 Fix OOM error in ReturnUnitMethodTransformer
#KT-22345: Fixed
2018-01-19 20:13:23 +03:00
Ilmir Usmanov
ed11528664 Ignore unreachable code on tail call optimization
#KT-21759: Fixed
2018-01-15 12:57:10 +03:00
Ilmir Usmanov
32a94c70e9 Use tail call optimization if ARETURN has multiple sources
#KT-21977: Fixed
2018-01-10 20:14:32 +03:00
Ilmir Usmanov
5dbab2f907 Disable tail call optimization, if the call is inside try block
#KT-21165: Fixed
2018-01-10 20:13:55 +03:00
Alexander Udalov
f3f8db989a Fix test data for annotations on DefaultImpls members
After ea5505f80c, the annotations are now generated correctly
2017-12-27 14:12:14 +01:00
Ilmir Usmanov
c8904b1c7c Replace POP with ARETURN if it pops Unit and ARETURN shall return Unit
#KT-16880: Fixed
2017-12-21 18:08:39 +03:00
Dmitry Petrov
f586bd4a34 Generate proper visibility for companion object instance field in LV1.3+ 2017-11-27 17:15:16 +03:00
Ilmir Usmanov
0f9a21d429 Add regression test for KT-17640 2017-11-10 19:16:06 +03:00
Ilmir Usmanov
817f79520a Implement coroutineContext intrinsic
This intrinsic allows coroutine to access its context without suspention
and, furthermore, disabling tail-call optimization.
KT-17609: Fixed
2017-11-02 12:45:24 +03:00
Dmitry Petrov
891799c853 Generate 'Deprecated' annotation on invisible companion object field
Design decision: if the field for a companion object should have
non-public visibility, generate it with @Deprecated annotation in
language version 1.2.

TODO: generate it with proper visibility in 1.3 and later.

KT-11567 Companion object INSTANCE field more visible than companion object class itself
2017-07-19 17:38:17 +03:00
Dmitry Petrov
17d2472511 Do not patch generic signature for methods with special bridges
Somewhat awkward solution for KT-18189.
2017-05-31 10:18:48 +03:00
Dmitry Petrov
fd00a6fbe8 Generate generic signatures for special bridges
#KT-12408 Fixed Target versions 1.1.4
2017-05-31 10:18:48 +03:00
Dmitry Petrov
48a60e6f39 Dump generic signatures in bytecode listing tests if required
Add '// WITH_SIGNATURES' to test file if generic signatures should be
dumped.
2017-05-31 10:18:48 +03:00
Denis Zharkov
49453ca705 Avoid dependency on coroutine-related public API changes
These changes has been introduced in c3a032ea0b
to support new scheme for named functions

At the same time they can be avoided by generating some additional
code/accessors in the anonymous classes for coroutine state

Now we cannot simply remove introduced API because of bootstrap problems

 #KT-17898 Fixed
2017-05-18 12:42:12 +03:00
Denis Zharkov
5b5f612a7c Support new strategy for suspend inline functions
The main idea is to leave all the inline functions as is, without
state machines (but keeping suspend-calls markers) and
determine whether we need a state machine from the bytecode
after inlining into a non-inline function

 #KT-17585 In Progress
 #KT-16603 In Progress
 #KT-16448 Fixed
2017-05-05 14:14:00 +03:00
Mikhael Bogdanov
d24ebf711b Fix for KT-16441: NoSuchFieldError: $$delegatedProperties when delegating through provideDelegate in companion object
#KT-16441 Fixed
2017-02-21 13:01:40 +01:00
Alexander Udalov
0db60bf6cb Do not always generate synthetic "$annotations" as private
Since annotations are a part of the declaration, they must have the same
visibility as the declaration in the bytecode. Otherwise obfuscators like
Proguard might strip the "$annotations" method and no annotations would be
found via Kotlin reflection

 #KT-15993 Fixed
2017-02-03 19:35:15 +03:00
Denis Zharkov
8fa8ba7055 Move coroutine-related runtime parts to kotlin.coroutines.experimental package
#KT-15975 Fixed
2017-01-27 23:24:13 +03:00
Mikhael Bogdanov
456037a30d Generate proper annotaions on parameters for @JvmOverloads;
Fix for KT-15743: Overloaded Kotlin extensions annotates wrong parameters in java

 #KT-15743 Fixed
2017-01-27 14:09:13 +01:00
Denis Zharkov
9f217de10b Write kotlin metadata on class-files for coroutine state machines
Otherwise it breaks JPS assumptions, that leads to exceptions like:
Error:Kotlin: [Internal Error] java.lang.AssertionError: Couldn't load KotlinClass from /Users/jetbrains/IdeaProjects/KotlinPlaygroundBeta11/out/production/KotlinPlaygroundBeta11/Counter$both$1.class; it may happen because class doesn't have valid Kotlin annotations
    at org.jetbrains.kotlin.build.GeneratedJvmClass.<init>(generatedFiles.kt:36)
    at org.jetbrains.kotlin.jps.build.KotlinBuilder.getGeneratedFiles(KotlinBuilder.kt:469)
    at org.jetbrains.kotlin.jps.build.KotlinBuilder.doBuild(KotlinBuilder.kt:241)
    at org.jetbrains.kotlin.jps.build.KotlinBuilder.build(KotlinBuilder.kt:140)
...
2017-01-16 17:53:15 +03:00