Commit Graph

427 Commits

Author SHA1 Message Date
Dmitry Petrov b1bd138afb JVM_IR fix inline class <-> collection stubs issues
Move collectionStubMethodLowering before jvmInlineClassPhase, and make
them interact properly.

Note that some issues still remain in inline class <-> special bridges
interaction.

KT-40187 KT-42469
2020-10-06 17:08:24 +03:00
Dmitry Petrov 941a506885 Add test for inline classes implementing collection interfaces
KT-40186
2020-10-02 14:06:07 +03:00
Dmitry Petrov e018f2bd3e JVM_IR more precise check for special bridges in super class
KT-41123
2020-10-02 12:51:49 +03:00
Dmitry Petrov af86c52101 JVM_IR merge annotations when substituting types
Otherwise special annotations such as @EnhancedNullability are lost,
which affects JVM signatures.

KT-42330
2020-09-30 15:44:54 +03:00
Dmitry Petrov f79afd67f4 Add more tests for collections implemented by delegation 2020-09-29 22:44:00 +03:00
Dmitry Petrov 79a2d9858c JVM_IR emulate JVM stub generation scheme
KT-42114
KT-42115
2020-09-29 21:06:30 +03:00
Dmitry Petrov 1fc459ab4c JVM_IR KT-42260 add abstract overrides for generated stubs 2020-09-29 14:06:12 +03:00
Dmitry Petrov d9906ae8da Minor: unmute some bytecode listing tests in JVM_IR 2020-09-28 21:48:14 +03:00
Dmitry Petrov 70095712eb Minor: drop new bytecode listing test that passes only in JVM_IR
Unfortunately, there's no way to mute it in JVM right now.
Corresponding case is tracked as KT-42179, anyway.
2020-09-25 13:49:53 +03:00
Dmitry Petrov cfd62c15bf JVM_IR KT-36994 don't generate stub if present in superclass 2020-09-25 11:57:33 +03:00
Dmitry Petrov 1adce11257 Add tests for KT-40191 2020-09-25 11:57:32 +03:00
Dmitry Petrov 1c4567c999 Add tests for KT-40152 2020-09-23 18:14:21 +03:00
Dmitry Petrov 99dbeecc40 Some more bytecode listing tests for JVM_IR 2020-09-23 18:14:20 +03:00
Dmitry Petrov c03573fc18 JVM_IR fix override equivalence check for collection stub generation
KT-42043 KT-42033
2020-09-22 15:26:34 +03:00
Dmitry Petrov ee3ada4e55 JVM_IR KT-40304 KT-41998 special handling for 'removeAt' 2020-09-18 14:27:36 +03:00
Dmitry Petrov 54d5494ecd JVM_IR special handling for 'remove' collection method stub 2020-09-16 15:36:16 +03:00
Dmitry Petrov b395771d01 KT-37050 don't generate redundant special bridges
Loosely based on https://github.com/JetBrains/kotlin/pull/3662
2020-09-14 16:13:34 +03:00
Alexander Udalov f0282bcfdf JVM IR: add module name for internal functions before "$default"
The change is a bit complicated because the name mapping logic is
refactored so that we would compute the needed suffix first (either
module name, or multifile part class name), and then shove it into the
mangled name between the original function name and "$default", if the
function in question is the default arguments adapter.

The main motivation for this change was to fix KT-41809, but as a side
effect, private functions with default arguments in multifile parts now
also contain the file name, just like normal private functions.

 #KT-41809 Fixed
2020-09-14 13:18:24 +02:00
Alexander Udalov 2a0f64ebcb JVM IR: do not generate Deprecated(HIDDEN) class as synthetic
#KT-41810 Fixed
2020-09-14 13:18:24 +02:00
Alexander Udalov 9250d86915 JVM IR: generate field for private companion object in interface as synthetic 2020-09-13 09:13:27 +02:00
Alexander Udalov c46c80822c JVM IR: fix enclosing constructor for lambdas in inner classes
Before this change, we stored the enclosing constructor in a map in
JvmBackendContext before moving lambdas and local classes out of
initializer blocks. However, in case the lambda was declared in an inner
class, we stored a reference to the unlowered constructor of the inner
class, whose JVM signature is "()V" instead of the correct "(LOuter;)V".
Java reflection then threw exception if we tried to call
`getEnclosingConstructor()` on such class at runtime. Proguard finished
with errors for the same reason.

It turns out that we can just store the fact that the class has been
moved, and load the matching constructor in codegen, where everything is
already lowered and guaranteed to match with the signatures of the
actual generated declarations.

 #KT-41668 Fixed
2020-09-08 23:37:00 +02:00
Alexander Udalov 228e329d1f JVM IR: generate enclosing constructor only for lambdas in initializers
There was a typo in JvmLocalClassPopupLowering which allowed the
EnclosingMethod for lambdas and anonymous classes in initializers to
become any function in a class, in case when there was no primary
constructor in that class. E.g. in the added test, `getIrrelevantField`
was the EnclosingMethod of the lambda class before this change.
2020-09-08 23:37:00 +02:00
Steven Schäfer 4792be2522 JVM IR: Optimize static property references (KT-36975) 2020-09-07 21:01:29 +02:00
Alexander Udalov 0dea6b94c6 JVM IR: unmute boxInline tests on enclosing method/class
In box tests, only check that Java reflection does not crash on the
EnclosingMethod attribute generated in these classes. If it doesn't
crash, most likely it returns the value that can be read from the class
file by ASM, which is what the newly added bytecode listing tests are
checking now.
2020-09-07 19:41:37 +02:00
Dmitry Petrov ade1a346e1 JVM: add test for KT-40123 2020-09-07 16:09:42 +03:00
Dmitry Petrov dd016b759e JVM_IR: write raw types as raw in JVM generic signatures 2020-09-04 10:21:49 +03:00
Dmitry Petrov 714ab7c37f Handle java raw types in IR
Raw type Q is represented as a flexible type
  Q<B1, ... Bn> .. Q<*, ... *>
where Bi is a representative upper bound of the corresponding ith type
parameter of Q.
When mapping generic signature, JVM takes type arguments of lower bound
(which is 'Q<B1, ..., Bn>').

There is still some difference in how JVM and JVM_IR handle raw type in
signature. It requires additional investigation.
2020-09-04 10:21:48 +03:00
Alexander Udalov b8d16f3d46 Add EnclosingMethod information to bytecode listing tests 2020-09-02 16:46:05 +02:00
Alexander Udalov d4ecde5cb0 Minor, don't use token COROUTINES_PACKAGE in bytecode listing tests
Most of the tests that are run both for 1.2 and 1.3 coroutines have
different expectation .txt files anyway.
2020-09-02 16:46:05 +02:00
Dmitry Petrov 8cb8284957 EnhancedNullability annotation in IR
Fixes KT-40115 & KT-40117.

Move FlexibleNullability annotation to 'kotlin.internal.ir'.
2020-09-01 16:06:03 +03:00
Alexander Udalov a639915a34 JVM IR: do not mangle property accessors of unsigned types in annotations
Before this change, we incorrectly mangled the names of annotation
methods (e.g. `getI-pVg5ArA` instead of `i`) because the isSpecial
condition was false.
2020-08-31 14:19:14 +02:00
Steven Schäfer 02e78bcd76 JVM IR: Use package visibility for fields of captured variables 2020-08-28 20:03:19 +02:00
Dmitry Petrov 8f0aecce58 JVM_IR: KT-40330 Unify field names for captured 'this' with JVM
NB some cases such as captured extension receiver for an extension
lambda are not supported yet; to be discussed, to what extent should we
actually follow JVM code shape here.
2020-08-19 11:07:41 +03:00
Ilmir Usmanov 31e4ddafd1 Minor. Add test with boolean parameter 2020-08-13 15:52:53 +02:00
Ilmir Usmanov bcbb050326 Use fields for spilled variables for lambda parameters as well
In other words, do not generate p$ fields if we can use L$ fields,
which are being cleaned up.
 #KT-16222 Fixed
2020-08-13 15:52:51 +02:00
Ilmir Usmanov 405c9743ef Do not spill dispatch receiver of suspend functions if it is not used
#KT-20571
2020-08-04 15:42:36 +02:00
Dmitry Petrov e11c90f26c JVM_IR: KT-40293 Box return type for DefaultImpls methods if required 2020-07-31 14:48:12 +03:00
Ilmir Usmanov 60875f96b4 Do not take LVT into account when calculating liveness of variables 2020-07-29 00:01:09 +02:00
Alexander Udalov b9243aad24 Minor, fix test data in bytecodeListing/specialBridges 2020-07-28 12:12:39 +02:00
Dmitry Petrov 43fcb2330e JVM_IR: fix source file name for mutlifile class facades 2020-07-27 19:13:37 +03:00
Dmitry Petrov 89a0b3e944 Check class source in bytecode listing tests 2020-07-27 19:13:37 +03:00
Steven Schäfer 9d63412b3e JVM IR: Produce correct generic signatures for special bridge methods 2020-07-27 17:02:24 +02:00
Dmitry Petrov e2a4ca10d6 JVM_IR: fix inner class attributes for private class in interface 2020-07-23 19:13:28 +03:00
Dmitry Petrov 0741781462 Compare inner class access flags in bytecode listing tests 2020-07-23 19:13:28 +03:00
Dmitry Petrov 1272162a7f JVM_IR: generate "safe" names for functions in init blocks 2020-07-22 19:49:48 +03:00
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