Commit Graph

2384 Commits

Author SHA1 Message Date
Mikhael Bogdanov
2ed0cb2a89 Support type annotations
#KT-35843 Fixed
2020-01-09 14:00:11 +01:00
Alexander Udalov
fde9b21a40 Fix syntheticMethodForProperty.kt for JDK 9+ and Android tests 2020-01-09 11:34:51 +01:00
Mark Punzalan
137ef26723 [JVM IR] Fix issue with destructuring declaration in parameter for
suspend lambda.

The Name for the special destructuring declaration parameter was
incorrectly turned into a regular/non-special Name when the parameter
was moved to a field.
2020-01-08 19:51:16 +01:00
Mark Punzalan
36c4df6d99 [JVM IR] Use names of local functions in names of local classes.
This undoes changes in
fbe66c3496
which broke calculation of the simple name of local classes in
reflection (the enclosing method was not a substring of the name of the
local class).
2020-01-08 18:45:40 +01:00
Steven Schäfer
929fb5c82b Mute FIR tests containing broken function calls 2020-01-08 13:20:00 +01:00
Mads Ager
1b1dff9191 JVM_IR: fix default argument stub visibility.
Match the rules from the old backend:

1. Private and inline only methods get package private default
   argument stubs.

2. Everything else is public.
2020-01-08 13:19:14 +01:00
Mads Ager
98f5c5aa95 JVM_IR: Preserve annotations on inline class replacement methods. 2020-01-03 16:44:50 +01:00
Mads Ager
e7835fecfc JVM_IR: fix a couple of inline class reflection issues.
1. Postpone the computation of the signature for property
   reference getters for extension properties until codegen time.

2. Generate metadata for static replacement functions instead
   of the original functions.
2020-01-03 16:38:53 +01:00
Mads Ager
2ebb797e61 JVM_IR: Remove accessor for internal inline class properties. 2020-01-03 15:29:34 +01:00
Dmitry Petrov
d27593aeda PSI2IR: SAM conversion in method arguments of out-projected Java classes
It uses the same logic as an old back-end
(see SamType#createByValueParameter and genericSamProjectedOut.kt),
split into two parts:

1. When inserting SAM casts, use SamType#createByValueParamerer to get
the target SAM type.

2. When inserting implicit casts, cast SAM conversions as arguments of
methods of out-projected types to the original type of value parameter
instead of 'Nothing'.
2020-01-03 15:32:44 +03:00
Dmitry Petrov
0e4e5ac287 Update nullability assertion tests that use newer Java features 2019-12-31 11:14:52 +03:00
Alexander Udalov
cc0b231b3b Convert SyntheticMethodForAnnotatedPropertyGenTest to a box test 2019-12-30 16:30:50 +01:00
Alexander Udalov
8f30b25b24 Minor, fix some codegen tests for language version 1.4
These tests check behavior of an old language version on purpose: the
original bug KT-24708 has been fixed by introducing an error here in
1.4.
2019-12-30 16:30:45 +01:00
Dmitry Petrov
330dd789de Minor: mute test in FIR+JVM_IR 2019-12-30 16:08:44 +03:00
Dmitry Petrov
98bf0e278f Fix problem with empty vararg of boxed primitives in JVM_IR
When calling a generic Java generic method with vararg parameters with empty
vararg, incorrect array creation instruction was generated for primitive type:
NEWARRAY T_INT instead of ANEWARRAY java/lang/Integer. Here for Java method

  public static <T> void takesVarargOfT(T x1, T... xs) {}

corresponding vararg parameter was considered to be of type 'Array<T>?',
which is not a non-null array type, so, NewArray intrinsic failed to generate
proper bytecode.
2019-12-30 11:26:21 +03:00
Mikhail Glukhikh
6da3c2fa4e FIR2IR: set parent correctly (~) for anonymous functions 2019-12-27 16:13:02 +03:00
Juan Chen
3dc58bc995 [FIR2IR] Fix translating primitive array types
This commit fixes two issues in the existing implementation of translating primitive array types:

 * IrType.getArrayElementType throws an exception when the receiver is a primitive array type, because IR expects primitive array types use symbols defined in IrBuiltIns, but fir2ir translation doesn't;
 * IteratorNext.toCallable assumes all element types are boxed.

The first issue is fixed by changing the fir2ir type translation to use symbols in IrBuiltIns for primitive array types, and the second by not unboxing primitive types.
2019-12-27 15:32:18 +03:00
Mikhail Glukhikh
1cf582e9ed FIR2IR: set extension receiver for anonymous functions 2019-12-27 15:31:36 +03:00
Mikhail Glukhikh
15f373a864 FIR2IR: support object receiver case (this fixes 24 black box tests) 2019-12-27 13:46:05 +03:00
simon.ogorodnik
5e426fdc71 [FIR] Optimization & checking fix: remove usage of dispatchReceiverValue 2019-12-27 13:45:59 +03:00
Juan Chen
4c04ad2371 FIR: Add bindings for dispatch receiver parameters
Before this commit, such descriptors have null owners, which causes problems when the getter of the owner property is called.
2019-12-27 10:13:44 +03:00
Dmitry Petrov
babe6eb581 Fix explicit 'equals' for primitive types 2019-12-26 12:44:54 +03:00
Dmitry Petrov
08454aa47e Minor: add reference to language design issue 2019-12-26 10:31:12 +03:00
Mark Punzalan
2dd8727baf [JVM IR] ForLoopsLowering: Keep IMPLICIT_NOTNULL type-casts in next()
and `componentN()` calls.

There were issues when we have iterables from Java where the element
type has "not null" type information.
2019-12-26 10:11:18 +03:00
Dmitriy Novozhilov
b54169d312 [NI] Fix substitution in completion of callable references in coroutine inference 2019-12-25 16:19:19 +03:00
Dmitry Petrov
a8e9a6a1d0 Properly reference type parameter descriptors
'descriptor -> descriptor.original' relation is often inconsistent
wrt 'containingDeclaration', parameters, and type parameters,
we have to introduce some workarounds here.
2019-12-25 14:20:47 +03:00
Roman Artemev
f2f7d144aa [JS] Fix failing test 2019-12-24 19:26:06 +03:00
Roman Artemev
6ba8fbd451 [IR BE] Refactored FoldConstantLowering
- Fix `toString` evaluation for unsigned types in FoldConstantLowering
 - make corner cases around float/double evaluation work for K/JS
 - remove usage of kotlin type
2019-12-24 19:26:06 +03:00
Roman Artemev
fb3bd8a9ac [JS BE] Implement accessor inlining optimization (WIP)
- enable constant folding
2019-12-24 19:26:05 +03:00
Roman Artemev
540b3cfec3 [JS IR] Fix test to make them able to run with JS 2019-12-24 19:26:05 +03:00
pyos
982a088f00 JVM_IR: do not copy defaults in functions with inline class parameters 2019-12-24 18:59:33 +03:00
Igor Chevdar
9e17140daf [JS_IR] Turned on passing JS_IR tests 2019-12-24 15:54:45 +03:00
Dmitry Petrov
cdf9ef63ba Remove nullability assertions from special bridge call arguments 2019-12-24 12:50:06 +03:00
Georgy Bronnikov
d4b0151f51 JVM_IR: fix name of received field for suspend lambdas
$ at the start caused AnonymousObjectTransformer to skip the field.
2019-12-23 18:03:46 +01:00
Ilmir Usmanov
5c92da3f35 JVM_IR: Do not generate parameter annotations for continuation constructors
The idea is the same as in case of anonymous objects: they are created only
from Kotlin code, so we are sure, that the parameters are valid.
Also, the inliner complains on their transformations.
2019-12-23 18:03:43 +01:00
Ilmir Usmanov
a1448ebb37 JVM_IR: Support crossinline suspend lambdas
The main idea is the following: since we need to generate
(fake)continuations before inlining, we move IrClasses of suspend
lambdas and continuation classes of named functions into the functions.
Thus, it allows the codegen to generate them prior to inlining and
the inliner will happily transform them for us.
Because of that, lowerings which transform call-site function are likely
to change reference to lowered suspend lambdas or functions.
Hence, do not rely on references to lowered suspend lambdas or
functions, instead, rely on attributes.

Do not generate continuation for inline suspend lambdas.
Previously, inline suspend lambdas were treated like suspend functions,
thus we generated continuations for them. Now we just do not treat them
as suspend functions or lambdas during AddContinuationLowering.
We should add continuation parameter to them, however.

Do not generate secondary constructor for suspend lambdas, otherwise,
the inliner is unable to transform them (it requires only one
constructor to be present).

Generate continuation classes for suspend functions as first statement
inside the function.
This enables suspend functions in local object inside inline functions.
Since we already have attributes inside suspend named functions, we
just reuse them to generate continuation class names. This allows us
to close the gap between code generated by old back-end and the new
one.

If a suspend named function captures crossinline lambda, we should
generate a template for inliner: a copy of the function without
state-machine and a continuation constructor call. The call is needed
so the inliner transforms the continuation as well.

Refactor CoroutineTransformerMethodVisitor, so it no longer depends on
PSI.
2019-12-23 18:03:40 +01:00
Mads Ager
51f726be9b JVM_IR: Fix check for whether classes are from Java.
This allows us to not generate redundant immutable collection
stubs. The code to generate the immutable collection stubs does
not deal well with thinking that all external declarations
come from Java.
2019-12-23 14:24:48 +01:00
pyos
59f2aa7add JVM_IR: remove constructors of nested annotations 2019-12-23 13:59:42 +01:00
pyos
17d2fda946 JVM_IR: keep nullability when remapping type parameters 2019-12-23 14:28:05 +03:00
Dmitriy Novozhilov
c94dd2939e [NI] Add test for KT-32429
#KT-32429 Can't Reproduce
2019-12-20 11:33:06 +03:00
Mikhael Bogdanov
650cfeaaed Update inline tests to void PROTECTED_CALL_FROM_PUBLIC_INLINE_ERROR 2019-12-19 12:46:36 +01:00
Dmitry Petrov
09c3279cc7 PSI2IR: Infer smart cast on dispatch receiver of FAKE_OVERRIDE calls
NB here we have use derived class type with type arguments replaced
with star-projections. This emulates JVM erasure (to some degree),
but, unfortunately, that's best we can offer here at the moment.
2019-12-19 12:24:58 +03:00
Alexander Gorshenev
ab79c3e0a0 Properly mute (and unmute) tests for unrelated backends 2019-12-18 19:29:56 +03:00
Alexander Gorshenev
dc8240c24e Expect/actual support in klibs under -Xklib-mpp 2019-12-18 19:29:56 +03:00
Georgy Bronnikov
220ea72d65 JVM_IR: add coercion for index in ArrayGet intrinsic 2019-12-18 13:03:12 +03:00
Alexander Udalov
7eda60d57e Minor, add more tests on signature-polymorphic calls
Add a test on null (since null is a special case in the
PolymorphicSignature spec), and a test on a call without assignment to a
variable
2019-12-17 18:44:19 +01:00
Alexander Udalov
64d40b4743 Support JVM polymorphic signature calls to methods with void return type
#KT-32026 Fixed
2019-12-17 18:39:05 +01:00
Svyatoslav Kuzmich
f099277210 [JS IR] Unmute tests and add KJS_WITH_FULL_RUNTIME 2019-12-17 15:33:43 +03:00
Svyatoslav Kuzmich
e32ec2a789 [JS IR BE] Support typeOf 2019-12-17 15:33:43 +03:00
Ilmir Usmanov
b6de3c2fcc Disable tail-call optimization for suspend functions with Unit return type
if it overrides functions with another return type.
Otherwise, we cannot determine on call site that the function returns Unit
and cannot { POP, PUSH Unit } in order to avoid the situation when callee's
continuation resumes with non-unit result. The observed behavior is that
suspend function, which should return Unit, suddenly returns other value.
 #KT-35262: Fixed
2019-12-17 12:08:35 +01:00