Commit Graph

98833 Commits

Author SHA1 Message Date
Nikolay Lunyak 3c36a4fabd [FIR] KT-56665: Filter-out valid cycles
^KT-56665 Fixed

Merge-request: KT-MR-8861
Merged-by: Nikolay Lunyak <Nikolay.Lunyak@jetbrains.com>
2023-02-16 17:48:38 +00:00
Ilya Kirillov c60fd38e05 [LL FIR] allow recursive access to the same FirThreadSafeCache
^KT-56721 fixed
2023-02-16 17:42:29 +00:00
Egor Kulikov d670e5a695 [FIR] Do not get expressions from contract effect list in lazy mode
Eleventh step for ^KT-52615
2023-02-16 17:18:10 +00:00
Leonid Startsev c564dd973b Add declarations from serialization plugin to FIR metadata declarations provider.
These declarations should not be visible to users (and therefore are not added to FIR),
but plugin itself can reference them in already compiled serializable classes,
and therefore they should be available in metadata:

- synthetic deserialization constructor
- static write$Self function

See also:
^KT-55885
2023-02-16 15:36:18 +00:00
Leonid Startsev 8953b25c5b Improve documentation for FIR builders 2023-02-16 15:36:18 +00:00
Sebastian Sellmair 1cce57b50b [Gradle] KT-56712: Add assertions for ide dependencies
^KT-56712 Verification Pending
2023-02-16 13:51:10 +00:00
Sebastian Sellmair b83a490034 [Gradle] MppDependencyProjectStructureMetadataExtractorFactory: Cache on rootProject...
Because composite builds might have isolated classloaders,
therefore caching the MppDependencyProjectStructureMetadataExtractorFactory
on a compositeBuildRoot will lead to ClassCastExceptions

^KT-56712 Verification Pending
2023-02-16 13:51:10 +00:00
Sebastian Sellmair 70a44ccc67 [Gradle] ExtraPropertiesExtension.getOrPut: Use castIsolatedKotlinPluginClassLoaderAware
To provide better error messages for users when this function
fails due to isolated classpaths

... for KT-56712
2023-02-16 13:51:10 +00:00
Sebastian Sellmair 45a99d197a [MPP] MppCompositeBuildIT: Implement sample6-KT-56712-umbrella-composite test
... for KT-56712
2023-02-16 13:51:09 +00:00
Pavel Punegov 83d1de56bf [K/N][build] Add coroutines dependency for bootstrap test
Bootstrap test builds compileKotlin that fails to resolve
coroutines.
2023-02-16 11:56:35 +00:00
Pavel Punegov cc258934c4 [K/N][build] Cleanup obsolete build tasks
* Remove obsolete reporting
* Remove old build tasks: BuildPusher and CollisionDetector
* Gradle build file cleanup
* Remove old wrappers

Merge-request: KT-MR-8788
Merged-by: Pavel Punegov <Pavel.Punegov@jetbrains.com>
(cherry picked from commit a9cae3fe87)
2023-02-16 11:56:34 +00:00
Alexander Udalov 0e767a7020 Log Kotlin compiler classpath with File.pathSeparator in Gradle
To make it easier to copy-paste it to run the compiler outside of
Gradle.
2023-02-16 11:29:30 +00:00
Alexander.Likhachev 0ab8d07e23 [Gradle] Don't trigger all root project properties evaluation on FUS report
`Project.properties` triggers all the properties computation to return them as `Map`. We should query only for a required property instead.
#KT-56421 Fixed
2023-02-16 11:25:27 +00:00
Marco Pennekamp 5d391bc261 [FIR] KT-56505 Fix checkVisibilityModifier taking wrong modifier list
- KT-56505 occurred because `source.getChild(KtNodeTypes.MODIFIER_LIST)`
  returns any modifier list in the subtree of the source element, not
  necessarily the modifier list belonging to the checked element.
  `depth = 1` restricts the search to the modifier list belonging to the
  checked element itself.
- For example, given `f1` from KT-56505, `getChild` would return the
  modifier list of `public var foo = 0`. Because it contains a
  visibility modifier, `f1` wasn't marked with
  `NO_EXPLICIT_VISIBILITY_IN_API_MODE`.

^KT-56505 fixed
2023-02-16 10:50:48 +00:00
Marco Pennekamp e86c877733 [FIR] Explicit API mode: No REDUNDANT_VISIBILITY_MODIFIER for public
- In explicit API mode, the `public` visibility modifier is not
  redundant unless a declaration is hidden by a container. The
  `REDUNDANT_VISIBILITY_MODIFIER` diagnostic is now not reported in such
  cases.

^KTIJ-24485 fixed
2023-02-16 10:50:48 +00:00
Marco Pennekamp 5909b191a5 [FIR] KT-54507 Report REDUNDANT_MODALITY_MODIFIER for open interface
- `REDUNDANT_MODIFIER_FOR_TARGET` is already reported for `open`
  interfaces, but for consistency and IDE support, the compiler now
  reports `REDUNDANT_MODALITY_MODIFIER` as well via the extended
  checker.
- `REDUNDANT_MODIFIER_FOR_TARGET` cannot be disabled for this case
  because it's reported via a basic checker while
  `REDUNDANT_MODALITY_MODIFIER` is reported via an extended checker.
- Rename `implicitModality` to `redundantModalities` and return a set of
  modalities. The idea of a *single* implicit/redundant modality doesn't
  stand up to scrutiny. For example, for interfaces with `ABSTRACT`
  implicit modality, `OPEN` is also a redundant modifier. But this is
  not necessarily the case for all kinds of declarations.
  Hypothetically, if it was possible to declare a class that is abstract
  by default, adding an `open` modifier to that class would not be
  redundant, as it would make the class instantiable.
2023-02-16 10:50:48 +00:00
Alexander.Likhachev 76ca96d2e2 [Gradle, JS] Apply module name setup regardless of enabled stats
#KT-56705 Fixed
2023-02-16 10:29:23 +00:00
Dmitriy Novozhilov bdf8e6f3a5 [FIR] Extend capacity of ArrayMapImpl until it fits required size
There are cases when we have some indices in TypeRegistry left from
  previous compilations, so registering new service may increase index
  not by one
So such situation is possible:
First compilation (jvm project): register 20 different jvm services in
  session + one from compiler plugin (with index 21)
Second compilation (common project): register only 10 common services in
  session + one from compiler plugin (with index 21)
*numbers are imaginary

And in this situation increasing `ArrayMapImpl.data` size only one time
  may not cover required index

^KT-56685 Fixed
2023-02-16 10:25:20 +00:00
Ilya Chernikov 27db8ce1bb FIR LT: extract syntax diagnostic info from error element
#KT-56701 fixed
2023-02-16 10:21:04 +00:00
Ilya Chernikov e39eb62e6e FIR LT: Fix diagnostic location calculation on the last line
it was calculated incorrectly on the last line that do not end
with EOL.
#KT-56649 fixed
2023-02-16 10:21:03 +00:00
Roman Efremov d120d83d60 Fix navigation in IDE to synthetic methods in compiled Kotlin
For some synthetic methods from compiled Kotlin classes, it is
not possible to find the PsiElement, when navigating to declaration
in the IDE.

For other methods it works like this:
1. There is a SourceElement with a psi inside
2. Or for K1, the element is searched in the decompiled text
   (see ByDescriptorIndexer),
3. Or for K2, the element is searched by Stub taken from metadata
   (see FirDeserializedDeclarationSourceProvider)

However, these approaches do not apply to synthetic methods which have
no SourceElement and are not written into decompiled text and metadata.

These are methods values, valueOf, entries from enum and
copy, equals, hashCode, toString from data classes.

Therefore, it was decided to handle their cases separately
at the resolve stage.

Tests (in idea repository):
- org.jetbrains.kotlin.idea.resolve.ReferenceResolveWithLibTestGenerated#testDataClassSyntheticMethods
- org.jetbrains.kotlin.idea.resolve.ReferenceResolveWithLibTestGenerated#testEnumSyntheticMethods
- org.jetbrains.kotlin.idea.fir.resolve.FirReferenceResolveWithLibTestGenerated#testDataClassSyntheticMethods
- org.jetbrains.kotlin.idea.fir.resolve.FirReferenceResolveWithLibTestGenerated#testEnumSyntheticMethods

^KTIJ-24413 Fixed
2023-02-15 19:56:08 +00:00
Aleksei.Cherepanov f640a7be2e Add the possibility to mute Gradle IC tests by folder
If you need to mute a test for Gradle IC, the only way is to add exclude pattern and regenerate tests aka remove unnecessary tests. But the filter is absolute, so if you have the same test name in different subfolders (e.g. `pureKotlin/classRemoved/` and `classHierarchyAffected/classRemoved`) you cannot disable only one of them. This commit adds logic to specify which name pattern in which subfolder should be excluded
2023-02-15 18:33:27 +00:00
Vladimir Sukharev 1c055b3b23 Use proper way to remove Windows \r char for LF(EOL)
Merge-request: KT-MR-8850
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-02-15 18:08:08 +00:00
Dmitriy Novozhilov 81c1014391 Advance bootstrap to 1.9.0-dev-1777 2023-02-15 16:35:15 +00:00
Jérôme Prinet 24d39ec815 Add task dependency from kotlin-compiler:sourcesJar to :compiler:ir.tree:generateTree
This allows cache hits for `:kotlin-compiler:sourcesJar`

#5094
2023-02-15 17:09:23 +01:00
Justin Paupore fa517180b7 [AA-FIR] Add support for constant evaluation of string templates.
Support FirStringConcatenationCall in FirCompileTimeConstantEvaluator.
This allows string templates ("foo${bar}") to be evaluated as constants,
assuming the interpolated expressions are themselves constant.

In addition, fixes some handling bugs with KtConstantEvaluationMode,
where some expressions that are not valid in a `const val` declaration
were being supported for `CONSTANT_EXPRESSION_EVALUATION`, including
non-static final Java fields in FIR, and composite expressions of
non-const properties in FE1.0.
2023-02-15 16:45:22 +01:00
Simon Ogorodnik 0193c83b05 Modularized tests. Remove obsolete parameters from run configurations
^KT-56075
2023-02-15 15:43:31 +00:00
Simon Ogorodnik a69bc5939f Modularized tests. Remove obsolete PassEventReporter
^KT-56075
2023-02-15 15:43:31 +00:00
Simon Ogorodnik 8a0f3c4f1c Modularized tests. Remove use of -Xuse-k2 argument in FP test
Use just language version to configure frontend, as -Xuse-k2 flag
is deprecated

^KT-56075
2023-02-15 15:43:31 +00:00
Simon Ogorodnik 6ffd3ed970 Modularized tests. Support configuring known compiler plugins in FP test
Construct compiler plugins classpath based on original
compiler arguments
Support of plugins in full pipeline test allows us to test projects
where some common compiler plugins are used without excluding modules

^KT-56075
2023-02-15 15:43:30 +00:00
Simon Ogorodnik 59e69481a3 Modularized tests. Support parsing of original compiler arguments
Now testData contains info about original compiler arguments, which can
be reused to support plugins and various other arguments

Support original arguments in modularized tests
- Properly support JDK9 modules
- Opt-ins from original arguments
- jdkHome from module data or arguments, as well as noJdk option
- Fix friendPaths not configured
- jvmDefault now handled properly

^KT-56075
^KT-55879
2023-02-15 15:43:30 +00:00
Simon Ogorodnik 36c3d62ba1 Modularized tests. Fix java source scope for light tree mode
We should use appropriate java source scope for java files,
not kotlin files

^KT-56075
2023-02-15 15:43:30 +00:00
Simon Ogorodnik 233469d249 Modularized tests. Extract common arguments for full-pipeline tests
^KT-56075
2023-02-15 15:43:29 +00:00
Simon Ogorodnik 780fe4848f Modularized tests. Migrate to JDOM for model loading
Previously org.w3c was used
In order to reuse intellij serialization migrate to JDOM

^KT-56075
2023-02-15 15:43:29 +00:00
Simon Ogorodnik f54453950e Modularized tests. Extract common class for FE1/FIR tests
^KT-56075
2023-02-15 15:43:28 +00:00
Simon Ogorodnik 52890ca601 K2 Tests: Add rendering of FirSmartCastExpression in html dump
Previously it was just skipped
2023-02-15 15:43:28 +00:00
Simon Ogorodnik 7c8fffbb3d Modularized tests. Enable renderInternalDiagnosticNames for K1
^KT-56075
2023-02-15 15:43:28 +00:00
Simon Ogorodnik 83ead8fb6f Modularized tests. Remove obsolete use_build_file switch
^KT-56075
2023-02-15 15:43:27 +00:00
Simon Ogorodnik 1bb5635570 Modularized tests. Force noStdlib and noReflect in full-pipeline tests
In fact, test-data classpath contains references to stdlib and reflect
already
In order to avoid duplicating libraries on classpath set flags
accordingly

^KT-56075
2023-02-15 15:43:27 +00:00
Pavel Kirpichenkov 317b9d28e0 [MPP] Use correct name for resolved K/N distribution libraries for IDE
KT-56671
2023-02-15 14:19:54 +00:00
Vladimir Sukharev b61a02db73 [K/N] Update degrade script
Merge-request: KT-MR-8690
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-02-15 14:06:52 +00:00
Ilmir Usmanov b262070922 JVM IR: Copy type parameters from outer class to suspendImpl
Previously we copied only type parameters from containing class, but we
need to do that for outer classes as well.
 #KT-55125
2023-02-15 13:43:24 +00:00
Leonid Startsev 5cd817955b Actualize README.md for kotlinx-serialization plugin 2023-02-15 13:39:58 +00:00
Alexander Korepanov 43cef114c6 [Compiler CLI] Sort flags and features before appending them to string
JS IR BE incremental compilation infrastructure uses
 LanguageVersionSettings::toString method to detect if any
 compiler features or flags were enabled or disabled.
 It is important that the features and flags order are stable
 in the result string.

^KT-56580 Fixed
2023-02-15 13:24:11 +00:00
Svyatoslav Scherbina df450ac43c [K/N][tests] Add pre-release check tests 2023-02-15 12:26:56 +00:00
Svyatoslav Scherbina ac95ca12cf [K/N][tests] Support running the compiler without altering its output 2023-02-15 12:26:55 +00:00
Svyatoslav Scherbina e0c7d72cee [K/N][tests] Remove -Xskip-prerelease-check flag
The flag is not necessary and doesn't allow meaningfully testing
pre-release checks.
2023-02-15 12:26:55 +00:00
Leonid Startsev 4b524b8589 Document that read/write methods may throw IAE and make sure this is true:
- Replace !! with requireNotNull()
- Add try/catch to wrap all other exceptions (mainly protobuf parser ones)
- Add tests for malformed input for both read and write
- Hide InconsistentMetadataException from public API
- Replace its external usages with IllegalArgumentException
2023-02-15 11:21:43 +00:00
Leonid Startsev 64838d5ec9 Extract separate ArrayKClassValue from KClassValue
Remove `data` from KmAnnotation
2023-02-15 11:21:43 +00:00
Kirill Rakhman 7f8dc56d36 [FIR2IR] Don't generate fake overrides for clashing synthetic properties
If a synthetic prop clashes with a real property (e.g. @JvmField
property from parent Kotlin class), don't generate fake override for the
synthetic property. This fixes a CONFLICTING_INHERITED_JVM_DECLARATIONS
error in a mixed hierarchy.

^KT-56538 Fixed
2023-02-15 10:10:31 +00:00