Commit Graph

105198 Commits

Author SHA1 Message Date
Alejandro Serrano Mena 166b99181b [Test] Ensure that properties cannot be used as operators
In some cases the combination of property + invoke was incorrectly allowed

^KT-62349
2023-10-12 08:32:17 +00:00
Sergej Jaskiewicz a909a28f29 [FIR generator] Use more type-safe field builders 2023-10-12 08:24:12 +00:00
Sergej Jaskiewicz 8be455649c [FIR generator] Use TypeVariable instead of TypeArgument for TPs
This is a step towards commonizing the code generator between
FIR and IR: KT-61970
2023-10-12 08:24:12 +00:00
Dmitriy Novozhilov c25cde8871 [FIR2IR] Provide correct module data to FirModuleDescriptor
Properly implement friend modules visibility check

^KT-61384 Fixed
^KT-62475 Fixed
2023-10-12 06:47:02 +00:00
Anastasia.Nekrasova e3bab4a7da [K2] Prohibit smart casts for 'expect' properties
^KT-61340
2023-10-11 17:05:29 +00:00
Roman Efremov e4ea733482 [K2] Support reporting of EXPECTED_ENUM_ENTRY_WITH_BODY
Test for the case when enum entry has constructor call but doesn't have
body already exist in
`compiler/testData/diagnostics/tests/multiplatform/enum/constructorInHeaderEnum.kt`.

^KT-59978 Fixed
2023-10-11 15:04:02 +00:00
Roman Efremov db886a0435 [K2] Make impl classes in SourceNavigator private to prevent
...accidental use of tree-specific implementation instead of common one.
Actually, I stepped on this rake myself in next commit, when
accidentally imported function from `PsiSourceNavigator`.

^KT-59978
2023-10-11 15:04:02 +00:00
Sergej Jaskiewicz 8798fdeb82 [FIR generator] Use TypeRef for denoting types
(instead of `Type` and `Importable`)

This is a step towards commonizing the code generator between
FIR and IR: KT-61970
2023-10-11 11:16:08 +00:00
Vyacheslav Gerasimov 918cf183c1 Build: Use cache-redirector for Node.js downloads
#KTI-1401
2023-10-11 11:13:13 +00:00
Nikolay Lunyak df6f51b49f [FIR] Ignore the operator keyword when checking conflicting overloads
^KT-59880
2023-10-11 08:54:09 +00:00
Nikolay Lunyak 09436d0480 [FIR] Report conflicts for constructors of top-level classes
^KT-59880
2023-10-11 08:54:09 +00:00
Nikolay Lunyak bc2eb546b4 [FIR] Report conflicts for data class generated members
^KT-59880
2023-10-11 08:54:09 +00:00
Nikolay Lunyak afc22728fa [FIR] Don't miss annotations while generating augmented assignments
^KT-62473 Fixed
2023-10-11 08:33:05 +00:00
Nikolay Lunyak 54e9cafc73 [FIR] Reproduce KT-62473 2023-10-11 08:33:05 +00:00
Vladimir Sukharev bae8b283c7 [IR] Normalize temp var names in Kotlin-like dump
^KT-61983 Fixed
2023-10-11 07:49:35 +00:00
Igor Chevdar 6c519488a6 [IR] Reworked K/N variables inliner hint 2023-10-11 06:27:02 +00:00
Igor Chevdar 1b30f76a78 [K/N][tests] Added a test on stepping through inline arguments 2023-10-11 06:27:02 +00:00
Vladimir Sukharev 69d2b94a68 [FIR] Fix Disappeared NULLABLE_TYPE_IN_CLASS_LITERAL_LHS
^KT-59970 Fixed
2023-10-10 18:23:19 +00:00
Vladimir Sukharev 1c395ef0df [FIR-TEST] Remove accidentally committed testfiles 2023-10-10 18:22:41 +00:00
Anna Kozlova 1f4d985b7b [AA] include inferred types in functional exp expected type
Fixed for K2 only, k1 remains as is

^KT-62466 fixed
2023-10-10 14:06:48 +00:00
Ilya Kirillov c32e7c723d [Analysis API] resolve [this] in KDoc to extension receiver
^KT-62407 fixed
2023-10-10 14:03:49 +00:00
Mikhail Glukhikh a5a8f6736b Raw FIR: set source for setter parameter <set-?> access in delegated properties
Related to KT-59864
2023-10-10 13:38:52 +00:00
Mikhail Glukhikh d321fa3fd9 K2: add partial reproduction of KT-59864 2023-10-10 13:38:52 +00:00
Mikhail Glukhikh 162ba59d7f Raw FIR: set source for delegate field references
Related to KT-59864
2023-10-10 13:38:52 +00:00
Mikhail Glukhikh 9d3bf69212 Raw FIR/LT: use similar sources for delegated constructor calls
After this commit all IR source range tests behave in the same way
for FIR/PSI and FIR/LT, test data is now consistent
2023-10-10 13:38:52 +00:00
Mikhail Glukhikh 4ed6ece78b Test: IR source ranges: make line/column -1 for negative offsets
Before this commit, test data for 'synthesizedDataClassMembers' test
was different between PSI and LT, because we had SYNTHETIC_OFFSET = -2
for synthetic functions and NaiveSourceBasedFileEntryImpl calculated
line/column as 0 for LT. In this commit the dumper was edited to
count -1 as line -1 / column -1 independent of a file entry used.
2023-10-10 13:38:51 +00:00
Mikhail Glukhikh 1d631500f5 Test: add K2 version of IR source ranges test
After this commit there are three different versions of
IR source range tests: classic (K1), FIR/PSI (K2), FIR/LT (K2).
Since 5 tests behave differently for FIR/PSI and FIR/LT,
in this commit their test data was set to FIR/LT state,
so relevant 5 tests are failing for FIR/PSI right now.
They will be fixed in two subsequent commits

Related to KT-59864, KT-60111, KT-59584
2023-10-10 13:38:51 +00:00
Mikhail Glukhikh 072757cdde Test: convert IR source ranges test to the new infrastructure
Related to KT-59864, KT-60111, KT-59584
2023-10-10 13:38:51 +00:00
Marco Pennekamp dab06c0942 [AA] Cover both static and inner classes in Java member scope tests
^KT-61900
2023-10-10 13:38:00 +00:00
Marco Pennekamp ab717c25d7 [AA] Avoid duplicate inner classes in Java declared member scopes
- Java combined declared member scopes are implemented as a composition
  of the non-static and static scope, so we have to exclude inner
  classes from the non-static scope to avoid duplicates.
- This is not an issue for Kotlin combined declared member scopes,
  because the combined scope is already the base scope.

^KT-61800
2023-10-10 13:38:00 +00:00
Marco Pennekamp 17b8d59e4b [AA] Include inner classes in non-static Java declared member scopes
- `FirNoClassifiersScope` erroneously filtered out inner classes from
  non-static Java declared member scopes.

^KT-61800
2023-10-10 13:38:00 +00:00
Marco Pennekamp 17e181885f [AA] Restrict FirJavaDeclaredMembersOnlyScope to non-local classes
- Comparing the callable ID with the owner's class ID is the simplest
  way to check whether a callable is declared inside an owner class.
  However, this does not work for local classes, because they do not
  have proper class IDs. The same issue occurs when trying to get the
  containing class, because it is a lookup tag search in symbol
  providers.
- Given that the scope is only needed for Java classes and local Java
  classes cannot leak from function bodies, the easiest solution is to
  disallow creating this scope for local classes.

^KT-61800
2023-10-10 13:38:00 +00:00
Marco Pennekamp 3d1262140d [AA] Add member scope tests for inner classes
^KT-61900
2023-10-10 13:38:00 +00:00
Marco Pennekamp 9fa0dfe4bc [AA] Allow inner classes in non-static declared member scopes
- An inner class `Inner` in a class `Outer` is accessible as
  `Outer().Inner()` and should thus be part of the non-static declared
  member scope.
- Related issue containing a discussion about inner classes in use-site
  scopes: KT-62023.

^KT-61800
2023-10-10 13:38:00 +00:00
Marco Pennekamp 239cfa6d29 [AA] Add tests for combined declared member scopes
^KT-61800
2023-10-10 13:38:00 +00:00
Marco Pennekamp 5679acbbdb [AA] Remove classifiers from non-static declared member scopes
- The semantics of a non-static declared member scope should be as
  follows: For a variable `c: C` of class type `C`, the declared member
  scope should contain all members `x` accessible as `c.x` (visibility
  notwithstanding) which are *also* explicitly declared in `C`.
- Classifiers are not accessible as properties of a variable `c`, only
  as static members of the class `C` itself, so non-static declared
  member scopes should not contain any classifiers.

^KT-61800
2023-10-10 13:38:00 +00:00
Marco Pennekamp 8b24baade9 [AA] Refactoring: Simplify JavaClassDeclaredMembersEnhancementScope
- `JavaClassDeclaredMembersEnhancementScope` actually had nothing to do
  with Java enhancement, so it is easily replaceable with a more general
  `FirDeclaredMembersOnlyScope`.

^KT-61800
2023-10-10 13:38:00 +00:00
Marco Pennekamp 7a7a923197 [AA] Add getCombinedMemberScope to KtScopeProvider
- The function is mostly for convenience, but scope providers will be
  able to optimize this scope if needed (similar to how combined
  declared member scopes are already optimized).
- `getCombinedMemberScope` will be used by `KDocReferenceResolver`.

^KT-61900
2023-10-10 13:38:00 +00:00
Marco Pennekamp 1408556511 [AA] Refactoring: Rename AbstractMemberScopeByFqNameTest to AbstractMemberScopeTest
^KT-61900
2023-10-10 13:38:00 +00:00
Marco Pennekamp 9db9f58fba [AA] KtFirSymbolProviderByJavaPsi: Remove workaround for missing static callables in Java declared member scopes
- Now that combined declared member scopes for Java classes contain
  static callables, we don't need to search symbols in the static member
  scope. (Note that the static member scope is too broad for this use
  case, as it contains symbols from superclasses, but we only need to
  look at declared members because the correct `containingClass` is
  already chosen.)

^KT-61901
^KTIJ-25126
2023-10-10 13:38:00 +00:00
Marco Pennekamp df54540a81 [AA] Update usages of declared member scopes
- Now that non-static declared member scopes don't contain static
  callables anymore, we have to update some usages in the Analysis API.
- In symbol light classes, many usages of `getDeclaredMemberScope` can
  be kept as-is because Kotlin classes/objects generally cannot declare
  static callables (and we do not need to create symbol light classes
  for Java classes). The only exception are enum classes, which
  implicitly declare some static callables.

^KT-61800
2023-10-10 13:38:00 +00:00
Marco Pennekamp 21efd6aff3 [AA] Add tests for *static* (declared) member scopes
^KT-61900
^KT-61800
2023-10-10 13:38:00 +00:00
Marco Pennekamp 4ba0aef23b [AA] Refactoring: Simplify member scope test classes
^KT-61900
2023-10-10 13:38:00 +00:00
Marco Pennekamp c2d08b9462 [AA] Add additional tests for declared member scopes and member scopes
^KT-61800
2023-10-10 13:37:59 +00:00
Marco Pennekamp dc689952cb [AA] Fix isDeclared for static callables in Java declared member scope
- Static callables don't have a `dispatchReceiverType`, but certainly a
  `CallableId`.

^KT-61800
2023-10-10 13:37:59 +00:00
Marco Pennekamp e5bfcfc9fc [AA] Refine documentation of getMemberScope and getStaticMemberScope
^KT-61900
2023-10-10 13:37:59 +00:00
Marco Pennekamp 71017298d9 [AA] Provide separate non-static and static declared member scopes
- Member scopes already don't contain static callables, only their
  static member scope counterparts. However, declared member scopes
  contained both non-static and static callables, which was confusing to
  users. See for example KT-61255.
- Now declared member scopes only contain non-static callables and
  static declared member scopes only contain static callables.
- In `KtFirScopeProvider`, the new implementation is different for
  Kotlin and Java classes, because the standard declared member scope
  doesn't work for Java. Instead, we have to get the Java *enhancement*
  scopes from `JavaScopeProvider`. Unfortunately, `JavaScopeProvider`
  doesn't have a direct enhancement declared member scope. This results
  in a somewhat complex scope structure with the declared members filter
  scope around the use-site/static Java enhancement scope, but since the
  declared members filtering scope properly reduces the set of callable
  names and scopes in general are cached, this shouldn't be an issue.
- `getCombinedDeclaredMemberScope` is introduced as a separate public
  function because for Kotlin scopes, we don't actually have to create a
  combined scope, as the non-static and static scopes are just filters
  around a combined declared member scope provided by the compiler. It's
  also important to have a convenient function to get the combined
  declared member scope, because some usages explicitly want access to
  all declared members (such as symbol light classes).
- This commit also fixes KT-61901, because
  `getFirJavaDeclaredMemberScope` now provides a proper static scope for
  Java classes, which will be accessible via the combined declared
  member scope as well.

^KT-61800 fixed
^KT-61901 fixed
^KT-61255 fixed
2023-10-10 13:37:59 +00:00
Vyacheslav Gerasimov 8b5f87f15f Build: Fix verification-metadata.xml 2023-10-10 13:53:18 +02:00
Brian Norman ccda8ae23d [FIR] Comparison to String implies smart cast to String
When the left-hand side of an equality comparison is known to be a
String, and the equality condition resolves to true, then the right-hand
side can be smart-cast to a String as well. This was working for String
expressions on the left-hand side but not for String constants.

^KT-57513 Fixed
2023-10-10 11:20:40 +00:00
Artem Daugel-Dauge c19fc3ced3 [Gradle] Fix some macOS Gradle IT 2023-10-10 10:57:08 +00:00