Commit Graph

8267 Commits

Author SHA1 Message Date
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
Steven Schäfer 3098723406 Minor: Fix outdated test 2019-10-18 17:20:22 +02:00
Steven Schäfer 21af7dfbe1 Add tests for constructors taking inline class arguments 2019-10-18 17:20:22 +02:00
Steven Schäfer 9389d88232 JVM IR: Hide constructors with inline class parameters 2019-10-18 17:20:22 +02:00
pyos d1f25d1c26 JVM_IR: discard results of nonexhaustive whens' branches 2019-10-17 15:41:42 +02:00
Mikhael Bogdanov c78dbaf6b3 Initializer default values in 'tailrec' method in proper order
#KT-31540 Fixed
2019-10-17 13:06:36 +02:00
pyos 27094d0371 JVM_IR: fix synthetic accessor generation (again)
Turns out private inline functions *can* be called from other classes.
2019-10-17 12:38:19 +02:00
Steven Schäfer 4878c7967a JVM: Handle inline class equality in when statement with declaration
#KT-34268 Fixed
2019-10-16 19:23:49 +02:00
Mads Ager 8305baa5fe [JVM_IR] Avoid unbounded recursion for recursive suspend functions.
Additionally, deal with primitive types in AddContinuationLowering.
2019-10-16 13:50:52 +03:00
Georgy Bronnikov ed6ca7d67e JVM_IR: fix for SingletonReferencesLowering
When replacing an enum entry reference with `this`, you need to take
`this` from the function's `dispatchReceiverParameter`, not the class's
`thisReceiver`. Otherwise the code generator fails to find the reference
among accessible variables.
2019-10-16 13:19:40 +03:00
Georgy Bronnikov f3cae210f8 JVM_IR: handle type parameters in constructors for @JvmOverloads stubs 2019-10-15 14:55:18 +03:00
pyos d3992826e4 JVM_IR: discard parameter annotations in anonymous object constructors 2019-10-14 14:54:44 +02:00
pyos bc4be53569 JVM: generate $assertionsDisabled before inlining the node
This fixes the problem where compiling a class initializer that contains
a call to an `assert`ing function in a separate module causes the
assertion to always be enabled (i.e. the attached test used to fail in
CompileKotlinAgainstInlineKotlin mode).
2019-10-11 14:54:52 +03:00
Georgy Bronnikov 1abdcf3f57 JVM_IR: support function references with default parameters 2019-10-11 13:30:30 +03:00
pyos 301e3d27fd JVM_IR: "fix" reified type parameter scope check
where "fix" means "work around a bug that is much harder to fix". When
lambdas are extracted into the nearest class, captured type parameters
are not transformed into type parameters of the new method; because of
this, to check whether a reified type parameter is captured by a method
we need to check the outermost named function, not the current function.
2019-10-10 14:54:13 +02:00
Georgy Bronnikov c70b2e3e4b JVM_IR: specify correct type for defaultConstructorMarker arguments 2019-10-10 14:07:43 +03:00
Mads Ager 92cf521e11 [IR] Deal with forward references in default argument lambdas.
Rely on the frontend weeding out cases that are not supported.

In psi2ir, introduce all the parameters before processing default
values.

Change the DefaultArgumentStubGenerator to generate code that
matches the behavior of the current backend.
2019-10-10 09:00:51 +02:00
Pavel Kirpichenkov 42740c8b97 Fix capturing of outer type parameters for classes declared inside init block 2019-10-09 16:01:46 +03:00
Kristoffer Andersen cc6252098f Add a test to reveal flaw in call delegation with default implementations in interfaces. 2019-10-09 13:03:21 +02:00
Mads Ager f9d117970a [JVM_IR] Map suspend lambdas to original function for inlining. 2019-10-08 19:21:37 +03:00
pyos b6a1154672 Add a test for non-null assertions in local classes/functions 2019-10-08 17:19:41 +02:00
pyos 06c00f4d9e Unmute some JVM_IR inlining tests 2019-10-08 17:19:41 +02:00
pyos cea69e0706 JVM_IR: do not generate redundant load+stores before inline calls 2019-10-08 17:19:41 +02:00
pyos 07bde889b4 JVM_IR: generate more correct names for regenerated objects
and fake lambda types, too. (But those only matter for debugging.)

Also, share object name generators between methods with the same name to
avoid rewriting objects from one with objects from the other.
2019-10-08 17:19:41 +02:00
pyos 432ba62143 JVM_IR: omit annotations on outer this parameters 2019-10-08 14:41:05 +02:00