Commit Graph

2269 Commits

Author SHA1 Message Date
Mikhail Zarechenskiy
2cac6a9e7d Improve inference on generics for callable references
#KT-10711 Fixed
 #KT-12802 Fixed
 #KT-12964 Fixed
 #KT-15439 Fixed

Analyze callable references in `dependent` mode, then complete them with
respect to expected types
2017-01-24 02:15:26 +03:00
Anton Bannykh
07bb7ef4d3 JS: extension lambdas translated same as local lambdas (KT-13312 fixed) 2017-01-23 20:09:36 +03:00
Alexander Udalov
ebd577e52a Introduce KProperty{1,2}.getExtensionDelegate
These two functions are supposed to fix an inconvenience in the design of
KProperty{1,2}.getDelegate for extension properties, where you have to pass an
instance of the extension receiver which is going to be completely ignored

 #KT-8384 Fixed
2017-01-23 12:25:36 +03:00
Alexander Udalov
78f2515e95 Introduce KProperty{0,1,2}.getDelegate
#KT-8384 In Progress
2017-01-23 12:25:35 +03:00
Denis Zharkov
2edcd369a8 Fix inference issue with Stream.collect
See doNotCaptureSupertype test for clarification:
When resolving b.collect(toList()) we're building a common system with
two variables T and R.

The problem was that when introducing the constraint
C<T, Inv<T>> <: C<in String, R> we then were seeing the constraint
T <= in String, and add the constaint T=Captured(in String)

That lead to R=Inv<T>=Inv<Captured(in String)>, and after approximation
R=Inv<in String>, that is not the desirable result (Inv<String> suits here)

But the root problem was that we add captured constaint when projection was from supertype,
that seems to be wrong, and for example Java doesn't do that in the similar situation.

 #KT-11259 Fixed
2017-01-22 13:29:08 +03:00
Mikhael Bogdanov
da1b8a02ed Exclude builtins members mapped to java default methods from delegation 2017-01-20 13:16:58 +01:00
Mikhael Bogdanov
591de36666 Added deprecated diagnostic for invoking default methods within jvm-target 1.6 2017-01-18 10:50:59 +01:00
Denis Zharkov
37b364a70a Fix processing of uninitialized instances for coroutines
The problem is that code in the attached test led to VerifyError at runtime
because the Bar's uninitialized instance created in 'map' was being stored
to the field (leaked from the JVM point of view).

The actual problem was that after repeating visiting of NEW operation
we used to drop the set of already visited copy usages.

For clarification see the comment before 'processUninitializedStores'

 #KT-15016 Fixed
2017-01-18 12:00:46 +03:00
Denis Zharkov
630fab1952 Fix signature of accessor for suspend function
It must be a suspend function too to have an additional Continuation parameter

 #KT-15715 Fixed
2017-01-18 12:00:45 +03:00
Denis Zharkov
d0d617b44e Fix signature mapping for default suspend function from interface
Use jvm suspend function view in function codegen.
Also use SUSPEND_FUNCTION_TO_JVM_VIEW slice if the value exists
for the given key

 #KT-15552 Fixed
2017-01-18 12:00:45 +03:00
Denis Zharkov
fae9cc1c63 Fix codegen issue of safe-qualified suspension points
#KT-15527 Fixed
2017-01-18 12:00:44 +03:00
Denis Zharkov
9f217de10b Write kotlin metadata on class-files for coroutine state machines
Otherwise it breaks JPS assumptions, that leads to exceptions like:
Error:Kotlin: [Internal Error] java.lang.AssertionError: Couldn't load KotlinClass from /Users/jetbrains/IdeaProjects/KotlinPlaygroundBeta11/out/production/KotlinPlaygroundBeta11/Counter$both$1.class; it may happen because class doesn't have valid Kotlin annotations
    at org.jetbrains.kotlin.build.GeneratedJvmClass.<init>(generatedFiles.kt:36)
    at org.jetbrains.kotlin.jps.build.KotlinBuilder.getGeneratedFiles(KotlinBuilder.kt:469)
    at org.jetbrains.kotlin.jps.build.KotlinBuilder.doBuild(KotlinBuilder.kt:241)
    at org.jetbrains.kotlin.jps.build.KotlinBuilder.build(KotlinBuilder.kt:140)
...
2017-01-16 17:53:15 +03:00
Roman Elizarov
25739a08ea CoroutineContext Key and Element are now inside CoroutineContext interface itself (just like Map.Entry)
ContinuationInterceptor companion object is named Key
CoroutineContext.Element property for key is named just key
AbstractCoroutineContextElement implements all of CoroutineContext.Element, including key
2017-01-16 14:33:02 +03:00
Denis Zharkov
14f942aca7 Refine ABI for coroutine lambdas
Make their invoke work in the same way as any other suspend function:
it should return SUSPENDED_MARKER iff. it indeed became suspended
2017-01-14 19:51:05 +03:00
Denis Zharkov
d346cbbe61 Update test data for light-analysis/coroutines 2017-01-14 15:13:37 +03:00
Denis Zharkov
c7f76d7ec8 Minor. Fix tests after CoroutineContext introduction 2017-01-14 15:13:36 +03:00
Denis Zharkov
6a1ad3a279 Get rid of unnecessary additional declarations in tests 2017-01-14 13:24:53 +03:00
Roman Elizarov
8d6a913cee CoroutineContext and ContinuationInterceptor (instead of dispatcher) 2017-01-14 13:24:53 +03:00
Denis Zharkov
f56d9cfb26 Ignore failing coroutine related tests on JS 2017-01-14 13:24:53 +03:00
Denis Zharkov
c479aa7d65 JS: simplify how suspend functions inlined 2017-01-14 13:24:53 +03:00
Denis Zharkov
2286027bed Fix verify error with 'return when/if/try' in suspend function
The problem appears for tail-optimized suspend functions,
we erroneously assumed that when/if/try expressions in tail-call
position have simple types like `I` while actually, they can return SUSPENDED
object, i.e. must have `java/lang/Object` as return type.

But this only concerns branching operations in tail-call position,
so we have to make an additional analysis for remembering whether
a given expression is in a tail-call position.

Also, it's important here that we now assume
the return type of the current function  as `java/lang/Object`
that is necessary to avoid wrong checkcasts.

 #KT-15364 Fixed
2017-01-14 13:24:53 +03:00
Denis Zharkov
695b6d9e67 Minor. Add test on local vars of suspend function type 2017-01-14 13:24:53 +03:00
Denis Zharkov
7837d736f7 Merge RestrictedCoroutineImpl into CoroutineImpl 2017-01-14 13:24:53 +03:00
Denis Zharkov
d487c1ef0f Refine dispatching convention
Dispatching happens only via `suspendWithCurrentContinuation` calls
instead of each `resume` call

 #KT-15657 Fixed
2017-01-14 13:24:53 +03:00
Denis Zharkov
0240ab0738 Support non-tail suspend calls in JVM back-end
#KT-15597 In Progress
2017-01-14 13:24:53 +03:00
Denis Zharkov
2cb9d3a8ad Move coroutine intrinsics to kotlin.coroutine.intrinsics package
Also rename val SUSPENDED to SUSPENDED_MARKER

 #KT-15698 Fixed
2017-01-14 13:24:53 +03:00
Mikhael Bogdanov
b88a9025e0 Don't check DELEGATED_MEMBER_HIDES_SUPERTYPE_OVERRIDE when compiling to 1.0 2017-01-13 18:01:05 +01:00
Ilya Gorbunov
cdfb72ab76 Provide protected toArray implementation in AbstractCollection.
Relates to #KT-13898
2017-01-13 19:38:28 +03:00
Mikhael Bogdanov
09eeb414fe New test for jvm8 nondefaults target 2017-01-13 13:52:57 +01:00
Mikhael Bogdanov
d278a5c6d5 Move java 8+defaults tests to separate folder 2017-01-13 13:52:57 +01:00
Mikhael Bogdanov
0a363fd1a5 Introduced test flag: JVM8_TARGET_WITH_DEFAULTS 2017-01-13 13:52:56 +01:00
Mikhael Bogdanov
7f8acbb759 Use proper flag for interface method invocation 2017-01-13 13:52:55 +01:00
Dmitry Petrov
4dd100122b Explicitly remove NOPs inserted for bytecode analysis in post-conditional loops.
Remove redundant NOPs during bytecode optimization.

NOP instruction is required iff one of the following is true:
(a) it is a first bytecode instruction in a try-catch block (JVM BE assumption);
(b) it is a sole bytecode instruction in a source code line (breakpoints on that line will not work).
All other NOP instructions can be removed.

Note that it doesn't really affect the performance for mature JVM implementations.
However, the perceived quality of the generated code is somewhat improved :).

Related: KT-15609
2017-01-13 10:31:07 +03:00
Dmitry Petrov
ba933fa887 KT-15112, KT-15631
Revert changes for "tolerant to uninitialized values" in OptimizationBasicInterpreter:
this approach doesn't converge for some specific cases where local variable is reused
(e.g., in several inlined functions - see https://youtrack.jetbrains.com/issue/KT-15112).

Instead, treat fake always-false conditional jump in the beginning of the post-condition loop as a "reference point" for stack on loop break / continue.
This requires an extra abstraction layer in FixStackAnalyzer, since we can't perform fine-grain manipulations on Frames
(such as "combine frame C from local variables of frame A and stack of frame B").

NB additional NOPs will be generated for post-condition loops.
Should make a separate bytecode postprocessing pass to get rid of unnecessary NOPs
(several YT issues for perceived quality of the generated bytecode are about such NOPs).
2017-01-13 10:31:07 +03:00
Alexey Andreev
a016147a79 JS: fix translation of return statement surrounded by try..finally block in suspend lambda. See KT-15625 2017-01-12 18:12:39 +03:00
Alexey Andreev
10a3fbf53f JS: disable TemporaryAssignmentElimination, fix KT-15512 2017-01-12 18:12:39 +03:00
Alexey Andreev
7d170c0fcd JS: fix translation of reassignment of inline properties. See KT-15590 2017-01-12 18:12:38 +03:00
Alexey Andreev
4eed7c1fcb JS: fix translation of augmented assignment in class initializer. See KT-15569 2017-01-12 18:12:38 +03:00
Alexey Andreev
ee74342fbe JS: fix compiler crash when optimizing JS AST with empty do..while statement. See KT-15513 2017-01-12 18:12:37 +03:00
Alexey Andreev
bad6f41d6e JS: make some JVM tests compatible with JS BE 2017-01-12 18:12:37 +03:00
Alexey Andreev
70176dfacc JS: translate call arguments in the order the occur in source code, not in order of parameters in descriptor. See KT-15506 2017-01-12 18:12:36 +03:00
Alexey Andreev
e6b78f68cd JS: support case when class inherits method from superclass and both implements same method (but with optional parameter) from superinterface. 2017-01-12 18:12:36 +03:00
Alexander Udalov
abe2ad155c Sanitize names for script class files
Use the same process that is done for package parts in the JVM back-end, except
adding the "Kt" suffix

 #KT-15225 Fixed
2017-01-12 11:24:24 +03:00
Mikhael Bogdanov
2931c316a3 Fix for KT-15575: VerifyError: Bad type on operand stack
#KT-15575 Fixed
2017-01-11 11:50:33 +01:00
Mikhael Bogdanov
5071baf970 Support increment and '*=' operations on inline properties 2017-01-10 14:09:42 +01:00
Mikhael Bogdanov
043f3199c7 Fix for KT-15446: Property reference on an instance of subclass causes java.lang.VerifyError
#KT-15446 Fixed
2017-01-10 14:09:42 +01:00
Mikhael Bogdanov
dc4cdbf82d Fix for KT-14162: Support @InlineOnly on inline properties
#KT-14162 Fixed
2017-01-10 14:09:41 +01:00
Alexander Udalov
32d2faf3d1 Fix KAnnotatedElement.findAnnotation when no annotation is found
#KT-15540 Fixed
2017-01-10 12:23:26 +03:00
Mikhail Zarechenskiy
cff0865c87 Fix error type for implicit invoke with function literal argument
#KT-11401 Fixed
2017-01-10 11:44:51 +03:00
Alexey Andreev
069711c3d5 JS: fix translation of float constants. See KT-8413 2016-12-30 16:22:07 +03:00