Commit Graph

90 Commits

Author SHA1 Message Date
pyos cd47c11efd Generate unique parameter names in LocalDeclarationsLowering 2019-10-07 15:14:48 +02:00
Ilmir Usmanov f1d31c8221 JVM_IR: Minor. Unmute tests
Rename FAKE_CONTINUATION -> fakeContinuation
2019-09-19 19:28:11 +03:00
Steven Schäfer efb938a7c8 (Un)mute tests 2019-07-31 11:18:44 +02:00
Mikhael Bogdanov 74e49d91ca Proper implement 'classForImplicitThis' 2019-07-22 10:35:03 +02:00
Mark Punzalan 1abdf0561a Generate synthetic functions for local functions with default values, by
re-ordering the lowering phases.

The changes in InterfaceLowering are necessary so that IrElements that
target the removed functions are re-targeted to the new functions in
DefaultImpls. This affects local functions in interface functions since
now LocalDeclarationsLowering comes before InterfaceLowering.
2019-07-01 13:24:08 +02:00
Roman 0163019295 [JVM IR] Unmute fixed test 2019-05-31 18:49:54 +03:00
pyos e7dd41743f Prefix captured variables' names with $ 2019-05-24 11:27:19 +02:00
Ting-Yuan Huang 1c3b895fc0 Generate accessors for super calls if necessary
Current implementation of calls with super qualifier relies on
invokespecial, which has some more constraints than regular virtual
invocations. When those constraints aren't met, accessors are needed.
2019-05-10 08:57:37 +02:00
pyos ef5e02da84 JVM_IR: handle Nothing and Unit more consistently.
* In blocks, discard the result of any statement that has a return
   type other than void. This was previously done by wrapping each
   statement into an "implicit Unit conversion" that was actually
   compiled down to a stack pop instead. If an expression happened to
   already have type Unit, however, such a conversion was not inserted,
   resulting in a stray reference on the stack. These conversions are
   now redundant and should probably be removed.

 * In assignments and non-exhaustive conditionals, materialize a Unit
   on the stack to avoid depth mismatches that trip up the bytecode
   validator. Because such expressions are generally used at block level
   (and, indeed, the frontend will reject a non-exhaustive conditional
   used as an expression), combined with the above change this results
   in no additional GETSTATIC opcodes, as they are immediately removed
   by the peephole optimizer.
2019-03-26 13:32:02 +01:00
pyos ed298c48b7 Unmute a test fixed by a combination of PR #2151 and #2184 2019-03-19 12:00:29 +01:00
pyos 82ccf81da8 Fix this remapping in inner class constructors
Inner class constructors should use the argument instead of reading
outer `this` from a field because if such an access happens before a
delegating constructor call, e.g. when evaluating an argument, a JVM
bytecode validation error will be thrown. (The only operation on `this`
allowed before a delegating constructor call is SETFIELD, and only if
the field in question is declared in the same class.)
2019-03-19 09:20:41 +01:00
Mikhael Bogdanov 9ab6062295 Properly capture extension receiver for array convention expressions in object constructor
#KT-19389 Fixed
2019-02-05 16:14:50 +01:00
Svyatoslav Kuzmich aa811dcfb3 [JS IR BE] Add KJS_WITH_FULL_RUNTIME directive to compiler tests 2019-01-24 16:14:40 +03:00
Georgy Bronnikov c3352d5fdb Unmute several tests, mute one 2019-01-17 23:46:26 +03:00
Georgy Bronnikov da0a823992 Remove descriptors from LocalDeclarationslowering 2019-01-17 23:46:26 +03:00
Mikhael Bogdanov 3ef06c1e44 Specify JVM target backend for test with 'import java...' 2018-12-21 16:09:06 +01:00
Mikhael Bogdanov f36519d4f5 Specify JVM target backend for test with '.javaClass' usage 2018-12-21 16:09:05 +01:00
Roman Artemev 7f215d3f52 Update tests 2018-11-01 16:51:38 +03:00
Roman Artemev fb709cae92 [JS IR BE] Fix private field names 2018-11-01 16:18:44 +03:00
romanart d77a0f109b Update tests 2018-10-09 15:33:04 +03:00
Anton Bannykh 2e709a81fa [JS IR BE] Arrays, varargs 2018-09-18 14:36:20 +03:00
Svyatoslav Kuzmich ad58fdd158 [JS IR BE] Unmute tests after adding stdlib 2018-09-04 20:19:04 +03:00
Roman Artemev 0eba87b571 [JS IR BE] Mute temporary broken tests 2018-09-04 12:43:39 +03:00
Roman Artemev 8a871b3f0c Update tests 2018-08-31 15:34:18 +03:00
Roman Artemev d1621b80cc Fake wrapped descriptors first working draft
get rid of descriptors in Bridge and Enum lowerings
Replace property accessors function type with IrSimpleFunction because they couldn't be constructors
get rid of descriptors in Callable reference lowering
refactored descriptor factory and inner class lowering
Add isReified property to IrTypeParameter declaration
keep getting rid of descriptors
Get rid of descriptors in Shared Variable Manager
LocalDeclarationLowering also uses no descriptors
Fix psi2ir
Fix nested classes names
Fix outer reference in inner classes
Fix name generator
get rid of descriptors in coroutines - something is working
Fix name generator
Fix unbound symbols in JVM BE
Rename DeclarationFactory members
2018-08-31 15:34:18 +03:00
Svyatoslav Kuzmich 392ad521fd [JS IR BE] Reflection support 2018-08-15 13:35:14 +03:00
Mikhael Bogdanov a7d706f693 Unmute jvm ir-tests 2018-08-09 16:30:32 +03:00
Mikhael Bogdanov bbc5fa4705 Perform InnerClassLowerings after CallableReferenceLowering 2018-08-09 14:22:51 +03:00
Mikhael Bogdanov 357359b1dd Unmute ir-tests after CR support 2018-08-09 14:22:50 +03:00
Mikhael Bogdanov 06b16a6459 Unmute ir-tests after prev commit 2018-08-09 14:22:46 +03:00
Roman Artemev efec82c0eb Update test data
* add new tests for coroutines
 * add copy of some tests without dependency on stdlib
2018-08-08 18:33:41 +03:00
Mikhael Bogdanov 2884d728fd Mute/unmute jvm_ir tests 2018-08-01 12:29:24 +02:00
Svyatoslav Kuzmich 625983b28a [JS IR BE] Enum class lowering 2018-07-23 15:08:18 +03:00
Svyatoslav Kuzmich 77ad97a39e [JS IR BE] Bridges construction 2018-07-10 14:11:09 +03:00
Anton Bannykh 07b3b66fd9 JS IR: unmute tests 2018-07-10 13:34:19 +03:00
Denis Zharkov 0b3048f60a Replace trivial usages of suspendCoroutineOrReturn in tests
This is necessary since suspendCoroutineOrReturn gets removed in 1.3
2018-07-09 15:27:19 +03:00
Mikhael Bogdanov be40127ab3 Mute coroutines ir-tests in jvm 2018-07-04 15:33:41 +02:00
Dmitry Petrov 92430fc63a Update testData for JS_IR tests 2018-06-29 14:23:09 +03:00
Mikhael Bogdanov e149cbe852 Mute failed jvm ir tests 2018-06-28 12:26:41 +02:00
Anton Bannykh 5fdc304a51 JS_IR: mute coroutine tests 2018-06-09 19:15:38 +03:00
Anton Bannykh 96355e2732 JS IR: mute codegen box tests automatically 2018-06-09 19:15:38 +03:00
Ilmir Usmanov f60787d57c Move coroutines to kotlin.coroutines package: tests
Introduce COMMON_COROUTINES_TEST directive.
Every test with this directive is run twice: one time with
language version 1.2 and kotlin.coroutines.experimental package
and the other time with language version 1.3 and kotlin.coroutines
package. Each run is a separate method: with suffixes _1_2 and _1_3
respectively.
However, since codegen of release coroutines is not supported in JS
backend, we generate only one method: with suffix _1_2.
 #KT-23362
2018-04-23 21:51:59 +03:00
Mikhail Zarechenskiy 397cc4f772 [NI] Support implicit invoke calls on parenthesized receivers 2018-04-20 13:06:21 +03:00
Alexey Andreev 6ab87ad66a Fix failing JS tests 2017-11-27 17:01:15 +03:00
Dmitry Petrov 4365084645 Lookup for local variables taking into account uninitialized this
Consider a context with uninitialized this, e.g.:

  fun foo() {
    val x = "..."
    class Local(y: String) : Base(L@{ x + y })
  }

Lambda 'L' is an argument of a super class constructor call.
Here 'this@Local' is not initialized yet. Thus local variables captured
in 'Local' can't be used. Instead, they should be captured by lambda 'L'
itself.

Note that lambda 'L' sees both 'x' and 'y' as local variables that
should be captured.

When in context with uninitialized this (generating arguments for super
type constructor or delegating constructor call), and a variable in
question is not found in the current context, use enclosing local lookup
to determine whether a local variable should be captured by a closure.
2017-11-14 09:33:28 +03:00
Dmitry Petrov bbb0389c51 Fix determining enclosing class for closure
Enclosing class for closure is a class whose instance is captured by
closure as an outer 'this', and stored in a field 'this$0'.
Usually enclosing class for closure is an immediate outer class,
including classes for nested closures. For example:

  class C {
    fun foo() {}
    val example1 = L1@ { foo() }
    // Enclosing class for lambda 'L1' is 'C'
    val example2 = L2a@ { L2b@ { foo() } }
    // Enclosing class for nested lambda 'L2b'
    // is a closure class for outer lambda 'L2a'
  }

However, if the closure is created in a super type constructor call for
the outer class, corresponding instance is considered "uninitialized",
and can't be used as a proper class instance, and can't be referenced:
corresponding code is rejected by front-end.

  class Outer {
    fun foo() {}
    inner class Inner : Base(L3@ { foo() })
    // Enclosing class for lambda 'L3' is 'Outer',
    // because 'Inner' is uninitialized in super type constructor call.
  }

In CodegenAnnotatingVisitor, we maintain a stack of currently
uninitialized classes, and chose enclosing class for closure
as an inner-most surrounding class with initialized instance.

When generating code for this or outer class instance, we skip
contexts corresponding to classes with uninitialized instances.

This fixes a number of bytecode verification errors caused by incorrect
enclosing class for closure.

 #KT-4174 Fixed Target versions 1.2.20
 #KT-13454 Fixed Target versions 1.2.20
 #KT-14148 Fixed Target versions 1.2.20
2017-11-14 09:33:28 +03:00
Denis Zharkov d92c403f9e Move helpers for coroutine tests in separate package
It will help to skip their content when rendering bytecode listing
for box tests
2017-05-05 14:01:50 +03:00
Mikhael Bogdanov b9409523b0 Fix for KT-17588: Compiler error while optimizer tries to get rid of captured variable
#KT-17588 Fixed
2017-04-25 15:06:41 +02:00
Mikhael Bogdanov b51cb9a911 Delete clean reference instructions on dereferencing captured variables
Codegen generates clean instructions for ref values (captured vars)
on block exit so we should delete them on dereferencing captured values.

  #KT-17200 FIXED
2017-04-10 16:35:03 +05:00
Dmitry Petrov 3c09a26e16 KT-5248 Don't wrap variable if it is captured only in inlined closures
Remove non-escaping Ref's on bytecode postprocessing pass.
2017-03-13 09:04:31 +03:00