Commit Graph

63 Commits

Author SHA1 Message Date
Mads Ager 3a11322506 Enable bytecode text tests for the JVM_IR backend. 2018-12-21 16:20:45 +01:00
Alexander Udalov f5ff3d2fa9 Remove directives that have no effect from bytecode text tests
All bytecode text tests are run with stdlib in the classpath and only
for JVM backend, therefore directives WITH_RUNTIME, TARGET_BACKEND,
IGNORE_BACKEND are not needed
2018-12-20 12:53:24 +01:00
Mikhail Zarechenskiy d28488eaed Remove WITH_UNSIGNED directive from tests
#KT-25226 Fixed
2018-11-13 11:48:32 +03:00
Dmitry Petrov 5304754e88 Generate specialized 'toString' for inline classes when possible
#KT-25613
2018-10-15 12:21:14 +03:00
Dmitry Petrov 5480bf69e8 Support property delegation to inline class values (KT-27070) 2018-10-03 11:09:46 +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
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
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
Mikhail Zarechenskiy fcacdc1fc5 Fix bridge methods generation when inline class types are used 2018-06-19 20:09:35 +03: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 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
Mikhail Zarechenskiy 5c57c799fc Fix generation of elvis with null constant for inline classes 2018-05-07 15:25:45 +03:00
Mikhail Zarechenskiy f23b5103ec Avoid non-null assertions for inline classes based on nullable types
Note that there are more places where assertions for inline classes should refined:
  - lateinit vars
  - values that come from Java
  - type casts (interfaces to inline class type)
2018-02-20 14:41:48 +03:00
Mikhail Zarechenskiy 413e2d7fa1 Fix KotlinType of constructor call for inline classes 2018-02-20 11:58:18 +03:00
Mikhail Zarechenskiy 530dd01ca6 Fix unboxing values of inline class type from type parameters 2018-02-20 11:45:49 +03:00
Mikhail Zarechenskiy e017e9cb5f Support passing inline class values with spread operator 2018-02-13 13:16:45 +03:00
Mikhail Zarechenskiy 3919dc94e1 Box values of inline class types when passing to function as varargs 2018-02-13 13:16:44 +03:00
Mikhail Zarechenskiy 6687751cf5 Generate as check for inline classes using wrapper
Should be improved when inline class is based on non-null reference
2018-02-13 13:16:44 +03:00
Mikhail Zarechenskiy a88dbefcd9 Generate is check for inline classes same as for primitives
Should be improved when inline class is based on non-null reference
2018-02-13 13:16:44 +03:00
Mikhail Zarechenskiy d606e5bc89 Correct boxing for functional types containing inline classes 2018-02-13 13:16:43 +03:00
Mikhail Zarechenskiy 1d16d21dbb Fix boxing for non-local and labeled returns with inline classes 2018-02-13 13:16:42 +03:00
Mikhail Zarechenskiy 80dd5c106e Propagate KotlinType through call generator, fix boxing on arguments 2018-02-13 13:16:42 +03:00
Mikhail Zarechenskiy 22b9c25dd0 Add KotlinType info about this inside inline class 2018-02-13 13:16:41 +03:00
Mikhail Zarechenskiy c86d3e354b Skip call to the underlying value of inline class 2018-02-13 13:16:41 +03:00
Mikhail Zarechenskiy 2c279978c8 Fix generation of property accessor to the underlying value 2018-02-13 13:16:40 +03:00