Commit Graph

2699 Commits

Author SHA1 Message Date
Igor Chevdar 90abf1fda0 [JS_IR] Don't capture the bound receiver of a CR 2020-03-28 15:26:19 +03:00
Dmitry Petrov 042424d599 KT-27524 Don't box (some) inline classes in suspend fun return
If an inline class is mapped to a reference type (or an array), it's Ok
to treat JVM view on a suspend function as returning a value of
corresponding inline class (although in reality it returns 'Any?'
because of COROUTINE_SUSPENDED).
2020-03-27 18:29:36 +03:00
Steven Schäfer 58685be4e2 IR: Don't use IrStringConcatenation for ordinary toString calls
We can only use IrStrinConcatentation to represent calls to Any?.toString
and toString calls on primitive types. Otherwise, x.toString() and "$x"
are observably different when x is a non-null type with null value
(e.g., an @NotNull value coming from Java).
2020-03-27 17:31:48 +03:00
Mikhail Glukhikh b27152f903 Replace some FIR syntax errors with more proper diagnostics 2020-03-27 16:46:59 +03:00
Roman Artemev 6e01ec8dd3 [IR] Fix translation of synthetic generic java properties
- Compute substituted accessor descriptor to avoid unbound type parameters
2020-03-27 10:52:33 +03:00
Pavel Punegov ad20deb0b3 Ignore Java-sepcific test in Native 2020-03-26 13:26:17 +03:00
Juan Chen aba7706dec [FIR] fix test module set up (this fixes 193 BB tests)
Added creation and initialization of the test module and its dependencies.
When looking at the emptyProgression test,
I found that getProgressionLastElement was not found,
which should be resolved from the dependencies.
2020-03-26 10:30:47 +03:00
Jinseong Jeon cdf5a2a5a1 FIR: set dispatch receiver parameter for inner class's constructor. 2020-03-25 12:40:09 +03:00
Jinseong Jeon acbe3126b1 FIR: consider all functions in scope when computing dispatch receiver parameter. 2020-03-25 09:20:07 +03:00
Jinseong Jeon de0c9a5c73 FIR: use dispatch receiver of the enclosing function if any. 2020-03-25 08:27:21 +03:00
simon.ogorodnik 59393e06f0 [FIR-test] Mute tests with bad test-data 2020-03-24 18:58:19 +03:00
simon.ogorodnik f83c20065d [FIR-test] Unmute passing tests, mostly fir2ir 2020-03-24 18:58:19 +03:00
simon.ogorodnik 0acca52001 [FIR-Test] Unmute blackbox test 2020-03-24 18:58:18 +03:00
Mikhail Glukhikh 03143bc788 [FIR2IR] Implement mapping of FIR & IR built-in class members 2020-03-24 12:15:18 +03:00
Dmitry Petrov afacb4b4b2 KT-37604 Use proper type when generating constructor call 2020-03-24 11:31:47 +03:00
Mikhail Glukhikh a4c7619c89 [FIR2IR] Introduce & use FirBuiltInsPackageFragment
Without this commit, JVM name mapping logic in BE does not work for FIR,
because FIR cannot use old BuiltInsPackageFragmentImpl descriptor.
In this commit we add our own implementation thus fixing
a pack of FIR black box tests.
2020-03-24 10:37:53 +03:00
Mikhail Zarechenskiy 191fb02bf6 [NI] Consider intersection type with number type as Nothing
Currently, only for "in": In<in Int & A> == In<in Nothing> == In<*>

 #KT-37302 Fixed
2020-03-23 16:39:21 +03:00
Mikhail Glukhikh ca22e05acd [FIR2IR] Support safe calls 2020-03-23 15:13:50 +03:00
Jinseong Jeon e46a4246d2 FIR: regard property accessor without body as FirDefaultPropertyAccessor 2020-03-23 15:12:54 +03:00
pyos ac6036f366 JVM_IR: move state machine generation to ClassCodegen 2020-03-23 12:23:17 +01:00
Georgy Bronnikov 4742057b51 IR: generate lambdas in place in Psi2Ir
even when arguments are to be rearranged.
Lambdas have no side effects, and storing them in temporary variables
prevents processing in the backend
(such as inserting continuation parameter in AddContinuationLowering).
2020-03-23 11:09:30 +03:00
Dmitriy Novozhilov 6ce8d661ad [FIR] Add nullability to ILT. #KT-37639 Fixed 2020-03-20 23:11:28 +03:00
Dmitriy Novozhilov 5f9f01fe4e [FIR] Implement new completion mode calculator
Note that `testDelegates` now fails due to KT-37638 and
    `testSimpleIn` fails due to problems with type parameters
    of inner classes
2020-03-20 23:11:28 +03:00
Mikhail Glukhikh 9836520287 [FIR2IR] Generate synthetic bodies for Enum.values() and valueOf() 2020-03-20 11:55:34 +03:00
Mikhail Glukhikh 94fe79578e [FIR2IR] Generate unconditional branch in exhaustive whens 2020-03-20 11:55:34 +03:00
Mikhail Bogdanov bc214868ef Minor. Clean tests 2020-03-19 16:45:10 +01:00
Pavel Punegov 8ffb63ca6b Ignore test that relies on hashCode implementation 2020-03-19 11:14:58 +03:00
Jiaxiang Chen 03613d4708 JVM_IR: preserve old backend's logic for special mutable collection class stub methods 2020-03-18 19:28:04 +01:00
Mikhail Glukhikh 6739135d17 [FIR2IR] Add pre-caching of built-in classes to avoid their duplications 2020-03-18 17:09:37 +03:00
Mikhail Glukhikh 0bf4cac601 [FIR2IR] Unmute additional black box test after rebase 2020-03-18 17:09:37 +03:00
Mikhail Glukhikh 0f0e5e603d [FIR2IR] Use IR built-in types, their symbols & constructors directly 2020-03-18 17:09:36 +03:00
Mikhail Glukhikh 1036d8a35a [FIR] Provide dispatch receiver for 'field' synthetic variable 2020-03-18 17:09:36 +03:00
Mikhail Glukhikh 51c83e5f62 [FIR2IR] Move delegating constructor call to body start 2020-03-18 17:09:36 +03:00
Mikhail Glukhikh c0f8be5d4e [FIR2IR] Generate setter call for assignments, if any 2020-03-18 17:09:35 +03: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
Dmitriy Novozhilov 2b986194fb [FIR] Add desugaring of array assignments and resolve of it
#KT-37516 Fixed
2020-03-18 11:31:53 +03:00
Dmitry Petrov ade18d144a KT-36810 Implement javaPrimitiveType intrinsic in JVM_IR 2020-03-17 22:56:45 +03:00
Dmitry Petrov 6809f4439c Fix range-based 'for' loop with 'continue' in range bounds
1. Search for increment function in range element type, not in inferred
induction variable type
(which can be inappropriate, e.g., 'Nothing' in case of 'continue').

2. Handle nested loops with shared exit labels
(generated by JVM_IR for KT-37370 case).

KT-37370 KT-37373
2020-03-17 12:18:48 +03:00
Dmitry Petrov d5b65abc5d KT-37505 Add box test 2020-03-17 12:18:48 +03:00
Alexander Udalov 57fd449288 Minor, add check of const field modifiers to codegen test
#KT-29885
2020-03-13 23:26:12 +01:00
Roman Artemev d27954a6d4 [IR] Use erased types in backing field initializer in case of generic delegated property
- Since neither IrProperty nor IrField is Type Parameter container
 using of proprty's type parameter in IrField related code leads to
 creation of "hanging" type parameters which should be considered as
 incorrect IR.
 - Such code designed to be prohibited in LV 1.5
 - The fix makes use of erased type in such case
 where type parameter is expected.
2020-03-13 17:28:31 +03:00
Roman Artemev 34c17e2bed [KLIB] Add regression to about VarAsFun type parameter leak 2020-03-13 17:28:30 +03:00
Roman Artemev 8c1772d623 [KLIB] Add regression test 2020-03-13 17:28:30 +03:00
Mikhail Glukhikh 20c4a7b244 [FIR2IR] Introduce staged transformation (first step)
Now FE IR -> BE IR transformation is performed in multiple stages
controller by Fir2IrConverter. Stages are
 * files & classes registration
 * supertypes & type parameters handling
 * functions & properties signature generation
 * body generation

After each step we have guarantee (with exception of local classes &
type inference combination, and external symbols) that required symbols
(class/function/property/variable/type parameter)
are already bound to real declarations and have correct parents.

This commit also fixes incorrect parents for local classes
2020-03-13 12:18:02 +03:00
Zalim Bashorov 7cf8697e30 [JS BEs] use star projection when type parameter used recursively
#KT-37128 Fixed
2020-03-13 10:15:56 +03:00
Zalim Bashorov 8c7562d338 [CJS BE] don't crash when intersection types passed for a reified parameter
#KT-37163 Fixed
2020-03-13 10:15:53 +03:00
Alexander Udalov 244db9bcf9 JVM IR: don't rename fake overrides for fields
In case derived class has a field with the same name as the base class,
RenameFieldsLowering previously tried to rename one of the fields by
adding the "...$1" suffix, which led to NoSuchFieldError.
2020-03-12 13:51:40 +01:00
Mikhail Glukhikh 6fd8ccc293 [FIR2IR] Support (simple) conversion of captured types 2020-03-12 15:17:51 +03:00