Commit Graph

8267 Commits

Author SHA1 Message Date
pyos 8cca74c932 JVM_IR: support vararg & defaults in function references 2019-06-20 22:37:56 +03:00
Roman Artemev 88e92be091 [IR] Fix name clash between properties with the same fqn
Promote ABI version
2019-06-20 12:08:55 +03:00
Roman Artemev 50ad21e388 [IR BE] Fix symbol remapping for IrField/IrProperty
- Use appropriate wrapped descriptor
 - Add test
2019-06-19 10:24:15 +03:00
Roman Artemev 008cf03b06 [IR] Consider TypeParameter as public declaration and serialize it properly
- Add test case when TypeParameter of generic property is exposed outside its module
2019-06-14 18:40:59 +03:00
Roman Artemev efaf5a9947 [IR] Fix serialization of ENUM_SPECIAL members 2019-06-14 18:40:59 +03:00
Alexander Gorshenev a816de4865 Added a test for members of EnumEntry in a library. 2019-06-14 17:12:39 +03:00
Steven Schäfer 27a850be92 Fix genValueAndPut in IrInlineCodegen 2019-06-13 12:25:06 +02:00
Steven Schäfer 917ef250cf Add and (un)mute inline class tests 2019-06-13 12:25:06 +02:00
Ting-Yuan Huang f07be024b7 JVM_IR: handle JvmDefault for bridges. 2019-06-12 07:43:45 +02:00
Alexander Udalov c67517cb2b JVM IR: use fast class reading mode in boxAgainstJava tests
annotationsViaActualTypeAliasFromBinary.kt is ignored because
ExpectActualRemover can't find actual for the expected constructor of
Anno now, because `ExpectedActualResolver.findActualForExpected`
incorrectly filters out actual declarations without any source file, and
Java classes loaded in the fast mode don't have any source files.

This will need to be fixed separately, probably by making
ExpectedActualResolver look for the actual class of an expected class
member first (with source file-based filtering), and then
unconditionally locating the corresponding member there
2019-06-11 15:26:07 +02:00
Vasily Levchenko e3d2419beb [tests][codegen][coroutines] disable test simpleSuspendCallableReference for NATIVE too. 2019-06-11 12:07:58 +03:00
Mikhail Zarechenskiy 991e60c9e4 Add tests for obsolete issues
#KT-31784 Obsolete
 #KT-31757 Obsolete
2019-06-10 17:37:52 +03:00
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