Commit Graph

3991 Commits

Author SHA1 Message Date
Roman Artemev 78b29349c9 Fix lateinit isInitialized check in multi-file case 2019-10-31 14:45:15 +03:00
Mikhail Zarechenskiy ca8da22569 [NI] Improve CST algorithm to handle non-fixed variables
#KT-32456 Fixed
 #KT-32423 Fixed
 #KT-32818 Fixed
 #KT-33197 Fixed
2019-10-31 11:32:00 +03:00
Dmitry Petrov 2ff36c808e Minor: mute testEa35963 in WASM 2019-10-31 11:13:45 +03:00
Steven Schäfer b1b70e503c JVM IR: Improve codegen for try/catch statements 2019-10-31 11:13:44 +03:00
Steven Schäfer 0da4b06074 psi2ir: Fix return insertion
We should only insert a return statement at the end of a lambda or
function if the final statement is used as an expression (slice
USED_AS_RESULT_OF_LAMBDA and USED_AS_EXPRESSION).
2019-10-31 11:13:44 +03:00
pyos a835f07d51 JVM_IR: don't regenerate objects in lambdas inlined into objects 2019-10-31 09:09:54 +01:00
Kristoffer Andersen 1074a0ef69 JVM_IR: Fix Inline CallableReferences with Varargs
- Added tests to demonstrate broken behaviour: the interaction of inline
  functions and callable references with varargs and defaults in various
  combinations.
- Refactored InlineCallableReferencesToLambdaPhase to look like and use
  some of the infrastructure from CallableReferenceLowering.
- Lifted some of this infrastructure out to be broadly reusable.
2019-10-31 08:15:22 +01:00
Mads Ager 1713625718 JVM: Improve line number handling for suspend calls.
Take branching and method calls into account when finding the line
number of the continuation. If there is no line number before
branching instructions or method calls, the following code is
still on the line of the suspend call itself.

This fixes a couple of issues with incorrect line numbers for
multiple throws on the same line or multipe suspend calls on
the same line.

In addition, it avoids the need to spam the method node with
repeated line number instructions in the IR backend.
2019-10-30 13:40:21 +03:00
Georgy Bronnikov cd78e6ec50 JVM_IR: handle property references in SAM conversions 2019-10-29 18:38:59 +03:00
Alexander Udalov 896512f7cd Support KClass.isInstance/cast/safeCast in stdlib-only reflection implementation
#KT-14720 Fixed
2019-10-29 15:52:00 +01:00
Alexander Udalov 5c89f2fa54 Support KClass.qualifiedName in stdlib-only reflection implementation
#KT-34586 Fixed
2019-10-29 15:51:25 +01:00
Alexander Udalov c164745301 Support KClass.simpleName in stdlib-only reflection implementation
#KT-33646 Fixed
2019-10-29 15:51:21 +01:00
Alexander Udalov 8e4c7ad65d Merge pull request #2727 from pyos/fix-synthetic-accessors-v101
JVM_IR: add accessors for protected members in divergent hierarchies
2019-10-29 11:10:58 +01:00
Mikhael Bogdanov 63b115abb6 Workaround for KT-34656: temporary disable assertion 2019-10-29 09:48:49 +01:00
Mark Punzalan de333c18fc JVM_IR: Enable loopVarInterval and forInReversedCollectionIndices
bytecode text tests.
2019-10-29 07:43:37 +01:00
Mark Punzalan b4d2eae12d Add test data generator for stepped progression box tests. 2019-10-28 15:26:38 +01:00
Mark Punzalan 1738c2d4f6 Invoke GenerateInRangeExpressionTestData and
GeneratePrimitiveVsObjectEqualityTestData during
:compiler:generateTests.
2019-10-28 15:26:38 +01:00
Mark Punzalan 9bb9ab67a7 Add bytecode text tests for ForLoopsLowering. 2019-10-28 15:26:38 +01:00
Mark Punzalan 277cb39e3b Add new tests for step progressions and fix existing tests. 2019-10-28 15:26:38 +01:00
Igor Chevdar f413da3e58 Turned off test for native
It fixes current JVM BE behavior but seems like this should've been a FE error.
2019-10-28 12:38:19 +03:00
Georgy Bronnikov b63f9176a3 JVM_IR: repair overriddenSymbols in InterfaceDelegationLowering
When creating delegation redirectors for default implementations of
interface functions, `overriddenSymbols` should be repaired across the
whole module, not just a particular file.
2019-10-28 12:12:32 +03:00
Mads Ager 88dd8f663c JVM_IR: Do not generate null checks for suspend function views.
The arguments are null whenever the suspend function is resumed
and takes its state from the continuation parameter.
2019-10-27 07:37:15 +03:00
Alexander Udalov dac0fc7397 Remove obsolete assertion in ExpressionCodegen
With the mangling added in 488418d960, there's no longer any risk in
writing "special" function name ("<anonymous>" in this case) to the
local variable table.

 #KT-34356 Fixed
2019-10-25 19:31:20 +02:00
Mads Ager 52febbcc07 [JVM_IR] Support default interface suspend functions.
Do this by reordering the lowerings so that the lowering that
adds continuations happen after default methods have been
eliminated if needed.

Mark more functions as known to be tail-calls: bridges and
delegated members.

Preserve source info and annotations when creating replacement
functions.
2019-10-24 18:51:41 +03:00
Kristoffer Andersen 8af3b3e51e [Backend] Reorganize version 1.0 codegen tests
- Extract all backend codegen tests that specifically target behaviour
  in to-be-deprecated functionality from language versions < 1.3"
- Remove those tests from the JVM IR test suite.
2019-10-24 16:51:19 +02:00
pyos 75aef4633a JVM_IR: add accessors for protected members in divergent hierarchies
Class B : A cannot access a protected field of A through a reference to
an instance of C : A.
2019-10-24 12:46:48 +02:00
pyos 55acc296a2 JVM_IR: never create temporaries in $default stubs
Given the strict pattern-matching in the inliner, this is the only way
to make it not crash when attempting to inline these stubs. Note that
the IR backend does not currently use the inliner's default method stub
handling; the crash only occurs when a module compiled with the non-IR
JVM backend is attempting to call an inline function with default
arguments defined in a module that was compiled with the IR backend.
2019-10-23 11:11:16 +02:00
Alexander Udalov 95be7171bc JVM IR: fix "null" as the first entry in MappedEnumWhenLowering
If "null" was the first entry in an optimizable "when" over enum,
mapRuntimeEnumEntry was called before mapConstEnumEntry, and the
$WhenMappings field was not created. Now both mapConstEnumEntry and
mapRuntimeEnumEntry create this field on the first access
2019-10-23 11:03:22 +02:00
pyos 8c6916af52 JVM_IR inliner fixes: remove code that does nothing
other than randomly throw assertion errors on inline calls in synthetic
functions, which have no line number attached.

`lazySourceMapper.callSiteMarker` is set in `InlineCodegen.inlineCall`;
`IrSourceCompilerForInline.doCreateMethodNodeFromSource` does not need
to touch it.
2019-10-22 19:29:42 +03:00
Mads Ager 8b97819c04 [JVM_IR] Support suspend functions that can be overriden.
The challenge for overridable suspend functions is that the calling
the state machine method to resume after suspension would be
virtually dispatced to the wrong method. To avoid that a static
suspend implementation method is generated which becomes the
state machine method used to resume.
2019-10-22 12:48:21 +03:00
Dmitry Petrov 7dde503697 KT-34500 Use correct loop parameter type in ForInArrayLoopGenerator 2019-10-22 12:23:59 +03:00
pyos 847e287bd6 JVM_IR: add $assertionsDisabled when an inlined function uses it
NOTE: jvmCrossinlineLambdaDeclarationSite.kt is muted because the
inliner does not remap references to an anonymous object's parent
class after regenerating it. Unlike the JVM backend, JVM_IR uses the
top level named class' assertion status for all inner classes. (The
test used to pass because the lambda in `inline fun call` read the
`$assertionsDisabled` field of `CrossinlineLambdaContainer`, which
was not reloaded after changing the assertion status of package `test`.)
2019-10-21 21:05:18 +03:00
Roman Artemev 2cde7f2402 [KLIB] Fix explicitlyExported mode
- Refactor deserialization pipeline
 - Fix K/N test
2019-10-21 17:41:56 +03:00
Roman Artemev 43e855150c [KLIB] Correctly restore top level property order during deserialization - Add test - Fix KT-34273 2019-10-21 17:41:56 +03:00
Denis Zharkov d902a5f304 Temporary disable assertion in bridges generation
^KT-34431 Fixed
^KT-34507 Open
2019-10-21 17:24:15 +03:00
Kristoffer Andersen 28b6913a25 JVM IR: Support parameterless main methods
This commit:

- introduces tests explicating what is and isn't considered a
  proper main method on the JVM backends.
- implements support for parameterless main methods on the JVM IR
  backend
- See KT-34338 for more tests.
2019-10-21 15:08:34 +02:00
Mads Ager 4b77db8979 Fix test to actually fail if expected exception is not thrown. 2019-10-21 15:05:32 +02:00
pyos 0c3dfca6ee JVM_IR: remove an assertion that triggers due to a frontend bug 2019-10-21 14:59:03 +02:00
Mads Ager 8be6a1fe8a [JVM_IR] Contain 'invokeSuspend' rewriting to the suspend function.
Do not rewrite returns in methods in nested lambda implementations.
That leads to unintended non-local returns from nested non-suspend
lambdas.
2019-10-21 13:16:57 +03:00
Ilmir Usmanov 78b9c082e7 JVM_IR: Generate 'create' for suspend lambdas with one parameter 2019-10-21 13:15:45 +03:00
Ilmir Usmanov 5eeb2958f7 JVM_IR: Support is/as SuspendFunction operators 2019-10-21 13:15:43 +03:00
Ilmir Usmanov 6f47699796 JVM_IR: Calculate correct arity of callable reference to suspend
function
2019-10-21 13:15:41 +03:00
Ilmir Usmanov b0a0399dd0 JVM_IR: Support callable references to suspend functions 2019-10-21 13:15:39 +03:00
Ilmir Usmanov e736b782dd JVM_IR: Support suspend lambdas with multiple parameters 2019-10-21 13:15:37 +03:00
Ilmir Usmanov f4a7c839d3 JVM_IR: Generate as much LINENUMBER information as possible inside
suspend functions and lambdas.

Otherwise, when state-machine builder splits instructions and adds
LINENUMBER between states, the information becomes corrupted.
2019-10-21 13:15:35 +03:00
Steven Schäfer eb744cc9e1 JVM IR: Fix constant folding for unsigned toString 2019-10-18 17:24:53 +02:00
Steven Schäfer c905209504 JVM IR: Lower IrStringConcatenation 2019-10-18 17:24:53 +02:00
Steven Schäfer c2de89cb8c Minor: Make String.valueOf bytecode tests more precise 2019-10-18 17:24:12 +02:00
Steven Schäfer 64aa50a921 Add more tests for SAM wrappers 2019-10-18 17:22:58 +02:00
Steven Schäfer f2e0c1a930 JVM IR: Minor fix for nullable SAM wrappers 2019-10-18 17:22:58 +02:00