Commit Graph

46232 Commits

Author SHA1 Message Date
Marco Pennekamp d89e29f289 [FIR] FirSymbolNamesProvider: Provide default implementation for mayHaveSyntheticFunctionType
- Composite providers may call `mayHaveSyntheticFunctionType` on *all*
  of their children if *one* child has
  `mayHaveSyntheticFunctionTypes == true`, so
  `mayHaveSyntheticFunctionType` should have a proper default
  implementation to avoid runtime errors.
- The alternative of requiring to check `mayHaveSyntheticFunctionTypes`
  before calling `mayHaveSyntheticFunctionType` at the call-site was
  considered, but deemed too error-prone. Given that
  `mayHaveSyntheticFunctionType` is an optimization and admits false
  positives, an imprecise default implementation of it is allowed.

Thanks to Mikhail Glukhikh for discovering this problem.
2023-11-13 09:47:41 +00:00
Dmitriy Dolovov d65fc00578 [KLIB] Introduce isJsStdlib() and isWasmStdlib() checks for KLIBs 2023-11-11 13:33:06 +00:00
Dmitriy Dolovov 4892a81178 [Native] Simplify *.isNativeStdlib() checks as much as possible
...still preserving their reliability.
2023-11-11 13:33:06 +00:00
Alexander Udalov 6a0a64eb6d JVM: remove usages of trove4j
#KTI-1135
2023-11-10 21:56:34 +00:00
Alexander Udalov e0b2f2040b Minor, add regression test for K1 issue KT-61101 2023-11-10 21:51:53 +00:00
Roman Efremov 37b839f2c2 [Tests] Refactor: move one more annotation arguments lazy resolve test
for `ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT` checker near to
other tests of this diagnostic. It is fine to move it out of
`multiplatformCompositeAnalysis` dir, because, actually, it tests
the case with comparison of FirAnnotationCall and FirAnnotationImpl,
which doesn't require composite analysis mode.

^KT-62559
2023-11-10 19:36:10 +00:00
Roman Efremov 99bf96e747 [Tests] Refactor: move annotation arguments lazy resolve test for
...`ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT` checker near to
other tests of this diagnostic. This is because now such tests
are run in lazy resolve test suite, so no need to store them
separately.

^KT-62559
2023-11-10 19:36:10 +00:00
Roman Efremov c20a5fc650 [Tests] Fix .ll.kt KMP tests data added in previous commit
It is expected, that in some complex cases
`ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT` reports in .ll.kt disappeared
at all. This is because FIR checker doesn't catch comlex cases,
which are handled by IR checker.

Also add comments about bugs KT-62886 and KT-63382 found by tests.

^KT-62559
2023-11-10 19:36:09 +00:00
Roman Efremov 29980c6b85 [Tests] Run KMP tests in Analysis API LL FIR test suites
New tests are red in current commit!
All `.ll.kt` files are just copies of `.fir.kt` or `.kt`. This will be
fixed in the next commit to clearly show difference between LL and FIR.

The original purpose of this change was to test
`ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT` diagnostic, for which FIR checker
will be run only in IDE (to be changed in next MR), so its reports
a lost from usual KMP tests.
But this looks like a useful change for all KMP tests, not only this
diagnostic.

^KT-62559
2023-11-10 19:36:09 +00:00
Roman Efremov 026ad1cebc [Tests] Refactor: move unrelated tests out of annotationMatching dir
It will be used only for ACTUAL_ANNOTATIONS_NOT_MATCH_EXPECT
diagnostic tests.

^KT-62559
2023-11-10 19:36:09 +00:00
Leonid Startsev 4fa121071a Update kotlinx-serialization dependency for serialization compiler plugin tests.
Properly set up dom-api-compat dependency for JS IR tests. Since this dependency is added
automatically for every Kotlin/JS library, it should be present during tests just as stdlib.

As a result, tests for serializable enums were changed since 1.6.0 runtime does not require enums to be explicitly serializable.
2023-11-10 14:14:04 +00:00
aleksandrina-streltsova b694f063ac [FIR] Use callee reference source for resolved callable reference
KTIJ-23906
2023-11-10 12:48:47 +00:00
Sergej Jaskiewicz 918335e12e [IR] Replace error("Should not be called") with shouldNotBeCalled() 2023-11-10 12:31:40 +00:00
Sergej Jaskiewicz 5a86147e9c [JS IR] Remove dead code 2023-11-10 12:31:40 +00:00
Sergej Jaskiewicz 47f8dedfa5 [IR] Remove methods for computing full mangled names from non-IR manglers
A full mangled name of a declaration is a mangled name that includes
the mangled names of all the declaration's parents.

We don't use full mangled names for building `IdSignature`s. We use them
in two places:
- Generating stable names for JavaScript functions in Kotlin/JS
  (see `NameTables.kt`)
- Generating names for LLVM symbols from lowered IR functions in
  Kotlin/Native (see `BinaryInterface.kt`)

In both of these places we run the IR mangler, hence we don't need this
functionality in other manglers.
2023-11-10 12:31:40 +00:00
Sergej Jaskiewicz 69aeddcba8 [IR] In irText tests, test full mangled names only computed from IR
We plan to disable computing full mangled names of declarations in all
manglers except the IR mangler (see the subsequent commits).

From now on, in irText tests we dump only the following mangled names:

- Full mangled names computed using the IR mangler
- Signature mangled names computed using the Descriptor mangler
- Signature mangled names computed using the IR mangler
- Signature mangled names computed using the FIR mangler

Here by a full mangled name we mean the mangled name of a declaration
computed using the `MangleMode.FULL` mode. Those mangled names include
the mangled names of the declaration'a parents.

By a signature mangled name we mean the mangled name of a declaration
computed using the `MangleMode.SIGNATURE` mode.
These mangled names are used to compute an `IdSignature` for
the declaration, hence the name.
2023-11-10 12:31:40 +00:00
Mikhail Glukhikh 081e1de5af FE: fix a typo in irrelevantMapGetAbstract.kt diagnostic test
Related to KT-45053
2023-11-10 10:03:58 +00:00
Dmitrii Gridin c1094d8046 [FIR] FirFakeOverrideGenerator: add missed annotations on copied accessors
^KT-63361
2023-11-10 08:56:58 +00:00
Dmitrii Gridin fb087ff7e3 [FIR] CallableCopyTypeCalculator: unify logic about copied type calculation
Add missing type propagation to getter and setter that was missed due
to copy-pasted logic.
`computeReturnTypeRef` should check the session to avoid infinitive
recursion

^KT-63361 Fixed
2023-11-10 08:56:57 +00:00
Dmitriy Novozhilov 4164cecc2d [FIR2IR] Add TODO to fix smartcasted SAM conversions due to KT-62847, KT-63345
Note that `compiler/testData/ir/irText/expressions/funInterface/samConversionsWithSmartCasts.kt`
  test should be updated after this change
2023-11-10 07:50:01 +00:00
Dmitriy Novozhilov 40f95cd5dd [FIR2IR] Minor: reuse approximateForIrOrNull utility in Fir2IrTypeConverter 2023-11-10 07:50:01 +00:00
Dmitriy Novozhilov 10914eb23f [FIR2IR] Rename Fir2IrImplicitCastInserter.cast method
`cast` name is too generic and doesn't explain the actual
  meaning of this function
2023-11-10 07:50:01 +00:00
Dmitriy Novozhilov 8578a0bf6a [FIR2IR] Properly insert casts for smartcasts in argument position
Previously cast inserter didn't consider expected type for arguments
  of function calls

^KT-63257 Fixed
2023-11-10 07:50:01 +00:00
Dmitriy Novozhilov c70a6425f5 [FIR2IR] Don't insert not-needed upcasts for smartcasted expressions
Related to KT-63257
2023-11-10 07:50:00 +00:00
Dmitriy Novozhilov aa1a997f8a [FIR2IR] Cleanup and reuse utility for creating substitutor from call 2023-11-10 07:50:00 +00:00
Ilya Kirillov 8fbd6ab02b [LL FIR] do not provide cloneable for non-jvm platforms
It's a jvm-specific thing

^KT-62935 fixed
2023-11-10 06:41:03 +00:00
Ilya Kirillov bffbbe6293 [LL FIR] add LL FIR tests based on AbstractFirPsiNativeDiagnosticsTest
^KT-62910 fixed
2023-11-10 06:41:03 +00:00
Brian Norman 6df97dd199 [FIR] Add test cases to prove resolution of backlog tickets
^KT-41728 Fixed
^KT-46586 Fixed
^KT-49696 Fixed
^KT-51160 Fixed
^KT-53308 Fixed
2023-11-09 19:28:26 +00:00
Nikita Bobko 2b82726f1d Cleanup: rename getSingleExpectForActualOrNull w.r.t. KT-62590
New name makes slightly more sense after KT-6259 is fixed
2023-11-09 17:58:43 +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 ed28923282 [IR generator] Don't use kotlinpoet for auto-generating IR tree classes
KT-61970 Fixed
KT-61703 Fixed
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 84bd12c667 [FIR generator] Factor out field printer into the common code
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 bca35c0015 [FIR/IR generator] Add default arguments to TypeVariable constructor 2023-11-09 13:30:25 +00:00
Marco Pennekamp 730f98ba38 [FIR] Fix top-level property initialization checks in scripts
- While `collectionInitializationInfo` unwrapped a script's top-level
  declarations, `check` forgot to do it, so a script effectively had no
  top-level properties in the mind of the checker.

^KT-63286 fixed
2023-11-09 13:09:39 +00:00
Marco Pennekamp 1cc2390af6 [FIR] Add tests for top-level property initialization in scripts
- The test data is missing initialization checks and will be fixed with
  the subsequent commit.
- The test data is originally taken from
  `backingField/TopLevelPropertyInitialization` and has been simplified.
- I didn't add `const val` properties to the test data (compared to the
  original) due to KT-20110.

^KT-63286
2023-11-09 13:09:39 +00:00
Dmitrii Gridin b0d72c6292 [LL FIR] add lazy resolve tests for substitution override on function
^KT-63042
2023-11-09 13:07:14 +00:00
Dmitrii Gridin a25bac4bf9 add tests on implicit type with inaccessible annotations
^KT-63042
2023-11-09 13:07:14 +00:00
Ivan Kochurkin 64db96eda3 [K1, K2] Use safe names when accessing to type parameters
^KT-57529 Fixed
2023-11-09 12:21:43 +01:00
Ivan Kochurkin 3188f01720 [FIR] Handle ConeIntersectionType in createSimpleType
^KT-62819 Fixed
2023-11-09 11:19:07 +00:00
Dmitriy Novozhilov 11586975e8 [FIR2IR] Add KDoc to Fir2IrConfiguration.linkViaSignatures flag 2023-11-09 10:43:31 +00:00
Dmitriy Novozhilov 740dcfe3c5 [FIR2IR] Manage enum entry symbols in declaration storage instead of declaration generator
This is needed to be able to implement creation of unbound symbols
 for references of corresponding declarations (KT-62856)
2023-11-09 10:43:31 +00:00
Dmitriy Novozhilov 10ad526936 [FIR2IR] Manage typealias symbols in declaration storage instead of declaration generator
This is needed to be able to implement creation of unbound symbols
 for references of corresponding declarations (KT-62856)
2023-11-09 10:43:31 +00:00
Dmitriy Novozhilov d4b0627640 [FIR2IR] Manage class symbols in declaration storage instead of declaration generator
This is needed to be able to implement creation of unbound symbols
 for references of corresponding declarations (KT-62856)
2023-11-09 10:43:31 +00:00
Dmitriy Novozhilov 7652752e3f [FIR2IR] Pass proper typeOrigin to implicitCastOrExpression
Without it the following test is failing:
- `org.jetbrains.kotlin.test.runners.ir.FirPsiJvmIrTextTestGenerated.Types#testGenericPropertyReferenceType`
2023-11-09 10:43:31 +00:00
Dmitriy Novozhilov 78259e3ee0 [FIR2IR] Manage type parameter symbols in declaration storage instead of declaration generator
This is needed to be able to implement creation of unbound symbols
 for references of corresponding declarations (KT-62856)
2023-11-09 10:43:31 +00:00
Dmitriy Novozhilov 36c0ed3c9e [FIR2IR] Get rid of last usage of symbolTable in Fir2IrCallableDeclarationsGenerator 2023-11-09 10:43:31 +00:00
Dmitriy Novozhilov aab5664c5b [FIR2IR] Manage script symbols in declaration storage instead of declaration generator
This is needed to be able to implement creation of unbound symbols
  for references of corresponding declarations (KT-62856)
2023-11-09 10:43:31 +00:00
Dmitriy Novozhilov cd0baef087 [FIR2IR] Manage field symbols in declaration storage instead of declaration generator
This is needed to be able to implement creation of unbound symbols
  for references of corresponding declarations (KT-62856)
2023-11-09 10:43:31 +00:00
Dmitriy Novozhilov aadc9ce6d5 [FIR2IR] Manage property symbols in declaration storage instead of declaration generator
This is needed to be able to implement creation of unbound symbols
  for references of corresponding declarations (KT-62856)
2023-11-09 10:43:31 +00:00