Commit Graph

2973 Commits

Author SHA1 Message Date
pyos a3d85e108f JVM_IR: keep suspend fun return type in IrCalls
Otherwise:

  * should the dispatch receiver of a call be another call to a `suspend
    fun` wrapped in something that is optimized away later, the owner of
    the method will be incorrect;

  * references to functions returning non-Unit but casted to `() ->
    Unit` (allowed by new inference) might in fact not return Unit after
    tail call optimization.
2020-02-24 17:12:43 +01:00
Mikhail Glukhikh 39bd97147f [FIR] Don't create initializers for simple enum entries
Usually FIR enum entry is initialized by anonymous object,
which is the container for all enum entry' declarations.
However, for simple enum entries there is no need of initializer at all.
2020-02-21 16:38:52 +03:00
Pavel Punegov 94be4d77ff Fix init order in inline fun (native test) 2020-02-21 16:04:53 +03:00
Dmitry Petrov e9a7be4a46 Fix intersection type handling in PSI2IR 2020-02-21 15:11:16 +03:00
Mikhail Zarechenskiy 1624327ba4 [NI] Fix substitution in builder-inference for empty common system 2020-02-21 14:24:57 +03:00
pyos c5ffbfd33c JVM_IR: mark origins of capture fields in suspend lambdas 2020-02-21 12:11:19 +01:00
pyos 6b98ea2378 JVM_IR: do not place suspend markers around crossinline lambda calls 2020-02-21 12:11:19 +01:00
Mikhail Glukhikh a3f676317f FIR2IR: pre-cache type parameters before function creation
Type parameters can be referred from e.g. function return type,
so we should determine them earlier to be able to set their indexes
2020-02-20 18:34:51 +03:00
Mikhail Glukhikh 8c21f04bf4 FIR2IR: determine type parameters before value parameters
Type parameters can be referred from value parameters,
so we should determine them earlier to be able to set their indexes
2020-02-20 18:34:51 +03:00
Mikhail Glukhikh 334cab7357 [FIR] Don't build redundant fake overrides for private members
The only case we may need fake override for private members is
a situation when class refers itself with different type arguments.
So in this commit we forbid such fake overrides when we can prove
that class does not refers itself here.
2020-02-20 18:34:51 +03:00
Mikhail Glukhikh a6d11b0207 [FIR] Don't create redundant substitution scopes 2020-02-20 18:34:50 +03:00
Juan Chen 9dd8eda1c9 [FIR]: fix library methods in packages
Library methods such as 'listOf' are resolved
to have the package fragments as their parents,
but JVM expects their containing file classes as parents.
This fix generates those file classes and
uses them as parent replacements for such library methods.
2020-02-20 14:24:02 +03:00
pyos eff02b6e72 JVM_IR: improve suspend tail call detection.
* TailCallOptimizationLowering should go into local classes in order to
   transform their suspend methods;
 * the check for invokes of noinline lambda arguments in codegen was
   incorrect, as it also returned true for calls of lambdas stored in
   local variables;
 * IrInlineCodegen should mark non-inlinable arguments used as inline
   suspend parameters;
 * detection of suspend/inline call sites was incorrect (or maybe it's
   the `compilationContextDescriptor` that was incorrect?..)
2020-02-20 11:10:26 +01:00
Mikhail Glukhikh 14fd1d3c9f [FIR] Check visibility correctly for sealed class in file 2020-02-19 22:41:23 +03:00
Mikhail Glukhikh ace259314b Use 'symbol' instead of 'classId' in FirResolvedQualifier
This commit solves problem with resolved qualifier of local class
#KT-36758 Fixed
2020-02-19 22:41:23 +03:00
Mark Punzalan 3d51af2935 [JVM IR] Fix issue with suspend functions with @JvmOverloads. 2020-02-19 16:48:53 +01:00
Mikhail Glukhikh a4c4b2650c FIR2IR: remove hacky & redundant resolve of delegating constructor calls 2020-02-19 18:09:06 +03:00
Mikhail Glukhikh 9017654b9d [FIR] Handle default parameters when checking callable reference type
#KT-36759 Fixed
2020-02-19 18:09:06 +03:00
Victor Petukhov e8524137c3 NI: exclude not fixed type variables from types on which null checks should be generated
^KT-36371 Fixed
2020-02-19 15:58:08 +03:00
pyos 3080b4c435 JVM_IR: remove a suspend-related hack from BridgeLowering
`invoke` in suspend lambdas overrides FunctionN.invoke, so the
refactored BridgeLowering already generates correct bridges there.
All the hack does is break overrides of interface suspend methods.
2020-02-19 11:26:45 +01:00
Steven Schäfer 272f6abe69 JVM IR: Fix suspend lambda generic signatures 2020-02-19 11:18:27 +01:00
pyos 5d603a8be4 JVM_IR: detect lambdas capturing crossinline through fields 2020-02-19 10:47:27 +01:00
Pavel Kirpichenkov a50911156d [NI] Add regression tests for builder inference
Actual fix is c02dd720
^KT-33542 Fixed
^KT-33544 Fixed
^KT-36446 Fixed
2020-02-18 19:12:53 +03:00
Mads Ager 752ff9de5d JVM_IR: Support suspend lambdas with many arguments. 2020-02-18 16:21:25 +01:00
Steven Schäfer 4b954c347a JVM IR: Avoid optimizing comparisons between boxed primitives and null
A comparison of the form `x == null` where `x` is of type `Int` might not
be vacuous if `x` is a boxed value coming from Java code.
2020-02-18 13:37:48 +03:00
Mark Punzalan 64141b8b38 [JVM IR] Fix issue where fields are not being set to their default
values within initializer blocks.

The issue occurs in code like this:
```
class C {
  var b = true
  init {
    b = false   // Missing PUTFIELD for this statement
  }
}
```

Added a new statement origin for field initialization (at declaration)
instead of relying on `origin == null` in ExpressionCodegen to determine
whether to generate the initializations.

This was unintentionally broken in
d68a1898d0.
2020-02-17 23:04:11 +03:00
Mikhail Glukhikh 56c819f06e FIR2IR: add two-statements block with iterator + while for 'for' loops
Before this commit we had two statements blocks for 'for' loops:
range variable declaration + iterator variable declaration + while loop.
However, BE requires a bit different loop structure to make lowerings
properly so in this commit iterator declaration & while loop were
extracted to separate block.
2020-02-17 20:35:17 +03:00
Mikhail Glukhikh 4abbcd1267 Unmute two passing FIR black box tests (fixed by commits of demiurg) 2020-02-17 20:35:16 +03:00
Mikhail Glukhikh 91814364de Mute two failing FIR black box tests (broken by commits of demiurg) 2020-02-17 20:35:16 +03:00
Igor Chevdar 9bc7a43991 [IR] [JS_IR] Supported fun interfaces in JS 2020-02-17 12:21:00 +03:00
Mikhail Zarechenskiy 18b218bfa8 [NI] Use projected type for constraint like Cap(out A) <: out @Exact T
This is an implicit semantics of Exact annotation
2020-02-17 10:29:46 +03:00
Mikhail Zarechenskiy 3cf77d29b5 Unmute test for NI
It was fixed in 7f6c03c9
2020-02-17 10:29:45 +03:00
Mikhail Zarechenskiy 4542f3b720 [NI] Finish analysis for coerced last lambda expressions if needed 2020-02-17 10:29:45 +03:00
Kristoffer Andersen de33b83bb3 Update asFunKSmall.kt 2020-02-15 22:38:10 +03:00
Kristoffer Andersen 577250d73f [FIR] Fix FIR2IR Types on SetVariable Expressions 2020-02-15 22:38:06 +03:00
Kristoffer Andersen 4dc6583f31 Update asFunKSmall.kt 2020-02-15 22:32:23 +03:00
Kristoffer Andersen 4f36e2ccfc [FIR] Fix FIR2IR Types on SetVariable Expressions 2020-02-15 22:32:23 +03:00
Roman Artemev e57d34dd9e Make fix test:
- [JS IR] Unmute fixed tests
 - [IrText] Update testdata
 - [WASM] Temporary turn wasm test off
 - [FirText] Temporary turn fit text tests off
 - [JVM IR] Turn off klib jvm test
 - [IR] Add new test
2020-02-14 18:22:17 +03:00
Roman Artemev 5004bb3636 [Psi2Ir] Fix generation of hashcode for generic inline class 2020-02-14 18:22:16 +03:00
Dmitriy Novozhilov e696d1d06a [FIR] Improve mapping arguments to parameters 2020-02-14 17:53:28 +03:00
Georgy Bronnikov 79060e7f40 IR: handle conflicts in resolveFakeOverride() 2020-02-14 17:20:34 +03:00
Georgy Bronnikov c71e87068a JVM_IR: in InheritedDefaultMethodsOnClassesLowering, skip bridges when resolving overrides 2020-02-14 17:20:34 +03:00
Jinseong Jeon 5a49ccac76 JVM_IR: Relax bailout condition for SAM conversion generation.
Previously, resolved call is expected to have SAM converted argument map
if SamConversionPerArgument is enabled. However, if SAM argument is
followed by vararg parameter and an array _without_ a spread operator is
passed, New Inference left a type mismatch error on a resolved call, which
made that resolved candidate filtered out. Instead, another resolution
result wihtout SAM converted arugment map will be provided.

All other logics, such as adding SAM conversion type op and lowering SAM
conversion and/or call references, are already there for resolved calls
without SAM converted argument map. This change just relaxes the bailout
condition so that array passed to vararg after SAM argument can be
handled in JVM IR.
2020-02-13 23:43:03 +03:00
Alexander Udalov 3278451b07 JVM IR: do not generate certain special bridges as final
Special bridges which are generated as a replacement for a non-final
fake override and use invokespecial to call the already existing
implementation in the superclass, should not be final. Otherwise we
can't generate an override for the original Kotlin function in a
subclass with the same JVM signature.
2020-02-13 14:34:18 +01:00
Mikhail Zarechenskiy 3d28945ecb [NI] Disable feature explicitly as it's required in test 2020-02-13 12:08:10 +03:00
Dmitry Petrov 866f188120 Report JVM signature clashes from JVM_IR
Also:

* Do not rename public ABI fields
This includes backing fields for const, lateinit, @JvmField properties,
and instance fields for objects.

* FAKE_OVERRIDE declarations for static members of parent Java classes
Required to report cases when a Kotlin function accidentally overrides
Java class member.
2020-02-13 11:35:48 +03:00
Mikhail Zarechenskiy abc5eb4740 [NI-MIGRATE-BAD] Update problematic/questionable tests
These tests are going to be reviewed in more detail before 1.4
2020-02-13 11:15:59 +03:00
Mark Punzalan 89cf32eccc Clarify comments about KT-36625 that it is pending design decision. 2020-02-12 23:38:12 +03:00
Mark Punzalan ba606147c9 [JVM IR] Maintain KT-36625 bug compatibility between non-IR and IR
backends by removing IMPLICIT_NOTNULL casts from IrStringConcatenation
arguments.

Also fixed an issue where IrStringConcatenation can be lowered into
a null String instead of a literal "null" String if the lone argument
was a platform type String or String with enhanced nullability and the
value was null (e.g., "${FromJava.nullPlatformString()}").
2020-02-12 22:57:15 +03:00
Alexander Udalov d5987fd7f3 Minor, move wrongAnnotationArgumentInCtor.kt to CLI tests
The fact that this was a codegen box test was probably an abuse of the
testing infrastructure. It was never meant to pass, since it checks
presence of an error, and diagnostic tests aren't enough since they
might not check the full compiler execution.
2020-02-12 17:36:08 +01:00