Commit Graph

54 Commits

Author SHA1 Message Date
vladislav.grechko 1e7cc00dcb [FIR] Serialize type annotations of vararg parameters in metadata
^KT-63899: Fixed
2024-01-28 22:10:05 +00:00
vladislav.grechko 34bac48541 Add JVM ABI K1/K2 consistency tests 2023-12-26 10:18:19 +00:00
Ivan Kylchik c82bc8f0ce [WASM] Add ConstEvaluationLowering to the lowering list 2023-11-22 14:54:19 +00:00
Ivan Kylchik 8715bd6189 [IR] Don't evaluate expressions in inner class of an annotation 2023-11-21 09:48:58 +00:00
Ivan Kylchik 3fa82c7bb1 [K2] Properly evaluate complex boolean constants
Some boolean expressions could be transformed into `IrWhen`
node. To understand that this node is actually
a boolean expression, we need to analyze its origin.

#KT-62683
2023-11-21 09:48:57 +00:00
Ivan Kylchik 4334ae9da9 [FIR] Add JvmName to the list of REQUIRED_ANNOTATIONS
We need to resolve `JvmName` as soon as possible because
it can be analyzed in `FirJavaElementFinder` to create
the correct class stub.

#KT-57802
2023-10-20 16:33:20 +00:00
Ivan Kylchik a45bb8d92b [FIR] Find the correct FIR file in Java finder for file with JvmName
#KT-57802
2023-10-20 16:33:20 +00:00
Ivan Kylchik 8c7c44f9f5 [FIR] Fix evaluation of Java properties for Char and String types
#KT-57802
2023-10-20 16:33:20 +00:00
Ivan Kylchik 7935b2bdb1 [FIR] Allow to evaluate top level const properties in Java world
#KT-57802
2023-10-20 16:33:20 +00:00
Ivan Kylchik 886ef1a4b4 [FIR] Support the simple case of java field interpretation
#KT-57802
2023-10-20 16:33:20 +00:00
Mikhail Glukhikh b7b7dd1000 FIR2IR: make sources of qualified accesses & calls closer to PSI2IR
#KT-60111 Fixed
2023-10-13 15:42:58 +00:00
Ivan Kylchik abc061e17f [IR] Restore and fix ifConstVal test
It was accidentally dropped after KT-55196 fix.
2023-09-05 11:06:43 +00:00
Nikolay Lunyak 73b4a81663 [FIR] Forbid complex boolean expressions
Disabling the language feature is supported,
otherwise there are too many tests that
would need to be updated to account for
K2's inability to do it.

The `ifConstVal.kt` test is deleted,
because now it must also be ignored in K2,
and since it is ignored for both the
frontends, and the ignored backends
include all the target backends, this test
is basically unused.

Note that now both the frontends report
`CONST_VAL_WITH_NON_CONST_INITIALIZER`.
for `condition`.

^KT-55196 Fixed
2023-08-18 15:16:13 +00:00
Ivan Kylchik 88191e8b1a [IR] Add new test to check that nullable access to enum is not evaluated
Just a safety check. If an expression like `EnumClass.Value?.name` was
evaluated, we would consider it as breaking change.
2023-07-27 22:50:21 +00:00
Ivan Kylchik 30c00f7983 [IR] Specify explicitly that classes from Java can be interpreted
In early prototypes of interpreter, it was easier to assume that
all classes from Java can be interpreted and fix something if not.
Check for Java declaration was done by checking that the package name is
starting with "java". But this is actually wrong and can lead to errors
when some code is declared in "java" something package, but is not from
Java stdlib.

#KT-60467 Fixed
2023-07-20 09:40:42 +00:00
Ivan Kylchik ad6332112e [IR] Support const optimizations for Native backend 2023-07-10 13:19:51 +00:00
Ivan Kylchik d3d28783c5 [IR] Support const optimizations for JS backend 2023-07-06 11:00:14 +00:00
Ivan Kylchik d557bcaba4 [IR] Forbid unconditional interpretation of IrGetObjectValue
Earlier we always allowed to interpret `IrGetObjectValue` because
this value is used in const val getter. But now we do a special
check for such getter avoiding visit of `IrGetObjectValue` node.

#KT-59775 Fixed
2023-07-05 13:33:41 +00:00
Svyatoslav Kuzmich a3e2d2804c [Wasm] Update testData after adding K2 and new test infra support.
- Actualize muted K2 tests
- Actualize muted K1 tests with module systems because legacy Wasm test
  infra had no respect for "// MODULE: ..." test directives
2023-06-25 10:20:40 +02:00
Ivan Kylchik dd264cff50 [IR] Split const folding into necessary one and for optimizations only
In this commit we have a lot of change in test data. This was caused
by the way where we evaluate constants. We split constant evaluation
into two distinct parts: only necessary evaluations for `fir2ir`
(like const val and annotations) and optimizations for lowering.
Now we don't do all constant evaluation on `fir2ir`, but IR
dump is executed after this phase, so test data changed.

#KT-58923
2023-06-14 19:02:39 +00:00
Ivan Kylchik 8067df3c94 [IR] Combine IrInterpreterNameCheck with common one
This way we achieve faster compilation time. We want to traverse
IR tree as little as possible. If we add new checker than the time
to evaluate constants basically doubles.

#KT-58923
2023-06-14 19:02:39 +00:00
Ivan Kylchik ec4cf40f6f [IR] Allow to fold IrGetField expressions
#KT-58923
2023-06-14 19:02:38 +00:00
Vladimir Sukharev 7aea0af307 [K/N] Enable passed tests for K1/N in involvesInterpreter
^KT-59057

Merge-request: KT-MR-10524
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-06-08 14:13:54 +00:00
Ivan Kylchik fc75402f65 [IR] Add test to specify new logic of enum initialization with name call
#KT-58948
#KT-57538
2023-05-30 15:28:04 +00:00
Ivan Kylchik e0e1d57120 [IR] Check object init was called in case of name interpretation
#KT-58717 Fixed
2023-05-18 18:16:54 +00:00
Ivan Kylchik 70560fc3eb [IR] Handle each interpreter checker one by one
This wy we can interpret all expressions like `A::a.name` at first and
after that evaluate all complex expressions like
`A::a.name + A::b.name`.
2023-05-18 18:16:54 +00:00
Ivan Kylchik e58e20fc7b [IR] Add special preprocessors for ir interpreter
These preprocessors allow us to modify IR at first and only after that
try to evaluate. With this we can drop `KCallableNamePropertyLowering`.
2023-05-18 18:16:54 +00:00
Ivan Kylchik 1fd8ef801e [IR] Create special checker that will analyze name methods
We can insert all this logic into `IrCompileTimeChecker` but it is
a little bit specific and looks like it is nicer to just extract it.
2023-05-18 18:16:54 +00:00
Ivan Kylchik 535806d0ab [K2] Force interpretation of default argument for annotation's property
We miss these expression because they might be represented as
`IrGetFiled` values, but they still must be turned into `IrConst`.

#KT-58007 Fixed
2023-05-18 18:16:53 +00:00
Ivan Kylchik 3d4f3d2f57 [IR] Visit file annotations in IR interpreter
#KT-55866 Fixed
2023-05-15 08:32:37 +00:00
Ivan Kylchik d83f6a40fb [K2] Revert commit Pass FirFile to metadata serialization
We will ignore this for now. It is quite painful to bring `FirFile`
in all necessary places.

#KT-57812
2023-05-11 08:22:14 +00:00
Ivan Kylchik d26e3871ba [K2] Support interpretation of values in type annotations
#KT-57812
2023-05-11 08:22:13 +00:00
Ivan Kylchik 73cc73115e [FIR2IR] Simplify logic around annotationMode
#KT-58005 Fixed
2023-05-05 16:15:00 +00:00
Ivan Kylchik 7747643945 [IR] Filter chars and codePoints from allowed to interpret function
These two functions apparently are represented in Kotlin as methods
of `kotlin.String`. Because of that we accidentally treated them as
builtins.

To also minimize such cases, added filtration by return type. We are
allowing to interpret only these functions that have primitive or
unsigned return type.

#KT-57028 Fixed
2023-05-03 12:47:35 +00:00
Ivan Kylchik 6b75b3bc4a [IR] Drop duplicated meta info from interpreters tests 2023-04-19 13:52:48 +00:00
Ivan Kylchik 3f60c83921 [IR] Add id method in interpreter's tests to avoid optimizations 2023-04-19 13:52:48 +00:00
Ivan Kylchik 621f5a0fb7 [IR] Reorganize test files in involvesIrInterpreter dir 2023-04-19 13:52:48 +00:00
Ivan Kylchik c00c7ffbe0 [K2] Use file name as one of parameters to extract evaluated const
It is not enough to store evaluated constants only by
<startOffset, endOffset> pair. We need to consider case there constant
can be located in different files with the same offset but with
different values.

#KT-57928 Fixed
#KT-57929 Fixed
2023-04-19 13:52:46 +00:00
Ivan Kylchik 8cc8e54a9f [IR] Extract toString interpretation test of float value into new file
We need to distinguish `toString` results for JVM and JS
2023-04-19 13:52:46 +00:00
Ivan Kylchik 1ddcdcfc39 [IR] Rewrite logic around object interpretation
Basically we want to allow object interpretation only when we try
to access some const val property.

#KT-57810 Fixed
2023-04-19 13:52:44 +00:00
Ivan Kylchik 5956e9b500 [IR] Print evaluated const directly into interpreter's tests 2023-04-19 13:52:44 +00:00
Ivan Kylchik 08ba63df90 Implement proper name interpretation for suspend functions
#KT-57313 Fixed
2023-04-11 21:28:13 +00:00
Ivan Kylchik ac480e2285 [K2] Support serialization of complex annotations
#KT-57611 Fixed
2023-04-07 18:07:09 +00:00
Ivan Kylchik 4a50bd9b16 [K2] Fix annotation serialization for simple cases
#KT-57611
2023-04-07 18:07:09 +00:00
Nikolay Lunyak f0720c1d12 [FIR] Fix K2 behavior according to RULES1
The compiler should only report diagnostics for
comparisons over builtins and identity-less types,
other incompatibilities should be reported
via inspections.

It's ok that in `equalityChecksOnIntegerTypes`
instead of `EQUALITY_NOT_APPLICABLE_WARNING` we get
`EQUALITY_NOT_APPLICABLE`, because
`ProperEqualityChecksInBuilderInferenceCalls`
is already active by default.

This change also replaces the notion of a representative superclass
with the least upper bound.
This makes complex types like
intersection/flexible transparent to
RULES1-based compatibility checks.
One way to look at it is to think
that this is an automatic way of handling
type parameters: automatic picking of
"interesting" bounds, and checking them against one another.

Note that `TypeIntersector.intersectTypes`
for `Int` and `T` where `T` is a type parameter
may return both `{Int & T}` or `null`
depending on `T`-s bounds. At the same time,
for type parameters `T` and `K` it will
always return `{T & K}`.

`ConeTypeIntersector.intersectTypes`, on the
other hand, will always return `{Int & T}`
irrespectively of the bounds. Meaning, the two
intersectors differ in corner cases.

`lowerBoundIfFlexible` call in `isLiterallyTypeParameter` is backed by
the `equalityOfFlexibleTypeParameters` test.

^KT-35134 #fixed-in-k2
^KT-22499 #fixed-in-k2
^KT-46383 #fixed-in-k2
2023-03-31 15:01:50 +00:00
Ivan Kylchik 63b340651d Add possibility to interpret and fold IrStringConcatenation expression 2023-03-24 15:55:06 +00:00
Ivan Kylchik 7cf9dda8dc [JS] Support evaluation of const intrinsics for K2
#KT-56023 Fixed
#KT-51582 Fixed
2023-03-24 15:55:04 +00:00
Ivan Kylchik e981b1f958 [Native] Support evaluation of const intrinsics for K2
#KT-56023
#KT-55469 Fixed
2023-03-24 15:55:03 +00:00
Ivan Kylchik 8eeb7e2631 Modify test data to reflect changes with IntrinsicConstEvaluation 2023-03-21 20:02:44 +00:00
Nikolay Lunyak bcfafc601e Add EnumEntries to minimal-stdlib-for-tests
This change allows to revert adding `WITH_STDLIB` directive
to tests which happened at `a9343aeb`.

Co-authored-by: Alexander Udalov <Alexander.Udalov@jetbrains.com>
2023-03-02 10:23:38 +00:00