Commit Graph

377 Commits

Author SHA1 Message Date
Nikolay Lunyak 389f02b016 [FIR] Let FirErrorExpression have a working type if possible
^KT-65337 Fixed
2024-02-14 09:57:12 +00:00
Simon Ogorodnik 53e89a9722 K2. Minor. Rename FirConstExpression to FirLiteralExpression
FirConstExpression is usually confused with "constant" calculations,
while in fact, it just denotes a simple literal expression
and `1 + 1` isn't represented by a FirConstExpression.

^KT-64314 Fixed
2024-01-25 23:05:15 +00:00
Nikolay Lunyak 9b786d35f8 [FIR] Fix NO_RECEIVER_ALLOWED
If we do create an implicit invoke call, and
then put the receiver into the argument list,
we should mark it.
2024-01-24 12:49:56 +00:00
Ivan Kylchik aecf05c4ac [FIR] Use ConeKotlinType to represent vararg's element type
We are using `ConeKotlinType` instead of `FirTypeRef` to represent
that element type of vararg doesn't have any source. It has a type
that was inferred. If we try to specify a source, then we could
end up with the incorrect place for diagnostic.

#KT-59682 Fixed
2024-01-18 13:33:48 +00:00
Denis.Zharkov f8fd46a5b8 K2: Rename delegateProvider in node for delegate and refine its type 2024-01-09 18:03:05 +00:00
Dmitrii Gridin b6d373d8e5 Update copyright to 2024 2024-01-05 13:43:17 +00:00
Marco Pennekamp 85c4d6b67b [FIR] Add workaround for exception in JavaOverrideChecker.buildErasure
- `useMutableOrEmpty` causes the bounds to be replaced atomically, which
  avoids the race described in KT-60324.

^KT-60324 fixed
^KT-60445
2023-12-19 11:10:06 +00:00
Sergej Jaskiewicz cab87eba21 [SIR, FIR generators] Add KDocs for visitor-related methods of elements 2023-12-12 14:27:57 +00:00
Ilya Chernikov ff4f30ddc1 FIR: replace receiver in anon initializer with containing decl
This way the abstraction represents the intended use better and
doesn't stay on the way of using FirAnonymousInitializer in scripts
2023-12-12 09:58:19 +00:00
Ilya Chernikov eeb723eb01 K2 Scripting: wrap script statements into blocks
(reuse anonymous initializers as block wrappers) so the top-level script
elements are all declarations now. Rename the property accordingly (
together with the previous commit).
It makes script more similar to the class and thus simplify e.g.
control flow analysis and resolve code.
2023-12-12 09:58:19 +00:00
Ilya Chernikov c9aee5bf09 minor: rename FirScript.statements do declarations...
to simplify the following commit that actually convert the types
and wrap statements into blocks.
2023-12-12 09:58:19 +00:00
Ilya Chernikov b7057eb22f K2 Scripting: make FirScript a CFG owner 2023-12-12 09:58:18 +00:00
Dmitrii Gridin 6eca9fe3a9 [FIR] tree: introduce containingDeclarationSymbol for annotation calls
This symbol will be used during resolution to avoid transformation
of annotations in the wrong context in the case of FIR node sharing.
The symbol should be some containing declaration symbol to be able
to answer the question "Are we own this annotation?" during resolution

^KT-63042
2023-12-07 12:26:39 +00:00
Roman Golyshev ad2c77b298 KT-59732 [FIR] Get rid of FirErrorImport node
It's no longer relevant, since it's not created anywhere
2023-12-04 16:51:46 +00:00
Kirill Rakhman 0b28e770b2 [FIR] Introduce new FIR node for SAM conversion
#KT-62847
2023-11-30 08:39:03 +00:00
Ivan Kylchik 9f64edb31e [FIR] Add hasConstantInitializer field in FirField class
This field is required to be able to analyze Java fields
without triggering lazy const evaluation.

#KT-59894
#KT-61920
2023-11-29 16:33:17 +00:00
Sergej Jaskiewicz d7710b8e8d [FIR generator] Remove redundant full qualifier in generated builders 2023-11-22 10:00:06 +00:00
Kirill Rakhman 49e786f088 [FIR] Copy java enum entry during enhancement instead of mutating it
#KT-57949 Fixed
2023-11-20 15:21:49 +00:00
Nikolay Lunyak 5a1a23afac [FIR] Don't miss annotations on inits
^KT-59874
2023-11-14 15:19:33 +00:00
Sergej Jaskiewicz 02c12ae26f [FIR generator] Write kDocs for accept & transform methods in FirElement 2023-11-09 13:30:25 +00:00
Sergej Jaskiewicz 63e9dd588c [FIR generator] Factor out element printer to common module
This is a step towards commonizing the code generator between
FIR and IR: KT-61970
2023-11-09 13:30:25 +00:00
Sergej Jaskiewicz 54de11cb58 [FIR/IR generator] Generate kDocs for visitor classes 2023-11-02 23:05:18 +00:00
Sergej Jaskiewicz 570422dbd4 [FIR/IR generator] Print visitor method expression bodies on new line
This helps to avoid long lines in visitor classes.
2023-11-02 23:05:18 +00:00
Sergej Jaskiewicz c5f519f7c7 [FIR/IR generator] Commonize visitor printing logic
This is a step towards commonizing the code generator between
FIR and IR: KT-61970

Also, don't use kotlinpoet for generating IR visitors (KT-61703)
2023-11-02 23:05:18 +00:00
Vladimir Sukharev 0fb853a995 [FIR] Fix Disappeared CONTRACT_NOT_ALLOWED
https://youtrack.jetbrains.com/issue/KT-60004/K2-Disappeared-CONTRACTNOTALLOWED

Merge-request: KT-MR-12613
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-11-02 20:47:05 +00:00
Sergej Jaskiewicz 7b7bcb8ffa [FIR/IR generator] Introduce ImportCollector
This class enables printing the import list in generated files
in a smarter way.

Also, refactor `Importable` interface hierarchy, namely, don't inherit
`TypeRef` from `Importable`, since we have types like `TypeRef.Star`
which are not really importable.

Replace the `Importable#typeWithArguments` property with
the `TypeRef#render` method to utilize `ImportCollector` while rendering
types.
2023-10-26 17:33:59 +00:00
Ivan Kochurkin bb937a8a21 [FIR] Initialize annotations in FirErrorTypeRef
^KT-62447 Fixed
^KT-62628 Fixed
2023-10-24 10:53:33 +00:00
Sergej Jaskiewicz 9eacdb3314 [FIR generator] Print builder property name in generated classes' KDocs
Just like we do when generating the IR tree
2023-10-24 10:29:43 +00:00
Sergej Jaskiewicz 75b509c185 [FIR/IR generator] Share visitor-related properties between FIR & IR 2023-10-20 06:41:12 +00:00
Sergej Jaskiewicz 04c5ac0eb6 [FIR/IR generator] Factor out adding pure abstract element as parent 2023-10-19 12:00:25 +00:00
Sergej Jaskiewicz 417aa236fb [FIR/IR generator] Factor out printing the preamble in generated files 2023-10-18 18:42:40 +00:00
Roman Efremov 423f4ca5f0 [FE, IR] Check compatibility of annotations set on type usages in expect and actual declarations
This includes checking of annotatins set on:

- value parameter types
- type parameter bound types
- extension functions receiver types
- function return types
- class super types

Fix in `defaultParams_inheritanceByDelegation_positive.kt`
is needed because of problem in resolution of implicit return types
(KT-62064), which leads to crash in annotation checker, because it
expects resolved return type.

MR: KT-MR-12245

^KT-60671 Fixed
2023-10-16 10:48:08 +00:00
Sergej Jaskiewicz 04c0cc5a5c [FIR generator] In properties always print get() ... on new line
This is to unify the code formatting with IR classes.
2023-10-12 11:45:55 +00:00
Sergej Jaskiewicz 4507615c69 [FIR generator] Print accept method's body on new line
This is to unify the code formatting with IR classes
2023-10-12 11:45:55 +00:00
Dmitriy Novozhilov 9e5ee3afa0 [FE] Add isLocal name to ClassId constructor calls where it needed 2023-09-21 12:40:44 +00:00
Sergej Jaskiewicz 88c308dfd3 [FIR generator] Don't print extra space in the where clause 2023-09-20 15:39:40 +00:00
Kirill Rakhman 68bc2be4c9 [FIR] Regenerate FIR types
#KT-61367
2023-09-14 10:03:02 +00:00
Dmitriy Novozhilov f203681ffa [FIR] Make extensionReceiver and dispatchReceiver nullable
Get rid of FirNoReceiverExpression

^KT-59650 Fixed
2023-09-06 09:25:22 +00:00
Mikhail Glukhikh 3ff2c7d6f7 K2: introduce custom Enum.entries migration checkers
Related to KT-56623, KT-56587
#KT-59344 Fixed
2023-08-31 13:29:02 +00:00
Brian Norman b55fda0c55 [FIR] Create CFG for files to track top-level property initialization
In order to properly analyze top-level property initialization, a
control-flow graph must be created for FirFiles. This change adds the
foundation for the file CFG and updates body resolve to create the CFG.
Checking the CFG for proper initialization is separated into a following
change to ease code review.

KT-56683
2023-08-31 12:50:52 +00:00
Dmitriy Novozhilov 6169834bb3 [FIR] Make FirResolvedDeclarationStatus.modality non nullable
^KT-58764 Fixed
2023-08-31 09:38:44 +00:00
Kirill Rakhman 844ab4ee74 [FIR] Remove FirExpression.typeRef
#KT-61312 Fixed
2023-08-25 10:16:41 +00:00
Kirill Rakhman ab6d87a1a2 [FIR] Introduce deprecated FirExpression.typeRef property for compatibility with Compose
#KT-59855
2023-08-24 07:54:57 +00:00
Kirill Rakhman a5cff6ae36 [FIR] Make type of special expressions immutable 2023-08-24 07:54:57 +00:00
Kirill Rakhman b24afa0177 [FIR] Regenerate FIR tree after FirExpression.coneTypeOrNull introduction
#KT-59855
2023-08-24 07:54:57 +00:00
Nikolay Lunyak f238ffa4bf [FIR] Make FirErrorConstructor a FirDiagnosticHolder 2023-08-22 09:13:16 +00:00
Dmitrii Gridin 2f57916869 [FIR] add replaceStatements to FirScript
It is required to implement StateKeeper for scripts
statements should be MutableOrEmptyList to avoid CME

^KT-60728
^KT-60519
2023-08-02 16:50:45 +00:00
Ivan Kochurkin 2eba7da5eb [FIR] Rename FirArrayOfCall to FirArrayLiteral 2023-07-27 17:53:44 +00:00
Ilya Chernikov d24fc3b581 K2 Scripting: add support for result field 2023-07-26 08:49:26 +00:00
Arseniy Terekhov be9d2953b2 [FIR] Make own accept methods of FirTypeParameterRef inheritors
This change is necessary in order to make `FirElement` abstract class. To do it we need to remove all `accept` and `transform` methods from fir interfaces. So we have to make sure that all fir element implementations have their `accept` and `transform` implementations in their super classes. In particular this change makes 'accept' and 'transform' methods in `FirConstructedClassTypeParameterRef` and `FirConstructedClassTypeParameterRef` base classes.
2023-07-25 11:53:47 +00:00