Commit Graph

825 Commits

Author SHA1 Message Date
Ivan Kochurkin ad7c213ab2 [FIR] Initialize type for annotation arguments during deserialization
Get rid of IrErrorTypeImpl creating in FIR2IR
2022-05-29 23:41:23 +03:00
Mikhail Glukhikh 7c89f0188a FIR: resolve conflicts around SAM calls properly 2022-05-24 12:29:27 +00:00
Denis.Zharkov 9f7876efb6 FIR: Avoid potentially dangerous checks at makesSenseToBeDefinitelyNotNull
Sometimes, it might be called before type parameter bounds are initialized
or even before the symbols are bound to FIR
In such cases, we just assume it makes sense to create DNN there
2022-05-19 16:54:06 +00:00
Denis.Zharkov c766f20554 FIR: Adjust override checker to definitely-not-nullable types
^KT-52201 Related
2022-05-19 16:54:05 +00:00
Denis.Zharkov 40119cb041 FIR: Fix regression-like CONFLICTING_JVM_DECLARATIONS
See the class org.ini4j.Ini used in intelliJ (derived kt class MyIni)
It contains inherited remove override with the following signature:
String remove(Object sectionName, Object optionName)

While also, from kotlin.collections.MutableMap we inherit
boolean remove(Object, Object)

And we should treat them as different methods to have correct signatures
in resulting class scope
2022-05-19 16:54:04 +00:00
Denis.Zharkov 784a911d1a FIR: Minor. Clarify some names at FirTypeIntersectionScopeContext 2022-05-19 16:54:03 +00:00
Denis.Zharkov fb5755a0fa FIR: Refine processing special functions with erased parameters 2022-05-19 16:54:01 +00:00
Denis.Zharkov bf96abeed1 FIR: Fix special members came from superclass
class JavaSuperClass {
  // members impls with special signature, but it doesn't override any Kotlin specials
}

class KotlinInterface {
   // special members
}

class JavaSubClass extends JavaSuperClass implements KotlinInterface {
   // we should obtain members from JavaSuperClass with their Kotlinish
   // signature, not the Java one
}
2022-05-19 16:54:00 +00:00
Denis.Zharkov f70ae2df3a FIR: Refine inference constraints when type variable in flexible position
That issue might be fixed via changing
TypeVariableMarker.shouldBeFlexible at ConeConstraintSystemUtilContext
but this and some other tricks have been added because of incorrect
handling of constraints where type variable has a flexible bound

^KT-51168 Fixed
2022-05-19 16:53:59 +00:00
Denis.Zharkov b87412c5af FIR2IR: Fix substitution work for context receivers 2022-05-13 18:04:02 +00:00
Victor Petukhov 313da6f41e [FIR] Unbind type parameter erasing from java 2022-04-27 19:50:23 +00:00
Ivan Kochurkin 3b8183a736 [FIR] Support of importing optional annotation classes (JS/Native), ^KT-51757 Fixed 2022-04-18 15:36:21 +00:00
Ilya Kirillov 69a53bc742 [low level fir] use correct FirModuleData for declarations provided by FirJavaFacade 2022-04-13 12:53:23 +02:00
Denis.Zharkov 90b12433ec FIR: Add replaceContextReceivers to FirCallableDeclaration 2022-04-06 16:05:31 +00:00
Denis.Zharkov a89680fb34 FIR: Prepare tree for context receivers 2022-04-06 16:05:23 +00:00
Ilya Chernikov 11d6dccf51 FIR IC: do not record lookup on const - builtin types are not recorded 2022-03-30 08:31:26 +00:00
Mikhail Glukhikh b327f5c731 Substitute type variables properly in ConeOverloadConflictResolver
#KT-46187 Fixed
2022-03-23 09:54:46 +00:00
Mikhail Glukhikh 70366c3bcb FIR: forbid java.lang.String deprecated constructors #KT-51364 Fixed 2022-03-21 13:58:13 +00:00
Dmitriy Novozhilov 18fc2802e5 [FIR] Make FirTypeParameter.containingDeclarationSymbol not null
Also fix initializing this property in all places
2022-02-28 11:42:34 +03:00
Dmitriy Novozhilov 52b72a7dac [FIR] Implement Int -> Long conversions for literals and operators over them
^KT-38895
^KT-50996 Fixed
^KT-51000 Fixed
^KT-51003 Fixed
^KT-51018 Fixed
2022-02-07 13:36:36 +03:00
Dmitriy Novozhilov 0bd3e8f418 [FIR] Rename ConeClassErrorType to ConeErrorType, drop ConeKotlinErrorType alias 2022-02-07 13:36:33 +03:00
Mikhail Glukhikh 983fa4c8c7 FIR: add temporary access to Enum.getDeclaringClass (see KT-49653) 2022-01-27 17:27:39 +03:00
Dmitriy Novozhilov 1a3841d66d [FIR] Properly enhance raw Class type in java annotations 2022-01-20 11:25:44 +03:00
Dmitriy Novozhilov 345fdc214b [FIR] Store enhanced functions and properties in session component
Previously enhanced symbols were cached inside SignatureEnhancement,
  which is created independently for each enhancement scope. This may
  cause creation of multiple enhanced symbols for same java declaration
  in presence of multiple scope sessions (mutithread compiler, IDE,
  separate scope session for checkers)

^KT-50858 Fixed
2022-01-19 15:24:43 +03:00
Dmitriy Novozhilov c80cfb0fdb [FIR] Replace single supertype scope with list of scopes of supertypes in use site scopes
This big refactoring is needed to cleanup building of overrides
  mappings and prevent creating redundant intersection overrides in
  cases when there is no need in them:

```kotlin
interface A {
    fun foo()
}

interface B {
    fun foo()
}

interface C : A, B {
    override fun foo()
}
```

Before this refactoring there was next override tree:
C.foo
  intersection override (A.foo, B.foo)
    A.foo
    B.foo

Also this commit fixes special mapping of overrides in jvm scopes
  for declarations which have kotlin builtins in supertypes with
  special java mapping rules (collections, for example)
2022-01-19 15:24:43 +03:00
Dmitriy Novozhilov 17916d4a63 [FE] Return Name? instead of List<Name> from getBuiltinFunctionNamesByJvmName
This is much more correct, because we have one to one mapping for
  special java functions in this case, so using single nullable name
  instead of list of names makes code more readable
2022-01-19 15:24:43 +03:00
Dmitriy Novozhilov d588b2e654 [FIR] Add toString to all type scopes 2022-01-19 15:24:43 +03:00
Roman Golyshev 4418d76a0d FIR: Replace fir.bounds with resolvedBounds where it is appropriate
If there is a `coneType` call immediately after the `fir.bounds` call,
it means that the fully resolved type is expected, hence
`resolvedBounds` should be used
2022-01-14 01:04:24 +03:00
Vyacheslav Gerasimov f7a9065b75 Build: Use intellij maven repo instead of downloaded IDEA
#KTI-82
2021-12-16 21:48:23 +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
Leonid Startsev 767c570af4 Load default values for annotation members from classfiles
so that defaults are available to synthetic implementations.

#KT-48181 Fixed

Implementation is for JVM IR; other backends & FIR need to be supported
separately.
2021-12-07 10:10:04 +00: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
Mikhael Bogdanov a1262a4ecd Rename JVM default flags 2021-12-06 14:20:25 +01:00
Denis.Zharkov 46217318c0 FIR: Load final static constant Java fields as non-nullable 2021-11-26 19:39:48 +03:00
Denis.Zharkov 6f55d23bab FIR: Support nested light classes 2021-11-26 19:39:31 +03:00
Mikhail Glukhikh 4a8f00bc7c FIR2IR: support reading of isNewPlaceForBodyGeneration in lazy class 2021-11-26 09:18:11 +03:00
Mikhail Glukhikh c652cd2245 Fix typo 2021-11-26 09:18:11 +03:00
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