Commit Graph

56 Commits

Author SHA1 Message Date
Simon Ogorodnik bb13583862 FIR: Rename stub type for builder inference 2021-12-15 22:23:13 +03:00
Simon Ogorodnik df9da371cb FIR: Fix synthetic type variables to independent stub types 2021-12-15 22:23:11 +03:00
Simon Ogorodnik 19a9091966 FIR: Add correct Any? supertype for stub types 2021-12-15 22:23:00 +03:00
Simon Ogorodnik 3fadf1cb46 FIR: Avoid creating new stub type constructors on nullability replacing 2021-12-15 22:22:59 +03:00
Simon Ogorodnik 61ea65906c FIR: Implement captured type substitution 2021-12-15 22:22:58 +03:00
Simon Ogorodnik 7b8ece8758 FIR: Make constraint injector treat stub types as type variables 2021-12-15 22:22:55 +03:00
Simon Ogorodnik 196be93d42 FIR: Add separate type constructor to stub types 2021-12-15 22:22:54 +03:00
Simon Ogorodnik 2e01377ce0 FIR: Substitute dispatch receiver in substitution overrides 2021-12-15 22:22:53 +03:00
Tianyu Geng a5844b754e Type Approximation: add separate flag to control approx. anonymous type
This extra flexibility is useful for IDE where we always want to
approximate anonymous types but may not want to approximate other local
 types
2021-12-15 16:09:27 +03:00
Mikhail Glukhikh 09585d116e FirTypeIntersectionScope: fast success in isMoreSpecific 2021-12-13 16:24:58 +03:00
Ivan Kochurkin f68c8f8f01 [FIR] Fix visibility issues with private members within inner and anonymous scopes ^KT-49992 Fixed 2021-12-09 12:31:24 +00:00
Dmitry Petrov 50b0dae786 KT-47939 fixes after review 2021-12-08 14:12:37 +03:00
Dmitry Petrov 1fd0dec5e7 FE KT-47939 callable references to functional interface constructors
Allow callable references to Kotlin 'fun interface' constructors.
Prohibit callable references to Java SAM interface constructors.
2021-12-08 14:12:33 +03:00
Mikhail Glukhikh f8b3eb0801 FIR: introduce helpers to get resolved reference / symbol 2021-12-07 23:17:34 +03:00
Mikhail Glukhikh 852475337b FIR: use only most specific members when building intersection
In this commit we drop less concrete members in intersection.
See for example change in test data: before the commit, we intersected
all three A.foo, B.foo and C.foo in diamond hierarchy. After the commit
we drop A.foo and intersect B.foo and C.foo only.
2021-12-07 23:17:20 +03:00
Mikhail Glukhikh a4f7bee9ad FirTypeIntersectionScope: minor mutability refactoring 2021-12-07 23:17:15 +03:00
Victor Petukhov 61d40403e7 [FE 1.0] Create captured star projection for self types by replacing type arguments deeply
^KT-49752 Fixed
2021-12-07 11:38:45 +03:00
Mikhail Glukhikh de783ad51f FIR: clarify some calls around lookupTag.toSymbol 2021-12-06 18:07:20 +03:00
Mikhail Glukhikh d842ac5d3e FIR: change dispatch receiver type to ConeSimpleKotlinType 2021-12-06 18:07:20 +03:00
Mikhail Glukhikh 2ba2453062 ConeFlexibleType: statically require to have simple bounds 2021-12-06 18:07:19 +03:00
Dmitriy Novozhilov 1f0b62b25f [FIR] Add smartcasts from == if equals is from Any
^KT-49127 Fixed
2021-12-03 14:19:25 +03:00
Dmitriy Novozhilov c46e9943cc [FIR] Get rid of FirExtension.key
In reality plugin key was used only in two ways:
- found corresponding generator for member scope of generated class
- pass it to declaration origin so it can be read in backend IR plugin

Because of first usage plugin key was required to be an object, which
  reduces functionality of second usage, because there was no way to
  pass any additional info via key to IR (in future this usecase will be
  covered with IR declaration attributes, but right now we don't have
  them)

So now generator which created some class is now saved in its attributes
  and plugins can use any keys they want. And since there is no other
  usages of `FirExtension.key` it removed from FirExtension API at all
2021-11-30 12:57:53 +03:00
Dmitriy Novozhilov e7af50fe2b [FIR] Allow all extensions register declaration predicates 2021-11-30 12:57:52 +03:00
Denis.Zharkov 883b18a0c6 FIR: Preserve non-custom attributes after substitution
The test is being fixed since synthetic call for elvis has @Exact-attribute on return type
2021-11-26 19:39:45 +03:00
Dmitriy Novozhilov f2c319c4ae [FIR] Add ability to safe proper ConeKotlinType in FirErrorTypeRef
This is needed for cases when some type ref is resolved to proper type
  but has some diagnostic (e.g. this type is invisible)
2021-11-26 11:26:16 +03:00
Dmitriy Novozhilov cb0705ec03 [FIR] Change scheme of generating declarations by plugins
Methods `needToGenerateAdditionalMembersInClass` and
  `needToGenerateNestedClassifiersInClass` are removed, now compiler
  uses `get...Names` and `getTopLevel...` methods to determine which
  extension may generate declaration with specific classId/callableId

This is needed to simplify API of FirDeclarationGenerationExtension and
  provide guarantee that `generate...` method will be called with
  specific classId/callableId only if specific extensions returned name
  for this id from `getName...` functions
2021-11-23 15:01:28 +03:00
Dmitriy Novozhilov 9948ba57c0 [FIR] Add ability to generate companion object from compiler plugin 2021-11-23 15:01:15 +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 339c69fef0 [FIR] Collect all supertypes with same type constructor in corresponding supertypes cache
This is needed to fir behavior of cache with algorithm in
  abstract type checker
2021-11-22 17:01:17 +03:00
Dmitriy Novozhilov d72fcc92fe [FIR] Add utility function for collecting overridden tree for debug purposes 2021-11-22 17:01:16 +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
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 5fda933c33 [FIR] Unify code of type unification, fix intersection types processing in FirCastDiagnosticsHelpers.kt 2021-11-12 15:20:47 +03:00
Ivan Kochurkin 4ca757446a [FIR] Add getCorrespondingPlatformClass, getCorrespondingKotlinClass methods to FirPlatformClassMapper 2021-11-12 15:20:43 +03:00
Ivan Kochurkin e52a410599 [FIR] Initialize outer type parameters for local classes 2021-11-12 15:20:42 +03:00
Mikhail Glukhikh d91384434c Drop some unnecessary casts in FIR code 2021-11-12 12:53:22 +03:00
Ivan Kochurkin ee490128fc [FIR] Optimize FirDeprecationChecker 2021-11-10 19:07:25 +03:00
Mikhail Glukhikh 3d60064310 Extract & reuse ConeKotlinType.findClassRepresentation in FIR2IR 2021-11-09 21:04:40 +03:00
Mikhail Glukhikh 6eaeada1e6 FIR: cache properties in use-site scope properly 2021-11-09 21:04:40 +03:00
Roman Golyshev 29bb8cea8f [FIR] Add missing ensureResolved to FirClassSubstitutionScope
`createNewTypeParametersAndSubstitutor` call might need resolved types
to be able to work correctly with the generics' type bounds
2021-10-29 15:59:35 +03:00
Dmitriy Novozhilov 0cce0fbbfb [FIR] Remove unused methods from FirProvider
Those methods were created for first prototype of FIR plugin API, and
  now they are completely redundant
2021-10-28 15:01:22 +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
Jinseong Jeon 3f2c86afb8 FIR IDE/LC: introduce/use delegated member scope 2021-10-27 17:06:32 +02:00
Victor Petukhov 64c682f465 Remove constraints containing stub types after completion of the common system of a builder inference call
^KT-49285 Fixed
2021-10-26 19:37: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
Ivan Kochurkin c13822a2c5 Optimize containsKey -> get pattern 2021-10-25 21:21:44 +03: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