Commit Graph

109905 Commits

Author SHA1 Message Date
Ivan Kylchik fd961452b3 [K2] Move IRTranslation perf calculation inside convertToIr* methods 2024-03-08 15:58:33 +00:00
Ivan Kylchik 8275c92cd4 [K2] Move Analysis perf calculation inside corresponding fronted runner
This way it is easier to understand where `notifyAnalysis*`
methods were called. Also, in K1, we are not including
`checkKotlinPackageUsageFor*` in the analysis time.
2024-03-08 15:58:33 +00:00
Ivan Kylchik cbda22ab48 [K2] Don't include IRTranslation time as total Generation time
Such behavior is more on par with K1.

#KT-65094 Fixed
2024-03-08 15:58:33 +00:00
Dmitrii Gridin de74ca5902 [FIR] FirLocalVariableAssignmentAnalyzer: do not try to propagate empty information
`recordAssignments` merges properties into all parents which is
redundant work in the case of empty `VariableAssignments`.
This redundant work leads to critically poor performance in cases
with many local declarations.

^KT-66416 Fixed
2024-03-08 15:39:17 +00:00
Nikolay Lunyak 405852980d [FIR] Prohibit is-checks and casts for unrelated nullable types
This decision was made after a discussion
in Slack.
2024-03-08 15:37:45 +00:00
Nikolay Lunyak a4c33ee785 [FIR] Reuse shouldReportAsPerRules1() in FirCastOperatorsChecker
This change better aligns the checker with
the description in KT-57779.

^KT-57779
2024-03-08 15:37:45 +00:00
Nikolay Lunyak 4c0ec0fae4 [FIR] Remove redundant checks from isUpcast() and isExactTypeCast()
`T.() -> R` and `(T) -> R` should only be
different for resolution, but casts are only
about typechecking. Values of either of
these types can always be put into variables
of the other type.
2024-03-08 15:37:45 +00:00
Nikolay Lunyak fbdf7e33bd [FIR] Ensure KT-50293 is no longer a problem
PCLA-related changes led to this change in
behavior. In K1 an explicit cast was needed
to prevent ORA, but now in K2 this code
is green without casts.

^KT-50293 Obsolete
2024-03-08 15:37:45 +00:00
Nikolay Lunyak a5423032a3 [FIR] Remove an always false condition from replaceType()
Otherwise, bootstrapping fails.

This condition is `false` because of
`require(this is ConeKotlinTypeProjection)`,
since `ConeKotlinTypeProjection` is its
sibling, not a subtype.
2024-03-08 15:37:45 +00:00
Nikolay Lunyak 4cdddb1b08 [FIR] Unify checks for is and as 2024-03-08 15:37:44 +00:00
Nikolay Lunyak 88ff93df7f [FIR] Check is for impossibility
^KT-58203 Fixed
^KT-62646
2024-03-08 15:37:44 +00:00
Nikolay Lunyak 92d8da621e [FIR] Merge the two type operator checkers into a single one
This way it's easier to reason about where
useless casts/is checks come from, because
everything is on the same screen.

`USELESS_CAST` disappeared from
`FirPsiJsOldFrontendDiagnosticsTestGenerated.testDynamicCastTarget`
because
`LanguageFeature.EnableDfaWarningsInK2`
is disabled, and previously it only
affected `FirCastOperatorsChecker`, but
not `FirUselessTypeOperationCallChecker`,
which felt like an unintended mistake.
A related issue: KT-50965
2024-03-08 15:37:44 +00:00
Nikolay Lunyak 116ff60325 [FIR] Extract isRefinementUseless() to casting helpers 2024-03-08 15:37:44 +00:00
Nikolay Lunyak fab6cec93a [FIR] Utilize equality compatibility logic for cast checks
This makes it more consistent and fixes some
overlooked corner cases. Also it was decided
on the last equality applicability DM
(KT-62646) that we'd like
`is`/`!is`/`as`/`as?` to work similarly
to `===`/`!==`.

Also note that it now gives a clearer
explaination of why some corner cases work
the way they do. For example,
`FirPsiDiagnosticTestGenerated.testLambdaInLhsOfTypeOperatorCall`
yields `UNCHECKED_CAST` instead of
`CAST_NEVER_SUCCEEDS`, because
`toTypeInfo()` replaces all type arguments
with star projections, even when the argument
is not a type parameter. This is because
it has been desided to work this way in
KT-57779.

In
`FirPsiOldFrontendDiagnosticsTestGenerated..NeverSucceeds#testNoGenericsRelated`
the diagnostic is introduced, because
`t2 as FC1` and `FC1` is a final class with
no `T5` supertype.

`UNCHECKED_CAST` in
`FirPsiOldFrontendDiagnosticsTestGenerated.testSmartCast`
disappeared, because previously we didn't
take smartcasts into account.

Note that
`FirPsiOldFrontendDiagnosticsTestGenerated.testMappedSubtypes`
is a false positive. It appears because `isSubtypeOf()` doesn't
take into account platform types in supertypes of the given types
(doesn't map them).
2024-03-08 15:37:44 +00:00
Nikolay Lunyak a5e43c9e3f [FIR] Remove a strange check from ArgumentInfo.smartCastType
Most probably it was there just to guarantee
that if `argument` is not a smartcast
expression then this property is exactly the
same thing as `originalType`, but it seems
there's not much point in that as none of
the tests fail.
2024-03-08 15:37:44 +00:00
Nikolay Lunyak 5ce3812f39 [FIR] Move some functions from the equality checker into a separate utils file
They will be used later for casts
2024-03-08 15:37:44 +00:00
Nikolay Lunyak cd3202ddd4 [FIR] Map platform types to Kotlin for equality checks
During the DM it was decided to support
such comparisons, if I remember correctly.

^KT-62646
2024-03-08 15:37:44 +00:00
Nikolay Lunyak 6607c8a056 [FIR] Allow Int? === null
It was decided to allow this comparison
duting the last DM.

^KT-62646
2024-03-08 15:37:44 +00:00
Nikolay Lunyak 4abfb2534a [FIR] Add the Int? === null test example
^KT-62646
2024-03-08 15:37:44 +00:00
Nikolay Lunyak a19994b8b6 [FIR] Rename canHaveSubtypes() and lowerThanBound() in K2
`lowerThanBound()` was renamed to:

- draw attention to its corner cases
- make its single usage less cryptic

We may want to reserve the pretty name for
a function that, for example, returns `true`
if `argument` suits all the bounds.

Similarly, `canHaveSubtypes()`
does some questionable logic in case of
`INVARIANTxINVARIANT`: some hypothetical
`Inv<Foo>` doesn't have subtypes so
checking "Foo has subtypes strictly above
Nothing || Foo has supertypes strictly below
the parameter bounds" doesn't seem correct.
`Foo` may have some, but `Inv<them>` are
not related to `Inv<Foo>`.
2024-03-08 15:37:44 +00:00
Nikolay Lunyak bb812add14 [FIR] Don't miss modality of anonymous objects in canHaveSubtypes()
They are not `FirRegularClassSymbol`, but are
final. `FirClassSymbol` is enough, because
`toSymbol()` returns `FirClassifierSymbol`, and:

- type parameters are always expected to have
  subtypes
- typealiases have been expanded in the
  previous line
2024-03-08 15:37:44 +00:00
Nikolay Lunyak 226d4df277 [FIR] Forbid erroneous ===-checks
It was decided to forbid such comparisons,
as we know how `===` works. Also, added some more
test cases, just for comparison.

Reusing the proper `canHaveSubtypes()`
from `TypeUtils` prevents a breaking change
in:

- `comparingTripleWithPair.kt`
- `comparisonOfGenericInterfaceWithGenericClass.kt`

But it does lead to warnings
(instead of errors) in
`incompatibleEnumEntryClasses.kt`, which is an
unrelated mistake that will be fixed in the next
commit.

The refactoring in `canHaveSubtypes()` is purely
cosmetic - otherwise reading these conditions is hard
(and they don't fit my screen vertically).

^KT-62646
^KT-65541
^KT-57779
2024-03-08 15:37:44 +00:00
Brian Norman 6bf987e772 [AllOpen] Do not open members of non-class type classes
The logic of the AllOpen compiler plugin for opening classes and opening
declarations of classes does not match. This leads to declarations being
open when the containing class is not open. There is a warning reported,
for exactly this situation.

However, creating meta-annotations of AllOpen annotation is quite common
in certain ecosystems. In particular, Spring. This can lead to a warning
if the meta-annotation has properties.

Align the class kind check for members, so they are not opened if the
containing class cannot be opened.

^KT-63507 Fixed
2024-03-08 14:55:39 +00:00
Brian Norman bdaacb9427 [AllOpen] Test case to recreate open annotation member warning
The AllOpen compiler plugin opens all declarations of the annotated
class, regardless of class type. However, it only opens classes (not
interfaces, objects, enums, etc). This leads to a warning where members
of an annotation are open when annotated. Spring has many such
annotations, as it is common to create meta-annotations from the core
set of AllOpen supported annotations.

^KT-63507
2024-03-08 14:55:39 +00:00
Anton Lakotka 753e365c9e [Gradle, WASM] Move stability warning to Diagnostics Infra
And report it only once per build, so it doesn't spam users with
multiple projects in the logs.

^KT-66429 Verification Pending
2024-03-08 10:58:12 +00:00
Andrey Yastrebov 08f6e21f5d KT-66225 Add NativeBinary baseName test 2024-03-08 10:46:40 +00:00
Andrey Yastrebov bec832d39f KT-66225 Do not rewrite baseNameProvider in NativeBinary 2024-03-08 10:46:40 +00:00
Ivan Kochurkin ea44d4defd [FIR2IR] Remove non-existent accessors from property references on Java fields
Rename `MissingFieldInJavaClass` to `FieldsFromJavaClass` to correspond its content

^KT-65722 Fixed

Merge-request: KT-MR-14837
2024-03-08 10:10:05 +00:00
Ivan Kochurkin 2d4f4b9bb5 [FIR] Disallow operators not on functions
Introduce `NOT_FUNCTION_AS_OPERATOR` and use it instead of `PROPERTY_AS_OPERATOR`

^KT-65881 Fixed

Merge-request: KT-MR-14547
2024-03-08 10:07:23 +00:00
Alexander Udalov df9d59851d IR: do not use SymbolRemapper in FakeOverrideCopier
It was only used to keep track of mappings from old type/value
parameters to new. We can do it manually instead of inheriting from
DeepCopySymbolRemapper, because the latter does more work than needed,
namely it creates 16 hash maps, and traverses the IR tree looking for
any other declarations.

 #KT-66281
2024-03-07 20:04:38 +00:00
Alexander Udalov 79a224cc0f IR: remove patchDeclarationParents in FakeOverrideCopier
#KT-66281
2024-03-07 20:04:38 +00:00
Alexander Udalov 41a8b02202 IR: do not use DeepCopyIrTreeWithSymbols in FakeOverrideCopier
#KT-66281
2024-03-07 20:04:38 +00:00
Kirill Rakhman 09a19d7dbe [FIR] Support flexible and DNN types in upper bound violated extra message
#KT-66379 Fixed
2024-03-07 16:40:22 +00:00
Brian Norman 926ae2abb8 [PowerAssert] Add Gradle build tools integration tests for Power-Assert
The integration test project was copied from the sample project in
github.com/bnorm/kotlin-power-assert. Original license information has
been preserved even though commit history has not been.

^KT-65951 Fixed
2024-03-07 16:31:18 +00:00
Brian Norman 024c825355 [PowerAssert] Update Power-Assert license information 2024-03-07 16:31:18 +00:00
Vyacheslav Gerasimov 0a60f2924f Build: Introduce limitTestTasksConcurrency build property
Is true by default. It can be used to disable the concurrency limit for
test tasks
2024-03-07 15:53:01 +00:00
Dmitriy Novozhilov 6740a596c7 [Frontend] Provide ProjectExtensionDescriptor for DiagnosticSuppressor
`DiagnosticSuppressor` didn't contain `ProjectExtensionDescriptor`, which
  prevented usages of this extension point with API provided by
  `CompilerPluginRegistrar`

See discussion in KT-60952
2024-03-07 15:33:07 +00:00
Nikolay Lunyak 7f12af9452 [FIR] Ensure KT-66161 is not reproducible in the compiler
^KT-66161


Merge-request: KT-MR-14730
Merged-by: Nikolay Lunyak <Nikolay.Lunyak@jetbrains.com>
2024-03-07 15:10:18 +00:00
Alexander Shabalin aee87468a6 [K/N][tests] Move stress tests into a separate project 2024-03-07 15:01:30 +00:00
Igor Yakovlev 60d425e2c7 [Wasm] Make specialisations for closured primitive values
Fixed KT-66065
2024-03-07 14:51:02 +00:00
Wojciech Litewka 4eba0075bb [IR] Autogenerate IrFileImpl
#KT-65773 In Progress
2024-03-07 14:32:31 +00:00
Wojciech Litewka 2ed0ffd123 [IR] Autogenerate IrExternalPackageFragmentImpl
#KT-65773 In Progress
2024-03-07 14:32:31 +00:00
Wojciech Litewka f92670024e [IR] Autogenerate IrErrorDeclarationImpl 2024-03-07 14:32:31 +00:00
Wojciech Litewka 2b26163030 [IR] Temporarily move to-be-autogenerated files under gen directory 2024-03-07 14:32:31 +00:00
Wojciech Litewka 46162395be [IR] Extract IrFileImpl secondary constructors to functions
#KT-65773 In Progress
2024-03-07 14:32:31 +00:00
Wojciech Litewka 943be239ee [IR] Simplify IrFileImpl and IrExternalPackageFragment
#KT-65773 In Progress
2024-03-07 14:32:31 +00:00
Wojciech Litewka 16ae7651a2 [IR] Simplify IrErrorDeclarationImpl for autogeneration
#KT-65773 In Progress
2024-03-07 14:32:31 +00:00
eugene.levenetc 0a7839a29a [ObjCExport] Fix primary constructor parameter annotation translation
KT-66401
2024-03-07 14:21:03 +00:00
Ilya Chernikov b318566ecf Scripting: temporarely disable compiler plugin test
related to #KT-66395
2024-03-07 13:13:30 +00:00
Dmitrii Gridin 8cc2208c00 [LL FIR] support lazy resolution tests for scripts with custom definition
^KT-66276
^KT-66232
2024-03-07 12:50:59 +00:00