Commit Graph

417 Commits

Author SHA1 Message Date
Alexander Udalov 3ca81b95c2 Use non-allowed actual defaults in backends to workaround compiler exception
It's difficult to fix KT-22818 until the IR comes along, so we're
providing a workaround where one can disable the
ACTUAL_FUNCTION_WITH_DEFAULT_ARGUMENTS error and provide default values
in the actual function, to avoid exception from the backend.

 #KT-22818
2018-09-21 17:30:05 +03:00
Dmitry Petrov 0f898dc6dc Fix default interface generic extension fun call with inline class type
When we've determined that we are going to invoke an erased inline class
method ('static foo-impl(this, ...)' in inline class), keep track of it
so that the remaining type mapping logic proceeds correctly.

 #KT-26998 Fixed Target versions 1.3.20
2018-09-21 09:48:11 +03:00
Dmitry Petrov 8d2b1950e6 Fix Kotlin default interface methods calls for inline classes
When mapping callable method signature for erased inline class methods,
use original function descriptor instead of super declaration
(otherwise it would map to a default interface method with mismatching
signature).

When generating delegates to Kotlin default interface methods, keep
track of the original Kotlin types for delegating method arguments and
interface method arguments.

'original' for value parameters of fake overrides points to the
overridden function value parameters instead of the value parameter of
the unsubstituted function. This causes inconsistent type mapping for
inline classes implementing generic interfaces with default methods.

 #KT-25295 Fixed Target versions 1.3.20
 #KT-26931 Fixed Target versions 1.3.20
2018-09-21 09:48:11 +03:00
Dmitry Petrov d9593c7a34 Add tests for inline class variables captured in closure 2018-09-21 09:48:11 +03:00
Roman Artemev 24e7bafa7d Port test from K/N 2018-09-20 19:59:12 +03:00
Mikhael Bogdanov 38652372ce Generate private constructors for Enums
#KT-2680 Fixed
  #KT-16867 Fixed
2018-09-19 12:14:08 +02:00
Ilmir Usmanov 5dea245a37 Fix linenumbers written to debug metadata
#KT-26848 Fixed
2018-09-18 20:06:25 +03:00
Ilmir Usmanov c4038729ea Minor. Split tests with buildSequence into LV 1.2 and LV 1.3 versions 2018-09-18 14:56:08 +03:00
Mikhail Zarechenskiy fa9a3868b7 Make generation of assertions for platform types aware of kotlin types
#KT-26859 Fixed
2018-09-17 16:21:06 +03:00
Georgy Bronnikov f04733ef33 JVM_IR. support big arity 2018-09-13 18:44:47 +03:00
Alexander Udalov 3a5de13dd4 Support inline classes in function signatures in call/callBy
#KT-25664 Fixed
 #KT-26748 Open
 #KT-26765 Open
2018-09-13 16:04:20 +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
Mikhail Zarechenskiy 66a00f442c Add tests for obsolete issues
#KT-12008 Obsolete
 #KT-11881 Obsolete
 #KT-10822 Obsolete
2018-09-11 12:34:09 +03:00
Dmitry Petrov 006c0aa740 Hide constructors accepting inline class parameters 2018-09-07 15:57:59 +03:00
Alexander Udalov 06ce0cb0f0 Fix deserialization of default property accessor flags
In MemberDeserializer.loadProperty, we incorrectly passed 0 to
getAnnotations when loading annotations on property accessors in case
the protobuf field getter_flags/setter_flags was not present. The
correct behavior, as described in metadata.proto, was to pass a special
"default accessor flags" value, constructed from the main property
flags. Otherwise in case there were annotations both on the property and
on the accessor (as in PropertyAndAccessor.kt) and the accessor was
otherwise default, we would assume that it had no annotations and would
not load them in compiler and reflection

 #KT-25499 In Progress
2018-09-07 11:49:41 +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
Mikhail Zarechenskiy 83975bd6ac Generate stub for specialized equals inside inline class 2018-09-06 10:39:33 +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 05daa21657 Fix inline class secondary constructor call generation
Don't generate NEW+DUP for inline class constructor calls.
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
Alexander Udalov ac14c5e74f Fix KType.javaType for suspend function return type
#KT-26293 Fixed
2018-08-30 16:47:48 +02:00
Ilmir Usmanov f3879af9f6 Implement suspend lambdas of big arity
Suspend functions and callable references to suspend lambdas are already
supported.
Support callSuspendBy of suspend function of big arity.
 #KT-24854: Fixed
2018-08-30 17:29:09 +03:00
Ilmir Usmanov 22f9a6ce08 Add coroutines debug metadata: compiler
#KT-25557 Fixed
 #KT-25559 Fixed
2018-08-30 16:19:41 +03:00
Ilmir Usmanov fe451dce31 Implement correct is check for SuspendFunction
Add test for suspend functions with language version 1.2.
Minor edit in SuspendFunction docs.
2018-08-30 16:17:46 +03:00
Dmitry Petrov a205019156 Additional tests and fixes for function name mangling 2018-08-30 14:58:54 +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
Ilmir Usmanov e93683621a Implement callSuspend and callSuspendBy functions as KCallable's
extension methods.
Also make isSuspend a member of KCallable.
 #KT-21972: Fixed
2018-08-30 14:57:48 +03:00
Alexander Udalov ceb909d261 Inherit KType from KAnnotatedElement, implement KType.annotations
#KT-16795 Fixed
2018-08-30 14:56:57 +03:00
Alexander Udalov b55fc818d1 Support JvmName on annotation constructor parameters
#KT-25372 Fixed
2018-08-30 14:56:42 +03:00
Alexander Udalov dc1f4c7d5b Generate get-targeted annotations on annotation constructor parameters
This change would also make NotNull annotations to be generated on
non-primitive annotation methods, but we skip this deliberately because
annotation methods never return null on JVM anyway

 #KT-25287 Fixed
2018-08-30 14:56:40 +03:00
Alexander Udalov cbc92bc9a1 Add KClass.sealedSubclasses to get direct subclasses of sealed class
#KT-14657 Fixed
2018-08-30 14:56:21 +03:00
Alexander Udalov 877dfd8ff4 Fix generic signature of FunctionN type visible from Java 2018-08-30 14:55:56 +03:00
Mikhail Zarechenskiy d94b47bcd3 Support other kinds of translation for unsigned literals 2018-08-30 14:55:34 +03:00
Alexander Udalov c369e67e9f Revert "Ignore tests on big function types until master is 1.3"
This reverts commit f03dc62173.
2018-08-30 14:52:38 +03:00
Roman Artemev cc14442be1 Add tests for primitive companion object
Update test data
2018-08-24 14:58:42 +03:00
Dmitry Petrov 2a524920a5 Don't remap inline function args requiring inline class boxing/unboxing
Same as for primitives: inline lambda expects to see a boxed value,
so, even if an argument is a local variable, it can't be remapped,
because it contains unboxed representation.
2018-08-24 14:52:29 +03:00
Dmitry Petrov 6e2d05cd94 Fix argument original type order in InlineCodegen
Arguments are put on stack in the direct order, and then stored into
local variables for inlining in the reversed order:

    <arg0>
    <arg1>
    <arg2>
    store <param2>
    store <param1>
    store <param0>

Original value parameter types were taken in direct order, though.
2018-08-24 14:52:29 +03:00
Ilmir Usmanov 0559cfb724 Move SuspendFunction{N} interfaces to kotlin.coroutines package
#KT-25824: Fixed
2018-08-22 16:21:30 +03:00
Ilmir Usmanov 4a7703ed66 Implement correct is check for SuspendFunction
Let callable references implement SuspendFunction
Do not generate CHECKCAST SuspendFunction when LV is 1.2

 #KT-25825: Fixed
2018-08-22 16:21:27 +03:00
Dmitry Petrov 533f87ac33 Use proper KotlinType for prefix increment/decrement
Otherwise inline class values (such as UByte) are boxed incorrectly,
see KT-26219.
2018-08-22 12:24:50 +03:00
Alexander Udalov 1c2a9e4b21 Map annotation target TYPE -> TYPE_USE if JVM target >= 1.8
And TYPE_PARAMETER -> TYPE_PARAMETER similarly

 #KT-23857 Fixed
2018-08-21 12:38:05 +02:00
Dmitry Petrov 7d4dfc87b1 Use proper KotlinType in get/set methods for property reference 2018-08-21 08:43:12 +03:00
Ilmir Usmanov d3dbcae7a4 Get rid of typed create and invoke wherever possible
in coroutine lambdas.
 #KT-26243 Fixed
2018-08-20 21:33:24 +03:00
Dmitry Petrov b6e3218ca2 Use mapping mode for inline class underlying type without wrapping 2018-08-16 15:03:50 +03:00
Dmitry Petrov 8e95ecb821 Use underlying type when computing type mapping mode for inline classes 2018-08-15 15:37:46 +03:00
Ilmir Usmanov a470fd21ca Eliminate only first {ASTORE, ALOAD} in locals elimination
of ALOAD.
 #KT-25912: Fixed.
2018-08-15 13:45:24 +03:00
Dmitry Petrov ebf8ec455d Box/unbox nullable inline class values with null check
When we have a nullable inline class value with non-null underlying
type, corresponding value in unboxed representation is nullable. E.g.:

  inline class Str(val value: String)

  fun test(s: Str?) = listOf(s)

Here 'test(s: Str?)' accepts nullable 'java.lang.String' as a parameter.

When boxing/unboxing nullable values of such inline classes, take care
of nulls.

 #KT-26052 Fixed Target versions 1.3-M2
2018-08-14 10:22:07 +03:00
Dmitry Petrov 0af33462ef Fix code generation for Array<C> element access where C is inline class 2018-08-13 08:49:04 +03:00
Dmitry Petrov 4f6aa50417 Fix == for inline classes with boxes
TODO generalize code generating object vs primitive equality

 #KT-25914 Fixed
 #KT-25981 Fixed
 #KT-25983 Fixed
2018-08-10 10:34:57 +03:00
Mikhail Zarechenskiy be38263fc7 Introduce conversions from signed pure constants to unsigned ones
#KT-24717 In Progress
 #KT-25996 Open
 #KT-25997 Open
2018-08-09 09:47:48 +03:00