Commit Graph

4640 Commits

Author SHA1 Message Date
Mikhail Zarechenskiy 2cee82a348 [NI] Resolve receiver of provideDelegate independently
#KT-38259 Fixed
2020-05-25 16:06:55 +03:00
Dmitry Petrov de4ebe4395 Prohibit @JvnName on functions mangled because of return type 2020-05-20 07:19:29 +03:00
Victor Petukhov eff5f3a242 NI: do type checking for anonymous functions not inside a call
^KT-38890 Fixed
^KT-38439 Fixed
2020-05-19 16:29:14 +03:00
Victor Petukhov 73dec25eb1 NI: intersect DFI types before capturing
^KT-37887 Fixed
2020-05-14 19:54:59 +03:00
Alexander Udalov 82551e91a4 Add KClass.isFun modifier to reflection
#KT-38881 Fixed
2020-05-14 14:05:51 +02:00
Alexander Udalov 0ce16b9d8c Support non-reified type parameters in typeOf in JVM and JVM_IR
#KT-30279 Fixed
2020-05-13 10:04:28 +02:00
Sergey Rostov 4daac14008 Revert due to massive flaky tests 2020-05-12 23:01:01 +03:00
Alexander Udalov 012ffa2993 Support new scheme of compilation of OptionalExpectation annotations
Instead of generating these annotation classes as package-private on
JVM, serialize their metadata to the .kotlin_module file, and load it
when compiling dependent multiplatform modules.

The problem with generating them as package-private was that
kotlin-stdlib for JVM would end up declaring symbols from other
platforms, which would include some annotations from package
kotlin.native. But using that package is discouraged by some tools
because it has a Java keyword in its name. In particular, jlink refused
to work with such artifact altogether (KT-21266).

 #KT-38652 Fixed
2020-05-12 19:28:57 +02:00
Sergey Rostov fc59e28610 Fix lastIndexOfOrNull 2020-05-12 16:20:47 +03:00
Victor Petukhov 11d05c1abd NI: propagate isNullabilityConstraint flag into constraint injector and inherit it
^KT-37510 Fixed
2020-05-12 16:15:07 +03:00
Sergey Rostov 14edc26cf1 Revert due to test failing in 201 2020-05-08 10:13:07 +03:00
Sergey Rostov e099ee3af8 Fix lastIndexOfOrNull 2020-05-07 21:48:50 +03:00
Alexander Udalov a0400f59c2 Add -Xskip-prerelease-check compiler argument
#KT-38070 Fixed
2020-05-07 13:24:26 +02:00
Victor Petukhov 260683c20e NI: Improve postponed arguments analysis
Introduce seven stages:
1) Analyze postponed arguments with fixed parameter types
2) Collect parameter types from constraints and lambda parameters' declaration
3) Fix not postponed variables for parameter types of all postponed arguments
4) Create atoms with revised expected types if needed
5) Analyze the first ready postponed argument and rerun stages if it has been analyzed
6) Force fixation remaining type variables: fix if possible or report not enough information
7) Force analysis remaining not analyzed postponed arguments and rerun stages if there are

^KT-37952 Fixed
^KT-32156 Fixed
^KT-37249 Fixed
^KT-37341 Fixed
2020-05-07 11:42:00 +03:00
Mikhail Zarechenskiy 1a26d2e157 Fix exception during resolution of incorrect fun interface
#KT-37541 Fixed
2020-04-29 14:15:25 +03:00
Mikhail Zarechenskiy 780bc1f607 Fix fun interfaces with extension receivers
#KT-37712 Fixed
2020-04-29 14:15:25 +03:00
Ilya Chernikov 4a0d1b0b9d Use precalculated intersection type in JVM backend
also test all backends for the problem in the issue
#KT-37715 fixed
2020-04-29 11:12:22 +02:00
Steven Schäfer 905a8ca0d0 Reflect: Handle methods with inline class default parameters 2020-04-28 19:49:35 +02:00
Alexander Udalov 098a935aa7 Fix exponential string table size of anonymous classes during inlining
When we inline an anonymous object which captures something such as
crossinline values or reified parameters, we copy and transform its
metadata in `AnonymousObjectTransformer.transformMetadata`. Basically we
read the metadata of the original class, add a minor protobuf extension
and write it to the new class.

This also includes copying the string table. We read the string table
into `JvmNameResolver` (a representation of string table used in
deserialization), then construct a `JvmStringTable` (a representation
used in _serialization_) and then write it back.

There's a few optimizations in the string table representation in JVM
metadata which allow to store less strings and thus take less space. See
`StringTableTypes.Record` in `jvm_metadata.proto` for more information.
One of the optimizations `Record.range` allows to avoid storing the same
record many times in a sequence. For example, if we have N different
strings in the string table but none of them require any operation (such
as substring, char replacement, etc.), then we only store the record
with all default values (no operation, no predefined string, etc.) and
set its `range` to N. Upon reading such optimized record list in
`JvmNameResolver`, we "expand" it back to normal, so that we could index
it quickly and figure out what operation needs to be performed on each
string from the string table.

The problem was that when we expanded this list, we didn't set the range
of the expanded record entry to 1. So each record in
`JvmNameResolver.records` still has its original range. It doesn't cause
any problems most of the time because the range in this expanded list is
almost unused. However, when copying/transforming metadata for anonymous
objects, we mistakenly passed this expanded list with incorrect ranges
to `JvmStringTable`. So the metadata in the copied anonymous object
ended up being incorrect: each record now was present the number of
times equal to its range. Copying such metadata once again led to
another multiplication of the record list size. Multiple copies resulted
in exponential increase in memory consumption and quickly led to OOM.

For the fix, we now take the original, unexpanded list of records when
creating `JvmStringTable` out of `JvmNameResolver` for transformation of
anonymous object metadata.

Note that another possible fix would be to make range for each record in
`JvmNameResolver.records` equal to 1. This is undesirable though, since
then we'd need to copy each `JvmProtoBuf.StringTableTypes.Record`
instance, of which there could be many, and use some memory for no
apparent gain (since ranges in that expanded list are now not used at
all).

 #KT-38197 Fixed
2020-04-28 12:59:52 +02:00
Pavel Kirpichenkov dfc86dbf63 [NI] Avoid type rendering in member scope for intersection type
KT-38544
2020-04-28 12:53:09 +03:00
Dmitriy Dolovov 90e888a1b6 Discriminate overloading expect MemberDescriptors
Issue #KT-38298
2020-04-28 13:16:18 +07:00
Sergey Igushkin 4b0da0688a Fix expect discrimination with actual typealias in deserialization
* For types encountered during deserialization, search for a classifier,
  not necessarily a class, across module dependencies (i.e. accept type
  aliases, returned when actual type alias discriminates an expect
  class).

* When the referenced type is a type alias, expand it, so that when
  the descriptor is compared to the expansion in other places,
  they match.

* Also, when resolving an abbreviation, don't expand the type aliases,
  as there are assumptions in the code base that an abbreviation is a
  type alias.
2020-04-24 12:54:38 +03:00
Dmitriy Dolovov 22dc837e26 IDE. Allow expect declarations in completion in shared native modules
Issue #KMM-218
2020-04-21 10:21:19 +07:00
Jinseong Jeon c26adf53dd FIR: resolve suspend lambda properly 2020-04-20 17:05:30 +03:00
Georgy Bronnikov 2c4fcebfec IR: handle adapted bound references 2020-04-18 20:31:57 +03:00
Mikhail Zarechenskiy 4ffcbc0c2f [NI] Properly support UnsafeVariance annotation
#KT-38134 Fixed
 #KT-34433 Fixed
 #KT-31823 Fixed
2020-04-16 13:55:47 +03:00
Mikhail Zarechenskiy 9607739d30 Introduce synthetic scope for constructors of fun interfaces
#KT-37434 Fixed
2020-04-15 02:37:34 +03:00
Mikhail Zarechenskiy e9e21caeaf Refactoring: move utils to create & initialize SAM constructors to core 2020-04-15 02:29:57 +03:00
Mikhail Zarechenskiy cf90fe81ac Move Sam(TypeAlias)ConstructorDescriptor to core 2020-04-15 02:06:32 +03:00
Mikhail Zarechenskiy 54497d11ac Move SyntheticMemberDescriptor.kt to core
This is a first part of unification SAM constructors for all platforms
2020-04-15 02:06:32 +03:00
Dmitriy Dolovov 0a2429c6f6 Minor. Remove redundant import 2020-04-14 21:14:33 +07:00
Dmitriy Dolovov 6d0e73191c HMPP: Fix detection of NativePlatform in CompositeResolverForModuleFactory 2020-04-14 21:07:44 +07:00
Dmitriy Dolovov fee6a752e0 HMPP: Fix serialization of TargetPlatform in Kotlin facet 2020-04-14 21:07:22 +07:00
Dmitriy Dolovov adc457548b Minor. Formatted 2020-04-14 21:07:16 +07:00
Dmitriy Dolovov 0f60b5a71e HMPP: Avoid false positive detection of "common native" as "common" 2020-04-14 21:07:00 +07:00
Vladimir Dolzhenko b0483a67c2 Perform tryLock-and-checkCanceled on waiting lock in LockBasedStorageManager
Relates to #KT-38012
2020-04-14 13:11:30 +02:00
Alexander Udalov 683489687e Fix NPE in KCallable.isAccessible for interfaces loaded by boot class loader
Class.getClassLoader returns null for classes loaded by the system class
loader (the one used to start the application). In this case we need to
use ClassLoader.getSystemClassLoader. We already have an extension
`safeClassLoader` specifically for this purpose in reflection.jvm, but
forgot to use it in d59f2bcc80.

 #KT-37707 Fixed
2020-04-09 12:35:28 +02:00
Mikhail Bogdanov 7d54027f41 Minor. Rename new proto property, JvmFlags.getClassFlags method
Compiler requires this new flag to know where actual interface method body is generated to emit proper method calls
2020-04-09 07:37:33 +02:00
Mikhail Bogdanov 7876d821a9 Minor. Rename jvm default utility methods 2020-04-09 07:37:33 +02:00
Mikhael Bogdanov ff8eac29a0 New flag in proto 2020-04-09 07:37:31 +02:00
Mikhail Zarechenskiy 86fd4da567 [UAST] Fix mapping types containing type aliases
#KT-27935 Fixed
2020-04-08 01:25:14 +03:00
Kevin Bierhoff 7448761dfd only stub default constructor when compiling against .java source files 2020-04-07 17:48:39 +02:00
Ilya Gorbunov 8194652793 Allow placing Suppress on a type parameter
#KT-12448
2020-04-03 19:36:37 +03:00
Victor Petukhov 164f25937f NI: take into account an extension function annotation during CST calculation 2020-04-02 15:28:35 +03:00
Mathias Quintero 34a64d9171 Making var arg kParameters default to empty array no argument given
fixes KT-29969
2020-04-01 16:00:16 +02:00
Ilya Gorbunov f3fc1197ae Add SIZE_BITS and SIZE_BYTES constants to Double and Float
#KT-29182
2020-04-01 08:06:57 +03:00
Ilya Gorbunov 1c93911279 Make Double and Float known values constant
#KT-13887
2020-04-01 08:06:57 +03:00
Alexander Udalov 92534eadaa Remove dependency of 'resolution' on 'deserialization'
Replace it with a dependency on 'descriptors'.

Move the existing marker interface ContractProvider to 'descriptors',
and create a new marker interface DeserializedDescriptor.
2020-03-28 21:30:07 +01:00
Alexander Udalov d70271b6aa Move RequireKotlinNames to 'descriptors'
Also move version string regex there and rename the class to
RequireKotlinConstants. This allows to get rid of dependency of
'serialization' on 'frontend'.
2020-03-28 21:30:07 +01:00
Georgy Bronnikov b0d96eb140 Revert "Workaround for KT-37302"
This reverts commit ae208f58a4.
Issue fixed, workaround no longer needed.
2020-03-27 14:19:45 +03:00