Commit Graph

218 Commits

Author SHA1 Message Date
Jinseong Jeon
04af6846a7 FIR2IR: handle more vararg spreads for adapted callable references 2020-08-31 14:31:58 +03:00
Igor Chevdar
527de030fc [box-tests] Turned on some tests for K/N 2020-08-31 12:01:31 +05:00
Dmitriy Novozhilov
b21a0213df [NI] Get rid of FE 1.0 types in AbstractTypeApproximator 2020-08-28 10:59:51 +03:00
Jinseong Jeon
553ae68c96 FIR2IR: convert adapted callable reference with vararg 2020-08-26 14:26:19 +03:00
Jinseong Jeon
1b6c4329d2 FIR2IR: handle unbound reference with adapted arguments 2020-08-18 21:53:07 +03:00
Jinseong Jeon
7ef1c74bbf FIR2IR: apply adapted reference conversion to coercion-to-unit 2020-08-05 17:07:27 +03:00
Jinseong Jeon
0e54f98b79 FIR: support adapted callable reference with vararg 2020-08-03 16:37:36 +03:00
Jinseong Jeon
bff36e0199 FIR2IR: convert annotations on FirTypeRef 2020-07-30 11:25:36 +03:00
Jinseong Jeon
5a3367e09c FIR: initial support of suspend conversion for function reference 2020-07-28 13:37:05 +03:00
Jinseong Jeon
4e14f9500f FIR: account for vararg when creating KFunction type for callable reference 2020-07-20 09:39:34 +03:00
Mikhail Zarechenskiy
c2c139ef4f Fix adaptation for references with default values after varargs
After vararg argument it's possible to pass values only by name, so
 here we modulate this behavior

 #KT-37721 Fixed
2020-06-26 14:03:48 +03:00
Ilya Gorbunov
2fe222e8e7 Add SKIP_DCE_DRIVEN directive in JS-IR tests
Otherwise they fail with a compiler exception:
"An operation is not implemented: SAM conversion"
2020-06-17 19:45:15 +03:00
Mikhail Zarechenskiy
718f23b34f Compatibility warning for references to companion via name (KT-13934) 2020-06-05 13:24:18 +03:00
simon.ogorodnik
8afbb4542b [FIR2IR] Fix check if interface is SAM 2020-05-29 21:10:56 +03:00
Vitaly
fe047f9b47 [JS BE] mutes tests for JS_IR_ES6, which muted for JS_IR 2020-05-27 00:32:56 +03:00
Denis Zharkov
e1e149a062 FIR: Support coercion-to-unit semantics for callable references 2020-05-18 11:17:45 +03:00
Anton Bannykh
86b5c63891 JS IR: fix origin for callable references with bound reciever
In case of IrFunctionReference with type SuspendFunction (no K!) there
was a misalignment between the base class (Any) and the
origin (LAMBDA..). As a result the SuspendFunctionLowering was
getting confused and produced hanging code.
2020-05-14 14:33:12 +03:00
Anton Bannykh
bdca4b45bd JS: inliner supports extra argument caused by suspend conversions 2020-05-14 14:33:12 +03:00
Mikhail Glukhikh
e7e80be34a [FIR2IR] Populate overridden symbols even for !isOverride
Before this commit we considered !isOverride as a sign that
function / field / accessor has no overridden symbols.
However, it's false for deserialized, because isOverride
is always false there.

This commit fixes 68 BB tests but breaks 25 BB tests (not yet muted)
2020-05-14 13:40:36 +03:00
Alexander Udalov
91ef053fbc IR: keep local scope with counter maps across LDL invocations
Since LocalDeclarationsLowering is a BodyLoweringPass, local
functions inside one declaration are handled independently of local
functions in the other declaration. This can lead to name clashes, in
case a local function with the same name and signature is declared in
overloads in the same container, which results in a signature clash
error in JVM IR.

The issue became more common with the introduction of adapted function
references, where psi2ir generates a local adapter-function with a
predefined name, which can easily clash with another reference to the
same target in an overload. This led to a compilation error when
bootstrapping Kotlin with JVM IR, for example in GradleIRBuilder.kt
where there are a lot of references to the same function.
2020-05-08 14:33:34 +02:00
Alexander Udalov
54f9f130e2 Do not generate references as adapted with -Xno-optimized-callable-references
The reason for this is that this flag is used right now in 'cli-common'
to workaround the problem that this module is compiled with API version
1.4, but runs with stdlib of version 1.3 (bundled to Gradle). The same
problem would appear with adapted function references, since we use
kotlin/jvm/internal/AdaptedFunctionReference in the bytecode, only
available since 1.4.

The fix is to generate adapted references in this case as subclasses of
the already existing kotlin/jvm/internal/FunctionReference. This can
change behavior in some extreme corner cases (because such references
can now be observed to have reflection capabilities), but it's an -X
argument anyway.

Another option would be to introduce another compiler argument
specifically for this, but it looks like it would only complicate things
without much benefit.
2020-05-04 13:24:53 +02:00
simon.ogorodnik
a11866ab5a [FIR2IR] Fix labeled this references 2020-04-30 13:15:43 +03:00
Dmitry Petrov
f9bb07e128 JVM_IR: generate flags for adapted function references 2020-04-29 00:55:52 +03:00
Dmitry Petrov
878e838f0b JVM: Suspend converted references inherit AdaptedFunctionReference 2020-04-28 18:56:37 +03:00
Mikhail Glukhikh
c6c848f929 Introduce & use FirJvmSerializerExtension & FirBasedClassCodegen
#KT-38156 In Process
2020-04-28 07:34:56 +03:00
Dmitry Petrov
c7a96810bf JVM: Suspend conversion for function references 2020-04-27 21:02:37 +03:00
Alexander Udalov
025d1ca64d psi2ir: rework representation of bound adapted function references
This fixes the problem in JVM IR backend which didn't pass bound
receiver value of an adapted function reference to the superclass
(kotlin/jvm/internal/AdaptedFunctionReference), which caused equals to
work incorrectly on such references (see changes in box tests).

Previously, bound adapted function reference was represented as
IrFunctionExpression to an adapter function which calls the callee. The
value of the bound receiver in that case could only be found in the body
of that adapter function. This is not very convenient, so this change
makes psi2ir produce a block of the adapter function + reference to it.
The bound receiver value is then found in the reference. This is
basically similar to what ProvisionalFunctionExpressionLowering is doing
for all function expressions. And since this IR structure is already
supported in FunctionReferenceLowering, the problem in the JVM IR is
fixed without any additional modifications.

However, inliners do not support this IR structure yet, see KT-38535 and
KT-38536.
2020-04-23 16:47:23 +02:00
Mark Punzalan
b74652aa5b [FIR] Use ieee754equals for floating-point equality operations 2020-04-23 11:50:54 +03:00
Mikhail Glukhikh
96d8b0bea3 FIR: make KFunctionX derived from KFunction 2020-04-20 17:05:37 +03:00
Georgy Bronnikov
2c4fcebfec IR: handle adapted bound references 2020-04-18 20:31:57 +03:00
Juan Chen
a1e0e8b0e7 [FIR] Handle receiver types of extension methods when computing maximally specific types.
Test case (from testPrimitiveReceiver):

fun Short.foo() = 3
fun Int.foo() = 4

1::foo
2020-04-15 11:16:33 +03:00
Dmitriy Novozhilov
f7dc06a772 [FIR] Approximate integer constants in lhs of callable reference 2020-04-15 11:13:01 +03:00
Mikhail Bogdanov
b0e72f90f1 Android tests: add reflect flavor 2020-04-14 13:53:22 +02:00
simon.ogorodnik
356e42196c [FIR2IR] Fix inner class constructor receiver parameter type 2020-04-13 20:26:19 +03:00
simon.ogorodnik
0e21ac8ed2 [FIR] Apply BAD testData changes after type parameters support 2020-04-13 20:26:18 +03:00
Jinseong Jeon
c370b86141 IR: consolidate generation of synthetic members for data class 2020-04-13 17:30:05 +03:00
Alexander Udalov
7652117e3d Minor, ignore test on adapted function references for Android 2020-04-09 12:50:21 +02:00
Alexander Udalov
9f758b4f25 Support toString for AdaptedFunctionReference subclasses
Also make it serializable like other lambdas, suspend lambdas and normal
callable references.
2020-04-08 19:16:38 +02:00
Alexander Udalov
fa879e667f Add some tests on adapted references with varargs and reflection
Also rename "varargAndDefaults" test directory to "adaptedReferences"
2020-04-08 19:15:40 +02:00
Alexander Udalov
0681231e99 Introduce AdaptedFunctionReference runtime class
It's used as a superclass for anonymous classes for adapted function
references. Its main feature is that it _doesn't_ inherit from KFunction
(as opposed to FunctionReference), as per the decision to postpone
reflection support for adapted function references in KT-36024.

 #KT-36024 Fixed
2020-04-08 19:15:38 +02:00
Dmitry Petrov
d1c5a42124 KT-36024 Generate adapted callable references as lambdas
Make sure both JVM and JVM_IR use the same information to determine
whether a callable reference requires argument adaptation.
2020-04-08 19:02:33 +02:00
Dmitriy Novozhilov
8a2b39d647 [FIR] Add checking receivers of callable references 2020-04-08 10:38:45 +03:00
Alexander Udalov
774fc32f3e JVM IR: support optimized callable reference superclasses
See KT-27362.

 #KT-37334 Fixed
2020-04-03 15:37:56 +02:00
Mikhail Glukhikh
f374c36cd2 [FIR2IR] Generate property extension receiver references properly 2020-04-03 13:31:15 +03:00
Mikhail Glukhikh
f3f7bf70f6 [FIR] Set delegate field receiver properly 2020-04-03 13:29:55 +03:00
Jinseong Jeon
3e6b38a921 [FIR] Fix type reference for 1st arg of GetClassCall 2020-04-02 12:42:50 +03:00
Alexander Udalov
e44f12d7b0 Minor, unmute passing FIR black box tests 2020-04-01 19:33:45 +02:00
Alexander Udalov
3269a7e693 Change behavior of equals/hashCode on adapted function references
Function references are now equal if they refer to the same function,
and if the parameter/return type adaptation, which happens when a
reference is used where some function type is expected, is exactly the
same. This includes the number of expected positional parameters (which
can be affected by defaults/varargs), whether the coercion of vararg
parameter to Array type happened, and whether the coercion of return
type to Unit happened.

 #KT-37543 Fixed
2020-04-01 14:18:49 +02:00
Mikhail Glukhikh
a377a6fccb [FIR2IR] Handle references to constructors separately 2020-03-31 20:27:40 +03:00
Mikhail Glukhikh
282509b0da [FIR2IR] Provide object receivers for callable references 2020-03-31 20:27:24 +03:00