Commit Graph

657 Commits

Author SHA1 Message Date
Andrei Klunnyi f45af5ea0e KT-44821 [Sealed Interfaces]: when-exhaustiveness failure in IDE
Compiler check for 'when' exhaustiveness requires that module
descriptors of a sealed class and its inheritors are the same (reference
identity matters). Prior to this commit and under some conditions they
were not. Details follow below.

Resolution related data structures (resolution facades) are organized
into trees (sdks, libs, and modules have their own nodes/facades,
module/class descriptors are stored inside). And the trees themselves
are put into a map associating so called PlatformAnalysisSettings and
GlobalFacades (plays a role of a root). PlatformAnalysisSettings is an
abstraction describing target platform and sdk of a module. The more
combinations exist for a project the more facades are used. Please, see
KotlinCacheService for more details.

So why a module can have multiple ModuleDescriptor-s?
Every tree mentioned above is an isolated resolution environment
containing its own instances of the outer world descriptors. Say, if a
project has modules X, Y, Z and we consider X then all three might have
their own vision of X, i.e. 3 descriptors exist at a time.

What descriptor instance does compiler get?
The path starts when the user opens a file in the editor and
highlighting pass starts (see usages of
ResolutionUtils#analyzeWithAllCompilerChecks). Module descriptor stored
in the resolution tree of the file's module gets injected into the
compiler's context. Starting from this moment compiler sees other
modules through the prism of a single resolution facade (tree).
Descriptors residing outside are alien.

This commit allows IdeSealedClassInheritorsProvider to figure out what
PlatformAnalysisSettings are associated with the resolution facade (read
ModuleDescriptor) seen by the compiler. Later on the same facade is used
to provide correct instances of sealed inheritors back to the compiler.
2021-03-01 12:12:00 +01:00
Ilya Kirillov 91581d6c1a Move KotlinBundle to frontend-independent module
to use from IDEA FIR
2021-02-16 12:16:17 +01:00
Vladimir Dolzhenko 558338f997 Lazy diagnostics API in frontend
Relates to #KT-37702
2021-02-01 13:18:37 +00:00
Vyacheslav Gerasimov 8620d26a8a Delete 193 bunch files 2020-11-11 14:28:53 +03:00
Dmitriy Novozhilov 0484ab8cca Don't unwrap captured types in IDE descriptors renderers
#KT-42263 Fixed
2020-10-21 11:53:42 +03:00
Dmitriy Novozhilov 10fd164b77 Extract FE 1.0 dependent part from JavaToKotlinClassMap
Also move JavaToKotlinClassMap to :core:compiler.common.jvm
2020-09-04 11:07:41 +03:00
Alexander Udalov a21f273570 Fix compiler warnings in compiler code 2020-08-17 21:18:20 +02:00
Pavel Kirpichenkov f431da2a66 Reapply "Introduce @FrontendInternals annotation""
This reverts commit 9ca4717d11.
^KT-39643 Fixed
2020-08-10 12:22:55 +03:00
Pavel Kirpichenkov 9ca4717d11 Revert "Introduce @FrontendInternals annotation"
Revert due to Mobile IDE Trunk IJ TC configuration
This reverts commits:
ffc3d8bdfc
c0e713980b

^KT-39643 In Progress
2020-08-07 12:10:03 +03:00
Pavel Kirpichenkov c0e713980b Add helpers for getting commonly used services without an opt-in
These services are LanguageVersionSettings, DataFlowValueFactory
#KT-39643 Fixed
2020-08-05 21:44:47 +03:00
Pavel Kirpichenkov ffc3d8bdfc Introduce @FrontendInternals annotation
#KT-39643
2020-08-05 21:44:47 +03:00
Ilya Kirillov 606dc2f723 Fix binary compatibility problems in ImportInsertHelper & ShortenReferences 2020-08-04 12:46:13 +03:00
Ilya Kirillov dccac34282 J2K: do not run runUndoTransparentAction outside EDT
#KT-39739 fixed
2020-07-17 16:02:46 +03:00
Vladimir Ilmov a2040f01bf Body elements resolution in KotlinDebuggerCache added / analyzeWithContentAndGetResult
While we trying to find an inlined SourcePosition, the body should be
resolved KotlinPositionManager.getLambdaOrFunIfInside / InlineUtil.isInlinedArgument
to make shure the lambda is an argument for a call.

 #KT-39309 fixed
 #KT-39435 fixed
2020-07-06 11:33:50 +02:00
Nikolay Krasko 21fa2bf98c Switch to 201 platform 2020-06-30 19:53:18 +03:00
Dmitry Gridin 5ad94daaa5 ImportOptimizer: cleanup code
#KT-31331
2020-06-23 09:48:07 +00:00
Dmitry Gridin 4de582564c ImportOptimizer: basic support for removing unresolved imports
#KT-32409 Fixed
Part of #KT-31331
2020-06-23 09:48:05 +00:00
Dmitry Gridin 8faced9192 KotlinImportOptimizer: replace LinkedHashMap with HashMap and BodyResolveMode.FULL with BodyResolveMode.PARTIAL 2020-06-23 09:48:05 +00:00
Dmitry Gridin 383fa2d111 ImportOptimizer: cleanup code 2020-06-23 09:48:04 +00:00
Ilya Chernikov 484d026d2f Optimize resolution scope queries from the synthetic scopes
now required descriptors are queried in advance and passed to the
methods, to avoid multiple same name queries in a row
2020-06-11 16:16:15 +02:00
Ilya Chernikov a0efd1e323 Optimize scopes handling inside ChainedMemberScope 2020-06-11 16:16:15 +02:00
Ilya Chernikov 3da6ff7ec3 Optimize scopes handling inside LexicalChainedScope 2020-06-11 16:16:14 +02:00
Toshiaki Kameyama 957a927790 KT-15846 'Change lambda expression return type' quick fix does nothing (#3182)
* Change parameter type quickfix: fix it works correctly on property delegate

#KT-15846 Fixed

* Change parameter type quickfix: fix it works correctly when function literal has trailing comments

#KT-15846 Fixed
2020-06-11 12:07:44 +03:00
Vladimir Ilmov 4f1b7b38b2 (Resolve) lightweight resolve annotations
relates to #KT-38653
2020-06-05 00:19:16 +02:00
Vladimir Ilmov 47c25982b6 (ResolveElementCache) KtAnnotationEntry resolveToDescriptor added 2020-06-04 14:23:45 +02:00
Pavel Kirpichenkov 7fff8f82e2 Changes after review
- Replace leaking ModuleResolverTracker with use of ModuleDescriptor.Capabilies
- Provide API for retrieving ResolverForProject from ResolutionFacade
- Update names
2020-06-03 20:58:07 +03:00
Nicolay Mitropolsky 8434806f56 Ide-common: resolveToKotlinType moved to TypeUtils.kt in the *ide-common* 2020-05-26 17:39:43 +03:00
gcx11 8849a66c00 KT-10974 - add import layout configuration table 2020-05-25 10:40:24 +03:00
Ilya Kirillov d825428718 New J2K : move resolve resolve out of EDT in shorten references processing
relates to #KT-31812
2020-05-20 11:11:46 +03:00
Dmitry Gridin b2be1a53cf SpecifyTypeExplicitlyIntention: remove annotations from result type
#KT-36930 Fixed
2020-05-19 01:17:39 +00:00
Dmitry Gridin f12ed33a70 AbstractKotlinBundle: introduce withHtml
#KT-37483
2020-03-16 18:40:52 +07:00
Dmitry Gridin 177b7eb024 i18n: fix compilation 192 2020-03-16 18:40:43 +07:00
Dmitry Gridin dd6abec660 i18n: rewrite bundles with AbstractKotlinBundle 2020-03-16 18:40:40 +07:00
Dmitry Gridin d644214251 i18n: add bundle for ide-common 2020-03-16 18:40:40 +07:00
Dmitry Gridin c8c316c379 i18n: introduce AbstractKotlinBundle 2020-03-16 18:40:40 +07:00
Vladimir Dolzhenko 9fdf8530ff Add checkCanceled in loops in KotlinImportOptimizer to avoid freezes
#KT-37301 Fixed
2020-03-16 11:08:19 +00:00
Dmitry Gridin 8dbbd64beb idea: cleanup code 2019-12-17 13:56:48 +07:00
Roman Golyshev 28e2d2faf2 KT-34740 Make getImplicitReceiversWithInstanceToExpression keep script implicit receivers
- This makes completion aware of scripts implicit receivers (it matters in .gradle.kts files, for example)
- ^KT-34740 Fixed
2019-11-22 11:22:46 +03:00
Roman Golyshev be2fe256ba KT-34740 Refactor implicitReceiversUtils.kt 2019-11-22 11:22:46 +03:00
Vyacheslav Gerasimov 3b088818a5 Build: Add sources and javadocs to Kotlin Plugin publication 2019-11-01 16:22:42 +03:00
Vyacheslav Gerasimov 579645bcfa Build: Publish ide-common as separate artifact in KotlinPlugin publication
#KT-34452
2019-11-01 16:22:42 +03:00
Vyacheslav Gerasimov 7401a7c63f Build: Fix dependencies of ide-common
#KT-34452
2019-11-01 16:22:42 +03:00
Vladimir Dolzhenko 34e941f26f Render unresolved types in a presentable way in refactorings
#KT-34459 Fixed
2019-10-21 17:18:24 +02:00
Denis Zharkov 67410f7a57 Parametrize behavior of DescriptorEquivalenceForOverrides::areCallableDescriptorsEquivalent
The changes introduced 471134d31e are only needed
for the case of HMPP project while for other cases it might break the behavior
a bit like in KT-34027

See org.jetbrains.kotlin.resolve.calls.results.OverloadingConflictResolver#filterOutEquivalentCalls

Before 471134d we were comparing
"fun foo(x: String)" with "[substituted] fun foo(x: String)"
and areCallableDescriptorsEquivalent returned false for such case.
Thus, both overrides were left in the resulting set.

After 471134d, those two descriptors
becamed considered as equal thus having a possibility to remove any of them.

The problem is that "areCallableDescriptorsEquivalent" has kind of
unclear contract. Effectively it checks whether two descriptors match
to the same declaration

But straightforward fixing of this exact call-site (using original descriptors)
doesn't help: behavior might change in a very subtle way (see org.jetbrains.kotlin.spec.checkers.DiagnosticsTestSpecGenerated.NotLinked.Dfa.Pos#test72)

So, the main idea is changing the contract for areCallableDescriptorsEquivalent
only when project is HMPP one.

^KT-34027 In Progress
2019-09-30 20:09:42 +03:00
Roman Golyshev b422485440 KT-30996: Use the last receiver to complete dsl methods
- change `detectReceiverTypes` return type to `List` instead of `Collection`
  - it reflects that receiver types are actually ordered
  - did not propagate signature changes to all possible places because it creates too much noise in git history
- ^KT-30996 Fixed
2019-09-13 15:52:52 +03:00
Natalia Selezneva 3f451d7eaf Switch off SAM adapter conversion for constructors in completion
It is very slow in completion for build.gradle.kts because it creates SAM adapters for constructors of all imported classes
Note that those SamAdapters weren't shown in completion in any case because they were filtered by name filter (SamAdapters for constructors have <init> name)
2019-09-06 10:53:16 +03:00
Dmitry Gridin a2f937e282 DescriptorRender: cleanup code 2019-08-01 16:08:45 +03:00
Dmitry Savvinov 54cdd3bfef [Misc] Refactor Module.cached extension to accept lambda instead of FunctionalInterface 2019-07-30 12:41:39 +03:00
Denis Zharkov 21cc93860b [Invariant Fix] Fix KotlinPsiUnifier after types refinement introduction
Refined types with non-trivial substitution may result in different
descriptors instances
See PsiUnifierTestGenerated$Equivalence$Expressions.testArrayAccess
2019-07-30 12:41:38 +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