Commit Graph

2832 Commits

Author SHA1 Message Date
Alexander Udalov 7d584e0eb4 K2/Java: add initial version of FirJvmPlatformDeclarationFilter
#KT-57268 In Progress
2024-01-30 19:44:00 +00:00
Kirill Rakhman 251827c9aa [FIR] Don't approximate captured types
This fixes some type argument mismatch errors caused by a captured type
being approximated and then captured again.
Some places need to be adapted to work with captured types that
previously only worked with approximated types.

#KT-62959 Fixed
2024-01-17 08:20:05 +00:00
Denis.Zharkov 2db031d71e Drop unused createDeprecatedAnnotation
^KT-60858 Fixed
2024-01-12 16:59:42 +00:00
Sergej Jaskiewicz eda30ff704 [klib] Implement diagnostics for clashing KLIB signatures
Now, we detect clashing signatures during serialization to KLIB and
report a compiler error if two or more declarations have the same
`IdSignature`

For example, for the following code:
```kotlin
@Deprecated("", level = DeprecationLevel.HIDDEN)
fun foo(): String = ""

fun foo(): Int = 0
```

the compiler will produce this diagnostic:
```
e: main.kt:1:1 Platform declaration clash: The following declarations
       have the same KLIB signature (/foo|foo(){}[0]):
    fun foo(): String defined in root package
    fun foo(): Int defined in root package
e: main.kt:4:1 Platform declaration clash: The following declarations
       have the same KLIB signature (/foo|foo(){}[0]):
    fun foo(): String defined in root package
    fun foo(): Int defined in root package
```

Note that we report this diagnostic during serialization and not earlier
(e.g., in fir2ir) for more robustness, so ensure that we check
exactly the signatures that will be written to a KLIB.
If we later introduce some annotation for customizing a declaration's
signature (e.g., for preserving binary compatibility), this
diagnostic will continue to work as expected.

^KT-63670 Fixed
2024-01-12 15:59:28 +00:00
Denis.Zharkov 276f5b26d8 K2: Implement partially constrained lambda analysis (PCLA)
It's expected to partially mimic the behavior of what
previously was called builder inference, but with more clear contracts
(documentation is in progress, though)

See a lot of fixed issues in the later commits with test data,
especially [red-to-green]

^KT-59791 In Progress
2024-01-10 14:56:30 +00:00
Alexander Udalov 9b5c331c8e IR, descriptors: remove (Ir)ExternalOverridabilityCondition.Result.CONFLICT
No existing external overridability condition reports a conflict anyway,
and there's no support for it in the IR case.
2024-01-09 16:19:14 +00:00
Artem Kobzar 2eb1e65bbf [K/Wasm] Allow to export unsigned numbers 2023-12-08 09:06:19 +00:00
Mikhail Glukhikh 06ce57ea56 K2: report MISSING_DEPENDENCY_CLASS for lambda parameters if needed
#KT-62525 Fixed
2023-12-05 18:16:52 +00:00
Kirill Rakhman 560c1cacf3 [FIR] Fix capturing of flexible types during resolution
Previously, because we didn't handle flexible types properly in
prepareCapturedType, projections inside flexible types would only be
captured during subtyping with captureStatus=FOR_SUBTYPING
which would lead to the constraint type being wrongly approximated
(see ConstraintInjector.TypeCheckerStateForConstraintInjector
.addNewIncorporatedConstraint).

Fixing the capturing produced two kinds of false positive diagnostics:

1. In ConstraintInjector.TypeCheckerStateForConstraintInjector
.addNewIncorporatedConstraint we would get two instances of cone types
that are structurally equal and containing the same captured type.
However, because we only skipped subtyping if the types were
referentially equal, we would get a contradiction here.
The fix was to use structural equality instead, which should be okay
as the captured type instances are the same.

2. Reified type variables were inferred to captured types because
flexible arrays with captured upper bounds
(Array<Foo>..Array<Captured(out Foo)>?) were not properly approximated.

#KT-62609 Fixed
2023-11-30 08:54:26 +00:00
Dmitriy Novozhilov 704e2ef5c5 Suppress K2 specific warnings in the codebase
^KT-62472
2023-10-18 07:59:27 +00:00
Ilya Kirillov 86c8f3cc35 Remove obsolete @OptIn(ExperimentalUnsignedTypes::class) annotations
^KT-62510
2023-10-12 10:41:00 +00:00
Dmitriy Novozhilov a43cb721ba [FE] Convert ClassId.java to Kotlin 2023-09-21 12:40:43 +00:00
Alexander Udalov bb381e7aef IR: check visibility when building fake overrides
This fixes the difference at least in the IR text test
testFakeOverridesForJavaNonStaticMembers. There's no fake override
created anymore for `packagePrivateMethod` in Test2.

 #KT-61366 Fixed
2023-09-18 12:33:07 +00:00
Timofey Solonin 53584cdd49 Don't emit CAST_NEVER_SUCCEEDS when casting to a forward declaration type
^KT-58929
2023-09-13 17:49:12 +00:00
Sergej Jaskiewicz 5cb252fe49 [descriptors] Move DeclarationDescriptor#findPackage helper to core
There is nothing serialization-specific about this function
2023-09-13 14:25:09 +00:00
Sergej Jaskiewicz dff2d2ed60 [descriptors] Move some annotation-related utilities to the core module
- AnnotationDescriptor#argumentValue is not frontend-specific
- AnnotationDescriptor#getAnnotationStringValue is not Native-specific

We are going to need these functions in the IR code, so it makes
sense to factor them out to the core module.
2023-09-13 14:25:08 +00:00
Alexander Udalov d528faa0fe Minor, add toString to OverrideCompatibilityInfo 2023-09-13 15:01:52 +02:00
Dmitry Savvinov 5736201e3a [K1, MPP] Implement hack for KTIJ-24195
Force-refine typealiases if their expansion isn't visible in the
refiner's module

^KTIJ-24195
2023-09-08 15:31:22 +00:00
Nikita Bobko 373abbde5d Partially revert "[FE] Stop ignoring ABSTRACT_MEMBER_NOT_IMPLEMENTED for expect classes"
^KT-61039 Fixed
KT-59739 is now open for K1 (but fixed in K2)
Review: https://jetbrains.team/p/kt/reviews/11867/timeline

This partially reverts commit 4f3ecedbca.
Only K1 part is reverted.

Motivation for revert: KT-59739 cannot be properly fixed in K1 because
of the bug it causes - KT-61039

We just accepted that we will have one more "green in K1 -> red in K2"
case
2023-08-30 14:35:59 +00:00
Denis.Zharkov eae97e4f76 K1: Force propagating deprecation on NOT_CONSIDERED JDK members to overrides
^KT-60858 Related
KT-60659 In Progress
^KT-60769 In Progress
2023-08-03 13:31:07 +00:00
Nikita Bobko f4ba5aaf9a [FE 1.0] Prohibit implicit Java actualization in K1
^KT-58545 Fixed
Review: https://jetbrains.team/p/kt/reviews/10561

It's not yet supported in K2 KT-59213

Related tests:
- ApiTest.testStdlib
- RuntimePublicAPITest.kotlinStdlibRuntimeMerged
- KotlinProjectViewTestGenerated.test_Arrays (in Kotlin plugin)
2023-07-25 22:30:09 +02:00
Nikita Bobko 4f3ecedbca [FE] Stop ignoring ABSTRACT_MEMBER_NOT_IMPLEMENTED for expect classes
^KT-59739 Fixed
Review: https://jetbrains.team/p/kt/reviews/11038/timeline
2023-07-24 09:15:11 +00:00
Pavel Kunyavskiy d797505f06 [K/N] Drop merging forward and real declaration in deserializer
^KT-59643
2023-07-24 08:24:20 +00:00
Vladimir Dolzhenko 4a7aea0dc6 Change the order of final properties initialization and ctor
To avoid case with NPE due to race-condition on publishing
non-fully initialized object in ctor via
`TypeRefinementSupport.Enabled(this)`

#KT-59852

Merge-request: KT-MR-10917
Merged-by: Vladimir Dolzhenko <Vladimir.Dolzhenko@jetbrains.com>
2023-07-03 10:51:53 +00:00
Ivan Kylchik 6f4f06757a [IR] Add KType to IrBuiltins 2023-06-14 19:02:39 +00:00
Dmitriy Novozhilov fdc236296d [FIR2IR] Generate @FlexibleMutability annotation on IR types if needed 2023-05-24 14:07:32 +00:00
Ilmir Usmanov f3a22e0ac4 Warn about suspend extension functional types as supertypes
They will become error in 2.0

 #KT-58529 Fixed
 #KT-49175 Fixed
2023-05-19 12:41:37 +02:00
Dmitriy Novozhilov 8338370fbd [FE 1.0] Provide implementation of ExpectActualMatchingContext for FE 1.0
^KT-58578
2023-05-19 10:19:17 +00:00
Anna Kozlova 366c67a668 extract StandartNames.NAME constant 2023-05-09 07:36:10 +00:00
Anna Kozlova f0af7c4228 [cls] include property constant initializer in stubs
^KTIJ-24667
this would allow building FirElements from stubs
2023-04-26 21:43:15 +02:00
Nikolay Lunyak e1158b1cb2 [FIR] Don't load unneeded things
It's confusing to stop at breakpoints
related to these loadings when they aren't
actually used.
2023-04-25 11:29:34 +00:00
Artem Kobzar 33c5068b79 [K/JS] Rework IR deserialization and lowering phases to consume less memory 2023-04-19 13:10:19 +00:00
Mikhail Zarechenskiy fc37885d6d K1: report a warning for invisible setter accessed from a derived class
The issue is that during binding fake overrides, the compiler doesn't
 differ setters from its properties, so the compiler uses the same
 visibility for setter and entire property.

 Changing logic at the binding stage can cause some unpredictable consequences so
 the fix is to do this differentiation right at the reporting stage

 ^KT-56662 Fixed

Merge-request: KT-MR-9565
Merged-by: Michail Zarečenskij <Mikhail.Zarechenskiy@jetbrains.com>
2023-04-17 11:08:16 +00:00
Denis.Zharkov 1071669a92 Fix project K2-bootstrapping when KT-57609 breaking change is introduced 2023-03-29 10:45:40 +00:00
Denis.Zharkov a3dcc2032f Drop RawTypeMarker as it's effectively unused anymore
See the previous commits
2023-03-10 18:35:01 +00:00
Denis.Zharkov 608cb01935 K2: Imitate K1 behavior for case of captured types with a raw supertype
See the comments in the code, but mostly the motivation is that once
it was decided to stick with such a legacy thing as raw types,
we are ok with some corner-cases hacks for them
(if there are not too many of them) and they don't break anything
when there are no raw types in the code.

^KT-56616 Fixed
2023-03-10 18:35:01 +00:00
Denis.Zharkov eb09a25239 TypeSystemContext: Rework raw types processing
All the current usages are about checking if the type is raw,
also in K2 it is simply incorrect to assume that only flexible types
might be raw
2023-03-10 18:35:00 +00:00
Mikhail Zarechenskiy 82524fde26 K1: Place integer cinterop conversions under a language feature
Note that it's quite hard to emit a particular diagnostic as
 type check happens later, after the conversion

 ^KT-56583
2023-03-10 09:48:01 +00:00
Roman Efremov 60787e9fe4 Add ability to override EnumEntries class search logic from IDE side
See KTIJ-24676
2023-03-09 14:01:10 +00:00
Evgeniy.Zhelenskiy 88f293d4a9 [IR] Support reflection for MFVC
Signed-off-by: Evgeniy.Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com>

#KT-1179
2023-03-07 21:44:43 +00:00
Stanislav Erokhin 57eae167cc Restore FunctionClassKind for compatibility with Android IDEA plugin 2023-02-10 16:01:05 +00:00
Stanislav Erokhin bec9ad0f6b Minor. Rename FunctionClassDescriptor#functionKind -> functionTypeKind
This commit is needed for the following commit.
There we will restore the compatibility API with Android IDEA plugin
2023-02-10 16:01:04 +00:00
Vladimir Dolzhenko b04b3d389f Add ability for DeclarationDescriptor validation
Not fully initialized DeclarationDescriptor could leak to bindingTrace.
It is hard to detect the outcome of that kind of leakage due to
possibility to have not fully initialized instances if PCE happens in
the middle of publication and instance full initialization.

#KT-56364
#KT-56388
#KT-54085
#KT-55150
2023-02-07 17:40:42 +00:00
Denis.Zharkov 6d7096b5e9 IR: Fix StackOverflowError caused by using DNN type in lambda
^KT-54140 Fixed
2023-02-03 14:08:57 +00:00
Dmitriy Novozhilov 89c42e20c9 [FIR] Consistently use _function_ instead of _functional_ in names of classes and functions 2023-02-02 08:24:52 +00:00
Dmitriy Novozhilov d1b797ed97 [FIR] Generify resolution and inference of arguments of functional types 2023-02-02 08:24:50 +00:00
Dmitriy Novozhilov 67aa80562d [FE] Completely replace FunctionClassKind with FunctionalTypeKind
FunctionalTypeKind can be used in FE 1.0 too, so there is no need to
  keep both classes. Also, removal of FunctionClassKind simplifies work
  with FunctionalTypeKind in common code, like Analysis Api
2023-02-02 08:24:50 +00:00
Vladimir Dolzhenko edf9c3a2f5 Add more diagnostic info
Resolver could be GCed if there is no any valid hard reference to it.
Some impl of PackageFragmentProvider (like DelegatingPackageFragmentProvider)
keep hard ref to resolver.
For the sake of investigation it is worth to know what kind of PFP is there.

#EA-725255

Merge-request: KT-MR-8581
Merged-by: Vladimir Dolzhenko <Vladimir.Dolzhenko@jetbrains.com>
2023-01-31 09:09:28 +00:00
Dmitriy Novozhilov a83caec94f [FE 1.0] Implement deprecation PRIVATE_CLASS_MEMBER_FROM_INLINE_WARNING warning
^KT-55179
^KT-56171 Fixed
2023-01-31 07:53:11 +00:00
Ivan Kylchik 13cad2a820 Don't save constant value for non-resolved array expression in K1
#KT-55912 Fixed
2023-01-27 09:56:35 +00:00