Commit Graph

56512 Commits

Author SHA1 Message Date
Dmitry Savvinov 9047ddfc2f [API Usage] Refine supertypes when getting content of member scope 2019-07-30 12:41:37 +03:00
Dmitry Savvinov 1d61d75225 [Core API] Introduce KotlinType.refine
The most interesting part happens in SimpleType.refine, other types
either don't implement refinement at all (they return just 'this',
mainly it's some special types, like ErrorType and such) or implement
it trivially via recursion (those are "composite" types)

SimpleType.refine captures so-called refinement factory, which is essentially
an injected callback which tells how to reconstruct the type with new
(refined) memberScope.

We have to inject callback because we express quite different types with
SimpleTypeImpl, and some of them need different refinement logic.
Another possible implementation approach (more invasive one) would be
to extract those types in separate subtypes of KotlinType and implement
'refine' via overrides.

The most meaningful callbacks are injected from
'AbstractClassDescriptor.defaultType' and from 'KotlinTypeFactory'.
2019-07-30 12:41:37 +03:00
Dmitry Savvinov c12f5f6055 [Core API] Introduce TypeConstructor.refine
This commit introduces TypeConstructor.refine method.

It's implementation can be roughly split in three parts:
- trivial implementations which just return 'this': mostly, it used for
typeConstructors which can not be refined at all (e.g.
IntegerValueTypeConstructor and other special cases of constructors)

- delegating implementations which call 'refine' recursively for
component typeConstructors -- obviously, they are used in composite
typeConstructors (like IntersectionTypeConstructor)

- finally, the most interesting one is in 'AbstractTypeConstructor'
which returns lightweight wrapper called 'ModuleViewTypeConstructor'.
The idea here is to propagate refinement to supertypes without eagerly
computing them all.

VERY IMPORTANT CAVEAT of TypeConstructor.refine is that call to this
method CAN NOT add new supertypes, so returned supertypes are not
entirely "valid". See the KDoc for TypeConstructor.refine for details
2019-07-30 12:41:37 +03:00
Denis Zharkov c20d565d93 [Core API] Introduce API for getting scopes with refinement
- All refinement-related methods are incapsulated in
ModuleAwareClassDescriptor

- most of classes implement it trivially by retning unchanged scope

- LazyClassDescriptor and DeserializedClassDescriptor have non-trivial
implementations of the refinement-related methods

- General idea is to return new scope which captures refiner and will
later use it to get correct content of itself (currently, refiner is
unused, and will be used for that in later commits)

- In order to not repeat similar work, those new instances of scopes are
cached in ScopeHolderForClass, which is essentially a cache of form
KotlinTypeRefiner -> MemberScope
2019-07-30 12:41:37 +03:00
Dmitry Savvinov d08bed888c [Core API] Introduce useTypeRefinement analysis flag 2019-07-30 12:41:36 +03:00
Dmitriy Novozhilov 2fe3a23183 [Core API] Introduce KotlinTypeRefiner component 2019-07-30 12:41:36 +03:00
Dmitriy Novozhilov 5c17148146 [Core API] Introduce TypeRefinement annotations 2019-07-30 12:41:36 +03:00
Denis Zharkov 38bcedc451 [Tests] Add tests for types refinement in IDE 2019-07-30 12:41:36 +03:00
Dmitriy Novozhilov d000341178 [Misc] Add missing type to lambda in ILTConstructor 2019-07-30 12:41:36 +03:00
Dmitry Savvinov fe78e153f7 [Misc] Introduce helper-method 'IntersectionTypeConstructor.createType()' 2019-07-30 12:41:36 +03:00
Dmitry Savvinov 5c13e02e9c [Misc] Clean-up and deduplicate code in 'findClassInModule.kt' 2019-07-30 12:41:36 +03:00
Dmitriy Novozhilov a0f339ffc7 [Misc] Enable @Experimental project-wide 2019-07-30 12:41:36 +03:00
Dmitriy Novozhilov f026a98403 [Misc] Make NewKotlinTypeChecker non-static 2019-07-30 12:41:36 +03:00
Dmitriy Novozhilov 4f1e85b468 [Misc] Add caching of hashCode in KotlinType
KT-32852
2019-07-30 12:41:35 +03:00
Denis Zharkov 8d1b063d62 [Misc] Add test on typealiased SAM 2019-07-30 12:41:35 +03:00
Denis Zharkov c1144f35f1 [Misc] Move TypeAliasExpander to core 2019-07-30 12:41:35 +03:00
Denis Zharkov 7ba3f7e599 [Misc] Make ArgumentTypeResolver::isSubtypeOfForArgumentType not static
Later, it will use type-refinement component that'll be injected there
2019-07-30 12:41:35 +03:00
Denis Zharkov 529763b9bd [Misc] Get rid of public Companion methods in SmartCastManager
It's necessary for type-refinement component to be injected
2019-07-30 12:41:35 +03:00
Denis Zharkov e7d6a9508e [Misc] Reformat CallType.kt 2019-07-30 12:41:35 +03:00
Denis Zharkov edb9623556 [Misc] Reformat DescriptorEquivalenceForOverrides.kt 2019-07-30 12:41:35 +03:00
Andrey Uskov 4e486e7738 Fix NewMultiplatformKaptProjectImportingTest (KT-32974)
Fix test case when importing module per source set is not supported
in Android Studio
#KT-32974 Fixed
2019-07-30 11:56:07 +03:00
Andrey Uskov c17a5bc8f2 Disable KaptImportingTest.testModulePerSourceSet in AS (KT-32683)
#KT-32683 Fixed
2019-07-30 11:55:17 +03:00
Andrey Uskov 02ee950836 Add transitive dependencies on common MPP modules
Transitive dependencies on modules available via
'dependsOn' dependencies are added to java modules
depending on MPP projects
#KT-33025 Fixed
2019-07-30 11:38:51 +03:00
Steven Schäfer 3ce731cf7c Avoid eager deserialization of array classes in ArrayConstructorLowering 2019-07-30 10:35:00 +02:00
Ilmir Usmanov 2910d8e9b2 Also check predecessors of PUSH Unit in unit tail-call optimization 2019-07-29 20:34:53 +03:00
Ilmir Usmanov e60674f5e1 Fix test data 2019-07-29 20:34:51 +03:00
Ilmir Usmanov cc06798e2c Implement unit suspend functions tail-call optimisation
Unlike previously, this optimisation works on every callee return type.
Tail-calls inside unit functions can be either
INVOKE...
ARETURN
or
INVOKE
POP
GETSTATIC kotlin/Unit.INSTANCE
ARETURN
The first pattern is already covered. The second one is a bit tricky,
since we cannot just assume than the function is tail-call, we also need
to check whether the callee returned COROUTINE_SUSPENDED marker.
Thus, resulting bytecode of function's 'epilogue' look like
DUP
INVOKESTATIC getCOROUTINE_SUSPENDED
IF_ACMPNE LN
ARETURN
LN:
POP

 #KT-28938 Fixed
2019-07-29 20:34:48 +03:00
Alexey Tsvetkov a16e03681b Substitute kotlin-reflect in compileOnly configurations too
This fixes running IDEA with JPS build.
Gradle only uses compileClasspath configurations
for compilation. Hence the substitution introduced in 5c99243c10
affected only compile tasks (without affecting existing POMs).

However, Intellij import also looks into compileOnly configurations
in order to determine PROVIDED dependencies.
Only dependencies, that are present in both
compileOnly and compileClasspath confgurations,
are considered to have PROVIDED scope.

The substitution was replacing kotlin-reflect with kotlin-reflect-api
in compileClasspath configuration. CompileOnly configurations still resolved
to kotlin-reflect, so a compileOnly dependency to kotlin-reflect
would result in kotlin-reflect-api dependency with COMPILE scope in
IDEA.
This is exactly what happened in 'idea-runner' module, thus breaking
running IDEA from JPS build.

This change fixes the issue by configuring the same substitution
for compileOnly configurations.
2019-07-29 19:48:10 +03:00
Alexey Tsvetkov 317c39f27d Enable assertions in Kotlin Compile Daemon process
#KT-32992 Fixed
2019-07-29 19:40:36 +03:00
Alexey Tsvetkov 560f1483e8 Drop MaxPermSize support from compiler daemon
#KT-17045 Fixed
2019-07-29 19:38:40 +03:00
Dmitry Gridin db23131611 AbstractFindUsagesTest: add read lock 2019-07-29 17:16:41 +03:00
Igor Chevdar e575ca4f53 [IR] Fixed parents during constructors moving 2019-07-29 16:18:15 +03:00
Vyacheslav Gerasimov 2c61572c50 Build: Fix artifact pattern for Android Studio bintray repo 2019-07-26 19:01:53 +03:00
Vyacheslav Gerasimov 10f5204f67 as36: Fix groovy-all dependency version 2019-07-26 18:27:41 +03:00
Ilya Chernikov aed9b13455 Fix jvm-host-embeddable artefact generation 2019-07-26 16:29:45 +02:00
Ilya Chernikov 333c7ff688 Filter out local classes on JSR-223 properties mapping
fixes e.g. Spring framework usages of the JSR-223 engine
2019-07-26 16:28:56 +02:00
Alexey Tsvetkov 2ae19e1d42 Run :kotlin-gradle-plugin:validateTaskProperties on every install
Previously `validateTaskProperties` was run with tests
(`test` task depends on `validateTaskProperties` task).
Tests run with `--continue` argument on TeamCity,
so the validation was not failing remote-run builds.
To fix this, make `install` depend on `validateTaskProperties`.
2019-07-26 15:31:59 +03:00
Alexey Tsvetkov aff66b6a29 Make KotlinJpsBuildTestBase abstract
Otherwise TeamCity warns that it does not contain any tests
2019-07-26 15:09:47 +03:00
Roman Artemev ce9ed26918 [DEBUGGER] Improve computation of source position for breakpoint
in KotlinLineBreakpointType more precise.

 - make `getOffset` of returned position point to lambda body start.

 Fix [WEB-29329]
2019-07-26 15:05:41 +03:00
Dmitry Gridin 2e0ec3b490 AbstractFindUsagesTest: add read lock 2019-07-26 12:57:29 +03:00
Dmitry Gridin dbb9b3b6fd AbstractFindUsagesTest: cleanup code 2019-07-26 12:52:02 +03:00
Nikolay Krasko 58f294a757 Fix kotlin compiler tests in 192 (KT-32193)
#KT-32193 Fixed
2019-07-26 12:38:40 +03:00
Georgy Bronnikov 3729c4e770 JVM: simplify choice of wrapped receiver descriptors 2019-07-26 11:57:51 +03:00
Dmitry Gridin a10e57eaec JavaOutsideModuleDetector: should refresh notification after move
#KT-32967 Fixed
2019-07-26 10:33:54 +03:00
Dmitry Gridin 4c8d0acb5d CreateExpectFix: shouldn't suggest create expect property with lateinit or const modifier
#KT-32705 Fixed
2019-07-26 10:33:28 +03:00
Ilya Chernikov a858607fac Fix script classpath utility functions that use classpath filtering by "keys"
The problem was that only the first matching classpath entry were used.
The problem was reported by @lion7 on github (https://github.com/JetBrains/kotlin/commit/67ad3773de2b12f7e1d29e00151b997a4f6373ba#commitcomment-34443927)
2019-07-26 08:55:16 +02:00
Ilya Chernikov ec3ccf1ba8 Properly handle REPL snippets with exceptions ...
so the REPL remain operational after exception in one of the snippets:
- separately return script class and script instance on evaluation (
  because in case of an exception the class is valid, while the instance
  is not).
- store both the class and the instance in the history
- handle this data accordingly
2019-07-26 08:55:16 +02:00
Ilya Chernikov 288fdc0952 Add a handler for providing evaluation context for scripts
use it on refinement.
also some refactoring on context class and around
2019-07-26 08:55:16 +02:00
Ilya Chernikov 2a5c4a2409 Move caching to after all configuration refinements and ...
move compilation cache setting to the scripting host configuration
The cache implementation can now take into account all external
dependencies that may appear during refinement.
Also change initial refinement location accordingly and rearrange
caching interfaces to make it available in scripting plugin.
2019-07-26 08:55:16 +02:00
Ilya Chernikov e41bbe9328 Introducing transient properties in scripting API 2019-07-26 08:55:16 +02:00