Commit Graph

637 Commits

Author SHA1 Message Date
Dmitriy Novozhilov 75b6f7ca00 [FIR] Make FirRegularClass.companionObject companionObjectSymbol field
This is needed for two reasons:
1. Before this change companion object appeared in FirRegularClass
  twice: in declarations list and in companionObject field. This may
  trigger twice transform of it
2. It's very hard to implement generation of companion object by plugins
  because if it is part of the tree then generated declaration must be
  registered in FirProvider, which is inconsistent with other generated
  declarations. Replacing FIR with symbol and removing custom logic of
  visiting/transforming companion FIR allows us to just replace companionSymbol
  in FirClass if plugin wants to generate it without any additional work
2021-11-23 15:01:05 +03:00
Dmitriy Novozhilov 5778cb440f [FIR] Add FirControlFloGraph owner supertype to FirField
FirField, just like FirProperty, can have control flow graph of it's
  intializer
2021-11-22 20:22:19 +03:00
Dmitriy Novozhilov 9807c67ae4 [FIR] Properly collect overriddens for method enhancement
If some java class has multiple supertypes then we need to collect
  overriddens from all those types directly, even if superTypeScope
  (which is FirTypeIntersectionScope in this case) returns only
  one symbol from one of this types (not intersection one)

This is needed to proper enhancement in cases when some type occurs
  multiple times in supertypes graph with different nullability
  of arguments:

class ConcurrentHashMap<K, V> : AbstractMap<K!, V!>, MutableMap<K, V>

If we try to find method `get(key: K): V` supertype scope returns
  `AbstractMap.get(key: K!): V!` (because it actually overrides
  `MutableMap(key: K): V?`), but we need to get both symbols to
  properly enhance types for `ConcurrentHashMap.remove`
2021-11-22 17:01:17 +03:00
Dmitriy Novozhilov 01c0cf80d0 [FIR] Support @kotlin.jvm.PurelyImplements annotation 2021-11-22 17:01:17 +03:00
Dmitriy Novozhilov 6edf191b7f [FIR] Save classId in declared and use site scopes
This is needed for debug purposes, because without classId or reference
  to class it's very hard to understand which scope you are observing
  in debugger
2021-11-22 17:01:16 +03:00
Ilya Chernikov cad57e693f FIR: introduce declaration origin for binary classes from source module
in particular for incremental compilation when module is only partially
recompiled.
#KT-49750 fixed
2021-11-19 08:36:15 +01:00
Dmitriy Novozhilov e7c9d76163 [FIR] Use SupertypeSupplier in type resolver for calculating supertypes
This is needed to avoid problems with checking visibility of types which
  are used in supertypes during supertypes resolution in IDE, when
  supertypes of some class can be already computed, but not saved in
  class itself, but still lay in supertypeComputationSession

There were 4 failing tests before this changes (all in
  `DiagnosisCompilerTestFE10TestdataTestGenerated$Tests$Exposed`):
- testInternal
- testInternalAndProtected
- testProtected
- testProtectedSameWay
2021-11-16 15:48:07 +03:00
Ivan Kochurkin 4ca757446a [FIR] Add getCorrespondingPlatformClass, getCorrespondingKotlinClass methods to FirPlatformClassMapper 2021-11-12 15:20:43 +03:00
Ivan Kochurkin 646d156bde [FIR] Reuse calculated values and clean up code 2021-11-10 19:07:27 +03:00
Ivan Kochurkin 0dab39b6e3 [FIR] Get rid of unnecessary allocations 2021-11-10 19:07:27 +03:00
Mikhail Glukhikh 6eaeada1e6 FIR: cache properties in use-site scope properly 2021-11-09 21:04:40 +03:00
Mikhail Glukhikh a05244eca1 FIR: don't enhance synthetic property if not needed 2021-11-09 21:04:38 +03:00
Mikhail Glukhikh 6b1da9eb70 Rename: generateAccessorSymbol -> generateSyntheticPropertySymbol 2021-11-09 21:04:37 +03:00
Denis.Zharkov 360d67410d FIR: Fix overridability rule for Java declarations with different return type kinds
See the class at org/jmock/Expectations
public <T> T with(Matcher<T> matcher);
public boolean with(Matcher<Boolean> matcher);

When we extending such class it we start assuming
that fake generic override overrides both of the overridden that is wrong
from POV of Java and it fails at FIR ultimate build

NB: It's hard to write a test because such Expectation-like
class is impossible to write in pure Java
2021-11-02 19:08:28 +03:00
Dmitriy Novozhilov 4490f64666 [FIR] Get rid of FirAnnotatedDeclaration
Now all fir declarations have annotations

^KT-49260 Fixed
2021-10-28 15:01:18 +03:00
Ilya Chernikov a65beb2dc5 Move Fir*SourceElement to frontend.common, rename to Kt* (complete) 2021-10-27 21:44:11 +02:00
Denis.Zharkov 5690a9f21b FIR: Fix overridability of Kotlin vararg from Java 2021-10-26 18:45:59 +03:00
Denis.Zharkov 52c2908bb7 FIR: Fix another inconsistency with FE1.0 in synthetic properties resolution 2021-10-26 18:45:59 +03:00
Denis.Zharkov 35a7f0f73e Minor cleanup 2021-10-26 18:45:58 +03:00
Tianyu Geng f23256bf49 FIR: filter out builtin symbols in JvmClassFileBasedSymbolProvider
These symbols are already provided by FirBuiltinSymbolProvider.
2021-10-23 15:33:31 +02:00
Mikhail Glukhikh 79b98f9173 FIR: introduce synthetic property symbol hierarchy 2021-10-23 01:19:07 +03:00
Mikhail Glukhikh c673c4cc91 FIR: refactor/use properly FirAccessorSymbol & FirSyntheticPropertySymbol 2021-10-23 01:19:06 +03:00
Mikhail Glukhikh 7b9ac4c5f7 FIR: create constructors copies with correct containers in JvmMappedScope
#KT-49133 Fixed
2021-10-23 01:17:10 +03:00
Denis.Zharkov 4ad5f01324 FIR: Support overrides of generic-typed members with raw-typed ones
^KT-49070 Fixed
2021-10-20 22:05:25 +03:00
Mikhail Glukhikh 98d34b40ab FIR: set substituteTypes value explicitly in calls inside providers 2021-10-20 12:17:04 +03:00
Dmitriy Novozhilov bee44c6e0f [FIR] Split :compiler:fir:resolve module into three different modules
Those modules are:
- :compiler:fir:providers, which contains Fir and Symbol providers,
    scopes, and different utilities used by them
- :compiler:fir:semantics, which contains different abstractions and
    entities which are used in resolution and in checkers
- :compiler:fir:resolve, which contains all stuff related to resolution
    and inference

There are two pros of this change:
1. It may increase gradle build, because it allows to compile :fir:resolve
  and :fir:checkers modules in parallel
2. Logic of working FIR (scopes, providers, DFA logic system, etc) is
  now separated from logic of resolution phases, so for example checkers,
  which are depend on scopes physically will not be able to run resolve
  in any way
2021-10-18 11:10:47 +03:00
Dmitriy Novozhilov 6995ee9334 [FIR] Move type context and type approximator to separate session compontent
This is needed to decouple components which are related to type system
  from type inference components
2021-10-18 11:10:47 +03:00
Dmitriy Novozhilov eadb91f9b2 [FIR] Move accessors to main session components close to declarations of those components 2021-10-18 10:55:39 +03:00
Mikhail Glukhikh f4067f05a2 FIR: forbid java.lang.String(String) constructor in JvmMappedScope
#KT-49135 Fixed
2021-10-15 01:24:51 +03:00
Dmitriy Novozhilov b4d955838e [FIR] Properly use FirContainingNamesAwareScope in all places
Split some delegating scopes to basic and name aware implementations

Also get rid of getContainingCallableNamesIfPresent and
  getContainingClassifierNamesIfPresent functions because they are not
  needed anymore
2021-10-12 17:26:43 +03:00
Dmitriy Novozhilov af6d6ec2b9 [FIR] Properly collect constructors from class in presence of plugins 2021-10-12 17:26:41 +03:00
Dmitriy Novozhilov 9bfa6c54b8 [FIR] Inherit FirContainingNamesAwareScope from FirScope
This is needed to simplify FirScope hierarchy, because in
  fact all inheritors of `FirContainingNamesAwareScope` were
  inheritors of `FirScope` too
2021-10-12 17:26:29 +03:00
Denis.Zharkov 9d9f191f51 FIR: Fix exception caused by empty supertypes of java.lang.Object 2021-10-07 17:26:25 +03:00
Roman Golyshev 9b9c51bc8d [FIR] Fix dispatch receivers on inner classes' constructors
1. Inner class constructor should have its outer class as a dispatch
receiver, since it is necessary for the call. Before it was null
2. Substituted inner class constructor should have its original dispatch
 receiver type with the proper substitution. Before it was set to the
 class itself (since the class was usually passed as a new dispatch
 receiver)

Also, modify FIR renderer, so it properly renders the dispatch receiver
of the constructors
2021-10-05 12:17:08 +00:00
Ivan Kochurkin 75b40e4b75 [FIR] Add INVISIBLE_SETTER 2021-10-03 17:10:06 +03:00
Tianyu Geng f35680f0a4 FIR checker: resolve property with protected getter and public setter
Assuming Java class `Super` has a protected `getName` method and a
public `setName` method.

Then, in a subclass of `Super`, FE1.0 allows calls to `setName` via the
property syntax if the property is protected and invisible due to
dispatch receiver is not `this` or `super`.
2021-09-29 19:39:12 +03:00
Denis.Zharkov 9ac29e0714 Fix enhancement when mixing TYPE_USE and non-TYPE_USE annotations 2021-09-28 22:59:18 +03:00
Denis.Zharkov 586dcae141 FIR: Avoid loading symbols when mapping Java type arguments 2021-09-23 16:58:26 +03:00
Denis.Zharkov 38fa900e56 FIR: Optimize case with no annotations on package 2021-09-23 16:58:26 +03:00
Denis.Zharkov 37785eb244 FIR: Rename KotlinDeserializedJvmSymbolsProvider -> JvmClassFileBasedSymbolProvider 2021-09-23 16:58:25 +03:00
Denis.Zharkov 0aa8181960 FIR: Rename AbstractFirDeserializedSymbolsProvider -> AbstractFirDeserializedSymbolProvider 2021-09-23 16:58:25 +03:00
Denis.Zharkov 54a97a860a FIR: Minor. Rename JavaClassConverter -> FirJavaFacade 2021-09-23 16:58:24 +03:00
Denis.Zharkov 9902d36d57 FIR: Minor. Rename 2021-09-23 16:58:24 +03:00
Denis.Zharkov 1fc2f13a35 FIR: Pull creation of JavaClassConverter to session factory 2021-09-23 16:58:22 +03:00
pyos 36b02082a6 FIR: try to load as Java class if KotlinClassFinder returns null
The IDE implementation of KotlinClassFinder does not always return the
class file contents.
2021-09-15 19:15:17 +03:00
Dmitriy Novozhilov 9d09b9605f [FIR] Cleanup and reorganize utils in :compiler:fir:java 2021-09-15 17:11:30 +03:00
Dmitriy Novozhilov 7a347b11e3 [FIR] Use StandardClassIds instead of StandardNames everywhere it's possible 2021-09-15 17:11:30 +03:00
Dmitriy Novozhilov 5c2a3bb78e [FIR] Move duplicating names and classIds to StandardClassIds 2021-09-15 17:11:29 +03:00
pyos 9fa3e2eb13 FIR: always load parents of nested classes first 2021-09-14 19:00:48 +03:00
pyos 032cf5a892 FIR: JavaSymbolProviderWrapper -> JavaSymbolProvider 2021-09-14 19:00:47 +03:00