Commit Graph

9603 Commits

Author SHA1 Message Date
Roman Artemev 1cdff7810e [Psi2Ir] Fix Lazy Fake override field
- add comment about problem with DeserializedPropertyDescriptor
2019-09-03 14:21:31 +03:00
Nikolay Krasko 372c6377e8 Remove AstLoadingUtil after removing 182
#KT-33536 Fixed
2019-08-30 12:13:50 +03:00
Vladimir Dolzhenko dd0e296af1 Use KotlinExceptionWithAttachments for ToFromOriginalFileMapper and MainFunctionDetector 2019-08-19 17:55:49 +02:00
Dmitriy Novozhilov 8bf61a12df Minor. Remove UNREACHABLE_CODE slice from BindingContext
There was no reading from that slice, so it is redundant
2019-08-09 09:56:37 +03:00
Mikhail Zarechenskiy 04e57f712e [NI] Introduce feature for passing function references with defaults
Relates to KT-8834, we continue reducing differences between old and new
 inference. Note that as for `SamConversionPerArgument`, this feature
 is enabled in the compiler and not in the IDE to avoid breaking code
 for those users that already enabled new inference in the compiler
2019-08-07 15:58:36 +03:00
Mikhail Zarechenskiy 0219b86d06 [NI] Fix poor performance of recursive types approximation
#KT-32407 Fixed
2019-08-07 15:21:16 +03:00
Mikhail Zarechenskiy 5f76918c90 [NI] Use approximator as a component, don't recreate it during resolve 2019-08-07 15:21:15 +03:00
Jim S 88db93853f Make context available to suppressors
We've found that the BindingContext is necessary for any meaningful suppressor.
This change adds the ability for suppressors to use the BindingContext when available.

Change-Id: I14d8148ef659eca273445bf0638bcdb8c3b21f02
2019-08-07 03:16:24 +03:00
Yan Zhulanow 0a092d6613 Debugger: Fix breakpoint firing in '$suspendImpl' (KT-27645) 2019-08-07 01:15:33 +09:00
Yan Zhulanow 79a5375ad1 Debugger: Fix NPE in CFA during evaluation (KT-32830) 2019-08-07 01:15:32 +09:00
Yan Zhulanow 780c0518e5 Debugger: Disallow breakpoints for @InlineOnly function bodies (KT-32687, KT-24408)
Kotlin compiler strips all debug information for @InlineOnly functions, making them non-debuggable.
This commit disables breakpoints inside @InlineOnly functions to prevent false expectations.
2019-08-07 01:15:28 +09:00
Nikolay Krasko ce3ad8f4da Use kotlin specific OOCB tracker for light classes inner cache
ClassInnerStuffCache from the platform caches everything with platform
OUT_OF_CODE_BLOCK tracker.
2019-08-01 18:16:35 +03:00
Denis Zharkov d042eb2cfb Fix type refinement for qualified expressions
Previously, type for "c.a"-receiver in "c.a.platformFun()"
has not been refined because typechecking of "c.a" doesn't go
through common facade org.jetbrains.kotlin.types.expressions.ExpressionTypingServices#getTypeInfo
where the most of expressions are expected to be type checked.

(see org.jetbrains.kotlin.resolve.calls.CallExpressionResolver#getUnsafeSelectorTypeInfo)
2019-07-30 12:41:41 +03:00
Dmitry Savvinov 2b4d70fcf0 [Resolve] Rewrite how built-ins are created
Under COMPOSITE mode we don't have a globally known way to create
built-ins, instead, we have to create them on per-module basis.

So, in this commit we:

1. Use builtInsProvider: (ModuleInfo) -> KotlinBuiltIns instead of
precomputed builtIns instance, in order to be able to calculate
builtIns on per-module basis

2. Introduce new entity, called BuiltInsCache, which, roughly
speaking, is a map of form ModuleInfo -> KotlinBuiltIns, to prevent
creation of multiple builtInsInstances
NB. Actually, it's of form BuiltInsCacheKey -> KotlinBuiltIns, because
we shouldn't create new builtIns for each module. Also, currently,
each platform has its own BuiltInsCacheKey implementation, because
parameters by which built-ins are created, are a bit different across
different platforms. Ideally, we should eliminate those differences
and they use one concrete implementation as a key.
2019-07-30 12:41:40 +03:00
Dmitry Savvinov 9f2a03947c [Resolve] Compute dependency on SDK properly
Under COMPOSITE resolution mode (see ResolutionModeComponent) we have
no fixed and globally known SDK, instead, for each module we have to
find SDK it it's transitive dependencies.

Currently, this is necessary in order to create proper JvmBuiltIns,
which need dependency on SDK to be present in immediate dependencies.
2019-07-30 12:41:40 +03:00
Dmitry Savvinov f9b8ab3a3a [Resolve] Introduce CompositeResolver
This commit introduces CompositeResolverForModuleFactory, which should
work under so-called "composite resolution mode", where sources of all
all modules are analyzed in one global facade.

This allows to:
- avoid re-analyzation of common sources
- avoid retaining memory for all platforms (which can be very bad as
soon as we'll start distinguishing various flavours of platforms,
especially "flavours" of common platform)
- support running platform-specific checks in common modules (e.g.,
report JVM_PLATFORM_DECLARATION_CLASH if common sources are going to have
it)
- support analysis of shared platform modules, like commonNative

This mode heavily depends on so-called "type refinement" support in the
compiler, which is introduced in other series of commits.

In this commit, CompositeResolver and related codepaths are left unused.
Also, this commit misses several important pieces of logic in
resolvers-setup code, which should be different for CompositeResolver
- computation of 'firstDependency'
- computation of built-ins
- computation of modules owned by facade

They will be covered in the following commits
2019-07-30 12:41:40 +03:00
Dmitry Savvinov b48218e722 [Resolve] Make ResolversForModule less static
As consequence, remove IdePlatformKindTooling.resolverForModule, because
it became more than just field, and it duplicates similar API in
IdePlatformKindResolution anyways
2019-07-30 12:41:40 +03:00
Dmitry Savvinov 68c1a7cedd Use stable order for dependsOn and related diagnostics 2019-07-30 12:41:39 +03:00
Denis Zharkov daa27016ca [Invariant Fix] Adjust DataFlowValue::Identifier for refinement
After refinement is introduced it becomes possible to have a different
descriptors instances for effectively the same descriptors

Also, it accidentally fixes KT-25432 because is caused by a different
version of descriptors created for NewCapturedType

^KT-25432 Fixed
2019-07-30 12:41:38 +03:00
Denis Zharkov 5c2c7e7776 [Invariant fix] Avoid re-resolving declared descriptors in lazy member scopes
It becomes necessary after scopes/types refinement
Without it being applied the code might fail with slice-rewrite errors

KT-32841
2019-07-30 12:41:38 +03:00
Dmitry Savvinov 6c44b6b859 [API Usage] Refine type of lambda's receiver in NI
It's needed because of lambda's receiver is not an expression and
  we can not refine it in usual way in TypingVisitor
2019-07-30 12:41:38 +03:00
Dmitriy Novozhilov 696aea004d [API Usage] Add type refinement for callable references 2019-07-30 12:41:38 +03:00
Denis Zharkov 53334c038f [API Usage] Use refinement in NI 2019-07-30 12:41:37 +03:00
Denis Zharkov b7e011a29b [API Usage] Use type refinements in overrides-related facilities 2019-07-30 12:41:37 +03:00
Denis Zharkov 694f521bfd [API Usage] Refine type for each separate element in ExpressionTypingVisitorDispatcher 2019-07-30 12:41:37 +03:00
Dmitriy Novozhilov a1b52b2f90 [API Usage] Inject Refiner into KotlinTypeChecker, use it for subtyping 2019-07-30 12:41:37 +03:00
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
Dmitry Savvinov fe78e153f7 [Misc] Introduce helper-method 'IntersectionTypeConstructor.createType()' 2019-07-30 12:41:36 +03:00
Dmitriy Novozhilov f026a98403 [Misc] Make NewKotlinTypeChecker non-static 2019-07-30 12:41:36 +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
Yan Zhulanow ccff347ffc Kapt: Attach generated Kotlin sources in 'compilation' mode (KT-32535) 2019-07-26 02:40:32 +09:00
victor.petukhov 60c4eb68ff Add condition for checkNonParenthesizedAnnotationsOnFunctionalType call to except error reporting in stub mode 2019-07-18 17:34:51 +03:00
victor.petukhov 7ee5583c89 Fix error message for non-parenthesized annotations on functional types 2019-07-17 17:02:46 +03:00
victor.petukhov 6a679d86ab Support non-parenthesized annotations on functional types without receiver
^KT-31734 Fixed
2019-07-17 16:18:15 +03:00
Roman Artemev af45e1c5dc [JS BE] Do not produce source mapping for fake KtElement
Fix [KT-26701], [KT-12935]
2019-07-17 10:21:34 +03:00
Alexander Udalov f38e4d618e Support Array::class literal, forbid Array<X>::class on non-JVM
#KT-31230 Fixed
2019-07-16 15:57:26 +02:00
Mikhail Glukhikh eb00af6b96 CFG: mark annotation arguments as "used as expressions" #KT-24596 Fixed
NB: only classes / function / properties annotations are considered here,
not including local declarations and other annotations
2019-07-10 15:10:52 +03:00
Mikhail Glukhikh b24b8bfb28 BindingContextUtils: fix warnings 2019-07-10 15:10:51 +03:00
Mikhail Glukhikh b97f187cf6 ControlFlowInformationProvider: fix warnings 2019-07-10 15:10:51 +03:00
Mikhail Glukhikh 5e94f537ef Refactoring: use isUsedAsExpression instead of USED_AS_EXPRESSION slice 2019-07-10 15:10:51 +03:00
Yan Zhulanow 54f78a2920 Debugger: Remove debugger-related hacks in resolution
Candidate ordering should be the same in ordinary Kotlin code and in evaluated expressions.
With the invention of 'foo_field' syntax, there is no need to do these nasty things any more.
2019-07-08 16:25:16 +09:00
Alexander Udalov 37002748c8 Do not wrap and display cause's message in compiler exceptions
In case the wrapped exception message contains some long text (bytecode,
IR, etc.), it could be displayed several times in the same stack trace,
which significantly worsened the experience of parsing such stack traces
2019-07-05 15:55:01 +02:00
Nikolay Krasko 4f678c8289 Create project service with Kotlin trackers (KT-32364) 2019-07-02 13:59:19 +03:00