Commit Graph

97754 Commits

Author SHA1 Message Date
Yahor Berdnikau 5c8b8bf009 Remove Gradle plugin variants from ':kotlin-gradle-statistics'
Code does not use any Gradle API imports and does not use any KGP API
classes.
2023-01-17 14:03:53 +00:00
Yahor Berdnikau 92509ad400 Remove Gradle plugin variants from ':kotlin-gradle-build-metrics'
Code does not use any Gradle API imports and does not use any KGP API
classes.
2023-01-17 14:03:53 +00:00
Mikhail Glukhikh 5af37e4647 kotlin-reflect: split K2/K1 branches in KotlinModuleShadowTransformer 2023-01-17 13:46:52 +00:00
Vyacheslav Gerasimov b4071e1bbe Build: Add a separate task for K2 native codegen box tests 2023-01-17 14:25:14 +01:00
Vladimir Sukharev e4d209cbde [K2] [KN-55977] Fix suspend type serialization
Merge-request: KT-MR-8328
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-01-17 13:07:21 +00:00
Jinseong Jeon b088e742ae Introduce a util to copy TypeMappingMode for UAST 2023-01-17 13:56:42 +01:00
Jinseong Jeon e89a387cd4 Optimal type mapping modes for UAST
As shown in (DEFALUT | GENERIC_ARGUMENT)_UAST, UAST's PsiType mapping
needs an automatic expansion of type alias. This commit makes utils that
generate optimal type mapping modes for return / parameter to consider
if this is used for UAST. In that case, utils will set `mapTypeAliases`
true so that typealias (even inside type arguments) can be expanded
properly.
2023-01-17 13:56:41 +01:00
Dmitrii Gridin 485fad1951 [FIR] FirJavaClass: make annotations and deprecationsProvider lazily enhanced
^KT-55387
2023-01-17 12:45:53 +00:00
Hung Nguyen 908dbf32cf IC: Clean up closing caches logic in IncrementalCompilerRunner.kt
Make the code more readable and address a small issue where we
did not close caches when returning `ICResult.RequiresRebuild`
(it was not exactly a correctness issue because we would recompile
non-incrementally in that case).

^KT-55709 In progress (This is a follow-up on a previous change for this
    bug)
2023-01-17 17:22:59 +05:30
Anna Kozlova 6f9cfe1943 [AA] don't treat broken code as function type parameter
inspired by KTIJ-23940
2023-01-17 11:50:20 +00:00
Nicklas Ansman Giertz 115bc6ac89 KAPT: Fix an ISE when processing unresolved generic types
Error types that are generic could sometimes throw an ISE when
generating the stub.

This fixes KT-43786
2023-01-17 11:40:13 +01:00
Vsevolod Tolstopyatov 21fe0e80ff [K2] Report CONCURRENT_HASH_MAP_CONTAINS_OPERATOR_ERROR for class hierarchies
Previously it wasn't reported in FIR for ConcurrentHashMap inheritors
because the receiver id hasn't matched CHM.contains id
Fixed by unwrapping origin of the call in case of fake overrides

^KT-55606 fixed
2023-01-17 09:46:25 +00:00
Dmitriy Novozhilov b09561c3c3 [FE 1.0] Deprecate declaration of expect and actual in the same module
^KT-40904 Fixed
^KT-55177 Fixed
2023-01-17 09:43:14 +00:00
Bogdan Mukvich 71a80c5e36 Reproducible build should not run as root inside docker 2023-01-17 09:33:30 +00:00
Svyatoslav Kuzmich 951b8026f5 [JS, Wasm] Don't generate unused constructors for interfaces 2023-01-17 09:14:57 +00:00
Nikolay Lunyak 23301e3369 [FIR] Remove annotations.any from FirParcelizeAnnotationChecker 2023-01-17 06:26:39 +00:00
Nikolay Lunyak 4cddbb5fc0 [FIR] Get rid of FirAnnotation.fullyExpandedClassId
It's duplicated by `toAnnotationClassId`.
2023-01-17 06:26:39 +00:00
Nikolay Lunyak 343b856cfc [FIR] Expand typealiases in FirNativeObjC checkers 2023-01-17 06:26:39 +00:00
Nikolay Lunyak f8643c90eb [FIR] Remove annotations.find {} from FirJvmRedundantRepeatableChecker 2023-01-17 06:26:38 +00:00
Nikolay Lunyak d105ce8681 [FIR] Support typealiases to java Repeatable 2023-01-17 06:26:38 +00:00
Nikolay Lunyak 2e8b177262 [FIR] Support typealiases in FirJsRuntimeAnnotationChecker 2023-01-17 06:26:37 +00:00
Nikolay Lunyak fc285c079e [FIR] Support typealiases in FirJsAbstractNativeAnnotationChecker 2023-01-17 06:26:37 +00:00
Nikolay Lunyak aaf30c2695 [FIR] Warn about unexpanded in extractDeprecationAnnotationInfoPerUseSite
This code may be called during status resolution, but
it can also be called during `COMPILER_REQUIRED_ANNOTATIONS`.
In the latter case we can't expand typealiases.

If we do try to expand typealiases if we can,
and leave them unexpanded otherwise, then we
still may have a problem. Consider the
FirBlackBoxCodegenTestGenerated.Reflection.Annotations.Repeatable
.testKotlinAnnotation test.
In this test we get the following cycle:

```
import kotlin.annotation.AnnotationTarget.* // <- requires TYPEALIAS

@SinceKotlin("1.1") // <- requires String
AnnotationTarget.TYPEALIAS

@IntrinsicConstEvaluation // <- fully expanding this requires
fun String.compareTo()    //    building it

@Target(AnnotationTarget.CONSTRUCTOR)     // <- requires
annotation class IntrinsicConstEvaluation //    AnnotationTarget
                                          //    in general

// The cycle repeats
```

Or in words if the picture isn't clear:

- Transform `import kotlin.annotation.AnnotationTarget.*`
- Find and deserialize class `kotlin/annotation/AnnotationTarget`
- Load the `TYPEALIAS` field
- Load its annotation `@SinceKotlin("1.1")`
- Find and deserialize `kotlin/String` for `"1.1"`
- Load `String.compareTo`
- Load its annotation `kotlin/internal/IntrinsicConstEvaluation`
>>> At this moment the `extractDeprecationAnnotationInfoPerUseSite`
function is called, and ideally we'd want to fullyExpand
`IntrinsicConstEvaluation`
- While calling `toAnnotationClassId` for it, we find and deserialize
`IntrinsicConstEvaluation`
- `IntrinsicConstEvaluation` has `@Target`
- At this moment we find and deserialize `AnnotationTarget` again.
But This time loading `@SinceKotlin("1.1")` succeeds,
because when loading `kotlin/String` we first create the symbol, then
cache it, then call `postCompute`.
It does not happen with `AnnotationTarget`, because it calls
`findAndDeserializeClass` during `createValue`,
not `postCompute`.
- Thus, we have duplicate `AnnotationClass`-es, and they fail in fir2ir
with "symbol is already bound"

We can't move `findAndDeserializeClass` into `postCompute`, because
during this process when we try to access the
already created and cached symbol for `AnnotationTarget`
(with yet empty fir) we are trying to build the declared member scope
by this `symbol.fir`.
2023-01-17 06:26:36 +00:00
Nikolay Lunyak f671a8c8a7 [FIR] Rename FirAnnotation.coneClassLikeType to unexpanded
The same reason
2023-01-17 06:26:36 +00:00
Nikolay Lunyak 0c86294ca4 [FIR] Rename FirAnnotation.classId to unexpandedClassId
This makes the eye catch each such thing in the source.
OptIn isn't that catchy, plus it may be declared
for the whole file, so noticing may be harder
2023-01-17 06:26:36 +00:00
Nikolay Lunyak cf73d59e29 [FIR] Remove FirAnnotation.classId from FirParcelize
The same reasoning as with the serialization. If we
decide to support it, we wouldn't need to think
about unexpanded types.
2023-01-17 06:26:35 +00:00
Nikolay Lunyak 647cdb1c9a [FIR] FirSerializationPluginClassChecker
This change affects nothing, because @Serializable is checked during
COMPILER_REQUIRED_ANNOTATIONS when typealiases
are not yet resolved, but in case we change something
in the Future and want to support it, we'd have one less problem
2023-01-17 06:26:35 +00:00
Nikolay Lunyak 6a1c9e9279 [FIR] Support typealiases in FirAssignAnnotationMatchingService 2023-01-17 06:26:35 +00:00
Nikolay Lunyak 0c00e79024 [FIR] Support typealiases in FirTypeAnnotationChecker
`directExpansionType` is needed here for cases like
`typealias S = @S Suppress`. Otherwise, `fullyExpandedType`
would cache the same typealias
2023-01-17 06:26:34 +00:00
Dmitrii Gridin 927d244682 [SLC] cleanup code 2023-01-16 18:00:43 +00:00
Dmitrii Gridin 6fb59cc19b [SLC] update copyrights 2023-01-16 18:00:43 +00:00
Dmitrii Gridin b05ade63cb [SLC] SymbolLightAccessorMethod: simplify isOverride for top-level case 2023-01-16 18:00:43 +00:00
Nikolay Lunyak c3b871652f [FIR] KT-55181: Ensure throw argument is Throwable
`TYPE_MISMATCH` in `throwJLException.fir.kt` appeared,
because in `throw Exn` the type of `Exn` is implicit Unit.
This is red code anyway.

^KT-55181 Fixed

Merge-request: KT-MR-8292
Merged-by: Nikolay Lunyak <Nikolay.Lunyak@jetbrains.com>
2023-01-16 17:24:22 +00:00
Egor Kulikov 842ad56266 [PSI] Fix highlightning hangs in libraries
Fixes ^KTIJ-23875
findChildrenByType was errorneously replaced with
getStubOrPsiChildrenAsList

Merge-request: KT-MR-8165
Merged-by: Egor Kulikov <Egor.Kulikov@jetbrains.com>
2023-01-16 17:24:05 +00:00
Mikhail Glukhikh 38b4bade40 K2/Native: use language version 2.0 instead of -Xuse-k2 in tests 2023-01-16 18:16:49 +01:00
Mikhail Glukhikh a13fd033fc Give slightly better names to language/API version variables in FP tests 2023-01-16 18:16:49 +01:00
Mikhail Glukhikh 70fc891260 K2: move -Xuse-k2 VS language version checks to CommonCompilerArguments 2023-01-16 18:16:49 +01:00
Mikhail Glukhikh 7a61578e08 Language version 2.0: fix compiler messages and minor details 2023-01-16 18:16:48 +01:00
Mikhail Glukhikh cbedbda527 Enhance API/messages around BinaryVersion / JvmMetadataVersion 2023-01-16 18:16:07 +01:00
Mikhail Glukhikh 13502abab9 Fix FIR bootstrap in version 2.0 2023-01-16 18:16:07 +01:00
Mikhail Glukhikh bbeae23b04 Allow to read metadata 2.0 from version 1.8 2023-01-16 18:16:07 +01:00
Mikhail Glukhikh 0c4a0360ac Deserialization/class reading: pass chosen JvmMetadataVersion whenever possible 2023-01-16 18:16:07 +01:00
Mikhail Glukhikh 52ab565cc6 Move LANGUAGE_TO_METADATA_VERSION to compiler:frontend.common.jvm 2023-01-16 18:14:52 +01:00
Mikhail Glukhikh 89dd28226b BinaryVersion: introduce isCompatibleWithCurrentCompilerVersion 2023-01-16 18:12:55 +01:00
Mikhail Glukhikh f6b8b3438a Extract & use GenerationState.metadataVersion helper 2023-01-16 18:12:55 +01:00
Mikhail Glukhikh f332b6dcec Handle LV 2.0 in modularized tests 2023-01-16 18:12:55 +01:00
Mikhail Glukhikh 17c434002a Move EnableDfaWarningsInK2 into experimental section until K2/IDE EAP
This commit means that we will not see K2 DFA warnings until
we explicitly enable them (probably in 1.9.20 or 2.0).
We are going to enable DFA warnings at the moment when
K2/IDE is accessible for external users
2023-01-16 18:12:55 +01:00
Mikhail Glukhikh 3dc05f4ec5 Introduce language version 2.0 and associate K2 compiler with it 2023-01-16 18:12:55 +01:00
Mikhail Glukhikh afe1150aec KotlinClassInfo: commit back an accidentally reverted fix of KTIJ-20954 2023-01-16 18:12:55 +01:00
Marco Pennekamp 88ac5727cc [LL FIR] KT-50732 Add support for LL FIR-specific tests (.ll.kt)
- `.ll.kt` test data can be added in cases where LL FIR resolution
  legally diverges from K2 compiler results.
- Each `.ll.kt` test is prefixed with an `LL_FIR_DIVERGENCE` directive
  which must explain why the test may diverge from K2 compiler results.
  - `LLFirDivergenceCommentChecker` ensures that each `.ll.kt` file
    contains an `LL_FIR_DIVERGENCE` directive.
- `LLFirIdenticalChecker` results in an assertion error if the `.ll.kt`
  test and its base test are completely identical, including in their
  meta info (but ignoring `LL_FIR_DIVERGENCE`).
  - The checker additionally ensures that the base source file and the
    `.ll.kt` source file have identical Kotlin source code (ignoring
    meta info and `LL_FIR_DIVERGENCE`). This ensures that both tests
    test the exact same thing.
- `.ll.kt` files are ignored by select test generators, in addition to
  `.fir.kt` files.
2023-01-16 15:20:50 +00:00