Commit Graph

98816 Commits

Author SHA1 Message Date
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
Denis.Zharkov d84490dcfa K2: Delete failing test for KT-55555
It appeared again after 2b3f34cc52
And still needs some investigation

^KT-55555 Open
2023-02-15 09:17:11 +00:00
Denis.Zharkov 14418a31ac K2: Adjust test data after 9fa0f51a61 2023-02-15 09:17:11 +00:00
Dmitriy Novozhilov b474d12b0a [Build] Exclude :repo:gradle-settings-conventions from JPS compilation 2023-02-15 09:15:45 +00:00
Denis.Zharkov b4b443034f K2: Fix false-positive OVERLOAD_RESOLUTION_AMBIGUITY
It's been introduced in the previous commit
("K2: Simplify handling mixed smartcast vs. original candidates")

Because previously, it was assumed wrongly that each next level of
ConeCallConflictResolver filter out the candidates that are 100% less
applicable/specific, but the main one (ConeOverloadConflictResolver)
either leaves the single candidate or the whole same set, thus at
FilteringOutOriginalInPresenceOfSmartCastConeCallConflictResolver
we've got 4 candidates only two of which we might filter out.
2023-02-15 08:13:57 +00:00
Denis.Zharkov 1e1d122dd3 K2: Simplify ConeConflictResolver hierarchy
Remove AbstractConeCallConflictResolver super class where it's actually
unnecessary
2023-02-15 08:13:56 +00:00
Denis.Zharkov 65f1485dc9 K2: Clarify condition for when-with-one-branch optimization
It's safe resolve the branch in the independent context when
resolution mode would require full completion and there's no expected type
2023-02-15 08:13:56 +00:00
Denis.Zharkov 1bacef4327 K2: Simplify handling mixed smartcast vs. original candidates
There's no real need in binding overrides for smartcast/original members
after FilteringOutOriginalInPresenceOfSmartCastConeCallConflictResolver

Instead, we just create candidates for all of them and filter out after
the ones that came from original type (if needed)
2023-02-15 08:13:55 +00:00
Denis.Zharkov 8fa84e7bea K2: Add clarification comment to KtFakeSourceElementKind 2023-02-15 08:13:55 +00:00
Denis.Zharkov 8ac39dc284 K2: Adjust spec test data behavior with KT-55725
^KT-55725 Related
2023-02-15 08:13:55 +00:00
Denis.Zharkov b6b132a9a3 K2: Avoid false-positive overload resolution ambiguity with smart casts
The idea is that when we have successful candidates both from smart cast
and original type, we should discriminate in the favor of former ones.

While this problem (see kt55722.kt) existed before this branch is merged,
initially it was recognized on FP Ultimate when we stopped assuming
captured types from the same projections as equal (see kt55722Initial.kt).

^KT-55722 Fixed
^KT-55024 Fixed
^KT-56283 Related
^KT-56310 Related
2023-02-15 08:13:54 +00:00
Denis.Zharkov 7b6c6fceb6 K2: Adjust test data for KT-55698
It started being reported after we stopped ignoring diagnostics
on synthetic calls.
2023-02-15 08:13:54 +00:00
Denis.Zharkov a4c5e1bc87 K2: Unwrap fake overrides before using them as DFA identifiers
It's necessary because even for stable a.b.c.d we can't guarantee that
this reference will always point to the same symbol because
different capture type instantiations generate different scopes
with different resulting symbol instances.
2023-02-15 08:13:53 +00:00
Denis.Zharkov 9af3e5704d K2: Do not add extension receiver's constraint twice for references
The job is already done at CheckExtensionReceiver resolution stage
And repeating it might only lead to incorrect errors caused by
double-capture of receiver type that leads to contradiction because
in previous commit we started assuming different capture instantiations
as different types.
2023-02-15 08:13:53 +00:00
Denis.Zharkov 2b3f34cc52 K2: Fix false-positive type equality for different captured types
This is mostly a revert of 2f61a2f56f
There, we erroneously assumed that we may take captured types as equal
if they are based on the same-typed projections.

Each instance of capturing defines its own captured type,
that should not be equal to any other type captured in other place.

Initial motivation was brought by FP Ultimate, where a piece of code
from the new test was found that started working differently after
recent changes.

The most obvious consequence is the change in addAllProjection.fir.kt:
one cannot use an instance as an argument when expected type
is captured type based on the same instance.

Otherwise, it would lead to CCE if we allowed to put arbitrary charsequences
to the list that initially was a MutableList<String>

All other test data changes (but addAllProjection.fir.kt and differentCapturedTypes.kt)
are irrelevant and will be fixed in the subsequent commits
2023-02-15 08:13:52 +00:00
Denis.Zharkov 181f23bd8d K2: Emulate K1 behavior in case of when-elvis combination
^KT-55692 Related
2023-02-15 08:13:51 +00:00
Denis.Zharkov e46ef0bbec Fix FIR bootstrap caused by KT-55281
In this branch it's necessary, because we started reporting diagnostics
that have been ignored before
2023-02-15 08:13:51 +00:00
Denis.Zharkov 2bafcddf7a K2: Avoid using Nothing? as inference result in the majority of cases
Namely, do not choose `Nothing?` result type when fixing a variable
that has other constraints besides the ones that came from
the relevant type parameter's upper bounds.

See more details in KT-55691.

In K1, the case from specialCallWithMaterializeAndExpectedType.kt
was working (inferred to String?) just because the branches
were analyzed independently with `String?` expected type.

This change became necessary after the previous commit when we united
inference subsystems for if/when branches (see motivation there).

NB: For K1, the behavior is left the same, but the code
was refactored a bit.

^KT-55691 Fixed
^KT-56448 Fixed
2023-02-15 08:13:50 +00:00