Commit Graph

3421 Commits

Author SHA1 Message Date
Alexander Udalov c1ef89df2c Make anonymous classes for callable references synthetic
#KT-28453 Fixed
2018-12-18 17:48:19 +01:00
Roman Artemev e436e7cf61 [JS IR BE] Support call super with default parameters 2018-12-18 15:55:09 +03:00
Roman Artemev 256317da15 [IR BE] Fix SharedVariableLowering
* make it able to detect shared vars under any declaration kind, not only IrFunction
 * Add & update tests
2018-12-18 15:19:17 +03:00
Mikhail Zarechenskiy c924a6efe8 Fix unbound class literals for inline classes
#KT-28361 Fixed
2018-12-18 11:35:36 +03:00
Alexander Udalov 8c74312cf6 Fix isInitialized for companion lateinit properties
Instead of trying to access a missing field `Foo.foo`, call the
synthetic accessor `Foo.access$getFoo$cp` which, as per previous commit,
no longer contains the lateinit assertion

 #KT-21862 Fixed
2018-12-13 14:12:33 +01:00
Alexander Udalov 43413fcc44 Move lateinit assertion for companion property to companion object
Previously, for a property named `x` in the companion object of a class
named `Foo`, we generated:
- `Foo.access$getX$cp`, consisting of `GETFIELD Foo.x` and lateinit
  assertion
- `Foo.Companion.getX`, consisting of `INVOKEVIRTUAL Foo.access$getX$cp`

Now, we generate:
- `Foo.access$getX$cp`, consisting of `GETFIELD Foo.x`
- `Foo.Companion.getX`, consisting of `INVOKEVIRTUAL Foo.access$getX$cp`
  and lateinit assertion

The reason is that this way we can avoid generating another accessor and
reuse `Foo.access$getX$cp` in case `isInitialized` is called on a
lateinit property from companion.

For private properties, getX is not generated, but instead the assertion
is generated on each access to the field (which can be improved, see
KT-28331). The same happens for access to non-private properties from
inside the same context where they're declared.

 #KT-21862 In Progress
2018-12-13 14:12:33 +01:00
Yan Zhulanow dd49d35320 Fix backend tests after changing format of synthetic variables for inline functions 2018-12-12 21:40:44 +09:00
Roman Artemev 2b436b493c Move test from js to common part 2018-12-11 16:11:01 +03:00
Dmitry Petrov 08d1c47ac3 KT-14227 Intrinsify MutableMap.set
This fixes the most common (and rather annoying) bug in augmented
assignment desugaring with collection element receiver.

Fix is somewhat hackish: introduce an intrinsic for MutableMap.set,
thus bypassing discrepancies in 'get' and 'set' call generation.
Fixing it properly requires design decisions for corner cases where
ad hoc augmented assignment desugaring with collection element receiver
"accidentally" works, producing identical objects and vararg arrays for
arguments of 'get' and 'set'.
2018-12-11 12:43:03 +03:00
Dmitry Petrov 8ede477f99 KT-28585 Fix boxing for values of captured vars of inline class type 2018-12-10 14:57:09 +03:00
Dmitry Petrov 45035d3e11 KT-28405 Fix toString for inline classes with underlying arrays 2018-12-10 14:57:09 +03:00
Roman Artemev 4e05be9a96 Update tests 2018-12-07 17:58:20 +03:00
Dmitry Petrov f8582c1929 psi2ir: ersatz type approximation for intersection types
Emulate old JVM back-end behavior for intersection type mapping.

IrType renderer should render the IR type, not the original Kotlin type.
2018-12-07 10:51:55 +03:00
Vyacheslav Gerasimov d84c5b1608 Switch to 183 platform 2018-12-06 20:16:58 +03:00
Ilmir Usmanov bdd1eef39a Use class name instead internal name in coroutines debug metadata
I.e. instead of slashes use dots in fqnames.

 #KT-28237 Fixed
2018-12-06 16:59:12 +03:00
Ilmir Usmanov 5483ce0933 Do not map this when remapping parameters of static function inside
inline lambda.

 #KT-23543 Fixed
2018-12-06 15:46:22 +03:00
Ilmir Usmanov 4a828f839f Support recursive local suspend functions
Previously they were trying to call constructor (incorrectly) for
recursive calls. This is redundant, since this.invoke creates one
automatically.

In addition, support callable references to recursive local suspend
functions.

 #KT-24780 Fixed
2018-12-03 18:49:23 +03:00
Roman Artemev c5922bf74b Refact stdlib generator, add support for different backends
[JS IR BE] Runtime fixes
 * Do not generate external declarations for IR BE
 * Move `arrayToString` helper function out of shared JS stdlib
 * Fix arrays type check for IR BE
2018-11-29 22:04:53 +03:00
Ilmir Usmanov 0934db8fbd Do not transform state-machine when inlining
Sometimes, state-machine, generated in inline functions with
crossinline parameter, is transformed, since all usages should be
renamed.
However, this is wrong: in this case, we will have state-machine
inside state-machine.
This fix addresses the issue.

 #KT-25893 Fixed
2018-11-29 14:58:35 +03:00
Mikhael Bogdanov 623f31a178 Remove redundant tests 2018-11-29 12:02:05 +01:00
Alexander Udalov a796f11934 Support calling methods annotated with PolymorphicSignature
#KT-14416 Fixed
 #KT-26165 Fixed
2018-11-23 18:41:33 +01:00
Mikhail Zarechenskiy b48614df47 Add test for class literals on inline classes
#KT-28361 Obsolete
2018-11-22 18:10:41 +03:00
Mikhail Zarechenskiy 9d2524a790 Fix failing test because of lack of inference annotation
LINENUMBER was incremented because of added import
2018-11-20 19:36:50 +03:00
Dmitry Petrov 3efb07bf7b Return kotlin ctor mapped to a java ctor even if java ctor is synthetic
This allows working with constructors with inline class parameters using
Kotlin reflection, as described in
https://youtrack.jetbrains.com/issue/KT-27429#focus=streamItem-27-3161148-0-0

 #KT-27913
 #KT-27429
2018-11-20 09:53:18 +03:00
Dmitry Petrov 9082f19c00 KT-25907: Use proper loop parameter type in for-in-CharSequence 2018-11-20 09:52:09 +03:00
Dmitry Petrov 90da274eaa KT-28054: Treat inline class constructor accessors specially 2018-11-19 09:42:03 +03:00
Mikhail Zarechenskiy 3a93cab3b6 Mark JVM specific test with TARGET_BACKEND directive
This is needed to avoid test failing for Kotlin/Native
2018-11-17 22:55:18 +03:00
Mikhail Zarechenskiy 090d3327c0 Use wrapper class of an inline one as a result for javaClass
#KT-28185 Fixed
 #KT-28246 Open
2018-11-16 00:55:01 +03:00
Alexander Udalov 1a2579d8e8 Minor, add test for obsolete issue
#KT-21692 Obsolete
2018-11-15 20:29:34 +01:00
Roman Artemev d5acc8ff5b [JS BE] Set enclosing exception state in finally block
[Fix KT-28207]
2018-11-15 18:44:22 +03:00
Mikhail Zarechenskiy 35fb3ba096 Fix CCE when unboxed inline class receiver is passed to inline function
Initial problem is started in `capturedBoundReferenceReceiver` method
 where we assume that bound receiver is captured for usual call.

 Note that if method is inline then we don't pass actual name reference
 receiver, but pass special CAPTURED_RECEIVER_FIELD, which is then
 is used to find special instructions during inline and fold several
 instructions in `foldFieldAccessChainIfNeeded`.

 As a result, we got unboxed reference receiver for inline call, which
 caused CCE and to fix it we should box receiver one more time during
 inline

 #KT-28188 Fixed
2018-11-14 11:21:04 +03:00
Dmitry Petrov 99d8f2eb0c Support 'call' for primary value of an inline class
Getter of a primary value of an inline class belongs to the box class.
Its arguments should not be unboxed when the method is called.
However, its result might require boxing if it's an inline class value.

When we have an internal primary value, there's no getter method.
In fact, we can use box/unbox methods for inline class directly
(don't forget to box the result, it may be an inline class type value).

 #KT-26748
2018-11-14 09:57:51 +03:00
Mikhail Zarechenskiy d28488eaed Remove WITH_UNSIGNED directive from tests
#KT-25226 Fixed
2018-11-13 11:48:32 +03:00
Mikhail Zarechenskiy 79159947a5 Coerce last value of delegated expression for inline classes
Note that this commit doesn't fix case when some inline class over
 `Any` is returned from a lambda, it'll be fixed further as part of the
 #KT-27586

 #KT-27737 Fixed
2018-11-12 14:21:24 +03:00
Mikhail Zarechenskiy 20ff74a726 Fix mapping for inline classes when JvmSuppressWildcards mode is using
#KT-28097 Fixed
2018-11-12 09:36:05 +03:00
Dmitry Petrov 6d0a403ead KT-26765: Support 'call' for constructors with inline class parameters 2018-11-09 10:21:46 +03:00
Roman Artemev b010d9eef8 Add Contract tests for JS 2018-11-08 17:35:06 +03:00
Svyatoslav Kuzmich 5ea7673950 [JS IR BE] Mute inline class tests 2018-11-08 15:00:32 +03:00
Svyatoslav Kuzmich 43b4b6eaae Add more specific fail messages in inline class box tests 2018-11-08 15:00:31 +03:00
Georgy Bronnikov c20f93ddbf Mute failing test 2018-11-07 19:09:15 +03:00
Dmitry Petrov 1523185734 KT-27948: Use proper KotlinType when comparing with literal 0
#KT-27948
2018-11-07 18:17:29 +03:00
Dmitry Petrov e14f74bc18 KT-27948: Properly coerce values when generating areEqual call
#KT-27948
2018-11-07 18:17:29 +03:00
Dmitry Petrov ac7cc0c08e KT-27706: Dispatch receiver type for constructor accessor is Object 2018-11-07 18:17:29 +03:00
Dmitry Petrov ea4afdaebe KT-27705: Use proper types for captured outer class instance
Call typeMapper only if we have an inline class.
2018-11-07 18:17:29 +03:00
Mikhael Bogdanov d2a205c72d Update synthetic parameter processing logic according to ASM 7 changes
#KT-27774 Fixed
2018-11-07 15:42:57 +01:00
Alexander Udalov 17d740a373 Do not try computing return type in OverloadChecker
Return type is not needed for checking overloads, but querying it may
involve resolving function bodies, which usually happens after overload
checking (see LazyTopDownAnalyzer.analyzeDeclarations) and at this point
can lead to incorrect BACKING_FIELD_REQUIRED value being computed for
some properties (see KT-27895)

 #KT-27895 Fixed
2018-11-07 11:00:15 +01:00
Anton Bannykh 829bdf6061 JS: fix noInline version of inline suspend fun (KT-27611 fixed) 2018-11-07 12:34:00 +03:00
Anton Bannykh 59009430e5 JS: report inline suspend functions to IC
* Also inline suspend lambda'a
* Also use correct JsName's in exported suspend inline fun's
* Also use less unused imports
2018-11-07 12:11:01 +03:00
Roman Artemev 0e7520fde3 [JS IR BE] Fix GetClass on primitive type 2018-11-01 16:51:44 +03:00
Roman Artemev 2d03f87ea5 [IR BE] Support lateinit locals and isInitialized property
* update tests
2018-11-01 16:51:43 +03:00