Commit Graph

232 Commits

Author SHA1 Message Date
Dmitry Petrov
d93885e71c Add tests for deprecated properties 2020-07-21 22:25:44 +03:00
Dmitry Petrov
e84339a0d3 JVM_IR: fields for deprecated enum entries have ACC_DEPRECATED flag
'Deprecated' annotation can't be applied to field itself.
2020-07-21 22:25:44 +03:00
Dmitry Petrov
2e31f95554 Update testData 2020-07-20 20:04:32 +03:00
Kristoffer Andersen
8d79a6ae03 [JVM IR] Copy inline class constructor annotations 2020-07-13 11:50:34 +03:00
Dmitry Petrov
b75de60afb Minor: mute failing test 2020-07-06 10:47:10 +03:00
Dmitry Petrov
17c15cfe0a JVM, JVM_IR: update bytecode listing testData for inline classes 2020-07-02 22:39:06 +03:00
Dmitry Petrov
d37b616e1f JVM_IR: Fix enum classes ABI
1. Enum entry fields don't have nullability annotations.

2. Enum class special methods (values, valueOf) are not 'final'
(although they probably should be, javac generates corresponding
methods without ACC_FINAL flag).

3. Enum class special methods don't have nullability annotations.

4. Don't generate synthetic accessor for enum entry class constructor.

KT-37019 KT-37020 KT-37021
2020-06-30 18:24:25 +03:00
Dmitry Petrov
e4198466b8 JVM_IR: No nullability annotations on static lambda instances 2020-06-29 19:32:03 +03:00
Dmitry Petrov
eefa621c56 JVM_IR KT-37006: InlineOnly property accessors are private in bytecode 2020-06-29 19:08:58 +03:00
Alexander Udalov
b94a4d9fc3 Render more information on inner classes in bytecode listing tests 2020-06-29 17:33:39 +02:00
Dmitry Petrov
2137a4b1e5 JVM, JVM_IR: no nullability annotations on private and synthetic methods
NB it looks like it doesn't cover all cases, e.g., some synthetic
methods generated for suspend functions.
2020-06-26 18:51:35 +03:00
Dmitry Petrov
64e47265e1 JVM, JVM_IR: no nullability annotations on lateinit backing fields 2020-06-26 15:08:23 +03:00
Dmitry Petrov
3f266aafb4 JVM: no nullability annotations on private and synthetic fields 2020-06-25 22:31:12 +03:00
Kristoffer Andersen
b95d3e711e [JVM IR] KT-36985: $default respects @Deprecated
$default dispatch methods gains @Deprecated if the original function
with default arguments has it.
2020-06-25 18:43:45 +03:00
Dmitry Petrov
4e92c79bc4 JVM_IR: don't generate nullability annotations on synthetic declarations
Fixes KT-36993 and some other related issues.
2020-06-23 20:51:48 +03:00
Dmitry Petrov
5bfec7f6bc JVM: don't generate nullability annotations on property delegate fields
Such fields are private, so these annotations are redundant.

They were incorrect, anyway (property type was used instead of delegate
type).
2020-06-23 20:18:42 +03:00
Mikhail Bogdanov
41511898a1 Deprecate DefaultImpl methods in compatibility mode 2020-06-23 18:59:04 +02:00
Dmitry Petrov
e9231b5624 JVM: Generate object and companion object INSTANCE fields as @NotNull 2020-06-22 16:28:00 +03:00
Dmitry Petrov
a493b21c7c JVM_IR: Deprecation cycle for companion object instance visibility 2020-06-19 20:41:54 +03:00
Mikhail Bogdanov
e93bcc55ae Revert "Deprecate DefaultImpl methods in compatibility mode"
This reverts commit 6c9c2a28
2020-06-19 12:58:46 +02:00
Mikhail Bogdanov
6c9c2a287d Deprecate DefaultImpl methods in compatibility mode 2020-06-19 12:23:05 +02:00
Mikhail Bogdanov
9c0b96af71 Report error on missed specialization in compatibility mode
#KT-39603 Fixed
2020-06-19 11:57:36 +02:00
Mikhail Bogdanov
b8f0ad2111 Generate nullability annotations on this receiver in DefaultImpls. Don't generate nullability annotations in private methods
#KT-36969 Fixed
2020-06-19 11:57:35 +02:00
Mikhail Bogdanov
5bdf3d5757 Don't generate compatibility stubs for @JvmDefaultWithoutCompatibility 2020-06-19 11:57:35 +02:00
Dmitry Petrov
4739adb6dc KT-36992 Do not generate annotations on synthetic accessors
Also, do not generate nullability annotations on synthetic methods.
2020-06-17 23:54:51 +03:00
Ilmir Usmanov
d9821412d0 Do not generate fields for unused suspend lambda parameters
This also allows us to not spill them in the lambda.
But, disable this optimization for local named functions.

 #KT-16222 In progress
2020-06-17 12:00:25 +02:00
Dmitry Petrov
02f6a03ff7 JVM_IR: fix nullability annotations on synthetic marker parameters
Synthetic marker parameters (of type
Lkotlin/jvm/internal/DefaultConstructorMarker;) don't have annotations
(including nullability annotations).

Also, for constructor accessors corresponding parameter should be
nullable (since we pass 'null' as an argument there).

KT-36966
2020-06-16 21:29:52 +03:00
Steven Schäfer
3291cf7a6e JVM IR: Mark lateinit fields as NotNull
This is needed for compatibility with the JVM backend.
2020-06-04 17:52:56 +02:00
Alexander Udalov
5647a935a2 JVM IR: do not generate DefaultImpls delegate for collection fake overrides
In the newly added test, prior to this change, JVM IR was generating
DefaultImpls classes with calls to things like
`kotlin/collections/MutableList$DefaultImpls.spliterator` and other
default methods present in JDK 8+. This obviously didn't make much
sense. Although these weren't explicitly mentioned anywhere in the
bytecode, they caused some validation tools to report errors (e.g.
animalsniffer used in arrow).
2020-06-04 14:27:46 +02:00
Dmitry Petrov
cf70c83ab7 JVM: Update tests 2020-05-20 07:19:29 +03:00
Alexander Udalov
012ffa2993 Support new scheme of compilation of OptionalExpectation annotations
Instead of generating these annotation classes as package-private on
JVM, serialize their metadata to the .kotlin_module file, and load it
when compiling dependent multiplatform modules.

The problem with generating them as package-private was that
kotlin-stdlib for JVM would end up declaring symbols from other
platforms, which would include some annotations from package
kotlin.native. But using that package is discouraged by some tools
because it has a Java keyword in its name. In particular, jlink refused
to work with such artifact altogether (KT-21266).

 #KT-38652 Fixed
2020-05-12 19:28:57 +02:00
pyos
82899e6243 JVM_IR: reuse MethodNodes for inline functions in same module
This fixes the weird cases when a class gets overwritten by an imperfect
copy, reduces the number of classes in the output if an inline function
contains an inline call that causes it to have regenerated anonymous
objects, and makes inlining of same module functions a bit faster in
general. On the other hand, this may increase memory footprint a bit
because classes cannot be flushed to the output jar, as the inliner
would not be able to locate classes for anonymous objects if they have
already been unloaded from memory.
2020-04-08 07:04:16 +02:00
pyos
829343cf6f JVM: surround captured lambdas with conditional suspension markers 2020-04-07 15:42:41 +02:00
pyos
e0a5ab7146 Do not regenerate objects if all captured lambdas are noinline 2020-03-19 15:11:20 +01:00
pyos
2c06503311 JVM_IR: partially fix inline methods using captured crossinline lambdas
The fields containing crossinline lambdas should be package-private to
avoid generating synthetic accessors, which break object regeneration.

Note that the inline methods cannot actually be called, as call sites
will attempt to read the captured lambda from a field through a *copy*
of the local containing the object, so these reads will not be inlined,
causing an exception at runtime:

    inline fun f(crossinline g: () -> Unit) = object : I {
        inline fun h() = g()
        // effectively `val tmp = this; return tmp.$g()`:
        override fun run() = h()
    }

    f {}.run() // NoSuchFieldError: $g

This particular example can be fixed by reusing locals for receiver
parameters in IrInlineCodegen, but explicitly assigning `this` to
another variable and calling an inline method on it will break it again.
(This is only applicable to the JVM_IR backend, as the non-IR one fails
to generate `f` at all for some other reason.)
2020-03-18 13:13:54 +01:00
Dmitry Petrov
dd27b3d4f1 KT-36973 Keep private default interface members private 2020-03-18 14:18:47 +03:00
Dmitry Petrov
1c24a97b9e KT-36972 Don't create proxies for companion @JvmStatic $default in host
When creating proxy functions in a host class for @JvmStatic members of
companion object, skip functions for default parameters handling.
2020-03-18 13:33:56 +03:00
Ilmir Usmanov
7efab887aa JVM_IR: Do not generate accessor for private function
if the function is called in suspendCoroutine's lambda.
 #KT-37242 Fixed
2020-03-12 11:15:46 +01:00
Ilmir Usmanov
fd70b10b17 JVM_IR: Generate suspend fun main wrapper as class instead of reference
This way, there is no getName, getOwner and getSignature generated.
 #KT-37404: Open
2020-03-11 15:34:38 +01:00
Steven Schäfer
34fb636904 JVM: Generate generic signatures for delegate fields 2020-03-06 21:51:30 +01:00
Alexander Udalov
98aecbef6b Optimize runtime representation for callable reference subclasses
Instead of generating overrides for getOwner/getName/getSignature in
each anonymous class representing a callable reference, pass them to the
superclass' constructor and store as fields. This occupies some small
memory but helps to reduce the size of the generated class files, and
will be helpful for adding further runtime information to callable
references, such as information about implicit conversions this
reference has been subject to.

Represent owner as java.lang.Class + boolean instead of
KDeclarationContainer, so that the unnecessary wrapping Class->KClass
wouldn't happen before it's needed, and also to make sure all callable
references remain serializable.

Note that the argument type where the "is declaration container a class"
is passed is int instead of boolean. The plan is to pass the
aforementioned implicit conversion information as bits of this same
integer value.

 #KT-27362 Fixed
2020-03-06 16:55:07 +01:00
Ilmir Usmanov
354fb3c4ba JVM_IR: Generate fake continuations and their constructors as public
#KT-37093 Fixed
2020-03-04 21:32:35 +01:00
Ilmir Usmanov
c94f8d3767 JVM_IR: Do not generate nullability annotation for synthetic result field
of continuation class.
 #KT-37084 Fixed
2020-03-04 21:32:34 +01:00
Ilmir Usmanov
4b4a6101c1 JVM_IR: Generate inline functions with reified generics as public synthetic
Otherwise, proguard will remove them.
 #KT-37004 Fixed
2020-03-04 21:32:31 +01:00
Ilmir Usmanov
f8903ca04b JVM_IR: Generate private suspend functions as synthetic package-private
Do not generate accessors for them.
 #KT-37086 Fixed
2020-03-04 21:32:29 +01:00
Ilmir Usmanov
5826db97c7 JVM_IR: Do not duplicate inline suspend functions with reified type parameters
They are inline-only.
Generate $$forInline versions of inline suspend functions as private.
This way, there is no nullability annotation on there parameters and return
values. Unfortunately, old BE does generate them.
 #KT-37088 Fixed
2020-03-04 21:32:27 +01:00
Ilmir Usmanov
42420cb6fc JVM_IR: Generate inner classes for continuations
Also, generate correct visibilities for constructors and continuation's fields.
2020-03-02 14:03:33 +01:00
Dmitry Petrov
84baa0b4c2 Check more flags in bytecode listing tests 2020-02-26 12:03:37 +03:00
Mark Punzalan
b782e8f0f0 Add IR equivalent of AbstractBytecodeListingTest and muted failures. 2020-02-13 23:44:53 +03:00
Mark Punzalan
06b6477d04 [JVM IR] Do not add nullability annotation for functions that return
platform types.

This behavior matches the non-IR backend, which was added in
f16dcdd8a9.
2020-02-13 23:44:53 +03:00