Commit Graph

1271 Commits

Author SHA1 Message Date
Denis.Zharkov dab50daf56 K2: Add ability identify DI components by string key instead of KClass
It allows having several the same typed-component in the container
2023-01-19 10:57:42 +00:00
Dmitrii Gridin e2e87bd107 [FIR] CustomAnnotationTypeAttribute: drop redundant type specification
^KTIJ-23547
^KTIJ-24141
2023-01-19 10:53:05 +00:00
Dmitrii Gridin 73cdaf5c3c [FIR] CustomAnnotationTypeAttribute: support type aliases
^KTIJ-23547
^KTIJ-24141
2023-01-19 10:53:03 +00:00
Dmitrii Gridin 8ce4c4eba9 [FIR] CustomAnnotationTypeAttribute: store fir symbol instead of declaration
^KTIJ-23547
^KTIJ-24141
2023-01-19 10:53:02 +00:00
Dmitrii Gridin 9d42a5cb01 [FIR] provide containerDeclaration to CustomAnnotationTypeAttribute for lazy resolve
tested by FirIdeNormalAnalysisSourceModuleSymbolByPsiTestGenerated.testTypeAnnotations

^KTIJ-23547 Fixed
^KTIJ-24141 Fixed
2023-01-19 10:53:02 +00:00
Dmitriy Novozhilov 4363b0815c [FIR] Add ability to specify if meta annotation itself should match metaAnnotated predicate
^KT-55843 Fixed
2023-01-17 14:51:28 +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 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
Ilya Kirillov 89f37816a8 [FIR] disable lazy resolve contract checks for FIR2IR 2023-01-13 15:57:06 +00:00
Dmitriy Novozhilov 1984a1615e [Serialization] Use new DSL for generating declarations 2023-01-12 17:45:41 +00:00
Dmitriy Novozhilov 42db0b14f0 [FIR] Move all type construction utilities into one file 2023-01-12 17:45:40 +00:00
Dmitriy Novozhilov ce8489a8a5 [FIR] Add ability to create accessor to declaration attribute on symbol 2023-01-12 17:45:40 +00:00
pyos aadea0e26f FIR CFA: properly visit subgraphs in checkers
Interpretation: a graph A is a subgraph of B if information available at
nodes of A depends on the paths taken in B. For example, local classes
are subgraphs of a graph in which they are declared, and members of
those classes are subgraphs of the local class itself - because these
members can reference captured values.

Consequences:

 * if graph G is a subgraph of node N, then G is a subgraph of N's
   owner;
 * `ControlFlowAnalysisDiagnosticComponent` will only visit root graphs;
 * `graph.traverse` will ignore subgraph boundaries, as if all subgraphs
   are inlined into one huge root graph;
 * if a control flow checker needs information from a declaration to
   which a graph is attached, it must look at subgraphs explicitly.

For example, consider the `callsInPlace` checker. When a function
has a `callsInPlace` contract and a local declaration, the checker must
visit that local declaration to ensure it does not capture the allegedly
called-in-place argument - hence `graph.traverse` will look at the
nodes. However, the local declaration can also be a function with its
own `callsInPlace` contracts, so the checker should also run for it in
isolation. If that sounds quadratic, that's because unfortunately it is.
2023-01-10 15:40:48 +02:00
Mikhail Glukhikh 7904f23660 FE: add & fix test with intersection property shadowed by base field 2023-01-09 21:37:22 +00:00
Nikolay Lunyak 5b3a73f7cd [FIR JS] Implement FirJsNativeAnnotationChecker 2023-01-09 08:57:12 +00:00
Nikolay Lunyak a20e29e8b7 [FIR JS] Implement FirJsExternalChecker
The JsAllowValueClassesInExternals feature is enabled explicitly,
because otherwise it's enabled
implicitly depending on the backend. See:
org/jetbrains/kotlin/test/builders/LanguageVersionSettingsBuilder.kt:90

A property may have a fake source return kind, while its accessor
has a real source kind. In this case we can't "just copy"
the property return type down to the accessor.
2023-01-09 08:57:11 +00:00
Nikolay Lunyak 7b8f5f9980 [FIR JS] Implement FirJsRuntimeAnnotationChecker 2023-01-09 08:57:11 +00:00
Nikolay Lunyak 4cf8d9ffb9 [FIR JS] Implement FirJsInheritanceChecker 2023-01-09 08:57:10 +00:00
Nikolay Lunyak eed2fada1f [FIR JS] Support WRONG_MULTIPLE_INHERITANCE 2023-01-09 08:57:09 +00:00
Nikolay Lunyak 0426f35684 [FIR JS] Report JS_MODULE-related diagnostics 2023-01-09 08:57:08 +00:00
Ilya Kirillov 79fe4100aa [FIR] extract exception handing into a service to have additional implementation for the ide 2023-01-03 10:23:50 +00:00
Ilya Kirillov 90436abb23 [FIR] add FirSession parameter to whileAnalysing
It will be needed in the following commits
2023-01-03 10:23:49 +00:00
Alexander Udalov 3c4b5529af Update year to 2023 in COPYRIGHT_HEADER.txt
This commit is the result of changing the year to 2023 in
COPYRIGHT_HEADER.txt and running all `generate*` tasks in
`generators/build.gradle.kts`.
2023-01-02 22:52:15 +01:00
Ilya Kirillov 4d7e9b2d5a [FIR] add possibility to specify initialCapacity and loadFactor in FirCachesFactory.createCache 2022-12-27 13:27:23 +00:00
Yan Zhulanow d652dc620c [FE] Preserve legacy contract description calls in bodies
^KT-55231 Fixed
^KTIJ-21012 Fixed
2022-12-26 11:46:58 +00:00
Anna Kozlova 15b1e429d7 [compiler] introduce dedicated Fir declaration for dangling modifier lists (KTIJ-23008)
ensure fir annotations are included in FirDanglingModifierList and resolved,
dedicated DanglingTopLevelModifierListStructureElement exists for top
level lists only, class level lists are processed by containing structure
element
2022-12-21 20:58:46 +00:00
Ilya Chernikov a89dfdce03 K2 Scripting: add support for script args to FIR part 2022-12-21 14:34:20 +00:00
Dmitriy Novozhilov c44993e586 [FE] Use FQN instead of KClass in TypeRegistry
TypeRegistry is the static map which contains mapping between type of
  session component and its index in the session array. Originally
  `KClass` of a component was used as a key in this map, which worked
  pretty well for compiler components. But there was a problem with
  components from plugins and Kotlin daemon: in compilation with daemon
  we keep TypeRegistry between compilations. But for each compilation
  we load plugins from jar, which brings to the situation when after N
  compilations there is N entries in TypeRegistry map with different
  KClass'es for same extension component. This not only causes AIOBE
  but also introduces the memory leak, because we keep reference to
  KClass which is not used anymore

So to fix this issue it's enough to just store FQN of component in
  TypeRegistry instead of KClass

There are no tests in this commit, but they will be added in next
  commit relevant to scripting. With those commits we will have gradle
  integration tests which uses Kotlin compiler daemon and registers
  a compiler plugin for scripting

^KT-55023 Fixed
2022-12-21 10:33:03 +00:00
Mikhail Glukhikh 7a7d93828e Fix MutableOrEmptyList implementation details 2022-12-20 11:04:28 +00:00
Mikhail Glukhikh 761a0f8248 K2: introduce & use (for annotation creation) smartPlus for lists 2022-12-20 11:04:27 +00:00
Mikhail Glukhikh f33f87e3d4 K2: drop unused qualifier in FirJavaTypeRef 2022-12-20 11:04:27 +00:00
Mikhail Glukhikh e9fbeb9be2 K2: use MutableOrEmptyList for context receivers on declaration site 2022-12-20 11:04:27 +00:00
Mikhail Glukhikh d20d63786b K2: use MutableOrEmptyList for type arguments 2022-12-20 11:04:26 +00:00
Mikhail Glukhikh a48610000d K2: introduce & use MutableOrEmptyList.EMPTY singleton 2022-12-20 11:04:26 +00:00
Mikhail Glukhikh ddc786364f K2: use MutableOrEmptyList for context receivers 2022-12-20 11:04:26 +00:00
Mikhail Glukhikh dff71a9602 K2: use MutableOrEmptyList for nonFatalDiagnostics 2022-12-20 11:04:25 +00:00
Mikhail Glukhikh 582b640bec K2: use MutableOrEmptyList for annotations storage in FIR elements 2022-12-20 11:04:25 +00:00
Mikhail Glukhikh be5394e211 Fix minor formatting issue in generated FIR tree 2022-12-20 11:04:24 +00:00
Dmitriy Novozhilov d75160250d [FIR] Drop transformExtensionReceiver and transformDispatchReceiver from FirQualifiedAccess
After removal of `StoreReceiver` transformers those methods are not used
  anymore, so it's ok to remove them at all
2022-12-20 08:12:10 +00:00
Dmitriy Novozhilov 9ccbf8639d [FIR] Add dispatchReceiverType to FirAnonymousInitializer
This is needed to add ability to quickly find class to which initializer
  belongs
2022-12-20 08:12:09 +00:00
Dmitriy Novozhilov d45ae59d33 [FIR] Add methods to replace dispatch and extension receivers 2022-12-20 08:12:07 +00:00
Dmitriy Novozhilov 4bddb27ca3 [FIR] Get rid of candidateSymbol in FirNamedReference
`candidateSymbol` has any reasonable meaning only for references with
  not completed candidate, so this property is moved from FirNamedReference
  to new node FirNamedReferenceWithCandidateSymbol, which has real
  implementation only in :resolve module (`FirNamedReferenceWithCandidate`)
2022-12-20 08:12:07 +00:00
Dmitriy Novozhilov 34be0f05b2 [FIR] Add utility for checking if FirReference is one of error reference
Also simplify relevant code in checkers
2022-12-15 12:12:21 +00:00
Dmitriy Novozhilov 7334694fd9 [FIR] Remove some rare used utilities 2022-12-15 12:12:20 +00:00
Dmitriy Novozhilov b53c4a6353 [FIR] Introduce some typed FirReference.toResolvedXXXSymbol utilities 2022-12-15 12:12:20 +00:00
Dmitriy Novozhilov cffc32ec76 [FIR] Fir utils for FirReference in package org.jetbrains.kotlin.fir.references 2022-12-15 12:12:20 +00:00
Dmitriy Novozhilov dde64c10ea [FIR] Create FirResolvedErrorReference for error reference with single candidate
Note that this reference won't be created for hidden candidates,
  because they are designed to be truly invisible from the user side
2022-12-15 12:12:19 +00:00
Dmitriy Novozhilov 9e4e5eed68 [FIR] Introduce FirResolvedErrorReference node 2022-12-15 12:12:19 +00:00
Ilya Kirillov 7bac119f20 [FIR] add lazy resolution contract checks in resolve 2022-12-12 16:21:06 +00:00