1979 Commits

Author SHA1 Message Date
Wojciech Litewka 6af930fc0e Partially revert "[IR] Hide constructors of implementation classes behind factory functions"
To restore binary compatibility with a compiler plugin used in
one of user projects.

#KT-66636 Fixed
2024-03-18 12:17:52 +00:00
Wojciech Litewka fae50f1258 [tree generator] Drop deprecated IrPackageFragment.fqName 2024-03-14 17:07:02 +00:00
Wojciech Litewka c1266daf73 [tree generator] Remove AbstractField.defaultValueInBase
It is now unneeded, and future needs should be possible to
be resolved otherwise.
Removing it will simplify further changes to tree generator,
especially for IR.
2024-03-14 17:07:02 +00:00
Wojciech Litewka 6b9a671476 [IR] Minor: Specify IrPackageFragment.fqName literally in IrTree
It is not a real field, only a compatibility facade for another one.
Needed for the next commit.
2024-03-14 17:07:02 +00:00
Wojciech Litewka 5e9c3025bb [IR] Move IrValueDeclaration.isAssignable to extension property
to remove custom logic from generated classes, in particular
to simplify source generator itself.
2024-03-14 17:07:02 +00:00
Wojciech Litewka b032e647f7 [IR] Move assert in IrSetValueImpl to factory function
#KT-65773 In Progress
2024-03-14 10:41:52 +00:00
Wojciech Litewka 62f546ca0c [IR] Hide constructors of implementation classes behind factory functions
This is a step towards generating those classes. The code generator
won't care about default values in parameters,
and secondly, it will reorder some constructor parameters.
To keep source compatibility, new factory functions are created,
with the same signature as the constructor.
They will resist the change in order of constructor parameters.
Eliminating direct calls to constructors should also make further
refactorings a bit easier.

This change omits classes deriving from IrMemberAccessExpression,
as they are a bit more complicated
and will require separate effort.

#KT-65773 In Progress
2024-03-14 10:41:51 +00:00
Alexander Udalov ee506c1369 IR: optimize IrAnnotationContainer.copyAnnotations
Annotation arguments cannot contain declarations, so we can use empty
SymbolRemapper instead of DeepCopySymbolRemapper because the latter
introduces some overhead.

 #KT-66281
2024-03-11 11:49:10 +00:00
Alexander Udalov d5c2aa4c0c IR: rename and move deepCopyWithVariables
Rename it to `deepCopyWithoutPatchingParents`, move to
`org.jetbrains.kotlin.ir.util`, make it inline+reified, and extract the
common implementation with `deepCopyWithSymbols` into `deepCopyImpl`.
2024-03-11 11:49:10 +00:00
Alexander Udalov 1d38c01afc IR: remove some usages of deepCopyWithVariables
At this point, `deepCopyWithVariables` is the same as
`deepCopyWithSymbols` except that the former doesn't call
`patchDeclarationParents`, which most likely produces incorrect IR in
some call sites.
2024-03-11 11:49:10 +00:00
Alexander Udalov e7e8cba1b4 IR: slightly simplify deep copy interface
Do not pass TypeRemapper explicitly unless an instance of something
other than DeepCopyTypeRemapper is required.
2024-03-11 11:49:10 +00:00
Alexander Udalov d659b76de5 IR: remove usages of SymbolRenamer
Its only implementation was DEFAULT so now it's inlined.
2024-03-11 11:49:10 +00:00
Wojciech Litewka 747b69c6c0 [IR] Avoid subclassing IrFileImpl
to avoid custom IrElement implementations.

#KT-65773 In Progress
2024-03-11 11:35:48 +00:00
Wojciech Litewka 1c17219a7b [IR] Mark IrConstructorCall as AnnotationMarker
IrConstructorCall is already used to represent both regular constructor
call and annotations.
Implementing AnnotationMarker avoids 'casting' it to this type later on
 in IrTypeSystemContext, which was done with
 a new IrElement implementation. We'd like to
 avoid such implementations, e.g. as so to make the IR hierarchy sealed.

#KT-65773 In Progress
2024-03-11 11:35:48 +00:00
Wojciech Litewka 392fa8f9bd [IR] Drop ReturnTypeIsNotInitializedException
It was unused since commit a005f2e75d.
2024-03-11 09:07:54 +00:00
Wojciech Litewka a53ba8a47b [IR] Drop IrUninitializedType
#KT-66053 Fixed
2024-03-11 09:07:54 +00:00
Wojciech Litewka d1e8016ab2 [IR] Pass null instead of IrUninitializedType to IrFactory
#KT-66053 In progress
2024-03-11 09:07:54 +00:00
Pavel Kunyavskiy 1222ef7fac [IrFakeOverrideBuilder] Do not compute signatures in Fir2IR
No one need them, while it requires significant time usage

^KT-66281
^KT-66441 Fixed
2024-03-08 21:36:59 +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
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
Alexander Udalov 47a4ee7fdf IR, JS: remove duplicate FQ name check from hasEqualFqName
`hasEqualFqName` is called from `hasAnnotation`, which takes more than
1% of total backend time, so it's important to avoid doing extra work
here.

It seems to be a quirk of the JS IR backend specifically that
`JsExport.Ignore` has incorrect IR parent structure here; for all other
backends, checking FQ name by traversing IR parents should work fine.

 #KT-66281
2024-03-06 22:03:10 +00:00
Alexander Udalov 45b74d0313 IR: simplify IrOverrideChecker.isOverridableByWithoutExternalConditions
Inline property-related utilities to the only call site, rearrange the
code to make declarations closer to their usages, etc.
2024-03-06 22:03:10 +00:00
Alexander Udalov 9a7d7483a3 IR: simplify IrFakeOverrideBuilder.isMoreSpecific
Using the logic from `OverridingUtil.isMoreSpecific` as a reference.
2024-03-05 14:48:23 +00:00
Wojciech Litewka eec14f0054 [tree generator] Remove Suppress("unused") from implementation classes
Those only implement base classes, their members are not supposed
to be referenced directly (those sometimes they are).
So unused code in there can be suspicious.

On the other hand, some generated builders are truly unused, so leave
the suppression for them.
2024-03-05 13:06:03 +00:00
Alexander Udalov 77b3f415a5 IR: fix "most specific" check in IrFakeOverrideBuilder
There were several problems with it:

1) `isMoreSpecific` should return true if a == b. Otherwise
   `isMoreSpecificThenAllOf` would never return true because it's always
   invoked with a collection that contains the candidate. K1 behaves
   similarly, `OverridingUtil.isMoreSpecific` returns true if a == b.
   So in fact, "more" should be understood as "not less" here.
2) `transitivelyMostSpecificMember` in `selectMostSpecificMember` was
   always equal to the first element, so `isMoreSpecific` was invoked
   with incorrect arguments.
3) At the end of `selectMostSpecificMember`, we selected the first
   candidate with the non-flexible return type, however only dynamic
   type was considered. We need to check `isFlexible` via type system
   instead.

 #KT-66120 Fixed
2024-03-05 09:19:38 +00:00
Wojciech Litewka baaaf4567e [IR] Convert methods in IrConstantValue classes to extension functions
to get rid of custom logic inside generated classes.

#KT-65773 In Progress
2024-03-04 14:07:06 +00:00
Wojciech Litewka 42668e2bf6 [IR] Remove IrFactory property from IrBlockBody and IrExpressionBody
in effort to simplify implementation classes when possible.

Those two properties always point to IrFactoryImpl, so it may as well
be used directly.

#KT-65773 In Progress
2024-03-04 14:07:06 +00:00
Wojciech Litewka 49db500369 [IR] Drop IrErrorCallExpressionImpl.addArgument
It was a remnant from the original IR implementation.

#KT-65773 In Progress
2024-03-04 14:07:06 +00:00
Wojciech Litewka 4c7c123fe8 [IR] Drop IrSyntheticBodyImpl.toString
It was the only IrElement with custom toString. And there is
a pending MR, which will override toString in IrElementBase, so this one
would be useless.

#KT-65773 In Progress
2024-03-04 14:07:06 +00:00
Wojciech Litewka 4d2aadb925 [IR] Remove old @IDEAPluginsCompatibilityAPI constructor 2024-02-29 11:22:57 +00:00
Alexander Udalov b88ce50500 IR: do not visit function body at all in IrFakeOverrideBuilder
This change fixes FIR tests with JVM IR serialization enabled, some of
which start to fail after enabling IR fake override builder mode by
default.

In this case, even accessing the function body with `IrFunction.body`
does not work in some cases because it tries to load IR and ends up with
unbound symbols for some reason (most likely related to KT-63509). So we
avoid accessing the body by copying the `IrFunction.acceptChildren`
implementation and removing the `body.accept` call.

Using deep-copy to create a fake override is questionable here, but it
will need to be refactored separately.
2024-02-28 09:32:34 +00:00
Wojciech Litewka 0b78cf9aa3 [IR] Autogenerate IrTypeAliasImpl
^KT-65773 In Progress
2024-02-28 09:29:57 +00:00
Wojciech Litewka 1008fa566f [IR] Autogenerate IrModuleFragmentImpl
^KT-65773 In Progress
2024-02-28 09:29:57 +00:00
Wojciech Litewka 97e2dab9f0 [IR] Autogenerate IrScriptImpl
^KT-65773 In Progress
2024-02-28 09:29:57 +00:00
Wojciech Litewka f30f2216cc [IR] Autogenerate IrEnumEntryImpl
^KT-65773 In Progress
2024-02-28 09:29:57 +00:00
Wojciech Litewka 401113cc27 [IR] Autogenerate IrClassImpl
^KT-65773 In Progress
2024-02-28 09:29:57 +00:00
Wojciech Litewka fde3ea14ae [IR] Autogenerate IrVariableImpl
^KT-65773 In Progress
2024-02-28 09:29:57 +00:00
Wojciech Litewka 222268b6f9 [IR] Autogenerate IrValueParameterImpl
^KT-65773 In Progress
2024-02-28 09:29:57 +00:00
Wojciech Litewka e23aff7256 [IR] Autogenerate IrTypeParameterImpl
^KT-65773 In Progress
2024-02-28 09:29:57 +00:00
Wojciech Litewka 6de200dea1 [IR] Autogenerate IrPropertyWithLateBindingImpl
^KT-65773 In Progress
2024-02-28 09:29:57 +00:00
Wojciech Litewka 5aedc24f00 [IR] Autogenerate IrLocalDelegatedProperty
^KT-65773 In Progress
2024-02-28 09:29:57 +00:00
Wojciech Litewka 87f5d3901c [IR] Autogenerate IrPropertyImpl
^KT-65773 In Progress
2024-02-28 09:29:57 +00:00