Commit Graph

383 Commits

Author SHA1 Message Date
Ilya Gorbunov
fab69d2f22 Use new sequence builders in tests
Coroutine tests will fail when LV=1.2 because there're no such builders
in kotlin.coroutines.experimental.

#KT-26678

(cherry picked from commit 1b889c976a)
2018-09-17 14:38:48 +03:00
Ilmir Usmanov
02d1d832f1 Use our own primitive boxing methods in coroutines codegen
#KT-26490 Fixed
2018-09-12 17:01:19 +03:00
Denis Zharkov
c1cc722ac4 Turn off incorrect switch-optimization for when by enums
#KT-24708 Fixed
2018-09-12 09:49:25 +03:00
Yan Zhulanow
d16b55033e Introduce new naming convention for captured receiver backing fields
'receiver$0' -> '$this_<label>'
2018-09-11 16:41:20 +03:00
Dmitry Petrov
e3fa785678 Minor: drop irrelevant test case
Hiding constructors with inline class type parameters
is tested by bytecodeListing tests
2018-09-10 17:45:05 +03:00
Roman Elizarov
e2713501ce Rename SuccessOrFailure to Result and hide Failure from ABI
* The members of Result are isSuccess, isFailure, exceptionOrNull, getOrNull
* The rest of API is implemented via inline-only extensions
* There are two internal functions to hide detailed mechanics of an internal
  Result.Failure class: createFailure and throwOnFailure
* Result.toString is explicit: either Success(v) or Failure(x)

See KT-26538
2018-09-09 11:34:31 +03:00
Dmitry Petrov
cafaa3e13c Mangle inline class members
<IMPL_SUFFIX> for method is a method signature hash,
if method value parameter types contain inline class types,
otherwise 'impl'.

Constructor methods are named as 'constructor-<IMPL_SUFFIX>'.

Synthesized 'box' and 'unbox' methods are named as
'<METHOD_NAME>-<IMPL_SUFFIX>'.

Erased implementations of overriding and non-overriding methods
are named as '<METHOD_NAME>-<IMPL_SUFFIX>'.

Fully specialized implementation of 'equals' will have a special suffix.
2018-09-07 10:25:53 +03:00
Dmitry Petrov
43b4190f7c Test: visibility of inline class members
Also merge in testInlineClassWrapperPrimaryConstructorIsSynthetic
and testInlineClassConstructors.
2018-09-07 09:31:33 +03:00
Dmitry Petrov
d8a6db8774 Mark synthesized box/unbox methods in inline classes as ACC_SYNTHETIC 2018-09-07 09:31:26 +03:00
Dmitry Petrov
0bd1c4d1b7 Make inline class wrapper constructor private 2018-09-07 09:31:26 +03:00
Dmitry Petrov
c094b3a5a2 Drop erased class for inline class 2018-09-07 09:31:26 +03:00
Dmitry Petrov
db13ab59a6 Test: SuccessOrFailure calls don't generate erased class references 2018-09-05 12:20:57 +03:00
Dmitry Petrov
203fd6a5d6 Make inline class wrapper constructor synthetic 2018-09-05 12:20:57 +03:00
Dmitry Petrov
65881dda97 Fix tests after rebase 2018-09-05 12:20:57 +03:00
Dmitry Petrov
1bf8cfca8b Test: property accessors are called by inline class 2018-09-05 12:20:57 +03:00
Dmitry Petrov
a2900282fd Call factory method for primary constructors of inner classes
We might want to add 'init' blocks later, so now, for the sake of
binary compatibility with 1.3-RC binaries, we have to generate these
'constructor' calls.

Note that in some tests inline class boxing is no longer redundant,
because resulting value is passed to 'constructor' as an argument.
2018-09-05 12:20:57 +03:00
Dmitry Petrov
b1016936b2 'box'/'unbox' methods are called by inline class 2018-09-05 12:20:57 +03:00
Dmitry Petrov
687b492bf9 Test: inline class secondary constructors are called by inline class 2018-09-05 12:20:57 +03:00
Dmitry Petrov
80a67477db Generate method calls for inline classes through IC, not IC$Erased
IC extends IC$Erased, so it should be fine.
2018-09-05 12:20:57 +03:00
Dmitry Petrov
3080b65f7d Inline (wrapper) class IC extends erased inline class IC$Erased 2018-09-05 12:20:57 +03:00
Dmitry Petrov
583c66a2a7 Don't mangle synthesized 'box' function for inline classes 2018-08-30 16:21:30 +03:00
Dmitry Petrov
99498eb7b8 Use 'name-hash' mangling scheme
'-' is allowed as a name character both in JVM and in Dalvik, but can't
be a part of a Java identifier.
2018-08-30 14:58:52 +03:00
Dmitry Petrov
a56d1d3ce8 Mangle function names with inline class parameters
Avoid name clashes in cases such as

  inline class Login(val login: String)
  inline class Password(val password: String)

  fun validate(login: Login) { ... }
  fun validate(password: Password) { ... }
2018-08-30 14:58:50 +03:00
Denis Zharkov
f594cb22e8 Add "LANGUAGE_VERSION: 1.2" directive where it's necessary 2018-08-30 14:58:41 +03:00
Ilmir Usmanov
300876348a Fix line numbers generation for coerced primitives
in coroutines
 #KT-25076: Fixed
2018-08-15 13:47:45 +03:00
Mikhail Zarechenskiy
1497c19dc9 Do not generate useless methods inside wrapper for inline class
Fix for test data (inlineFunctionInsideInlineClassesBox.kt) is needed
 to avoid check about "no inline functions".

 This check has two steps: first, names of inline functions from
 the metadata are loaded, then these names are checked that they are
 presented for physical methods in the classfile.

 Because now there are no physical methods in the classfile, we can't pass
 the second check, therefore this fix is needed.

 #KT-24872 Fixed
2018-08-07 12:15:46 +03:00
Mikhail Zarechenskiy
1972387022 Fix test data after 6d4d244c28 2018-08-06 17:45:24 +03:00
Mikhail Zarechenskiy
6d4d244c28 Generate function from Any for inline classes same as for data classes
#KT-24873 Fixed
 #KT-25293 Fixed
 #KT-25299 Fixed
2018-08-06 10:56:01 +03:00
Mikhail Zarechenskiy
043ce1cb27 Support secondary constructors for inline classes
#KT-25614 Fixed
 #KT-25246 Fixed

 KT-25599 Will be fixed after recompilation of unsigned classes
2018-08-06 10:55:57 +03:00
Ilmir Usmanov
82f64b9b14 Generate LVT entry for continuation
#KT-25688: Fixed
2018-07-26 16:12:54 +03:00
Mikhail Zarechenskiy
9aa4247065 Do not box primitives in a single-entry string template expression 2018-07-20 13:46:11 +03:00
Mikhail Zarechenskiy
ec9d8e580e Leave boxing for compareTo/areEqual methods for inline classes
Inline classes can override methods and thus introduce side effects
2018-07-20 11:51:34 +03:00
Ilmir Usmanov
0ed5ec868c Generate probeCoroutineSuspended call in suspendCoroutineUninterceptedOrReturn
#KT-25508: Fixed
2018-07-19 14:24:09 +03:00
Dmitry Petrov
82f22f92ca Don't generate ConstantValue for non-const vals in Kotlin 1.3+ 2018-07-18 15:02:54 +03:00
Denis Zharkov
0b3048f60a Replace trivial usages of suspendCoroutineOrReturn in tests
This is necessary since suspendCoroutineOrReturn gets removed in 1.3
2018-07-09 15:27:19 +03:00
Denis Zharkov
8c65e55c02 Fix some of the bytecodeText tests
The changes are necessary because of release coroutines support:
- Get rid of suspendCoroutineOrReturn calls. It's anyway irrelevant
to what is being tested here

- In varValueConflictsWithTable.kt, variables slots have been shifted
because the variable for continuation's exception was removed

- In varValueConflictsWithTableSameSort.kt, a variable has been introduced
to preserve the same slot numbers for old variables.
Otherwise, they become shifted and to the second slot,
and there are a lot of irrelevant "ALOAD 2" instructions

This change is another example of why bytecode text tests are evil
2018-07-09 15:27:19 +03:00
Denis Zharkov
820506d9c6 Fix tests after new Continuation API support
#KT-24863 Fixed
2018-07-09 15:27:19 +03:00
Mikhail Zarechenskiy
4f490ac264 Fix generation of checkcast instructions for inline classes
Normalize LHS and RHS types to use only boxed ones and then let bytecode
 optmizer reduce redundant boxing
2018-07-05 12:55:39 +03:00
Ilya Gorbunov
3c86e40bcb Fix WITH_UNSIGNED directive in noBoxingOperationsOnNonTrivialSpread 2018-07-03 03:52:18 +03:00
Mikhail Zarechenskiy
ba6da7c40a Support varargs of inline class types with non-trivial spread
#KT-24880 In Progress
2018-06-25 17:15:50 +03:00
Dmitry Petrov
d35a92a81d Generate accessor for private companion object 2018-06-22 16:53:07 +03:00
Dmitry Petrov
a4b5d74ae3 Generate debug information for 'when' subject variable
NB debugger tests currently don't support language version or individual
language feature settings.
2018-06-20 14:06:34 +03:00
Mikhail Zarechenskiy
fcacdc1fc5 Fix bridge methods generation when inline class types are used 2018-06-19 20:09:35 +03:00
Alexander Udalov
863639c9ab Revert changes to data class equals/hashCode (KT-12330)
This looked like a small and useful change, but caused so many issues
(KT-24474, KT-24790, 30b9caea, and another unreported one -- see the
test update in this commit) that it didn't pay off after all. The
optimization is not that critical for now, as it's only relevant for
data classes where component types have trivial equals/hashCode
implementation, which is not very often

 #KT-12330 Declined
2018-06-19 12:05:55 +02:00
Mikhail Zarechenskiy
246d5e294c Fix bytecode optimisations for consequent boxing 2018-06-18 11:52:37 +03:00
Mikhail Zarechenskiy
01d9be65bc Perform bytecode optimisations for inline classes
#KT-23742 Fixed
2018-06-18 11:52:36 +03:00
Mikhail Zarechenskiy
656f6cbded Support constant evaluation of unsigned type constructors
#KT-23816 In Progress
2018-06-04 18:37:34 +03:00
Ilmir Usmanov
f568149863 Implement new assert semantics in back-end
Previously, assert was just a regular function and its argument used to
be computed on each call (even if assertions are disabled on JVM).
This change adds support for 3 new behaviours of assert:
* always-enable (independently from -ea on JVM)
* always-disable (independently from -ea JVM)
* runtime/jvm (compile the calls like javac generates assert-operator)
* legacy (leave current eager semantics) - this already existed

Default behaviour is legacy for now.

The behavior is changed based on -Xassertions flag.
 #KT-7540: Fixed
2018-05-21 20:43:37 +03:00
Mikhail Zarechenskiy
50116fd8fc Fix coercion result for inline classes, add comment 2018-05-07 15:25:48 +03:00
Mikhail Zarechenskiy
b25a1d9522 Support inline functions inside inline classes 2018-05-07 15:25:46 +03:00