Commit Graph

56591 Commits

Author SHA1 Message Date
Mikhail Glukhikh eedebcfe4c FIR lazy resolve: fix test data 2019-07-30 17:42:51 +03:00
Mikhail Glukhikh 869e970bfd FIR resolution API: fix handling of expressions inside imports 2019-07-30 16:28:18 +03:00
Mikhail Glukhikh 14e9404afd FIR (raw / resolution API): set correctly elvis/bang-bang bound PSIs 2019-07-30 16:28:18 +03:00
Mikhail Glukhikh 1f771a2407 FIR resolution API: fix handling of expressions inside secondary ctors 2019-07-30 16:28:18 +03:00
Mikhail Glukhikh 2a69efba8a FIR resolution API: fix handling of expressions inside local functions 2019-07-30 16:28:18 +03:00
Mikhail Glukhikh 760fb668bb Introduce FIR resolution API with lazy resolve to use in IDE
Now lazy resolve atomic element is a file (declaration-level resolve)
or a callable declaration (expression-level resolve)

#KT-24351 In Progress
2019-07-30 16:28:17 +03:00
Mikhail Glukhikh 1cd559a626 Remove FirTotalKotlinResolveInIde test with its provider as obsolete 2019-07-30 16:28:17 +03:00
Mikhail Glukhikh c3a31dcdf5 Optimize FirSession component storage 2019-07-30 16:28:17 +03:00
Mikhail Glukhikh 7529d557fe FIR resolution: introduce FirResolvePhase & FirAbstractPhaseTransformer
The phase determines which transformers were already applied to declaration.
The transformer controls current resolve phase in phasedFir and
performs additional resolve if necessary.
2019-07-30 16:28:17 +03:00
Mikhail Glukhikh a38b4756b5 FIR tree refactoring: move FirElement.session to FirDeclaration
#KT-30275 Fixed
2019-07-30 16:28:16 +03:00
Dmitriy Novozhilov 98f75669a5 [FIR] Make resolution sequence of CallKind static field 2019-07-30 16:28:16 +03:00
Dmitriy Novozhilov 53404e5dac [FIR] Extract ResolutionStageRunner component
That component is responsible to run all resolution stages on candidate
  and calculating resulting applicability.

This is needed for completion of `when` and `try` as function calls
2019-07-30 16:28:16 +03:00
Dmitriy Novozhilov 8bbb60df25 [FIR] Refactoring. Split CallResolver.kt to several files 2019-07-30 16:28:15 +03:00
Dmitriy Novozhilov 3c7b25b8c9 [FIR] Minor. Cleanup code in ConeTypes.kt 2019-07-30 16:28:15 +03:00
Dmitriy Novozhilov a226e40e34 [FIR] Refactor FirResolveBodyTransformer
Extract from it components responsible for call completion,
  call resolution and resolution of FQN
2019-07-30 16:28:15 +03:00
Dmitriy Novozhilov 43e7f54fae [FIR] Add string representation for ConeKotlinType
`ConeKotlinType.render` moved from `tree` module to `types` module
2019-07-30 16:28:15 +03:00
Dmitriy Novozhilov 6c26fc1943 [FIR] Don't render Any? upper bounds of type parameters 2019-07-30 16:28:14 +03:00
Dmitriy Novozhilov 7245475196 [FIR] Add DeclaredUpperBoundConstraintPosition to Fir 2019-07-30 16:28:14 +03:00
Dmitriy Novozhilov d3670d4f5f [FIR] Add Any? as default bound for all type parameters 2019-07-30 16:28:14 +03:00
Dmitriy Novozhilov 8a21785883 [FIR] Add Any? builtin typeref 2019-07-30 16:28:14 +03:00
Dmitriy Novozhilov 2a360272f6 [FIR] Add Any to supertypes of functional types 2019-07-30 16:28:14 +03:00
Dmitriy Novozhilov 71ca1aa608 [Type system] Fix algorithm of folding recursive types
There was a problem when we get type from type projection even if
  it is a star projection what is meaningless. Now we try to fold argument
  only if it's not a star projection
2019-07-30 16:28:13 +03:00
Dmitriy Novozhilov a453ed50fa [FIR] Fix class cast exception in ConeInferenceContext 2019-07-30 16:28:13 +03:00
Dmitriy Novozhilov 6215662e33 Replace usage of ClassicTCContext with abstract context in NewCSTCalculator 2019-07-30 16:28:13 +03:00
Andrey Uskov 0276a6262f Fix compilation of NewMultiplatformKaptProjectImportingTest in AS 3.3,3.4 2019-07-30 14:34:36 +03:00
Dmitry Savvinov 6177b3e8dc Minor. Add empty file to previously empty directory in test
Otherwise Git doesn't commit empty folder into repository and test fails
later with "invalid directory exception"
2019-07-30 14:19:02 +03:00
pyos d715344639 psi2ir: precompute sort keys when generating members
On kotlinx.serialization, this improves the performace of the compiler
with -Xuse-ir by about 5% (average of 30 runs after 10 warmup runs:
3096 ms -> 2970 ms, minimum: 3037 ms -> 2884 ms). Flamegraphs for
comparison (careful, huge SVG images):

https://drive.google.com/open?id=1BlIFN4ivSKrXjY6vZ0xkZymwucGc7bSI
https://drive.google.com/open?id=1xIW2IvW7LMCaAe4P2dOGOG8nCcpWI9PW
2019-07-30 12:07:12 +02:00
Vladimir Dolzhenko 2d5a1e19d0 Perform GC between performance test runs, add geometric mean calculation and close stats in the end 2019-07-30 11:59:33 +02:00
Vladimir Dolzhenko 3f9480e1c5 Specify parent disposable in JavaOutsideModuleDetector Vfs listener 2019-07-30 11:59:22 +02:00
Dmitry Savvinov ddb685a8f9 Add test on nonMPP -> MPP dependency 2019-07-30 12:41:41 +03:00
Dmitry Savvinov 79313037d1 Minor. Merge multiplatformTypeRefinement testdata with multiplatform testdata 2019-07-30 12:41:41 +03:00
Dmitriy Novozhilov 9f90486893 [Misc] Update spec testData according changes in NI 2019-07-30 12:41:41 +03:00
Denis Zharkov ffaca279bc Minor. Turn TypeBasedStarProjectionImpl into StarProjectionForAbsentTypeParameter
It's needed to avoid abusing of the class
Star projections should be created based on the relevant type parameter
whenever it's possible
2019-07-30 12:41:41 +03:00
Denis Zharkov 579838cb4e Avoid recursive refinement in NewCapturedTypeConstructor
Potentially, it might contain infinite recursive supertypes
And for such cases, we have to perform lazy refinement (one level per request)
2019-07-30 12:41:41 +03:00
Denis Zharkov a2a1c7e50f Avoid recursive refinement with star projections
Otherwise StackOverflowError or recursion-detection in LockBasedStorageManager
may happen

It's fine to have non-refined type there because it only can affect
content of containing type member scope that should be refined after
being requested
2019-07-30 12:41:41 +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 6695ddd1d5 Change 'hashCode' of 'TypeProjection'
according to bug when there was exception in
`hashCode` call when projection has some `SpecialType`
like `NO_EXPECTED_TYPE`
2019-07-30 12:41:41 +03:00
Dmitry Savvinov b103f42ca8 Add test on using correct builtins in MPP
Note that Native built-ins are not resolved correctly in this module
(CPointed and similar). This is not a bug, but rather a technical
limitation of the current testing infrastructure: we can't depend on
kotlin-native stdlib in "big-Kotlin" repo, and native stdlib is used as
the only one source of Native built-ins.
2019-07-30 12:41:41 +03:00
Dmitry Savvinov 1fe8e4ba15 Use CompositeResolve in HierarchicalExpectActual tests 2019-07-30 12:41:41 +03:00
Dmitry Savvinov aaf76a0e46 Enable TypeRefinement in COMPOSITE resolution mode 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 02c07a4a6c [Resolve] Introduce an ability to get all moduleInfos without filtering by platform
Previously, each ProjectResolutionFacade was tied to the respective
platform, so there were no point in collection moduleInfos for all
possible platforms.

For composite resolution mode, we have to get all modules no matter
what their platform is (because all modules will be analyzed in one
facade), so this commit adds such an ability.
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 adb0f5eaf9 [Resolve] Introduce CompositeAnalysisSettings
Because we want to support both COMPOSITE and SEPARATE resolution modes
at once, we have to leave 'globalFacadesPerPlatformAndSdk'-map, but in
COMPOSITE mode it should use less parameters for that map, and, in
particular, we shouldn't use Platform and SDK for equality.

This commit introduces separate instance which should be used in
COMPOSITE mode.

COMPOSITE mode itself will be introduced in the following commits.
2019-07-30 12:41:40 +03:00
Dmitry Savvinov 5e95890028 [Resolve] Introduce KotlinMultiplatformAnalysisModeComponent
Introduce a component which tells which resolution mode should be used.

COMPOSITE mode will analyze all sources for all platforms in one facade,
and will use proper support in the frontend instead of
CombinedModuleInfo.

SEPARATE mode is essentially a "legacy" mode, where each platform is
analyzed in separate facade (leading, in particular, to multiple
re-analyzation of common sources)

Facilities for support of COMPOSITE mode will be introduced in the
following commits.

resolution component
2019-07-30 12:41:40 +03:00
Dmitry Savvinov 90cf9daff3 [Resolve] Abstract creation of platform-specific package fragment providers 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 0f56d243cb [Resolve] Support test/production/dependsOn internal-visibility 2019-07-30 12:41:40 +03:00
Dmitry Savvinov c50eeb3edb Add few tests on internal visibility in MPP 2019-07-30 12:41:40 +03:00