Commit Graph

59029 Commits

Author SHA1 Message Date
Svyatoslav Kuzmich 42c4591df8 [JS IR] Add -Xgenerate-dts CLI argument 2019-11-12 18:19:06 +03:00
Toshiaki Kameyama e81fbe0a05 Folding: fold function with expression body (KT-6316)
#KT-6316 Fixed
2019-11-12 16:07:52 +03:00
Toshiaki Kameyama 58fb1dede3 Multiline string enter handler: do not insert 'trimIndent()' in const (KT-34785)
#KT-34785 Fixed
2019-11-12 16:07:52 +03:00
pyos ce0fb662c0 JVM_IR: fold inline lambdas when computing OUTERCLASS
so that the enclosing method of objects defined inside lambdas is the
one they are declared in.

Note that this does not fix *all* enclosingInfo tests because JVM_IR
currently follows the KT-28064 proposal, i.e. does not regenerate
objects defined inside lambdas under any circumstances. For example,
this causes test boxInline/enclosingInfo/inlineChain2.kt to fail because
the enclosing method of objects is _2Kt.box instead of (non-existent in
source code) `_2Kt$box$inlined$call$1.invoke` or whatever. What's more
important is that OUTERCLASS no longer points to a non-existent
`box$lambda-N` and therefore `.enclosingMethod` no longer throws.
2019-11-12 12:44:46 +01:00
pyos f906524d76 Mark a SAM conversion test as JVM-only 2019-11-12 12:24:55 +01:00
Mikhail Glukhikh c66b6b6a3a FIR visibility check: support companion private members correctly 2019-11-12 11:24:31 +03:00
Mikhail Glukhikh e96aeb77a6 FIR visibility check: support private class members 2019-11-12 11:24:25 +03:00
Mikhail Glukhikh a5ad05083a Add some stubs for FIR visibility checking 2019-11-12 11:24:24 +03:00
Mikhail Glukhikh 7e07b88eab Code cleanup: FirCallResolver 2019-11-12 11:03:59 +03:00
Mikhail Glukhikh ac13a8c8b2 Cone conflict resolver: extract JVM equivalent call filtering to a separate class 2019-11-12 11:03:58 +03:00
Mikhail Glukhikh 96c5003a13 Cone conflict resolver: filter equivalent top-level callables 2019-11-12 11:03:58 +03:00
Mark Punzalan dc10d25661 Ensure ForLoopsLowering only handles the CharSequence.iterator()
extension function from the standard library (kotlin.text.iterator()).
2019-11-12 08:09:30 +01:00
Simon Ogorodnik 1bd861c5eb Save use_ni key state to log 2019-11-11 20:32:07 +03:00
Alexander Udalov 57a674e9e6 Make fast class files reading mode default in compiler tests
This makes sense because this mode is the default in the production
compiler. Forgetting to enable it where necessary led to different
bizarre test failures, see for example changes around 3fee84b966 and
KT-34826
2019-11-11 15:40:49 +01:00
Mikhail Glukhikh dde2d08cfc FIR resolve: add extra test for generic with bounds in Java 2019-11-11 17:07:58 +03:00
Mikhail Glukhikh f66b2ca772 FIR resolve: add forgotten constraint subsystem from generic qualified access
This fixes exception in resolve of an attached test
2019-11-11 17:07:57 +03:00
Mikhail Glukhikh 26281bfe89 FIR Java: use different names for anonymous parameters (p0, p1, p2, ...) 2019-11-11 17:07:57 +03:00
Mikhail Glukhikh c657d46437 FIR Java: add nullable (instead of not-null) type parameter bounds 2019-11-11 17:07:57 +03:00
Mikhail Glukhikh db11c14fee FIR Java: don't add type parameter bounds multiple times 2019-11-11 17:07:57 +03:00
Roman Golyshev a18da68171 Remove redundant toList call in LazyJavaPackageScope 2019-11-11 16:01:23 +03:00
pyos 82fb5c4d19 JVM_IR: move lambda captures to end of signature when inlining
For example, a lambda `{ param -> captured }` of type `E.(T) -> U` will
be transformed by LocalDeclarationsLowering into a private static method

    fun f$lambda-0($this: E, $captured: U, param: T) = $captured

The reason for such an ordering is that a lambda looks the same as a
local function, and local function can have default arguments, and those
arguments can reference captured variables; thus, captured variables
must come before actual declared arguments.

However, this is not the order that the inliner wants. Moreover, since
it was written to handle lambdas represented as `invoke` methods of
anonymous objects, it does not expect the actual callable method to have
any parameters corresponding to captured variables at all. This results
in it attempting to generate a temporary node with descriptor

    (LE;LU;LT;LU;)LU;

while still using locals 1 and 2 as `param` and `$captured` respectively.
In the example above, this is not critical, as they both have reference
type and the lambda will eventually be pasted into a different node
anyway; however, if it happens that one of them is a primitive, or both
are primitives of different types, the bytecode will use incorrect
instructions, causing verification errors. The correct descriptor is

    (LE;LT;LU;)LU;
2019-11-11 13:46:42 +01:00
pyos 433e0e4740 JVM_IR: remember facade fqnames of imported classes
Necessary to support importing file classes annotated @JvmPackageName,
since the actual package fragment they are a part of has the name from
the `package` declaration.
2019-11-11 13:31:57 +01:00
Natalia Selezneva 42cb53a380 Always apply new script configuration in tests 2019-11-11 15:15:17 +03:00
Natalia Selezneva 423f1909fa Disable script configuration update in AbstractInspectionTest 2019-11-11 15:15:17 +03:00
Sergey Rostov 698d675efe Scripting: fix saving to file attributes 2019-11-11 15:15:17 +03:00
Sergey Rostov 05e8acffa7 Scripting: restore reports for applied configuration in case of previous error 2019-11-11 15:15:17 +03:00
Sergey Rostov 96b4ceb067 scripting: skip loading when reverting to applied configuration 2019-11-11 15:15:17 +03:00
Sergey Rostov 2499c42ac4 scripting: PsiModificationStamp add virtual file modification stamp 2019-11-11 15:15:17 +03:00
Sergey Rostov 789ad23e8d Minor: isScriptDependenciesUpdaterDisabled -> isScriptChangesNotifierDisabled 2019-11-11 15:15:17 +03:00
Sergey Rostov 61b17de625 Minor: change ScriptConfigurationCache.kt declarations order for better readability, more docs 2019-11-11 15:15:16 +03:00
Sergey Rostov fbb2b260dd Split script configuration state into applied and loaded to make markUpToDate more clear 2019-11-11 15:15:16 +03:00
Natalia Selezneva fde1d3fdf7 Wrap exceptions from external script configuration loader with error handling 2019-11-11 15:15:16 +03:00
Natalia Selezneva 56eb86b7c6 Remove KotlinGradleBuildScriptsResolver for IDEA < 191
In 191 there is no method to invoke model building after invocation of some task
2019-11-11 15:15:16 +03:00
Natalia Selezneva 2a22cc23e9 KotlinGradleBuildScriptsResolver: update to new API from IDEA Gradle plugin 2019-11-11 15:15:16 +03:00
Natalia Selezneva 8bb6cf81c5 Extract logic common for different platforms to simplify bunch process 2019-11-11 15:15:16 +03:00
Sergey Rostov e2928550ca Fix retrieving virtual file 2019-11-11 15:15:16 +03:00
Sergey Rostov 9105e38041 Mark not applied configuration as up-to-date, simplify concurrency handling 2019-11-11 15:15:16 +03:00
Sergey Rostov 0422abdb7b LoadedScriptConfiguration and CachedConfigurationSnapshot are merged to ScriptConfigurationSnapshot 2019-11-11 15:15:15 +03:00
Sergey Rostov a89ce4c590 BackgroundExecutor: cancel all tasks on user cancel, remove useless updateProgress call 2019-11-11 15:15:15 +03:00
Sergey Rostov 19d35d7f27 Implement Gradle specific behavior for script configuration update logic
We have plans to extract separate implementation for Gradle scripts, but it
would be better to support something at this point.
For now, we have custom listener, loader and up-to-date check for default configuration manager:
- listener will do forced reload on editor activation, even it is already up-to-date
this is required for Gradle scripts, since it's classpath may depend on other files (`.properties` for example)
- loader will force save failures before running loader. also it will skip loading if
`kotlin.gradle.scripts.useIdeaProjectImport` registry key is enabled
- loader will return inputs with overridden up-to-date checks: file will be considered
out-of-date only when `buildscript` or `plugins` blocks are changed
2019-11-11 15:15:15 +03:00
Natalia Selezneva 548e8e27dc Minor: rename parameter 2019-11-11 15:15:15 +03:00
Natalia Selezneva f0053ee34c Minor: use properties instead of string constants 2019-11-11 15:15:15 +03:00
Sergey Rostov 9d2cc484aa ide, scripting: rework script configuration caching, introduce persistent fs cache
## Simplify ScriptConfigurationManager mental model
Everything related to cache managing moved to `org.jetbrains.kotlin.idea.core.script.configuration`.
DefaultScriptConfigurationManager slitted into:
- `AbstractScriptConfigurationManager`
- `DefaultScriptConfigurationManager`
- `ScriptClassRootsCache`
The main idea is to simplify the mental model of ScriptConfigurationManager.
Concrete implementation should provide just two things:
- `createCache(): ScriptConfigurationCache` that should return cache implementation with `get` and `set` methods
- `reloadOutOfDateConfiguration(...)` will be called on [cache] miss or when [file] is changed.

Implementation should initiate loading of [file]'s script configuration and call [saveChangedConfiguration]
immediately or in some future (e.g. after user will click "apply context" or/and configuration will be
calculated by some background thread).
Everything around it is implemented in `AbstractScriptConfigurationManager`.

`ScriptClassRootsCache` is extracted from `DefaultScriptConfigurationManager`:
this simplifies `AbstractScriptConfigurationManager`
Also it simplifies ScriptClassRootsCache reset: we can just drop old `ScriptClassRootsCache`
and create new one instead of resetting all internals of `ScriptClassRootsCache`.
Please see KDoc of these classes for more details:
- AbstractScriptConfigurationManager
- DefaultScriptConfigurationManager
- ScriptClassRootsCache

## Cache and up-to-date checks
Writer should put related inputs snapshot for loaded configuration.
This allows reader make up-to-date check for existed entry to avoid starting loading
process for same inputs.
Cache entry may be marked out-of-date.
Also it can be marked up-to-date, but it means that we have up-to-date loaded configuration,
ScriptConfigurationSnapshot.configuration will still contain old applied configuration.
todo: make it more clear by splitting cache entry into loaded and applied configuration with
it's own inputs.

## Loaders
Previously both sync and background loaders may be started for same files - this was useful, but not
required anymore and at the same time greatly complicates the model. So, it was dropped
and now exactly one loader should work for given file (first applicable loader will be called).
Also `ScriptConfigurationLoadingContext` is introduced to limit access to the `ScriptConfigurationManager`
internals.

## Listeners and updating configuration
This things is introduces:
- `ScriptChangesNotifier`
- `ScriptChangeListener`
- `ScriptConfigurationUpdater`
`ScriptChangesNotifier` will call first applicable `ScriptChangeListener` when editor is activated or document changed.
(it treated as applicable if [editorActivated] or [documentChanged] will return true).
Listener may call [ScriptConfigurationUpdater] to invalidate configuration and schedule reloading.
Plugins may override default listening logic by adding it's oven `ScriptChangeListener`.
`ScriptConfigurationUpdater` was extracted from `ScriptConfigurationManagerImpl`.

## Fixed issues and implement persistent FS cache
- Script configuration was not reloaded if query for same file already in progress or ready but not yet applied
- Don't start async loaders for outsider files
- Unused imports: don't start loading script configuration if the result will be not applied automatically
- Fix cases when virtual file can be null

See `DefaultScriptConfigurationManager.reloadOutOfDateConfiguration` KDoc for more details on
dealing with concurrent operations.

## Background executor and progress indicator
This things changed and fixed:
- progress displayed not only when we have more then 3 loading tasks, but also
after 1sec of loading (including case with 1 loading task for example)
- current file is displayed under the progress bar
- progress indication added: it works similar to indexing indicator. When
progress bar is displayed, max is fixed. When all work done for this max,
progress will be started from zero and new max is fixed, and so on
- cancel will drop all loading operation, not just current
- concurrency issues fixed: EA-5244265 and other related to switching between silent and
under progress worker
See `BackgroundExecutor` for more details.

## Gradle specific behavior
We have plans to extract separate implementation for Gradle scripts, but it
would be better to support something at this point.
For now, we have custom listener, loader and up-to-date check for default configuration manager:
- listener will do forced reload on editor activation, even it is already up-to-date
this is required for Gradle scripts, since it's classpath may depend on other files (`.properties` for example)
- loader will force save fails before running loader. also it will skip loading if
`kotlin.gradle.scripts.useIdeaProjectImport` registry key is enabled
- loader will return inputs with overridden up-to-date checks: file will be considered
out-of-date only when `buildscript` or `plugins` blocks are changed
2019-11-11 15:15:15 +03:00
Natalia Selezneva 915c9c367c Minor: rename script related classes 2019-11-11 15:15:15 +03:00
Natalia Selezneva 33475f30bc Minor: move files 2019-11-11 15:15:15 +03:00
Sergey Rostov 9f3c2d0292 build.gradle.kts: import script dependencies on Gradle Project sync 2019-11-11 15:15:14 +03:00
Alexander Udalov de54e549af Refactor CHECK_BYTECODE_LISTING directive for JVM IR tests
Create a separate _ir.txt bytecode listing file for JVM IR, to avoid
duplicate tests and to fix "Codegent tests on different JDKs"
configuration where this test is muted but passes because only execution
is checked there, not bytecode listing.
2019-11-11 12:10:31 +01:00
Alexander Udalov ce09be3f59 Add TargetBackend.isIR, simplify JVM IR test configuration 2019-11-11 12:10:29 +01:00
Vladimir Ilmov ab65a6bc6c Build fix, tests regenerated 2019-11-11 12:34:58 +03:00
Sergey Bogolepov 608885d118 [Linker] Extend KotlinIrLinker infrastructure to support libraries that
doesn't contain IR. Also bump ABI version because of addition of `ir_provider` property
2019-11-11 15:55:36 +07:00