Commit Graph

5399 Commits

Author SHA1 Message Date
Roman Efremov bcf4528763 [MPP] Forbid actual member in expect class
Such member descriptor will be actual and expect at the same time,
so we should run both checks.

^KT-40903 Fixed
2023-04-04 12:28:00 +00:00
Denis.Zharkov 56557fb8ff K2: Fix generic inference case with !! synthetic call
Result of the `checkNotNull` calls should always be a non-nullable
values.
The simplest idea how to acheive it is adding not-nullable Any bound
to the type parameter declaration.

Existing comment stating about impossibility of such bound seems to be
not 100% correct because it doesn't take into account presence of
definitely-non-nullable X & Any types that allow described case with
nullable generic.

^KT-55804 Fixed
2023-04-03 12:44:52 +00:00
Dmitrii Gridin 77e1bc6f9e [LL FIR] calculate lazy bodies for type annotations
^KT-56543
2023-04-01 06:39:46 +00:00
Dmitrii Gridin eb2cfb3d62 [FIR] computeRepresentativeTypeForBareType: add missing lazy resolve
^KT-56543
2023-04-01 06:39:45 +00:00
Dmitrii Gridin 3ea1f7851b [FIR] add missing resolve to isFinalClassConstructor
fix checking for intersection types in CheckIncompatibleTypeVariableUpperBounds

we need this resolve, because getEmptyIntersectionTypeKind under
the hood uses org.jetbrains.kotlin.resolve.checkers.EmptyIntersectionTypeChecker.computeEmptyIntersectionEmptiness
which uses computeByHavingCommonSubtype where we have
isFinalClassConstructor() call, so we need to resolve to STATUS phase
to get the correct modality

^KT-56543
2023-04-01 06:39:45 +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
Kirill Rakhman 38f0ac332d [FIR] Report INVISIBLE_REFERENCE in imports
#KT-55405 Fixed
2023-03-31 12:54:30 +00:00
Kirill Rakhman 7dde3603b5 [FIR] Report missing UNRESOLVED_IMPORT
#KT-54781 Fixed
2023-03-31 12:54:29 +00:00
Kirill Rakhman f18591ffef [FIR] Fix IllegalStateException on broken import
#KT-55316 Fixed
2023-03-31 12:54:28 +00:00
Nikolay Lunyak 8096e94c88 [FIR] KT-57458: Ensure the current K2 behavior differs from K1 2023-03-30 09:42:15 +00:00
Denis.Zharkov a8b9e8c44e K2: Fix false-positive TYPE_MISMATCH for suspend lambdas
Why did the problem existed?
At first, lambdas were analyzed with suspend function expected type,
because it's the WHEN-case and we propagate expected type info to
the branches.

Then, after the lambdas was introduced to the containing inference
system, we're creating ResolvedLambdaAtom using the information
from analyzed lambda's shape, but didn't use known lambda resulting
type (from which we might infer FunctionTypeKind).

So, the fix is just using that already obtained information.

^KT-57446 Fixed
2023-03-29 15:02:26 +00:00
Denis.Zharkov 55a58e54fe K2: Rework scopes for types with projection arguments for Out types
The only case when behavior is change is described at
 computeNonTrivialTypeArgumentForScopeSubstitutor

The idea is to avoid depending on the presence of @UnsafeVariance
and instead approximate captured types in covariant argument positions
before building substitution scopes

It's correct because for Captured(*) <: Supertype,
Out<Captured(*)> <: Out<Supertype> and when we've got @UnsafeVariance
value parameters at Out, it's ok to allow passing Supertype there.

^KT-57602 Fixed
^KT-54894 Fixed
2023-03-29 10:45:40 +00:00
Denis.Zharkov d9ca77f716 K2: Fix false-positive RETURN_TYPE_MISMATCH_ON_OVERRIDE
The reason was that `substitutorByMap` ignored the difference between
`T` and `T?`

^KT-57001 Fixed
2023-03-29 10:27:49 +00:00
Kirill Rakhman 3b0c36da3f [FIR] Fix ClassCastException when rendering ACTUAL_WITHOUT_EXPECT
#KT-57320
2023-03-29 10:19:47 +00:00
Dmitrii Gridin 19dbe69651 [FIR] move deprecations calculation on TYPES phase
can be moved to COMPILER_REQUIRED_ANNOTATIONS phase in the future

^KT-57256 Fixed
2023-03-29 08:52:37 +00:00
Nikolay Lunyak f644eb7988 [FIR JS] Implement FirJsExportDeclarationChecker 2023-03-29 08:51:48 +03:00
Dmitriy Novozhilov ef51cf9083 [AA] Ignore tests due to KT-57619 2023-03-28 15:35:12 +00:00
Dmitriy Novozhilov e02194b461 [FIR] Properly prohibit access to enum companion in enum entry initialization section
^KT-57456 Fixed
KT-57608
2023-03-28 15:35:12 +00:00
Dmitriy Novozhilov a9c1091140 [Test] Add test for KT-57456 2023-03-28 15:35:11 +00:00
Kirill Rakhman 1f0d56e157 [FIR] Make type parameters inaccessible for non-inner nested types
#KT-57209
2023-03-28 13:20:53 +00:00
Mikhail Zarechenskiy 681e85eaed Don't report unused variable warning for delegated variables with provide delegate
^KT-38871 Fixed
2023-03-27 13:46:13 +00:00
Kirill Rakhman 56da3c2ee2 [FIR] Bring conflicting overloads errors closer to K1 behavior
#KT-55860 Fixed
2023-03-27 11:56:16 +00:00
Dmitriy Novozhilov 1ac7d13c96 [FE] Add regression test for KT-57036 2023-03-27 10:54:27 +00:00
Dmitriy Novozhilov a705bfe2cd [Test] Add regression test for KT-57477 2023-03-27 10:44:50 +00:00
Kirill Rakhman 60b227c519 [FIR] Sort HMPP dependencies topologically for symbol providers
This fixes an issue where an actual class from an intermediate module
has more supertypes than its expect declaration which leads to a
false-positive resolution error because a type reference resolves to the
expect class. The fix is to sort the dependencies topologically from
"most actual" to "most expect" when creating the list of symbol
providers.

#KT-57369 Fixed
2023-03-27 07:41:05 +00:00
Ivan Kylchik f44d82ce6d Add test to check that name field in Java enum is not constant 2023-03-24 15:55:07 +00:00
Ivan Kylchik 63b340651d Add possibility to interpret and fold IrStringConcatenation expression 2023-03-24 15:55:06 +00:00
Dmitrii Gridin 9a4a3d1f49 [LL FIR] introduce test with reversed resolve order
^KT-56543

Merge-request: KT-MR-9299
Merged-by: Dmitrii Gridin <dmitry.gridin@jetbrains.com>
2023-03-22 17:34:07 +00:00
Ivan Kochurkin cd07eba25c [K2, MPP] Fix reporting of MANY_INTERFACES_MEMBER_NOT_IMPLEMENTED 2023-03-22 01:28:19 +00:00
Ivan Kochurkin 60edf1def3 [K2, MPP] Support actualization of enums and annotations that have primary constructor with arguments
^KT-57241 Fixed
2023-03-22 01:28:18 +00:00
Ivan Kochurkin 44807b7bd4 [K2, MPP] Support actualization of actual function with dynamic arguments
^KT-57210 Fixed
2023-03-22 01:28:18 +00:00
Ivan Kochurkin ec34b9fa7b [K2, MPP] Restore ir functions actualization by argument types instead of full signatures
Refactor IrActualizer
2023-03-22 01:28:17 +00:00
Ivan Kochurkin d99b4c78d2 [K2, MPP] Correct actualization of nested objects
^KT-57182 Fixed
2023-03-22 01:28:17 +00:00
Ilya Chernikov 59b88f33b2 [K2, MPP] implement IR errors reporting and test infrastructure
Fix test data

^KT-56344 Fixed
2023-03-22 01:28:16 +00:00
Ivan Kochurkin a3e7a35cb1 [FIR] Create separated FirBlock for loop local val
Refactor FIR builders code for ForExpression
2023-03-21 20:24:57 +00:00
Ivan Kochurkin e49bb1fe37 [FIR] Support of REDECLARATION for local val/var, ^KT-54405 Fixed 2023-03-21 20:24:57 +00:00
Ivan Kylchik 8eeb7e2631 Modify test data to reflect changes with IntrinsicConstEvaluation 2023-03-21 20:02:44 +00:00
Mikhail Glukhikh 45e78455b2 K2: repeat K1 behavior around multiple inheritance by delegation
#KT-56720 Fixed
2023-03-21 16:16:20 +00:00
Mikhail Glukhikh ab883d91c8 FE: add tests to reproduce KT-56720 2023-03-21 16:16:19 +00:00
Denis.Zharkov 38138bf079 K2: Fix bounds erasure for raw types
Basically, this commit reworks eraseToUpperBound* stuff
Instead of a bunch of vague flags, we introduce two modes
(rawTypes/intersection emptiness checker) which defined those flags.

Also, it makes choosing `eraseArgumentsDeeply` option always because
that how it works in K1 and also use invariant projection inside
`eraseArgumentsDeeply` for raw types for the same reason.

^KT-57198 Fixed
2023-03-21 12:38:22 +00:00
Nikita Bobko 48ed6c4cc7 2/2 Implement deprecation for use-site '@get:' target
^KT-15470 Fixed
Review: https://jetbrains.team/p/kt/reviews/9250
2023-03-21 13:29:10 +01:00
Nikita Bobko 8cf5216555 1/2 Refactoring: split GetterAnnotations & PropertyAnnotations tests for K1 and K2
These tests won't be FIR_IDENTICAL after the next commit. That's why I
split them prematurely. This allows me to have a nicer diff in `2/2`
commit.

In scope of KT-15470
Review: https://jetbrains.team/p/kt/reviews/9250
2023-03-21 13:28:55 +01:00
Kirill Rakhman 45d2424ad8 [FIR] Let prefix inc/dec call getter twice for compatibility with K1
#KT-57179 Fixed
2023-03-21 08:48:38 +00:00
Ilya Chernikov 0e77b67170 K2: implement correct check for ctors mapped from java
so the check is functionally the same as in K1.
#KT-57064 fixed
#KT-57065 fixed
One of the tests introduced here (javaMappedCtors) revealed an
additional issue, filed as KT-57368
2023-03-20 11:33:34 +00:00
Mikhail Glukhikh a43a16b25b Delay ForbidInferringPostponedTypeVariableIntoDeclaredUpperBound to 2.0
#KT-57395 Fixed
Related to KT-47986
2023-03-20 11:11:41 +00:00
Denis.Zharkov 823c60a7dc K2: Fix false-positive UNSAFE_CALL on safe call with flexible type alias
The idea of the fix is just unwrapping flexible version of type alias,
before creating a not-nullable version for safe-call subject.

Otherwise, it was remained to be JsExpressionResult after applying
makeConeTypeDefinitelyNotNullOrNotNull (and the type is still nullable)

^KT-57190 Fixed
2023-03-17 16:27:29 +00:00
Mikhail Glukhikh e8232a7572 FE: add one more test related to KT-56511 with the relevant feature ON 2023-03-17 14:57:41 +00:00
Mikhail Glukhikh 41c868445c K1: introduce smartcast deprecation for a public API property in invisible class
#KT-56511 Fixed
Related to KT-57290
2023-03-17 14:57:40 +00:00
Mikhail Glukhikh 0b31e5ad63 K2: reproduce & add test for KT-56511 2023-03-17 14:57:40 +00:00
Kirill Rakhman 9b89759755 [FIR] Explicitly resolve synthetic property return type if necessary
During implicit body resolve phase, we can encounter a reference to a
not yet resolved Kotlin class that inherits a synthetic property from a
Java class. In that case, resolve the return type in
FirSyntheticPropertiesScope.

#KT-57166 Fixed
2023-03-17 13:31:45 +00:00