Commit Graph

42956 Commits

Author SHA1 Message Date
Dmitry Jemerov dc4e673fb1 Initial support for chained call wrapping options
#KT-21529 Fixed
2017-12-11 17:58:02 +01:00
Dmitry Jemerov 1a93d10697 Refactoring: use more specific block type in signatures 2017-12-11 17:58:02 +01:00
Dmitry Jemerov 3233d650c1 Refactoring: cleanup access to code style settings 2017-12-11 17:58:02 +01:00
Dmitry Jemerov ff99b921b7 Refactoring: work with ASTNodes in functional style 2017-12-11 17:58:02 +01:00
Dmitry Jemerov 389729cc50 Option for normal indent in supertype lists
#KT-21527 Fixed
2017-12-11 17:58:02 +01:00
Dmitry Jemerov 67cd4ed17a Don't indent closing parenthesis in conditions
#KT-21485 Fixed
2017-12-11 17:58:02 +01:00
Dmitry Jemerov 26d47a034e Don't indent closing parenthesis of a destructuring declaration
#KT-20758 Fixed
2017-12-11 17:58:02 +01:00
Dmitry Jemerov 4068b3d9b9 Add continuation indent for wrapped type aliases
#KT-21078 Fixed

fixup type alias
2017-12-11 17:58:02 +01:00
Nikolay Krasko 1ada284a03 Better folding for mulitline strings (KT-21441)
#KT-21441 Fixed
2017-12-11 18:28:01 +03:00
Nikolay Krasko ab7ba3ae46 Add exit point highlighting for accessors (KT-21318)
#KT-21318 Fixed
2017-12-11 18:28:00 +03:00
Alexey Andreev 93f8542fc4 JS: serialize location of JsCase/JsDefault
See KT-21699
2017-12-11 17:20:15 +03:00
Alexey Andreev 25e56874c1 JS: readable error when source maps change in IC tests 2017-12-11 17:20:15 +03:00
Alexey Tsvetkov c13b2a6bbc Test incremental recompilation of enum usage in JS 2017-12-11 17:20:14 +03:00
Toshiaki Kameyama 4563cf250d "Add type" quick fix incorrectly processes vararg modifier with primitive type array initializer #KT-21544 Fixed 2017-12-08 15:46:45 +01:00
Dmitry Jemerov 846e50dcaa Wording fix 2017-12-08 15:44:18 +01:00
Toshiaki Kameyama 270b41dc66 KT-13378 Provide ability to configure highlighting for !! in expressions and ? in types 2017-12-08 15:44:18 +01:00
Dmitry Jemerov ab619c5655 Improve wording; mark inspection as cleanup tool 2017-12-08 15:41:22 +01:00
Toshiaki Kameyama 0e2bdf8995 Add inspection to sort modifiers #KT-21560 Fixed 2017-12-08 15:41:22 +01:00
Alexander Udalov 2be7116b0b Deduplicate classpath roots in compiler when -Xbuild-file is used
In kotlin-gradle-plugin, the compiler is invoked with a
K2JVMCompilerArguments instance where both the classpath is set, and the
buildFile is used (containing the same classpath entries in XML).
Previously, the compiler concatenated those two classpaths, which
resulted in duplicated entries, which could slow down compilation. Now,
if buildFile is used, the classpath passed explicitly is ignored
(exactly as, for example, destination ("-d"), which is also stored in
the XML build file).

No test added because there doesn't seem to be any change in
user-visible behavior
2017-12-08 12:07:22 +01:00
Alexander Udalov d65b999c2c Minor, rename variable for clarity 2017-12-08 12:07:22 +01:00
Ilya Gorbunov 0b9830248d Restore original accessor signature as deprecated
The deprecated function is not operator because it covers cases where it was used in explicit form.

#KT-18789
2017-12-07 20:26:53 +03:00
Ilya Gorbunov 7efaa7cabc Allow delegating val properties to out-projected MutableMap
Change generic signature of MutableMap.getValue, use 'out @Exact V' and `V1: V` types instead of single `in V`.
Fix affected IR generation tests.

#KT-18789 Fixed
2017-12-07 20:26:53 +03:00
Mikhail Glukhikh e503c1d411 Suspend call detector: fix delegated properties checking 2017-12-07 15:54:47 +03:00
Mikhail Glukhikh 24bd31457c Has suspend calls: fix suspend iterator case 2017-12-07 15:54:47 +03:00
Mikhail Glukhikh 4404439521 Introduce "redundant suspend" inspection #KT-19103 Fixed 2017-12-07 15:54:47 +03:00
Mikhael Bogdanov edefb45585 Copy sam wrappers during inline
#KT-21671 Fixed
2017-12-07 12:57:43 +01:00
Mikhael Bogdanov 4eb30b6626 Code clean 2017-12-07 12:57:42 +01:00
Mikhail Zarechenskiy d47130eff8 [NI] Don't check type for constants too early to avoid mismatch 2017-12-07 14:18:20 +03:00
Mikhail Zarechenskiy 6c27a49114 [NI] Use effective variance for equal approximated type
It's totally safe from the point of type system and reduces extra `out` projections that can add problems with subtyping
2017-12-07 14:18:17 +03:00
Dmitry Savvinov 874267b79d Report cyclic scopes properly
This commit introduces proper handling of recursion in scopes, which
could occur when some of companion object supertypes are members of
that companion owner:

```
class Container {
  open class Base
  companion object : Base()
}
```

To resolve `Base`, we have to build member scope for `Container`.
In the member scope of `Container`, we see all classifiers from
companion and his supertypes
So, we have to resolve companion objects supertype, which happens to be
`Base` again - therefore, we encounter recursion here.

Previously, we created `ThrowingLexicalScope` for such recursive calls,
but didn't checked for loop explicitly, which lead to a wide variety of
bugs (see https://jetbrains.quip.com/dc5aABhZoaQY and KT-10532).

To report such cyclic declarations properly, we first change
`ThrowingLexicalScope` to `ErrorLexicalScope` -- the main difference is
that latter doesn't throws ISE when someone tries to resolve type in it,
allowing us to report error instead of crashing with exception.

Then, we add additional fake edge in supertypes graph (from
host-class to companion object) which allows us to piggyback on existing
supertypes loops detection mechanism, and report such cycles for user.
2017-12-07 14:14:08 +03:00
Dmitry Savvinov 33f9576dd1 [NI] Turn off KnownTypeParameterSubstitutor for NI
The main consequence of it is that TYPE_MISMATCH range for control
structures became wider.

Also, for extra safety, don't change behaviour of OI.
2017-12-07 14:05:42 +03:00
Denis Zharkov 4ed6928e6b Avoid building stubs in KtFile::getClasses for compiled files
In Gradle, JavaPsiFacade finds Kotlin compiled files as KtFile instances
and tries to obtain classes from them.

And while it returns an empty array anyway, it starts building
unnecessary stub when calling `isScript`
2017-12-07 12:53:33 +03:00
Denis Zharkov 6007d244f3 Optimize LazyJavaAnnotations::isEmpty 2017-12-07 12:53:33 +03:00
Denis Zharkov 07df29dfbf Optimize LazyJavaScope::getPropertyType
Avoid running hasConstantNotNullInitializer for non-primitive fields
2017-12-07 12:53:33 +03:00
Denis Zharkov 5e334550eb Optimize entry point check in UnusedSymbolInspection
It helps to avoid return types calculation for light-class element
2017-12-07 12:53:33 +03:00
Denis Zharkov dd3dbda719 Optimize computation of default excluded import in IDE
Prior to this change, it was rather slow since it would lead
to a ModuleDescriptor::packageFragmentProviderForWholeModuleWithDependencies
computation, that would force the computation of libraries'
dependencies, that actually was the major bottleneck here.

The idea is that we do not need to search through dependencies
of dependencies, but only need contents of one of the modules
direct content.

This commit is made under the assumption that if a module has may see
some runtime parts, than runtime jar should be among its direct
depenencies.
2017-12-07 12:53:33 +03:00
Denis Zharkov 4b96311600 Add faster get*Names overrides in LazyClassMemberScope 2017-12-07 12:53:33 +03:00
Denis Zharkov ac56965a99 Do not force loading all kt-files inside LazyPackageDescriptor constructor
Effectively it leads to all stubs being built for any once used package

The idea is that they only were used for FILE_TO_PACKAGE_FRAGMENT
that is mostly read in backend and rarely in the IDE, so we can replace
its usages with searching through related package-fragments
2017-12-07 12:53:33 +03:00
Denis Zharkov d655c4075c Introduce index for the set of top-level names by package
It should help with actual loading of all the stubs for all declarations
in the package on every access when it's implemented through
`getDeclarations()`
2017-12-07 12:53:33 +03:00
Denis Zharkov ce41b5745a Avoid creating synthetic safe-call nodes when resolving == calls
Each of them leads to a separate synthetic file retained in the memory
2017-12-07 12:53:33 +03:00
Denis Zharkov cc312bcaa2 Avoid creating a separate synthetic file for each default import 2017-12-07 12:53:33 +03:00
Denis Zharkov 2d82cb936e Fix potential memory leak in light-classes
The problem is that they might indirectly retain a reference to an
obsolete ResolverForProject (it becomes outdated after out of block
modification).

The best solution would be to avoid preserving jvm-related diagnostics
(that are only used once to report them when highlighting, and exactly
they retains an obsolete resolve session)

But it seems that this may lead to a deep light-classes refactoring and
the temporary fix is storing diagnostics themselves in a CachedValue
bound to out of block modification tracker. There're no guarantees that
this would help, since CachedValue anyway is based on soft-reference
that is not the first thing GC collects
2017-12-07 12:53:33 +03:00
Denis Zharkov a67598e0c1 Minor. Apply intention for "?: false" -> "== true" in light classes 2017-12-07 12:53:33 +03:00
Denis Zharkov f1cbf21f96 Simplify LazyLightClassDataHolder
- Use only stubs instead of full results in LazyLightClassData
- Store only stubs for inexactStub
2017-12-07 12:53:33 +03:00
Dmitry Savvinov aaee401240 [NI] Minor renaming
Use words 'returnArgument' instead of 'resultArgument' when talking
about values, which can be possibly returned from lambda.

Correct 'addSubsystemForArgument' -> 'addSubsystemFromArgument'
2017-12-07 12:49:56 +03:00
Dmitry Savvinov 30a51af931 [NI] Minor: rename typo KotlinCallDiagnistics.kt -> KotlinCallDiagnostics.kt 2017-12-07 12:49:56 +03:00
Dmitry Savvinov 1ada52968b [NI] Fix KnownTypeParameterSubstitutor for !! 2017-12-07 12:49:56 +03:00
Dmitry Savvinov 15a595749b [NI] Weird testdata change after fixes in ErrorTypes
The issue here is that OI infers correct types for (k, v) destructing
declaration, while NI infers errors for them. That happens because NI
resolves iterator() on nullable 'm', but rightfully reports it as
unsuccessful, while OI somehow manages to resolve it to success (and
thus getting nice expected type, allowing destructing declaration to be
resolved in a proper types).
2017-12-07 12:49:56 +03:00
Dmitry Savvinov ea72c76a37 [NI] Testdata changes after fixes in error types 2017-12-07 12:49:56 +03:00
Dmitry Savvinov 957bbe291d [NI] Don't approximate error types
Previously, we did approximation of error types to Any?/Nothing in some
contexts (e.g. non-local declarations).

There are several reasons why it is not desired:
- OI doesn't approximate ErrorType
- This behaviour is inconsistent with ourselves (i.e. sometimes we *do*
  infer errortype for top-level declaration)
- It causes different digressions from OI in reported diagnostics

This commit turns off error type approximation. It causes large testdata
shift, which is deliberately split into several parts and commited in a
separate commits.
2017-12-07 12:49:56 +03:00