Commit Graph

3755 Commits

Author SHA1 Message Date
Alexander Udalov bbbd47ead3 Minor, rename codegen test 2019-06-07 15:01:44 +02:00
Ting-Yuan Huang a447c748bc JVM_IR: support @JvmDefaults in compatibility mode. 2019-06-06 14:10:28 +02:00
Alexander Udalov 43cb17cdd5 Check expected type of annotation parameter correctly in AnnotationDeserializer
The main idea of this refactoring is to separate two usages of
`AnnotationDeserializer.resolveValue`: the one where we load annotation
argument values, and the one where we load constant values of properties
for JS/Native/Common
(`AnnotationAndConstantLoaderImpl.loadPropertyConstant`).

In the latter case, `expectedType` is the type of the property and it
can be a supertype of the actual value (e.g. see `arrayConst` in
compiler/testData/serialization/builtinsSerializer/compileTimeConstants.kt).
But in the former case, we need to check that the value conforms to the
expected type and disregard it if it's not the case, which is possible
if the annotation was recompiled separately.

 #KT-28927
2019-06-05 14:44:15 +02:00
Alexander Udalov c666b60ca3 Support arrays of class literals in AnnotationDeserializer
#KT-28927 Fixed
2019-06-05 14:44:14 +02:00
Ting-Yuan Huang 1b4d26e490 psi2ir: keep the type of when when possible
Ideally, the type of `IrWhen` should be provided by type inference for
a consistent behavior. `USED_AS_EXPRESSION` from CFG isn't always
consistent with type inference, unfortunately.

The behavior is now aligned with `if`. The type of `when` is kept when
it *can* be an expression, instead of whether it is used or not.
2019-06-05 10:23:44 +02:00
Mads Ager 0c586ef5c1 JVM_IR: Maintain annotations in SAM conversion.
Copy method and parameter annotations to the generated SAM
implementation method.
2019-06-05 08:21:59 +02:00
Mikhael Bogdanov 81e6416bfe Support bound callable reference inlining in IR 2019-06-04 14:56:13 +02:00
Mikhael Bogdanov 3c093f321d Support unbound callable function references in inliner 2019-06-04 14:56:12 +02:00
Roman 0163019295 [JVM IR] Unmute fixed test 2019-05-31 18:49:54 +03:00
Mikhail Zarechenskiy 268dddcb3d Remove restriction about JS_IR backend for test 2019-05-31 17:23:58 +03:00
Alexander Udalov 4c9e9b1f3a Fix KotlinReflectionInternalError on encountering 'clone' in a class
`RuntimeTypeMapper.mapSignature` threw exception because the descriptor
for `clone` was created manually in CloneableClassScope and therefore it
didn't have a JVM signature as in deserialized descriptors, and wasn't
recognized as a Java method either.

 #KT-22923 Fixed
2019-05-31 12:29:20 +02:00
Roman Artemev beb1ce55f8 [IR BE] Fix capturing of var-locals inside class/field initializers 2019-05-31 13:14:43 +03:00
Roman Artemev 5686de7e09 [JS IR BE] Make kotlinx.io compile
- Fix expect/actual default arguments
 - Fix dynamic type in inliner
 - Fix external varargs
2019-05-31 13:14:43 +03:00
Mikhael Bogdanov 79d855f7a4 Minor. Revert deleted by mistake test directive 2019-05-31 07:09:28 +02:00
Ting-Yuan Huang 74e8c7c1c5 JVM_IR: generate default constructor
Quoted from https://kotlinlang.org/docs/reference/classes.html

"On the JVM, if all of the parameters of the primary constructor have
 default values, the compiler will generate an additional parameterless
 constructor which will use the default values. This makes it easier to
 use Kotlin with libraries such as Jackson or JPA that create class
 instances through parameterless constructors."
2019-05-30 18:53:27 +02:00
Mikhail Zarechenskiy 0bc4022242 Revert "Temporary remove failing test for new inference about SAM conversions"
This reverts commit 5bcd974944.

 Fixed in 7c4101e2

 #KT-29561 Obsolete
2019-05-30 16:45:31 +03:00
Alexander Udalov e72388895b JVM IR: invoke codegen after lowering all files in the module
Inspired by discussion in #2316
2019-05-30 13:28:31 +02:00
Dmitriy Novozhilov bcbbf4aba3 [NI] Fix replacing original in PropertyDescriptor 2019-05-30 11:01:10 +03:00
Mads Ager dc5f4ab240 Add annotation to static methods on DefaultImpls. 2019-05-29 15:37:09 +02:00
Anton Bannykh dad334ffcd JS IR: ignore the new suspend callable reference test 2019-05-29 10:17:15 +03:00
Ilya Gorbunov fe9bd9ee20 Fix method reference ambiguity in test after introducing 'capitalize' overload 2019-05-29 06:49:05 +03:00
Mikhail Zarechenskiy f702417655 [NI] Relax rules for call completion: require at least one constraint
It's enough to have at least one good constraint.

 Note that the whole algorithm can be a bit more general:
 we could check also Out<T>, In<T> and verify that T has good only
 lower constraint or upper constraint, but there are questions for
 types like Inv<Out<T>>, where T should have lower and upper constraints

 #KT-31514 Fixed
2019-05-29 02:14:00 +03:00
Anton Bannykh 052ddd60ce JS: support callable references on suspend functions (KT-30987 fixed) 2019-05-28 19:13:08 +03:00
Alexander Udalov f9d61f2dc7 Make inline+reified functions synthetic instead of private in bytecode
#KT-18563 Fixed
2019-05-28 16:17:49 +02:00
Alexander Udalov b42adcd73d Restructure bytecode listing tests on InlineOnly/inline+reified 2019-05-28 15:56:15 +02:00
Ilmir Usmanov 5631306165 Wrap result method node with max stack calculator in inliner
#KT-31347 Fixed
2019-05-28 16:37:45 +03:00
Jiaxiang Chen d3cc0e6ce9 JVM_IR: Optimize disjunction condition with intrinsic function call. 2019-05-28 08:48:43 +02:00
pyos 6d19eb1853 JVM_IR: sidestep defective getMethodAsmFlags when inlining lambdas
It uses isStaticMethod to determine whether to set ACC_STATIC, which is
not correct (see PR #2341). This results in using incorrectly typed
opcodes (as all arguments are shifted by 1) when modifying the inlined
lambda's bytecode. For example, in the test added by this commit, these
opcodes are inserted to spill the stack into locals before calling
another inline function.

Because getMethodAsmFlags is used by the non-IR backend (see PR #2341
again for why changing stuff might not be a good idea), the proposed
solution is to ditch it completely and override generateLambdaBody in
IrExpressionLambdaImpl to use FunctionCodegen's IR-based flag
computation logic.
2019-05-28 08:38:16 +02:00
Mikhail Zarechenskiy bbec3bf001 Fix exception on star import from typealias
#KT-30983 Fixed
2019-05-26 21:32:07 +03:00
pyos 4cd4ea126b JVM_IR: generate more accessors for use in inline functions 2019-05-24 11:27:19 +02:00
pyos cf74b5e87b Mark callable reference classes as synthetic 2019-05-24 11:27:19 +02:00
pyos e7dd41743f Prefix captured variables' names with $ 2019-05-24 11:27:19 +02:00
Ting-Yuan Huang bdcd6f73b1 Move tailrecPhase before defaultArgumentStubPhase
So that default values can be copied to the recursive call sites.
2019-05-24 09:51:07 +02:00
Ting-Yuan Huang 0aee2d0568 Fix signature generation for calls to enum and inner class constructors
The synthesized arguments caused the size of default value mask off by
one when it is close to the boundary of Int.SIZE, which in turn
resulted in wrong signature at call sites.
2019-05-23 12:29:57 +02:00
Roman Artemev 72f7287ad2 [IR BE] Fix array constructor loop. Use index parameter as immutable value 2019-05-22 15:18:13 +03:00
Roman Artemev dfa38f4a4d [JS IR BE] Fix state machine generation in case of composition of loops, inline functions and finally blocks
* lower finally blocks in any cases
 * do not optimize exit blocks for if-statements
2019-05-22 15:18:13 +03:00
Roman Artemev 9c7d47789c [JS IR BE] Implement type check for SuspendFunctionN 2019-05-22 15:18:13 +03:00
Ilmir Usmanov effbcdaf70 Do not generate $$forInline suffix for enclosing method
in OUTERCLASS field.

The inliner generates two versions of suspend functions/lambdas in
inline functions: with state-machine and without. The former is used
to call the function from Java or via reflection and have ordinary
name, while the latter is used by inliner and have $$forInline suffix.
The inliner throws the state-machine version away, duplicates
$$forInline version and then call state-machine generator.

If these suspend functions/lambdas are not going to be inlined,
$$forInline version is not generated. However, all objects, which are
used in these suspend functions/lambdas, have $$forInline version
written to OUTERCLASS field. This leads to errors by proguard.
Since they are used in both state-machine version and for-inline ones,
we can simply remove $$forInline suffix from OUTERCLASS field and this
fixes the issue.

 #KT-31242 Fixed
2019-05-21 21:09:36 +03:00
Svyatoslav Kuzmich 59617c97b4 [JS IR BE] Fix VarargLowering
- Enable empty vararg transformation for all IrFunctionAccessExpression
- Fix empty vararg boxing
- Refactor inline class boxing logic
- Fix types of generated expressions
2019-05-21 19:19:31 +03:00
Ilya Gorbunov 0a3ebb5780 Unmute tests for JVM_IR that pass after making assertFailsWith inline 2019-05-21 18:53:53 +03:00
pyos 6b2d874ccc JVM_IR: generate non-null assertions for arguments 2019-05-21 18:30:27 +03:00
Ilmir Usmanov 266976ac1e Fix Java interop of inline suspend functions with suspend parameters
In 1.3.31 I fixed Java interop for inline function with coroutines
(TL;DR: when we need a state machine, generate two methods: one with
normal name, and the other one with $$forInline suffix, for the inliner
to use, just like inline suspend functions), however, I forgot a case
with inline suspend function with inline suspend function parameter.
In this case, the compiler a generated two functions, as needed, but,
neither of them had a state-machine. This change adds the state-machine
for the method with normal name. Note, that suspend inline functions
with crossinline parameter, which are also supported by the change,
did not cause incorrect behaviour, since until now they were generated
as synthetic.

 #KT-31354 Fixed
2019-05-21 17:50:25 +03:00
Jiaxiang Chen afcbd76c9e Implement stub methods generation for Kotlin Immutable Collection classes.
This change is to fill the gap between Kotlin Collection
classes(immutable) and Java Collection classes(mutable), to avoid
calling an unsupported operation like remove() on an immutable class in
jvm.
2019-05-21 17:20:20 +03:00
Mikhael Bogdanov 007af75e1e Properly calculate call site file in JVM IR inliner 2019-05-21 07:42:16 +02:00
Ting-Yuan Huang 75646f97a4 MoveCompanionObjectFields: copy constants into interfaces
Fields having const attribute in companion objects are observable in
Java and should be copied to outer interfaces.
2019-05-20 08:43:00 +02:00
Roman Artemev 77c0e591af Set correct target backend 2019-05-16 19:27:41 +03:00
Roman Artemev c352117eab [JS IR BE] Set correct runtime for JS IR BE tests 2019-05-16 19:27:41 +03:00
Roman Artemev fabd306437 [JS IR BE] Fix varargs for inline arrays 2019-05-16 19:27:41 +03:00
Roman Artemev 600ad7e088 [JS IR BE] Fix KProperty access in case of both receivers 2019-05-16 19:27:41 +03:00
Mads Ager 34cf5a19df JVM_IR: Support @JvmSynthetic annotations. 2019-05-16 17:07:22 +03:00