Commit Graph

2421 Commits

Author SHA1 Message Date
Zalim Bashorov c021af0fef KJS: fix non-local return inside catch block 2017-04-19 20:20:21 +03:00
Ilya Gorbunov 4a5d8534c1 Fix array iterators to adhere to Iterator contract
#KT-17453 Fixed

Change expected exceptions in tests.
2017-04-18 18:51:20 +03:00
Alexey Andreev 7e6df03421 Fix improper handling of coroutine interceptors
Don't use coroutine facade in following cases:
* When calling coroutine functions in non-suspend mode (i.e.
  suspend flag is either false or skipped).
* When passing continuation from suspend function to suspend function.

Use facade only for corresponding intrinsics.
Reason: interceptor should not be called on each suspend function
invocation, it should be called after resume from innermost
suspend function.

Fix KT-17067. The example provided with the issue is very similar to
dispatchResume.kt which passes after these changes.

Add test to prove that KT-17446 is no more reproducible.
2017-04-18 11:22:18 +03:00
Mikhael Bogdanov 708bfdbd5f Generate line numbers for function call parameters
Before this fix line numbers for function call arguments were not generated,
 so if argument was on another line than function call it was
 impossible to stop on argument line during debugging.
 Now line number for each argument is generated if necessary
 (another line than function call line).

 #KT-17144 Fixed
2017-04-17 16:09:59 +02:00
Mikhail Zarechenskiy b17b3f4c63 Resolve local function parameters with function inner scope
This allows to use type parameters and value paramters in default value expressions

 #KT-7984 Fixed
 #KT-7985 Fixed
2017-04-17 16:21:06 +03:00
Mikhail Zarechenskiy e86d52b681 Fix return type of private members that return anonymous object
#KT-16813 Fixed

Anonymous objects returned from private-in-file members should behave as for private class members
2017-04-17 16:21:05 +03:00
Mikhail Zarechenskiy 1fbd8f3f53 Support automatic labeling for infix calls
#KT-8877 Fixed
2017-04-17 16:21:03 +03:00
Mikhail Zarechenskiy 6a352bccb6 Resolve control label locally when label name clashes with fun name
#KT-5354 Fixed
 #KT-15085 Fixed
2017-04-17 16:21:02 +03:00
Alexey Andreev 5c1882bfcc Unmute test that passes 2017-04-13 17:33:15 +03:00
Alexey Andreev 43c084fde3 Simplify coroutine generation in JS backend
Stop making aliasing suspend function descriptor with reference to
instance of state machine. This may cause problems in some cases,
for example, when compiling recursive suspend function. See KT-17281.
Instead, make alias for synthetic continuation parameter. This
additionally required some refactoring, e.g. *always* generating
continuation parameter during codegen.
2017-04-13 12:56:34 +03: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
Mikhail Zarechenskiy 682fe9e9ca Don't forget to resolve annotations from constructor parameter
#KT-12245 Fixed
2017-04-10 12:48:10 +03:00
Mikhail Zarechenskiy c9b468581a Fix type checking of local return inside return expression
#KT-16426 Fixed
2017-04-10 12:48:09 +03:00
Mikhail Zarechenskiy 9fdd5fe5e8 Allow to import private members if they are in the same file
#KT-7724 Fixed
2017-04-05 21:35:06 +03:00
Alexander Udalov 93d5f6e635 Fix NPE on equals/hashCode of local function references
Anonymous classes for local function references implement their
getOwner() as "return null" currently (KT-14291). To avoid NPE in this
case, we now consider two local functions the same if their name and
signature are equal. This is incorrect in general, but unlikely to cause
major problems and is going to be fixed by KT-14291 eventually anyway

 #KT-17055
2017-04-03 18:05:04 +03:00
Mikhael Bogdanov 7c3ad97df5 Test for obsolete KT-17134: java.lang.VerifyError: Bad type on operand stack
#KT-17134 Obsolete
2017-04-01 15:34:56 +02:00
Mikhail Zarechenskiy 54f034a636 Place array literals in annotations feature under the version 1.2 2017-03-30 13:27:46 +03:00
Dmitry Petrov caae6ff2ec KT-16264 Forbid usage of _ without backticks
Forbid underscore-only (_, __, ___, ...) names as callees and as types.

If CHECK_TYPE directive is on, filter out UNDERSCORE_USAGE_WITHOUT_BACKTICKS messages.
2017-03-29 15:47:22 +03:00
Anton Bannykh 867bd13ce4 JS: make tests dependent on primitive array is checks pass even when -Xtypedarray is disabled (related: KT-17137) 2017-03-28 21:41:20 +03:00
Alexey Andreev 8fe96664b7 Fix initialization order of enum with companion object in JS BE
Make enum entries initialize before companion object. This helps
in situation when companion object initializer refers to enum fields.
JVM be generates <clinit> method which first initializes all enum fields
and then runs companion object initializer. This commit introduces the
similar behaviour in JS BE. The old behaviour was: initialize companion
object in constructor. In enum, constructor is called to initialize
enum fields, so previously companion object was initialized first,
which is incorrect.

See KT-16745
2017-03-28 11:32:46 +03:00
Alexey Andreev 0606ebe0dc Fix suspend function with default argument
In JS BE, fix translation of suspend function with default argument
inherited from interface.

See KT-16658
2017-03-28 11:32:45 +03:00
Alexey Andreev 6ba3812582 Fix inlining of tail call suspend function
When inlining tail-call suspend function to regular
suspend function in JS BE, don't forget to insert suspension point.
See KT-16951
2017-03-28 11:32:45 +03:00
Alexey Andreev 466540399c Fix translation of copy() fun in data class
Fix translation of copy() function in data class which has secondary
constructor in JS BE. See KT-16717.
2017-03-28 11:32:44 +03:00
Mikhail Zarechenskiy b46205f60b Add tests to check collection literals with varargs 2017-03-28 09:01:57 +03:00
Anton Bannykh 9b34e21619 JS: fixed <Type>Array.iterator methods; added -Xtypedarray compiler key
The <Type>Array.iterator used to lack next<Type>() method (KT-16626).

The -Xtypedarray compiler key enables translation of primitive arrays
to TypedArrays, and primitive array`is`-checks (KT-15358, KT-14007,
KT-14614, KT-16056).
2017-03-27 23:09:34 +03:00
Alexander Udalov fef4c8ccd8 Fix VerifyError on bound function reference on generic property
Also add a test for obsolete KT-14755

 #KT-16929 Fixed
2017-03-24 11:06:15 +03:00
Alexander Udalov 82c5c586b1 Minor, remove unnecessary test data files 2017-03-22 20:11:02 +03:00
Mikhail Zarechenskiy bfe2ddf7c1 Introduce language feature for array literals in annotations 2017-03-22 17:59:58 +03:00
Mikhail Zarechenskiy 0f1acab40d Support collection literals in the JVM backend 2017-03-22 17:59:58 +03:00
Alexander Udalov dc3aa26e3f Ignore getMembersOfStandardJavaClasses light analysis test
See #KT-16616
2017-03-22 14:33:57 +03:00
Yan Zhulanow 7a5f94129c Add ClassBuilderMode.KAPT3 tests 2017-03-21 20:49:36 +03:00
Yan Zhulanow e25e19c4d6 Refactoring: Remove light analysis test data
The light analysis test data is not needed anymore cause the light analysis result is now automatically checked against the one from the full analysis.
2017-03-21 20:49:36 +03:00
Yan Zhulanow c50881fd02 Refactoring: Extract light analysis tests from box tests 2017-03-21 20:49:34 +03:00
Mikhael Bogdanov 211b58ac6e kt1770.kt test rewrote during migration to 171 platform 2017-03-20 18:46:08 +01:00
Mikhael Bogdanov 496a21254b Black box update 2017-03-20 18:46:01 +01:00
Pavel V. Talanov d34b73befb Light class codegen: all objects are considered static
Simplify code handling access flag computation
Fix a problem where kotlin nested object wasn't producing a nested light class
2017-03-15 20:55:01 +03:00
Mikhael Bogdanov 23698f93e0 Fix reification for crossinline lambdas inlined into object literal
Inline lambda could capture reified parameter of containing inline function ('a' function)
when it is inlined in another one.
If it's inlined in any anonymous object we should track it and
add reification marker to such anonymous object instance creation
to rewrite it on inlining bytecode of 'a' function.

  #KT-15997 Fixed
2017-03-14 15:54:13 +01:00
Mikhail Zarechenskiy 05ef705609 Add IGNORE_BACKEND directive for native automatically
Also parse correctly case IGNORE_BACKEND: JS, NATIVE
2017-03-13 19:56:13 +03:00
Mikhael Bogdanov ce3b455f57 Fix for KT-16801: Accessors of @PublishedApi property gets mangled
#KT-16801 Fixed
2017-03-13 10:51:10 +01:00
Dmitry Petrov c46164481a KT-15871 Unnecessary boxing for equality operator on inlined primitive values
Allow kotlin.jvm.internal.Intrinsics#areEqual for boxed values.
Rewrite to primitive equality.

NB we can't do that for Float and Double, because java.lang.Float#equals
and java.lang.Double#equals behave differently from primitive equality comparisons.
2017-03-13 09:04:31 +03:00
Dmitry Petrov a087ea559f Eliminate redundant CHECKCAST instructions
CHECKCAST is redundant if the corresponding static type exactly matches the target type.
CHECKCAST instructions to-be-reified should not be eliminated.

KT-14811 Unnecessary checkcast generated in parameterized functions
KT-14963 unnecessary checkcast java/lang/Object
2017-03-13 09:04:31 +03:00
Dmitry Petrov ec403bfdbc KT-16245 Redundant null-check generated for a cast of already non-nullable value
KT-16194 Code with unnecessary safe call contains redundant boxing/unboxing for primitive values
KT-12839 Two null checks are generated when manually null checking platform type

Recognize some additional cases of trivial null checks and trivial instance-of checks.

A variable is "checked for null", if it is:
- a function parameter checked with 'INVOKESTATIC kotlin/jvm/internal/Intrinsics.checkParameterIsNotNull'
- checked for nullability with 'IFNULL/IFNONNULL'
- checked for nullability with 'INSTANCEOF'
  (if objectref is instance-of T, then objectref is non-null)

Before analyzing nullability, introduce synthetic assumptions for execution branches
where a variable is guaranteed to be null or not null. For example, the following bytecode:

     ALOAD 1 // Ljava/lang/String;
     IFNULL L
     <non-null branch>
  L:
     <null branch>

is transformed to

     ALOAD 1
     IFNULL L1
     NEW java/lang/String
     ASTORE 1            // tells analyzer that variable 1 is non-null
     <non-null branch>
  L:
     <null branch>
  L1:
     ACONST_NULL
     ASTORE 1            // tells analyzer that variable 1 is null
     GOTO L

After the analysis is performed on a preprocessed method,
remember the results for "interesting" instructions
and revert the preprocessing transformations.

After that, perform bytecode transformations as usual.

Do not transform INSTANCEOF to-be-reified, because reification at call site
can introduce null checks. E.g.,

    inline fun <reified T> isNullable() = null is T
    ...
    assert(isNullable<String?>())
2017-03-13 09:04:31 +03: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
Dmitry Petrov 3fc106572e Make redundant null check optimization independent of boxing optimization algorithm.
Run DCE after each single redundant null check optimization pass.
2017-03-13 09:04:31 +03:00
Ilya Matveev eda43c8b45 Mute tests with standard collection extensions in native 2017-03-10 19:59:37 +03:00
Ilya Matveev 29e5ad5abe Mute tests with '::class' in native backend 2017-03-10 19:59:37 +03:00
Ilya Matveev 8a3fa2e4e5 Fix expected SMAPs after test muting for native 2017-03-10 19:59:37 +03:00
Ilya Matveev a5e4e0284e Mute some box tests for native backend
This patch mutes the following test categories:
   * Tests with java dependencies (System class,
     java stdlib, jvm-oriented annotations etc).
   * Coroutines tests.
   * Reflection tests.
   * Tests with an inheritance from the standard
     collections.
2017-03-10 19:59:37 +03:00
Denis Zharkov 52d11eb22b Minor. Revert workarounds for problem on KClass from annotation
See KT-9453 for clarification
2017-03-10 13:49:07 +03:00
Denis Zharkov 2b21280ba9 Unwrap underlying typealias constructor earlier
The problem is very subtle (see the test): when generating a signature
for an object literal we also were mapping its super-class
(a type alias here).

Although we did unwrap its underlying constructor to map it properly
we did too late (after obtaining value parameters from the type alias constructor descriptor).

Another problem is that TypeAliasConstructorDescriptor.getOriginal
in the case does return itself, while it's expected to return
unsubstituted version

Note: everything works for common calls for such constructors
because they mapped through mapCallableMethod which contains
another custom unwrapping of type alias constructors

 #KT-16555 Fixed
2017-03-10 13:45:37 +03:00