Commit Graph

28 Commits

Author SHA1 Message Date
Pavel Kirpichenkov c0dd731818 Load JVM built-ins in IDE from module dependencies
Fix built-ins for JVM platform and make them consistent
with module's dependency on standard library. Changes
don't affect non-JVM platforms.

Previously all built-ins in IDE were loaded from classloader
and were based on the same pre-serialized .kotlin_builtins files.
This approach is generally not correct as built-in declarations
differ for different platforms, but it had been working for a while
without immediately observalble effects (see KT-33233 for more info).
After changes in standard library JvmBuiltins started producing
false errors (see KT-39728).

To fix this, JVM built-ins in IDE now utilize the same technique as
applied in CLI: using dependency on standard library as a module
for built-ins instead of artificial module that considers only
.kotlin_builtins.

Change summary:
- Provide JvmBuiltins with kind FROM_DEPENDENCIES
  for all modules with stdlib dependency in IDE
- Add JvmBuiltinsPackageFragmentProvider to JVM-ish module resolvers
  (JVM and Composite with JVM platform) to support their use as
  built-ins module
- Create KotlinBuiltInsMetadataIndex file index for tracking libraries
  containing .kotlin_builtins to support JvmBuiltinsPackageFragmentProvider
- Create KotlinStdlibIndex file index for tracking kotlin-stdlib(-common),
  which looks for "Kotlin-Runtime-Component" manifest attribute
- Add caching service to track LibraryInfo for kotlin-stdlib(-common)
- Put LibraryInfo for kotlin-stdlib(-common) alongside SDKs
  due to the need to resolve that modules in BuiltInsCache
- Update BuiltInsCache to separate JvmBuiltins by module's dependency
  on stdlib and JDK
- Make platform of KotlinSDK common instead of JVM
- Set built-ins module lazily in IDE

^KT-33233 Verification Pending
2021-01-14 17:28:15 +03:00
Pavel Kirpichenkov 2df4d26b37 Built-ins in IDE: update tests
KT-33233
2021-01-14 17:28:14 +03:00
Alexander Dudinsky 10a5727260 Merge together MultiplatformHighlighting and MultiplatformAnalysis tests
Basically, the former uses an old quickly-scrapped infrastructure,
which were not applicable for HMPP, so  the latter tests were written.

So, both check for one and the same thing (highlighting in MPP projects),
but MultiplatformAnalysisTest is more modern,
and has a lot of inconvenient stuff in MultiplatformHighlighting fixed
^KT-43116 Fixed
2020-12-23 10:47:18 +03:00
Pavel Kirpichenkov b79b94fe75 [MPP] Allow smart casts for properties from dependsOn modules
Smartcasts for public properties from different module are not
stable because module declaring a property in general can be
compiled separately from the module using it. However, if client
module has dependsOn relation with declaring module their simultaneous
compilation is guaranteed which makes this smart cast safe.

Cache all transitive 'expected by' modules in module dependencies.
Extend test to check smart casts are allowed for properties from transitive
'expected by' dependencies and prohibited otherwise.

^KT-42754 Fixed
2020-11-08 15:33:30 +03:00
Pavel Kirpichenkov 778bbd76cb [MPP] Add test for KT-42754 2020-11-08 15:33:30 +03:00
Alexander Dudinsky 84d24e5b76 Migrate MultiplatformAnalysisTest to new test runner 2020-10-27 12:23:50 +03:00
Dmitry Savvinov 01d6181050 Add test on overriding declaration with a composite type with expect declaration 2020-10-09 13:44:06 +03:00
Dmitry Savvinov ac63d8b3bf Unify code for checking return type on override for fun/property
This fixes issues with the refinement of property' return type because
for functions' return type we already perform refinement properly
2020-10-09 13:44:05 +03:00
Dmitry Savvinov 736ecf3e9f Add test case on overriding property of expect-type
Current behaviour is undesired, the fix is in the next commit
2020-10-09 13:44:05 +03:00
Dmitry Savvinov ac107f362e Refine types of type parameters before checking their equality in OverridingUtil 2020-10-09 13:44:05 +03:00
Dmitry Savvinov 80f4061a3d Add test on override with expect in return type 2020-10-09 13:44:04 +03:00
Dmitry Savvinov 5649cbc2e1 Wire KotlinTypeRefiner in areCallableDescriptorsEquivalent
See the issue for details

^KT-41218 Fixed
2020-08-27 18:50:42 +03:00
Dmitry Savvinov 421efaa565 Add test for overload resoultion ambiguity in HMPP
The behaviour is undesired, see the next commit for fix

^KT-41218 In Progress
2020-08-27 18:50:42 +03:00
Dmitry Savvinov 68d931969d Minor: explicitly opt-in for diagnostics messages in MultiplatformAnalysisTests 2020-08-27 18:50:42 +03:00
Mikhail Bogdanov d083297366 Support additional flags in MPP tests. Add diagnostic tests for defaults 2020-07-24 12:10:04 +02:00
Alexey Trilis 593684ecb6 Fix testdata after changing API of kotlin.browser and kotlin.dom 2020-06-24 13:38:29 +03:00
Dmitry Savvinov 8fcd98639d Minor: merge HierarchicalExpectActualMatchingTests into MultiplatformHighlightingTests 2020-03-05 17:27:19 +03:00
Ilya Chernikov 6356807997 Reapply "Only create descriptors for candidates with lambda args"
#KT-36247 fixed
A lot of testdata changed because significanly less (error) descriptors
are created for unresolved types, so diagnostics became different.
2020-02-14 11:41:30 +01:00
Pavel Kirpichenkov 572dee6835 Revert "Only create descriptors for candidates with lambda args"
This reverts commits:
349d07ad43
2249c223fe

Revert due to differences in test data with NI enabled
^KT-36247 Open
2020-02-12 20:52:30 +03:00
Ilya Chernikov 349d07ad43 [minor] Fix testdata after commit "Only create descriptors for candidate"... 2020-02-11 11:20:05 +01:00
Ilya Chernikov 2249c223fe Only create descriptors for candidates with lambda args
#KT-36247 fixed
2020-02-10 14:21:02 +01:00
Denis Zharkov f91db5f0b8 Restore correct overloads ambiguity accidentally removed in 1.3.60
This problem is only relevant when isTypeRefinementEnabled == true (HMPP projects)

Ambiguity accidentally was removed after 471134d
There, for areCallableDescriptorsEquivalent we stopped assuming
as impossible a situation of having identity-different descriptors
in the same containing declaraton that still might be considered equal

So, 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 some of the usages expect that it also makes sure that descriptors
have the same substitution (see org.jetbrains.kotlin.resolve.calls.smartcasts.IdentifierInfo.Variable#equals)

So, the straight solution is using original descriptors for the cases
where we need to make sure that descriptors relates to actually different
declarations

^KT-34027 Fixed
2019-09-30 20:09:42 +03:00
Dmitry Savvinov 9290ec34db Provide proper platformSpecficContainer in CompositePlatformConfigurator
Now, call 'configureDefaultCheckers' and 'configureExtensionsAndCheckers'
from all childs configurators, instead of taking just container from
CommonPlatformAnalyzerServices

This is needed because some IDE services tend to re-create containers
(in particular, PerFileAnalysisCache and ResolveElementCache do that to
re-inject new trace) and use usual injection DSL, which, in particular,
takes 'platformSpecificContainer'.

Returning 'common'-conatiner leads to losing all platform-specific checkers.
On the other hand, calling exactly 'configureDefaultCheckers' +
'configureExtensionsAndCheckers' should be correct, because that's how
single-platform 'platformSpecificContainer' is composed (see
PlatformConfiguratorBase), and in 'createContainerForCompositePlatform'
we don't use 'platformSpecificContainer' anyways

^KT-23305 Fixed
2019-08-13 12:12:29 +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
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
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 c50eeb3edb Add few tests on internal visibility in MPP 2019-07-30 12:41:40 +03:00