Commit Graph

18358 Commits

Author SHA1 Message Date
Ilya Gorbunov 96c36fb317 Remove manifest.impl.value.kotlin.version and other unused properties from kotlinManifest.properties 2017-05-05 21:56:56 +03:00
Ilya Gorbunov 720e6ecdb6 kotlin.language.version property no longer used in maven build 2017-05-05 21:56:56 +03:00
Mikhail Zarechenskiy 3bfc17c2d4 Avoid redundant cache entries: move checks to the caller function 2017-05-05 21:30:39 +03:00
Mikhail Zarechenskiy adb8e60615 Fix resolve of last destructuring declaration in block
Last declaration in block is resolved in DEPENDENT mode because it has
 influence on return type and therefore fake call for destructuring declaration
 wasn't completed (see `getBlockReturnedTypeWithWritableScope`)

 Now we resolve fake call for destructuring declaration in INDEPENDENT
 mode as it doesn't have effect on return type

 #KT-15480 Fixed
2017-05-05 21:30:38 +03:00
Mikhail Zarechenskiy 7530a9426f Warn about val reassignment via backing field
#KT-16681 In Progress
2017-05-05 21:30:37 +03:00
Mikhail Zarechenskiy e821b25288 Resolve type alias SAM constructors in synthetic scope 2017-05-05 21:30:36 +03:00
Mikhail Zarechenskiy 7541a3754d Move SAM constructors to synthetic scope 2017-05-05 21:30:35 +03:00
Mikhail Zarechenskiy 429f0e4f68 Adapt changes in IDE after moving SAM adapters to synthetic scope
The main change is that now to get static sam adapters one should do it using synthetic scopes and static scope of container
2017-05-05 21:30:10 +03:00
Mikhail Zarechenskiy 8e233162ed Drop SamAdapterOverridabilityCondition as it became obsolete
There is no need in checking overridability of sam adapters as now we don't create fake synthesized methods for static sam adapters
2017-05-05 21:30:10 +03:00
Mikhail Zarechenskiy 95ede7fb67 Move SAM adapters from static scope to synthetic one 2017-05-05 21:30:10 +03:00
Alexey Tsvetkov 2ff28ebced Merge sequent filter and map calls into one loop
ScopeTowerProcessors.kt contains a few code snippets
that look like `collectCandidates(...).filter { ... }.map { ... }`.
Filter argument is always side-effect free, so it is safe
to merge `filter` and `map` calls into one for-loop.

The change also makes sense, because modified functions are quite hot.
For example `NoExplicitReceiverScopeTowerProcessor.simpleProcess`
produces 11,392,768 ArrayList instances (~1.08% of all objects)
when compiling the compiler according to aprof at the moment of writing.

On my machine the change improves compilation speed of the compiler up to 5%.
2017-05-05 20:02:04 +03:00
Denis Zharkov 7c6a15ddfe Treat inline suspend functions as inline-only
Now their bodies don't have real state machines, thus they cannot
be called correctly from Java

 #KT-17585 In progress
 #KT-16603 In progress
2017-05-05 14:14:38 +03:00
Denis Zharkov ba200f5de1 Minor. Remove redundant kind of coroutine markers
It was necessary while the additional code was being inserted
outside of transformer, but now we can just remember where
the actual body starts
2017-05-05 14:14:37 +03:00
Denis Zharkov b3f66c7641 Remove $ character from fake continuation parameter
The reason is that when it gets captured into the field
having name $$continuation inliner fails with an exception
as it skips fields starting with '$$'

At the same time it doesn't really matter how to call
that parameter because it's only visible in Java

 #KT-17585 In Progress
 #KT-16603 In Progress
2017-05-05 14:14:37 +03:00
Denis Zharkov 5b5f612a7c Support new strategy for suspend inline functions
The main idea is to leave all the inline functions as is, without
state machines (but keeping suspend-calls markers) and
determine whether we need a state machine from the bytecode
after inlining into a non-inline function

 #KT-17585 In Progress
 #KT-16603 In Progress
 #KT-16448 Fixed
2017-05-05 14:14:00 +03:00
Denis Zharkov 5d0aeb4ef6 Minor. Drop unused BindingContext slice 2017-05-05 14:01:50 +03:00
Denis Zharkov 0b99c5c54e Remove fix for tail-placed branch operations in suspend functions
It has been introduced in 2286027bed
and should've help to avoid verify error

Now it became both impossible and unnecessary:
- It's impossible now since we can't determine in codegen
if we'll needa state machine
(it depends from inline functions' contents)
- It's unnecessary since we'll introduce the state machines for cases
described in the 2286027bed tests

NB: There's still a problem that now we work a bit suboptimally
because actually these samples can be generated without state
machines
2017-05-05 14:01:50 +03:00
Denis Zharkov 7803c9c0ba Minor. Convert loop to 'removeIf' call 2017-05-05 14:01:50 +03:00
Denis Zharkov 00526f5934 Add optional JVM declarations rendering for box tests
This option will be used later to check if state machine has been
generated for suspend function
2017-05-05 14:01:50 +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
Denis Zharkov 035fcc2424 Minor. Rewrite part in CoroutineTransformer with 'run'
It helps to avoid unnecessary val customCoroutineStartMarker
in the scope of performTransformations
2017-05-05 14:01:50 +03:00
Denis Zharkov c3a032ea0b Generate state machine for named functions in their bodies
Inline functions aren't supported yet in the change

 #KT-17585 In Progress
2017-05-05 14:01:50 +03:00
Denis Zharkov 59d89a1ae3 Generate private suspend function in JVM as package-private
It helps to simplify implementation of generating state machines
into the named functions' bodies but of course has some flaws:
1. They may be called from the same package in Java
2. It may lead to problems when declaring clashing descriptor
in an inheritor

This change must be reverted at some moment, or these flaws
should be fixed in some other way

 #KT-17585 In Progress
 #KT-17584 Open
2017-05-05 14:01:50 +03:00
Denis Zharkov bb7a188f87 Minor. Weaken assertion in refined int type analysis
It's necessary because ASM remebers exact types obtained from
value parameters, and in the further commits we're going
to place code of suspend functions in their bodies, and there
we get already refined type for int-like slots
2017-05-05 14:01:50 +03:00
Denis Zharkov 0cd80d8b0e Get rid of class builder factory for coroutines
Initially it was a sort of hack: introducing another
interception class builder factory that will process all functions.

To differentiate suspend functions from the common ones
the fake annotation class has been used.

The problem is that now we should inject the different
class builder into the CoroutineTransformerMethodVisitor:
we need class builder for anonymous class representing state
for named function while currently it will be the one for the class
where the named function is defined
2017-05-05 14:01:50 +03:00
Mikhail Glukhikh 7271ca0b72 KT-13997 related: fix of JS relevant test 2017-05-05 11:17:52 +03:00
Kirill Rakhman cd07aea5e3 Add quickfix for adding 'lateinit'
Fixes #KT-17650
2017-05-05 11:09:07 +03:00
Dmitry Petrov e902cff937 Add 'getTypeArgumentOrDefault' extension for IrMemberAccessExpression 2017-05-05 09:59:30 +03:00
Dmitry Petrov f5fde2c24f Dump absent type arguments 2017-05-05 09:59:30 +03:00
Dmitry Petrov ddb2b7508b Generate property initializer within property scope 2017-05-05 09:59:30 +03:00
Dmitry Petrov 8e84862afa Generate do-while condition within loop body scope 2017-05-05 09:59:30 +03:00
Dmitry Petrov fdb4de355c Use original descriptors to create symbols for callable references 2017-05-05 09:59:30 +03:00
Dmitry Petrov c2601c947f Postpone call arguments generation in compound assignment expressions
Otherwise RHS is generated twice, causing ISE in symbol binding
2017-05-05 09:59:30 +03:00
Anton Bannykh 2e9a59819a JS: support internal visibility from friend modules
Friend modules should be provided using the -Xfriend-modules flag
in the same format as -libraries. No manual configuration required for
JPS, Gradle and Maven plugins.

Friend modules could be switched off using the -Xfriend-modules-disabled
flag. Doing that will
  * prevent internal declarations from being exported,
  * values provided by -Xfriend-modules ignored,
  * raise a compilation error on attemps to use internal declarations from other modules

Fixes #KT-15135 and #KT-16568.
2017-05-04 21:44:17 +03:00
Alexey Tsvetkov 5c041cb182 Kapt3: Remove source stubs together with the class files when .kt file is marked dirty (IC) 2017-05-04 19:59:29 +03:00
Yan Zhulanow 254e8156ac NoArg: Initialize properties in noarg constructor (KT-16692) 2017-05-04 18:46:42 +03:00
Anton Bannykh 7503376731 JS: unmute box/test/coroutinessuspendFunctionAsCoroutine/inlineTwoReceivers.kt 2017-05-04 16:47:00 +03:00
Mikhail Glukhikh 1273166ed0 Do not report redundant else for enum / sealed from another module
Related to KT-17497
2017-05-04 14:17:43 +03:00
Mikhail Glukhikh 14886827a2 Introduce warning REDUNDANT_ELSE_IN_WHEN #KT-17497 Fixed 2017-05-04 14:17:41 +03:00
Mikhail Glukhikh e53c548ead Consider property external if all accessors are external #KT-13997 Fixed 2017-05-04 14:17:40 +03:00
Mikhail Glukhikh b8af0f5922 J2K: move isEffectivelyExternal to kt-file, parameter -> receiver 2017-05-04 14:17:38 +03:00
Dmitry Petrov d5feb2d6f4 Deep copy fixes + sanitize file names for module dumps 2017-05-04 13:51:17 +03:00
Dmitry Petrov 506941e7e0 Optimize range operations for 'until' extension from stdlib (KT-9900)
NB: for-in-until loop is generated as precondition loop, because the
corresponding range is right-exclusive (and thus we have no problems
with integer overflows).
2017-05-04 10:09:42 +03:00
Dmitry Petrov b83620fdb9 Minor: DeepCopyIrTree: make some utility methods 'protected' 2017-05-04 09:33:03 +03:00
Dmitry Petrov e600a1af30 Minor: IrDeclarationOrigin.NEW_INSTANCE_RECEIVER -> INSTANCE_RECEIVER 2017-05-04 09:33:03 +03:00
Dmitry Petrov 1eb693b8ee Transform variable-as-function calls for extension functions
In the following code example
  fun test(f: Any.() -> Unit) = 42.f()
front-end resolves variable-as-function call for 'f' as 'invoke'
with signature 'Function1<Any, Unit>#Any.() -> Unit'.
However, Function1<Any, Unit> has a single 'invoke' method
with signature 'Function1<Any, Unit>#(Any) -> Unit'.
This didn't cause any problems with loosely typed JVM and JS back-ends.
However, in IR with symbols this means a reference to non-existing
declaration.
2017-05-04 09:33:03 +03:00
Dmitry Petrov 7bd75df1f1 Minor: small refactorings in IrElementTransformerVoid 2017-05-04 09:33:03 +03:00
Dmitry Petrov 0203ba4dff Use stable order when generating stubs for scope members 2017-05-04 09:33:03 +03:00
Dmitry Petrov 40939da9fb Minor: DeclarationGeneratorExtension already extends Generator 2017-05-04 09:33:03 +03:00
Dmitry Petrov 17706d0fb6 Generate parameter declarations for synthetic members of enum classes 2017-05-04 09:33:03 +03:00