For most of those the behaviour isn't set in stone, though at the moment
of making that commit we're more or less sure that it's reasonable.
Behaviour in some cases might be more strictly enforces (as much as you
can enforce something in esoteric cases with misconfigured project
sturcture). Those are marked with comments with '!'.
Note the behaviour in 'precisePlatformsWithUnrelatedModuleHmpp': it is
incorrect, as set of platforms still contains unrelated platforms.
This is because in the current solution, some source-sets
(commonMain/commonTest) always receive COMMON platform and then it gets
coerced to set of targets actually seen in the project.This helps if
projects uses as much targets as current module (like in
precisePlatformsHmpp), but fails if it uses more targets than the
current module (like in precisePlatformsWithUnrelatedModuleHmppp)
The upcoming commits will fix that issue
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
So far, quick-fix tests infrastructure neither supports the check
for multiple files (several .before/.after pairs) nor multi module
structure. Provided tests are quite limited yet allow to make sure that
the fix in question appears in expected context and get activated.
^KT-44043 fixed
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
A very probable failure that can be reproduced locally:
```
ERROR: While resolving call checkSubtype#<R|kotlin/collections/List<kotlin/Int>?|>(Collections#.emptyList#<R|kotlin/Int|>())
java.lang.RuntimeException: While resolving call checkSubtype#<R|kotlin/collections/List<kotlin/Int>?|>(Collections#.emptyList#<R|kotlin/Int|>())
at org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.FirExpressionsResolveTransformer.transformFunctionCall(FirExpressionsResolveTransformer.kt:282)
at org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.FirBodyResolveTransformer.transformFunctionCall(FirBodyResolveTransformer.kt:114)
at org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.FirBodyResolveTransformer.transformFunctionCall(FirBodyResolveTransformer.kt:30)
at org.jetbrains.kotlin.fir.visitors.FirTransformer.visitFunctionCall(FirTransformer.kt:957)
at org.jetbrains.kotlin.fir.visitors.FirTransformer.visitFunctionCall(FirTransformer.kt:140)
at org.jetbrains.kotlin.fir.expressions.FirFunctionCall.accept(FirFunctionCall.kt:31)
at org.jetbrains.kotlin.fir.FirElement$DefaultImpls.transform(FirElement.kt:29)
at org.jetbrains.kotlin.fir.FirPureAbstractElement.transform(FirPureAbstractElement.kt:11)
at org.jetbrains.kotlin.fir.visitors.FirTransformerUtilKt.transformSingle(FirTransformerUtil.kt:12)
at org.jetbrains.kotlin.fir.declarations.impl.FirPropertyImpl.transformInitializer(FirPropertyImpl.kt:104)
at org.jetbrains.kotlin.fir.declarations.impl.FirPropertyImpl.transformInitializer(FirPropertyImpl.kt:34)
at org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.FirDeclarationsResolveTransformer.transformChildrenWithoutAccessors(FirDeclarationsResolveTransformer.kt:278)
at org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.FirDeclarationsResolveTransformer.access$transformChildrenWithoutAccessors(FirDeclarationsResolveTransformer.kt:42)
at org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.FirDeclarationsResolveTransformer.transformProperty(FirDeclarationsResolveTransformer.kt:132)
at org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.FirBodyResolveTransformer.transformProperty(FirBodyResolveTransformer.kt:254)
at org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.FirImplicitAwareBodyResolveTransformer.access$transformProperty$s1271549241(FirImplicitBodyResolve.kt:116)
at org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.FirImplicitAwareBodyResolveTransformer$transformProperty$1.invoke(FirImplicitBodyResolve.kt:143)
at org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.FirImplicitAwareBodyResolveTransformer$transformProperty$1.invoke(FirImplicitBodyResolve.kt:116)
at org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.FirImplicitAwareBodyResolveTransformer.computeCachedTransformationResult(FirImplicitBodyResolve.kt:169)
at org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.FirImplicitAwareBodyResolveTransformer.transformProperty(FirImplicitBodyResolve.kt:142)
at org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.FirImplicitAwareBodyResolveTransformer.transformProperty(FirImplicitBodyResolve.kt:116)
at org.jetbrains.kotlin.fir.visitors.FirTransformer.visitProperty(FirTransformer.kt:753)
at org.jetbrains.kotlin.fir.visitors.FirTransformer.visitProperty(FirTransformer.kt:140)
at org.jetbrains.kotlin.fir.declarations.FirProperty.accept(FirProperty.kt:53)
at org.jetbrains.kotlin.fir.FirElement$DefaultImpls.transform(FirElement.kt:29)
at org.jetbrains.kotlin.fir.FirPureAbstractElement.transform(FirPureAbstractElement.kt:11)
at org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.FirBodyResolveTransformer.visitNoTransform(FirBodyResolveTransformer.kt:358)
at org.jetbrains.kotlin.idea.fir.low.level.api.trasformers.FirDesignatedImplicitTypesTransformerForIDE.transformDeclarationContent(FirDesignatedImplicitTypesTransformerForIDE.kt:42)
at org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.FirBodyResolveTransformer.transformFile(FirBodyResolveTransformer.kt:66)
at org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.FirBodyResolveTransformer.transformFile(FirBodyResolveTransformer.kt:30)
at org.jetbrains.kotlin.fir.visitors.FirTransformer.visitFile(FirTransformer.kt:801)
at org.jetbrains.kotlin.fir.visitors.FirTransformer.visitFile(FirTransformer.kt:140)
at org.jetbrains.kotlin.fir.declarations.FirFile.accept(FirFile.kt:32)
at org.jetbrains.kotlin.fir.FirElement$DefaultImpls.transform(FirElement.kt:29)
at org.jetbrains.kotlin.fir.FirPureAbstractElement.transform(FirPureAbstractElement.kt:11)
at org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.FirBodyResolveTransformer.visitNoTransform(FirBodyResolveTransformer.kt:358)
at org.jetbrains.kotlin.idea.fir.low.level.api.trasformers.FirDesignatedImplicitTypesTransformerForIDE.transformDeclarationContent(FirDesignatedImplicitTypesTransformerForIDE.kt:42)
at org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.FirBodyResolveTransformer.transformFile(FirBodyResolveTransformer.kt:66)
at org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.FirBodyResolveTransformer.transformFile(FirBodyResolveTransformer.kt:30)
at org.jetbrains.kotlin.fir.visitors.FirTransformer.visitFile(FirTransformer.kt:801)
at org.jetbrains.kotlin.fir.visitors.FirTransformer.visitFile(FirTransformer.kt:140)
at org.jetbrains.kotlin.fir.declarations.FirFile.accept(FirFile.kt:32)
at org.jetbrains.kotlin.fir.FirElement$DefaultImpls.transform(FirElement.kt:29)
at org.jetbrains.kotlin.fir.FirPureAbstractElement.transform(FirPureAbstractElement.kt:11)
at org.jetbrains.kotlin.idea.fir.low.level.api.lazy.resolve.FirLazyDeclarationResolver$runLazyResolvePhase$$inlined$runPhaseWithCustomResolve$3.run(utils.kt:82)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:627)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:572)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:61)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeNonCancelableSection(CoreProgressManager.java:188)
at org.jetbrains.kotlin.idea.fir.low.level.api.lazy.resolve.FirLazyDeclarationResolver.runLazyResolvePhase(FirLazyDeclarationResolver.kt:246)
at org.jetbrains.kotlin.idea.fir.low.level.api.lazy.resolve.FirLazyDeclarationResolver.runLazyResolveWithoutLock(FirLazyDeclarationResolver.kt:127)
at org.jetbrains.kotlin.idea.fir.low.level.api.lazy.resolve.FirLazyDeclarationResolver.lazyResolveDeclaration(FirLazyDeclarationResolver.kt:63)
at org.jetbrains.kotlin.idea.fir.low.level.api.lazy.resolve.FirLazyDeclarationResolver.lazyResolveDeclaration$default(FirLazyDeclarationResolver.kt:39)
at org.jetbrains.kotlin.idea.fir.low.level.api.file.structure.FileStructure.createDeclarationStructure(FileStructure.kt:131)
at org.jetbrains.kotlin.idea.fir.low.level.api.file.structure.FileStructure.createStructureElement(FileStructure.kt:171)
at org.jetbrains.kotlin.idea.fir.low.level.api.file.structure.FileStructure.access$createStructureElement(FileStructure.kt:29)
at org.jetbrains.kotlin.idea.fir.low.level.api.file.structure.FileStructure$getStructureElementForDeclaration$structureElement$1.apply(FileStructure.kt:48)
at org.jetbrains.kotlin.idea.fir.low.level.api.file.structure.FileStructure$getStructureElementForDeclaration$structureElement$1.apply(FileStructure.kt:29)
at java.util.concurrent.ConcurrentHashMap.compute(ConcurrentHashMap.java:1853)
at org.jetbrains.kotlin.idea.fir.low.level.api.file.structure.FileStructure.getStructureElementForDeclaration(FileStructure.kt:46)
at org.jetbrains.kotlin.idea.fir.low.level.api.file.structure.FileStructure.getStructureElementFor(FileStructure.kt:42)
at org.jetbrains.kotlin.idea.fir.low.level.api.file.structure.FileStructure.getAllDiagnosticsForFile(FileStructure.kt:71)
at org.jetbrains.kotlin.idea.fir.low.level.api.diagnostics.DiagnosticsCollector.collectDiagnosticsForFile(DiagnosticsCollector.kt:27)
at org.jetbrains.kotlin.idea.fir.low.level.api.FirModuleResolveStateImpl.collectDiagnosticsForFile$idea_fir_low_level_api(FirModuleResolveStateImpl.kt:63)
at org.jetbrains.kotlin.idea.fir.low.level.api.api.LowLevelFirApiFacade.collectDiagnosticsForFile(LowLevelFirApiFacade.kt:93)
at org.jetbrains.kotlin.idea.frontend.api.fir.components.KtFirDiagnosticProvider.collectDiagnosticsForFile(KtFirDiagnosticProvider.kt:26)
at org.jetbrains.kotlin.idea.frontend.api.KtAnalysisSession.collectDiagnosticsForFile(KtAnalysisSession.kt:63)
at org.jetbrains.kotlin.idea.fir.highlighter.KotlinHighLevelDiagnosticHighlightingPass.doCollectInformation(KotlinHighLevelDiagnosticHighlightingPass.kt:36)
at com.intellij.codeHighlighting.TextEditorHighlightingPass.collectInformation(TextEditorHighlightingPass.java:52)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$null$1(PassExecutorService.java:442)
at com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1106)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$doRun$2(PassExecutorService.java:435)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:627)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:572)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:61)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.doRun(PassExecutorService.java:434)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.lambda$run$0(PassExecutorService.java:410)
at com.intellij.openapi.application.impl.ReadMostlyRWLock.executeByImpatientReader(ReadMostlyRWLock.java:168)
at com.intellij.openapi.application.impl.ApplicationImpl.executeByImpatientReader(ApplicationImpl.java:168)
at com.intellij.codeInsight.daemon.impl.PassExecutorService$ScheduledPass.run(PassExecutorService.java:408)
at com.intellij.concurrency.JobLauncherImpl$VoidForkJoinTask$1.exec(JobLauncherImpl.java:171)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:163)
```
Kotlin compiler can add `@Deprecated` annotations to the fields of
private companion objects, and if those annotations are not supposed to
be shown in decompiled code and used, the field is marked with
`HAS_ANNOTATIONS=false` flag (see KT-25009)
However, it was not taken into account in stubs building process, which
led to the 'Stubs vs PSI mismatch' exceptions
^KT-43205 Fixed
Also, restore the order of nested typealiases and classes (see KT-41859)
We didn't want to bump the version of the stubs when we fixed this
issue; now we have an opportunity to restore the order back to
match the `MemberComparator`
Also, some refactoring is done to underscore that
`createPackageDeclarationsStubs` is suitable only for packages, not
for any declarations container
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