Commit Graph

3614 Commits

Author SHA1 Message Date
Alexander Udalov adb05ab076 JVM IR: write inherited multifile parts flag to kotlin.Metadata
This flag is unused at the moment, but might be used one day to support
proper incremental compilation for multifile classes.
2021-02-17 21:56:18 +01:00
Dmitry Petrov 6d019d9544 JVM_IR indy-SAM on functional expression 2021-02-17 22:18:06 +03:00
Alexander Udalov 4d9cffccf2 Support structural equals/hashCode for type constructors of type parameters
Use the same logic as for type constructors of classes, based on the
fully-qualified name of the classifier, with special cases for error
types and local declarations, with an additional check that the type
constructors' declaration descriptors are structurally equal via
`DescriptorEquivalenceForOverrides`. The latter is required because type
parameters of overloaded functions must be different, even though their
full FQ name is the same.

This (hopefully) has no effect for the compiler, but is useful for
kotlin-reflect where `KType.equals` runs the type checker on the
underlying `KotlinType` instances, which eventually ends up comparing
type constructors. Descriptors and types in kotlin-reflect are cached on
soft references, so they may be suddenly garbage-collected and
recomputed, and we want copies of the same type parameter to be equal to
each other.

This fixes flaky codegen tests which started to fail after migration to
the new test infrastructure, where tests are now run in parallel in the
same process, thus with higher memory pressure and more soft references
being GC'd:

* `codegen/box/reflection/types/createType/typeParameter.kt`
* `codegen/box/reflection/supertypes/genericSubstitution.kt`

Also, add a new test to check that we do the instanceof check in
overrides of `AbstractTypeConstructor.isSameClassifier`.

 #KT-44850 Fixed
2021-02-17 14:41:07 +01:00
Ilmir Usmanov bad197e075 Raise RESERVED_VAR_PROPERTY_OF_VALUE_CLASS to error 2021-02-16 20:59:21 +01:00
Dmitry Petrov 56a104dda9 JVM_IR KT-44974 fix SAM-converted capturing extension lambda 2021-02-16 19:51:59 +03:00
Dmitriy Novozhilov dfcff132fd [FIR] Fix false-positive smartcast on receiver in rhs of elvis
#KT-44942 Fixed
2021-02-16 17:51:32 +03:00
Dmitriy Novozhilov d4c26cca52 [FIR] Use type without smartcast for local variable with smartcasted initializer 2021-02-16 17:51:32 +03:00
Dmitriy Novozhilov 40e286b354 [FIR] Increase level of sequential when branches
Level of CFGNode is used to determine which call is a common one for
  creating node with union of arguments (to merge flow from multiple
  in-place lambdas). Before this change calls in different when branches
  may have same node level, which entail passing smartcasts from moddle of
  one branch to another

```
val x: Any = ...
when {
    ... -> run { x as String } // (1)
    ... -> {
        run {
            x.foo()
        } // (2)
        "hello"
    }
}
```

Call `(1)` was assumed as argument of call `(2)` which is incorrect

#KT-44814 Fixed
2021-02-16 17:51:31 +03:00
Dmitry Petrov b1ab64e854 JVM_IR KT-44483 argument adaptation is already done in PSI2IR 2021-02-15 19:41:39 +03:00
Alexander Udalov 899f75466d Remove tests on kotlin-annotations-android
#KT-44815
2021-02-15 17:23:44 +01:00
Jinseong Jeon a884555171 FIR: bail out early for override check if base candidate is private 2021-02-15 19:16:36 +03:00
Mikhail Glukhikh fa0f967c83 FIR2IR: support adapted references for constructors 2021-02-15 17:08:13 +03:00
Mikhail Glukhikh 8bab208322 FIR2IR: use information about callable reference adaptation from resolve 2021-02-15 17:08:08 +03:00
Mikhael Bogdanov f493766563 Add IR tests to Android codegen test 2021-02-15 11:24:10 +01:00
Dmitriy Novozhilov 5711a8d610 [FIR] Support PreliminaryLoopVisitor in FIR DFA 2021-02-15 11:37:39 +03:00
Victor Petukhov 6f64fd2fec Propagate inference session into declaration analyzers
It prevents missing inference session for local declaration (local functions, local classes or objects)

^KT-44801 Fixed
2021-02-15 11:12:58 +03:00
Dmitry Petrov 5013344bc4 JVM_IR nullability assertions test for indy lambdas
KT-44278 KT-26060 KT-42621
2021-02-12 16:52:32 +03:00
Dmitry Petrov afeb7e18cd JVM_IR indy: fix non-null assertions on indy lambda parameters
KT-44278 KT-26060 KT-42621
2021-02-12 16:52:31 +03:00
Dmitry Petrov 052f6929c9 JVM_IR indy SAM conversions: update tests
KT-44278 KT-26060 KT-42621
2021-02-12 16:52:30 +03:00
Dmitry Petrov 3ebeca5852 JVM_IR: use indy SAM conversions in jvmTarget 1.8+, fix bridges
KT-44278 KT-26060 KT-42621
2021-02-12 16:52:30 +03:00
Alexander Udalov 510b9e6f2a Move around some codegen box tests
In tests merged from boxAgainstJava in 29b96aa1, some directories were
named slightly differently compared to box, e.g. "property" vs
"properties", "varargs" vs "vararg". This change renames these, moves
some of the tests to more fitting directories, and also renames
"visibility" to "javaVisibility" because it's about Java visibilities
specifically.
2021-02-11 13:50:09 +01:00
Alexander Udalov 2d60fa787d Remove codegen tests on old language and API versions 2021-02-11 13:50:09 +01:00
Alexander Udalov 401f0ac583 Use TARGET_BACKEND instead of DONT_TARGET_EXACT_BACKEND in box against Java tests
"// TARGET_BACKEND: JVM" more clearly says that the test is
JVM-specific, rather than DONT_TARGET_EXACT_BACKEND which excludes all
other backends.
2021-02-11 13:50:08 +01:00
Victor Petukhov f797ee7803 Substitute captured types with inner intersection one (NewTypeSubstitutor)
^KT-44651 Fixed
2021-02-11 14:20:14 +03:00
Mikhail Glukhikh 57e06992c9 Skip JDK 6 in failing BB test (java.util.function in use) 2021-02-11 12:59:23 +03:00
Mikhail Glukhikh cd483ad231 FIR2IR: fix raw SAM conversion (avoid * in type arguments) 2021-02-11 11:48:35 +03:00
Mikhail Glukhikh 5f3102bf2f FIR2IR: expand type before getting nullability #KT-44803 Fixed 2021-02-11 11:48:35 +03:00
Mikhail Glukhikh 346ffb3acf FIR2IR: support substitution for SAM types 2021-02-11 11:48:34 +03:00
Mikhail Glukhikh 7050af9b79 FIR2IR: use invariant projections for SAM_CONVERSION types 2021-02-11 11:48:34 +03:00
Alexander Udalov 73aa465ee9 Add tests for issues fixed in JVM IR
Note that KT-30696 is fixed only in the single-module case, and KT-42012
is not fixed fully (see KT-44855).

 #KT-30041
 #KT-30629
 #KT-30696
 #KT-30933
 #KT-32351
 #KT-32749
 #KT-38849
 #KT-42012
 #KT-42990
 #KT-44234
 #KT-44529
 #KT-44631
 #KT-44647
2021-02-10 21:42:10 +01:00
Dmitriy Novozhilov 606ae45f5f [Test] Replace remaining KOTLIN_CONFIGURATION_FLAGS directives with specific ones 2021-02-10 13:02:06 +03:00
Dmitriy Novozhilov 490ef210ac [FIR] Support sealed class inheritors in multiple files 2021-02-09 16:04:39 +03:00
Mikhael Bogdanov 3dff225b98 Aligh test data with JDK 15 reflection output 2021-02-09 12:34:55 +01:00
Ilmir Usmanov 8af9ce1e0b Minor. Ignore test on WASM 2021-02-09 12:31:14 +01:00
Ilmir Usmanov 275fef94fe JVM_IR. Do not mangle callable reference constructor call
#KT-44703 Fixed
2021-02-09 12:31:11 +01:00
Roman Artemev ca6e1b8f1b Add box test for #KT-43831 2021-02-09 11:33:34 +03:00
Mikhail Glukhikh 4a381d4b83 FIR DFA: update receivers properly in case of single flow in merge point 2021-02-08 18:23:44 +03:00
pyos d96921e287 FIR2IR: collect annotations when expanding type aliases 2021-02-08 18:23:19 +03:00
Mikhail Glukhikh d4b0688690 FIR: introduce delegate field initializers
Before this commit we initialized delegate fields in primary constructor,
that could provoke NPE in case delegate is used in initializer of
some property backing field.
Now we initialize delegate fields directly instead.
2021-02-08 14:28:27 +03:00
pyos 64c5608f31 FIR: expect nullable type for elvis LHS 2021-02-08 13:00:22 +03:00
Ilmir Usmanov cd189c0812 JVM_IR. Do not unbox Result in inline lambda
Since JVM_IR generates inline lambdas differently from old backend,
in this case, it generates them as normal functions.
Thus, there is no need to unbox the lambda argument.
 #KT-44671 Fixed
2021-02-04 20:22:20 +01:00
Svyatoslav Kuzmich c9cb7bc0fd [JS IR] Update tests 2021-02-04 16:16:41 +03:00
Dmitriy Novozhilov 29b96aa15d [Test] Properly merge box against java testdata into codegen/box
Previous commit about it was 3199ce03 and it was completely wrong
2021-02-04 10:53:50 +03:00
Alexander Udalov acd8c4503b Do not generate $suspendImpl for JvmDefault functions in interfaces
#KT-44533 Fixed
2021-02-03 21:37:58 +01:00
Ilmir Usmanov 5f71cd5476 Minor. Mute test on FIR 2021-02-03 19:18:29 +01:00
Ilmir Usmanov 02f845636e JVM_IR: Box generic Result parameter in suspend lambda
#KT-44527 Fixed
2021-02-03 19:18:27 +01:00
Ilmir Usmanov a30a961cf5 Minor. Throw exceptions in test coroutine builders 2021-02-03 19:18:24 +01:00
Dmitry Petrov ab20a8ffff JVM_IR indy-lambdas: minor updates and fixes
KT-44278 KT-26060 KT-42621
2021-02-03 14:16:25 +03:00
Dmitry Petrov 088448043a JVM_IR indy-lambdas: don't use indy for big arity lambdas
KT-44278 KT-26060 KT-42621
2021-02-03 14:16:24 +03:00
Dmitry Petrov d94912ed62 JVM_IR indy-lambdas: initial implementation and tests
KT-44278 KT-26060 KT-42621
2021-02-03 14:16:22 +03:00