Commit Graph

2444 Commits

Author SHA1 Message Date
Alexander Udalov f48bdc1fcb Fix codegen box tests for language version 1.4
Since API version 1.4, NullPointerException is thrown for casts of null
to any type instead of TypeCastException.
2020-01-20 19:12:59 +01:00
Ilmir Usmanov 1ef5e25c60 JVM_IR: Minor. Update test data 2020-01-20 18:59:00 +01:00
Ilmir Usmanov 56c8fdc6c4 JVM_IR: Perform tail-call optimization on IR
It is easier to introduce a new lowering so the codegen will emit code for the old
tail-call optimizer to understand. Also, this is more flexible and would allow to
optimize cases, which are now feasible with the old optimizer.
Note, that because of bytecode inlining, we cannot replace the old one, but we cannot
emit code, that is simpler for it to optimize.
2020-01-20 16:00:35 +01:00
Ilmir Usmanov 9f5b51ed43 JVM_IR: Do not generate fake continuation markers inside inline suspend lambdas
Since the markers replace ALOAD 0 as continuations, passed to suspend calls, in
JVM_IR we do not need this, since in JVM_IR all inline lambdas are static
functions.
2020-01-20 16:00:35 +01:00
Ilmir Usmanov 4d9d62ad12 JVM_IR: Also check attributes for suspendImpls when generating continuation
Otherwise, it would not generate continuations for overloads.
2020-01-20 16:00:34 +01:00
Ilmir Usmanov d17afddaa9 JVM_IR: Fix bridges generation for suspend functions
Use view's signature as jvm signature.
2020-01-20 16:00:34 +01:00
Ilmir Usmanov 7167d5f75c JVM_IR: Generate $$forInline companion for transformed crossroutines 2020-01-20 16:00:33 +01:00
Ilmir Usmanov 64c1446fbe JVM_IR: Generate $$forInline companion for suspend inline functions
Set isInline flag for $$forInline functions. Otherwise, SMAP will not be generated
for inner objects/lambdas, leading to error in inliner.
2020-01-20 16:00:32 +01:00
Ilmir Usmanov 4ef2ecf9a9 JVM_IR: Add returns unit marker if suspend call returns unit 2020-01-20 16:00:32 +01:00
Mikhail Zarechenskiy 5c5635ce20 Fix codegen & bytecode tests after unifying exceptions in JVM backend
See KT-22275 for details
2020-01-20 16:36:03 +03:00
Mads Ager 1ed7e33f42 JVM_IR: Fix default argument bit mask for methods made static.
When called by reflection the bit mask will be generated
discounting dispatch/extension receivers. Make sure that the
interpretation of the bit mask is consistent for direct and
reflective calls.

In addition, this also fixes the modifiers on java 8 parameter
metadata for the dispatch and extension receivers for these
inline class methods.
2020-01-20 12:59:25 +01:00
Mads Ager 33a24bfd27 JVM_IR: Avoid using parent name in name of captures.
If parent is an anonymous object that could lead to the use
of names such as `$this$no name provided` which is invalid
in dex files.
2020-01-20 10:49:46 +01:00
Pavel Kirpichenkov cb0b44273d [NI] Check stub types in result type
An uninferred parameter stub may leak through calculation of CST(Inv<Uninferred Stub>, Nothing) into a result type.
A stub type in the result type means a type error. So we can afford recalculating
CST with stub-containing types filtered out, since its an error anyway.
This prevents stub types leakages and helps with reporting type error diagnostics.

KT-35914 Fixed
KT-35943 Fixed
2020-01-20 11:11:31 +03:00
Mikhail Zarechenskiy 58c235e722 Set up tests for fun interfaces for JVM backend for now 2020-01-17 19:37:48 +03:00
Mikhail Zarechenskiy 8350cf7d14 FIC: rename FunctionConversion -> FunctionalConversion 2020-01-17 19:37:47 +03:00
Mikhail Zarechenskiy 70094884ca FIC: support suspend conversions in jvm codegen 2020-01-17 19:36:11 +03:00
Mikhail Zarechenskiy 3849b5e723 FIC: add codegen tests, adapt previously tests for SAMs 2020-01-17 19:36:09 +03:00
Mikhail Zarechenskiy b7c43fc7db Refactoring: move test folder out of "inline classes" folder
It was added there by mistake
2020-01-17 19:36:08 +03:00
Mikhail Zarechenskiy 0ee977c42e FIC: Support base version of conversions in JVM backend
Proper support for JVM backend will be in the further commmits
2020-01-17 19:36:02 +03:00
Mikhail Zarechenskiy 55935cc98a FIC: introduce language feature, modifiers checks and basic tests 2020-01-17 19:36:00 +03:00
Victor Petukhov 437a26684d NI: Prefer nullable lower bound to flexible one when substitution of type variable is performed and remember flexibility of type parameters based on flexibility of its upper bounds
^KT-32435 Fixed
2020-01-17 19:16:09 +03:00
Steven Schäfer a49ed1eca2 JVM IR: Generate interface delegations for specialized interface defaults 2020-01-17 18:19:26 +03:00
Steven Schäfer 8746d08dd5 JVM IR: Don't skip bridge generation for concrete fake overrides 2020-01-17 18:19:26 +03:00
Dmitry Petrov 933ac3a16b Fix nullable number comparisons in JS 2020-01-17 14:14:59 +03:00
Dmitry Petrov d5ff1047a5 JVM: Fix IEEE 754 comparison generation for boxed numbers 2020-01-17 14:14:58 +03:00
Alexander Udalov 26f435eb90 JVM IR: mute tests which fail after advancing language to 1.4 2020-01-17 12:07:30 +01:00
Alexander Udalov e7864c7351 Fix inlineCallsStaticMethodFromOtherPackage.kt by disabling related language feature
This test is not possible for 1.4, where protected calls from public
inline functions are prohibited.
2020-01-17 12:07:30 +01:00
pyos 6e6f4d0503 IR: close over the set of captured type parameters 2020-01-16 16:37:40 +03:00
Ilya Gorbunov 9566f329f0 Mute FIR test failures and adjust failing test data due to KT-35948 2020-01-16 15:36:19 +03:00
Ilya Gorbunov 0f6df5971b Mute tests failing in JS_IR backend due to KT-35944 2020-01-16 15:36:16 +03:00
Ilya Gorbunov ac790bea71 Reorganize diagnostics tests with stdlib and reflect
DiagnosticsTestWithStdLib now require stdlib only.
Move test data accordingly.
The only test that required kotlin-reflect is transformed into
codegen box test.
2020-01-16 15:35:58 +03:00
Alexander Udalov 621936e951 Do not generate Throws attribute for delegated members from Kotlin interfaces
#KT-31763 Fixed
 #KT-35834
2020-01-16 12:43:09 +01:00
Dmitriy Novozhilov 5111d1721a [TEST] Add js runtime to failing box test 2020-01-15 22:12:29 +03:00
Dmitriy Novozhilov 04ce10b6c1 [NI] Improve completing callable references with type variable as expected type
#KT-32462 Fixed
2020-01-15 22:12:28 +03:00
Alexander Udalov 6fe214d825 JVM IR: fix handling of suspend extension lambdas with captured receiver
The problem in the added test was that a suspend lambda was represented
by a function reference with a bound argument for the ObjectRef value,
and the corresponding parameter was not the first parameter of the
referenced local function. This happens because
LocalDeclarationsLowering lifts the local function up and adds a
new parameter for the captured ObjectRef (which is bound at the call
site), but the original receiver parameter remains the first unbound
parameter. So, it's no longer correct to rely on the fact that all bound
parameters of a function reference are located in the beginning of the
parameter list, which was kind of assumed in the `withIndex` call in
`AddContinuationLowering.addCreate`.
2020-01-15 19:42:13 +01:00
Dmitriy Novozhilov 3428a17759 [NI] Postpone calls with not enough information in builder inference 2020-01-15 14:01:25 +03:00
Alexander Udalov 7742a3b697 Rename UseExperimental->OptIn, Experimental->RequiresOptIn in compiler tests 2020-01-14 21:04:42 +01:00
Mads Ager ca05ff1791 JVM_IR: Fix bug in suspend function with many default arguments. 2020-01-14 20:48:44 +01:00
pyos f73891af98 JVM_IR: actually forward the parameters to $suspendImpl 2020-01-14 20:46:48 +01:00
Svyatoslav Kuzmich 1333267983 [JS IR] Add serialization regressions tests 2020-01-14 18:00:29 +03:00
Dmitriy Novozhilov 02d9f258d1 [FIR-TEST] Mute failing blackbox test 2020-01-14 17:34:21 +03:00
Dmitry Petrov 6ad159bb01 JVM: Rewrite companion object accessor generation
Old version handled only private companions correctly.
Some situations require multiple companion object accessors
(including accessors for protected companion objects from supertypes)
to be generated in the corresponding class.
2020-01-14 16:12:18 +03:00
Georgy Bronnikov 049bb54ea6 IR: use map in remapTypeParameters
In LocalDeclarationLowering, the moved local function does not
necessarily receive a continuous chunk of type parameters that it captures.
2020-01-14 15:16:54 +03:00
Dmitriy Novozhilov 9367c6a762 [NI] Use infered delegate expression type if there is no resolved call in trace
#KT-35707 Fixed
2020-01-14 12:18:24 +03:00
victor.petukhov fc7b836151 Fix isNegated psi method in KtWhenConditionInRange
^KT-34395 Fixed
2020-01-13 15:36:33 +03:00
Mikhail Glukhikh 5c6341b4e4 [FIR] Handle fully qualified expressions separately in tower resolver 2020-01-13 13:26:13 +03:00
Mads Ager b2f8a4e82a JVM_IR: Put continuation parameter before default mask and handler.
This is important for calls using reflection as the reflect
library assumes this ordering of arguments.

It would be nice if this could be handled in the lowerings.
Currently AddContinuationLowering is after
DefaultArgumentStubGenerator. If we could add the continuation
first and then do default stub generation maybe we could avoid
the reshuffling introduced in coroutine codegen in this change.
2020-01-10 17:52:46 +01:00
Alexander Udalov b48d7f4ba7 JVM IR: fix InterfaceLowering for $default methods from base interfaces
The first change here is swapping the isCompatibility and hasJvmDefault
checks. Otherwise behavior could be different depending on -Xjvm-default
mode even for non-JvmDefault declarations, which makes little sense.

Another change is avoiding generating $default stubs for fake overrides
in interfaces, which replicates the behavior of the current backend.
(Note that this change also fixes the first problem on the newly added
tests, but the first change seems useful anyway.)
2020-01-10 14:05:27 +01:00
Alexander Udalov 3193689086 JVM IR: do not add suffix for accessors to top level functions
This only reproduced when compiling (technically incorrect) code in the
standard library, where private functions monitorEnter/monitorExit are
accessed from another file, and their names with suffixes are not
recognized as intrinsics which should be replaced by
monitorenter/monitorexit JVM bytecode instructions.
2020-01-10 14:05:25 +01:00
Alexander Udalov 957b100cd1 JVM IR: do not generate hidden constructor for inline classes more than once
SyntheticAccessorLowering was initially implemented under the assumption
that any access to an invisible declaration will cause an accessor to be
generated _in the same file_. Moreover, it's declared in the group of
phases that are performed by file.

But this assumption is incorrect for constructors which need to be
hidden (those which take parameters of inline class types), since such
constructor is public and can be called from anywhere. In this case,
SyntheticAccessorLowering actually generated a new accessor for the
hidden constructor for each (!) source file where that constructor is
called, which led to ClassFormatError because of the class file having
multiple methods with the same signature. The internal `functionMap`
cache didn't help because it's not shared among phase instances for
different files (well, it helped to generate not more than one accessor
per usage-file).

In this change, we use the global cache, stored in JvmBackendContext,
for accessors to hidden constructors. Note that after this change, calls
to hidden constructors are always transformed to the corresponding
accessor in SyntheticAccessorLowering right away, but that accessor
might be orphaned for a while (not declared in any parent's
declarations). Only when SyntheticAccessorLowering encounters the
original constructor which needs to be hidden, it adds the accessor
beside it.

The test is sensitive to the file order, so both variants are added.
2020-01-10 13:49:05 +01:00