Commit Graph

3811 Commits

Author SHA1 Message Date
Vladimir Sukharev f98451e381 rrn/sukharev/kt59433-add-text-for-NESTED_CLASS_ACCESSED_VIA_INSTANCE_REFERENCE
Follow-up to https://jetbrains.team/p/kt/reviews/12502/timeline which was incomplete for https://youtrack.jetbrains.com/issue/KT-59433/K2-Missing-NESTEDCLASSACCESSEDVIAINSTANCEREFERENCE
- Fix test DefaultMessagesTest by adding a text for new diagnostic.
- Move diagnostic's definition into better place

Merge-request: KT-MR-12680
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-10-20 18:04:21 +00:00
Ivan Kylchik 69a888b431 [FIR] Add diag test to verify const checker in Java world
Currently, this test is not working for FIR.

#KT-57802 Fixed
2023-10-20 16:33:21 +00:00
Marco Pennekamp 72438f4969 [AA] Remove obsolete memberScopeByFqName test data
- The test data was already moved to `memberScope`, but some files were
  not deleted (see: 67ac985be7).
2023-10-20 13:28:12 +00:00
Roman Golyshev 0747fc36de KTIJ-27434 [AA] Unwrap safe call expression when resolving implicit invoke calls
`FirSafeCallExpression` does not implement `FirResolvable`, so we need
to unwrap it to correctly resolve calls like `foo?.bar()` when `bar` is
a lambda with receiver parameter or a functional type property

^KTIJ-27434 Fixed
2023-10-20 13:27:31 +00:00
Pavel Kirpichenkov 770332152b [LL] Don't register Java components for built-ins of non-JVM modules
This is the cause for the 'missing dependency supertype: Serializable'
issue: symbols from built-ins will have the additional Serializable
supertype provided by FirJvmDeserializationExtension that shouldn't
be used for non-JVM. In regular modules it is correctly not added by
the non-JVM sessions, leading to difference in supertypes and the error.

KTIJ-27449
2023-10-20 10:35:13 +00:00
Dmitrii Gridin 0b45c6ce23 [FIR] FirScriptConfiguratorExtensionImpl: provide source for script parameters
We need this source to be able to find the parent declaration

^KT-62693 Fixed
2023-10-20 09:27:21 +00:00
Dmitrii Gridin 17ab005668 [Analysis API FIR] KtSymbolContainingDeclarationProvider: support script declarations
This commit also fixes a missing symbol for KtScriptInitializer
and some symbol pointers
Many tests marked as 'DO_NOT_CHECK_NON_PSI_SYMBOL_RESTORE'
due to KtFirFileSymbol#createPointer logic – the pointer can
be created only for PSI

^KT-61451
^KT-61887
^KT-62626 Fixed
^KT-62693
2023-10-20 09:27:21 +00:00
Dmitrii Gridin d689c1a38f [FIR] FirJavaFacade: fix contract violation from annotations
`isJavaDeprecatedAnnotation` can't be used here because it triggers
the resolution of an annotation ClassId

^KT-62705 Fixed
2023-10-20 09:24:43 +00:00
Alexander Udalov 731a1dd98d FIR: remove unused copy of CONFLICTING_JVM_DECLARATIONS
It was added as a placeholder in f3c58a1df7 and was not used anywhere.
The used error is declared in `JvmBackendErrors` and is reported by the
backend.
2023-10-20 08:01:59 +00:00
Ilya Chernikov 268d058bbb Implement missing invoke resolution branch with context receivers
#KT-61937 fixed
Note: the current implementation only resolves for a single receiver
in each group. See KT-62712 and KT-62709 for the followup.
2023-10-19 19:39:31 +00:00
Dmitrii Gridin 500de9f9bb [LL FIR] FirElementBuilder: avoid body resolution for type references inside 'where'
^KT-62691 Fixed
2023-10-19 16:24:32 +00:00
Dmitrii Gridin 35567d453b [LL FIR] add lazy resolution tests on 'where' construction
^KT-62691
2023-10-19 16:24:32 +00:00
Dmitrii Gridin 3817f37011 [FIR] rename ANNOTATIONS_ARGUMENTS_MAPPING phase to ANNOTATION_ARGUMENTS
^KT-62679
2023-10-19 14:34:35 +00:00
Dmitrii Gridin a86bae2c32 [FIR] drop ARGUMENTS_OF_ANNOTATIONS phase
^KT-62679 Fixed
2023-10-19 14:34:35 +00:00
Dmitrii Gridin a60777b9a7 [FIR] move annotation recheck logic to ANNOTATIONS_ARGUMENTS_MAPPING phase
ARGUMENTS_OF_ANNOTATIONS will be dropped, so this check should be moved
This commit also drops class annotations resolution from implicit type
phase and provides the correct scope during argument mapping phase.
This code was effectively unreachable before

^KT-62679
2023-10-19 14:34:35 +00:00
Dmitrii Gridin 01905a5a06 [LL FIR] move common annotation transformation logic into LLFirAnnotationArgumentMappingLazyResolver
^KT-62679
2023-10-19 14:34:35 +00:00
Dmitrii Gridin f5763cf34a [LL FIR] move context calculation to CONTRACTS phase
ARGUMENTS_OF_ANNOTATIONS will be dropped, so CONTRACTS is the next one

^KT-62679
2023-10-19 14:34:35 +00:00
Dmitrii Gridin 32ed81440c [FIR] add missing transformation of annotation type arguments
^KT-62679
2023-10-19 14:34:35 +00:00
Dmitrii Gridin 27c5a0b60d [LL FIR] add lazy resolve test on conflict of compiler required annotation
^KT-62679
2023-10-19 14:34:35 +00:00
Roman Golyshev 3c68b27280 KT-62071 [AA] Do not throw error from getScopeContextForPosition when implicitScope of receiver value is null
`implicitScope` can be `null`
in case when the implicit receiver resides in a user-defined `kotlin.*`
package, but the user have not yet allowed this with compiler argument
directive.

In this case,
we don't want the IDE to crush and show exceptions - the `kotlin`
package would be highlighted by the compiler diagnostics and other
resolve problems, and that would be enough

^KT-62071 Fixed
2023-10-19 12:59:47 +00:00
Nikolay Lunyak 06b3c6ec13 [FIR] Reproduce KT-62541 2023-10-19 09:27:44 +00:00
Ilya Kirillov 67ac985be7 [Analysis API Standalone] fix testdata for standalone mode tests
The commit (7db2fc522e) with changing behavior of builtin symbol provider
is in a conflict with a commit (72de86a8ba) where new tests were added.

The difference should be fixed as a part of KT-62651
2023-10-18 19:50:44 +00:00
Sergej Jaskiewicz 417aa236fb [FIR/IR generator] Factor out printing the preamble in generated files 2023-10-18 18:42:40 +00:00
Alejandro Serrano Mena b9b15cba08 [K2] Warn about deprecation and opt-in markers for overrides of Any
^KT-62620 Fixed

Include opt-in markers in the diagnostics
2023-10-18 12:34:58 +00:00
Dmitriy Novozhilov 43929398da [FIR] Pass implications from subject of safe call in DFA
^KT-59689 Fixed
2023-10-18 12:17:44 +00:00
Alexander Kuznetsov 45792c2e60 [Analysis API] support unsigned arrays creation functions
IDEA-335151, KT-62663


Merge-request: KT-MR-12614
Merged-by: Alexander Kuznetsov <Aleksander.Kuznetsov@jetbrains.com>
2023-10-18 10:53:52 +00:00
Mikhail Glukhikh 4ed7504d87 FIR deserializer: apply attributes on type parameter-based types
#KT-62578 Fixed
2023-10-18 10:30:31 +00:00
Dmitriy Novozhilov fa69d4837b [AA] Add workaround for KT-62578 2023-10-18 07:59:27 +00:00
Dmitriy Novozhilov 605a567e10 [AA] Add workaround for KT-62544 2023-10-18 07:59:27 +00:00
Dmitriy Novozhilov 704e2ef5c5 Suppress K2 specific warnings in the codebase
^KT-62472
2023-10-18 07:59:27 +00:00
Dmitriy Novozhilov 6114e4f068 Fix compilation problems caused by migration to 2.0 2023-10-18 07:59:27 +00:00
Anastasia.Nekrasova 9ad4cf4c55 [K2] Disappeared OPT_IN_USAGE_ERROR for a data class property during the destructuring declaration
^KT-62450
2023-10-17 21:27:13 +00:00
Dmitrii Gridin b03e3f0b0d [LL FIR] pass correct context during class annotation arguments mapping
The root cause of the problem is that we visit class annotations more
accurately than in the regular compiler transformer, so we have
a difference: the compiler assumes that annotation processing
of the class is called already inside this class, so it should enable
CLASS_HEADER_ANNOTATIONS mode to not capture extra context.
But we in LL FIR do this out of the class, so such context switching
is redundant and results in cutting out the outer class context

^KT-62587 Fixed
2023-10-17 20:32:11 +00:00
Dmitrii Gridin bbd09c6272 [LL FIR] add tests for nested class as annotation argument
^KT-62587
2023-10-17 20:32:11 +00:00
Dmitrii Gridin 5298d79dec [LL FIR] drop extra withContainingClass from annotation transformers
This call is redundant for annotation transformers because
they are override withRegularClass and add this call there,
so, as result, we have a class duplication in
containingClassDeclarations

^KT-62587
2023-10-17 20:32:11 +00:00
Dmitrii Gridin 21f81a8057 [LL FIR] fix lazy annotation arguments calculation for unresolved type references
Such references don't have explicit annotations yet (KT-62628), so we
should explicitly check type attributes

^KT-62625 Fixed
2023-10-17 20:32:11 +00:00
Dmitrii Gridin ec79d8cd27 [SLC] add multiplatform test cases on typealias actualization
^KT-62345
2023-10-17 17:19:40 +00:00
Dmitrii Gridin 8f0cf3f0cc [SLC] allow multi-module test cases
^KT-62345
2023-10-17 17:19:40 +00:00
Dmitrii Gridin 0771b60777 [Analysis API] support multiplatform test cases
^KT-62345
2023-10-17 17:19:40 +00:00
Ilya Kirillov 7db2fc522e [Analysis API Standalone] fix builtin resolution for common module
StubBasedBuiltInsSymbolProvider does not work for now for common modules (KT-61757)
 but compiler builtins provider `FirBuiltinSymbolProvider` works.

Also, stub-based symbol providers should not be used in standalone mode.

Testdata from standalone is updated because of the difference
in property accessors (KT-62449) between stub and compiler builtin symbol providers.

Additionally, this commit fixes the behavior of `KotlinStaticPsiDeclarationFromBinaryModuleProvider`.
As compiler builtin declarations have no PSI attached,
`KotlinStaticPsiDeclarationFromBinaryModuleProvider` is used to get PSI
from `DecompiledPsiDeclarationProvider.findPsi`.
`DecompiledPsiDeclarationProvider` is only used in UAST standalone mode.
2023-10-17 13:23:11 +00:00
Evgeniy.Zhelenskiy 5b4731a780 [FIR] Fix local typealias visibility resolution
#KT-60026
2023-10-17 12:48:04 +00:00
Dmitriy Novozhilov 8ccbbedbd5 [Test] Update debugger testdata because of KT-62521 2023-10-17 12:46:28 +00:00
Dmitriy Novozhilov 000c24fc69 [Raw FIR] Add test for callable ids of functions inside body of enum entry 2023-10-17 12:46:27 +00:00
Vladimir Sukharev 242c1cf5f0 [FIR] Fix disappeared REPEATED_ANNOTATION for dynamic types
https://youtrack.jetbrains.com/issue/KT-59916/K2-Disappeared-REPEATEDANNOTATION
FirAnnotationChecker does not detect repeated annotation on dynamic type, since FirTypeResolverImpl wrongly did not convert source annotations to attributes of ConeDynamicType.
This MR improves FirTypeResolverImpl to convert attributes of FirDynamicTypeRef to annotations and attach them to ConeDynamicType.

Merge-request: KT-MR-12551
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2023-10-17 10:18:36 +00:00
Dmitrii Gridin d9071aed78 [LL FIR] LLFirAnnotationArgumentsTargetResolver: add missing context for value parameters 2023-10-17 09:30:44 +00:00
Roman Golyshev cb65d2420f KTIJ-27139 [AA] Clean-up KtFirReferenceShortener
Unify the code which detects whether qualified expression/type is
actually selected
2023-10-16 20:05:01 +00:00
Roman Golyshev d2fcd71d23 KTIJ-27139 [AA] Shorten qualified expressions only when the callee/type reference is in selection
If you want to shorten call like `foo.bar()` into `bar()`, then you
need your range to intersect with `bar` callee reference. Having only
`foo` in the range is not enough

Same goes for the type references - to shorten `foo.Bar` into `Bar`, you
need at least some intersection of your range with `Bar` reference

^KTIJ-27139 Fixed
^KTIJ-27015 Fixed
2023-10-16 20:05:01 +00:00
Ivan Kochurkin 498f2e534a [FIR] Don't enhance Int and String Java final static fields
It's effectively a breaking change (^KT-62558)

K2 assigns flexible type to all static fields (from Java) and, for example,
`String? becomes String unlike K1. It affects IR signature generating.
That's why signature dump is disabled for some tests.

^KT-57811 Fixed
^KT-61786 Fixed
2023-10-16 17:16:56 +00:00
Ivan Kochurkin 2d61b9a477 [FIR] Elvis operator: flexible rhs type implies flexible type of whole elvis
It's required for further removing of enhancement of final static fields

Also, it's k2-potential feature

^KT-62467 Fixed
2023-10-16 17:16:56 +00:00
Dmitrii Gridin 976fb7d093 [LL FIR] support lazy resolution for synthetic properties and accessors
Such declarations are just wrappers, so we should delegate
resolution to the original declarations

^KT-61990 Fixed
2023-10-16 15:07:11 +00:00