Commit Graph

747 Commits

Author SHA1 Message Date
Ilya Kirillov 9ac9bef20f [FIR] fix nested access to FirCache
it's forbidden by the contract and causes ISE "Recursive update" or deadlock in the IDE
2022-10-02 19:00:02 +02:00
Mikhail Glukhikh f68f06a93f FIR visibility checker: remove redundant session from isVisibleForOverriding 2022-09-29 08:34:14 +00:00
pyos 3a5d75fd22 K2: introduce platform-specific visibility checks for overrides + tests
Related to KT-53197
2022-09-29 08:34:13 +00:00
pyos ecdd80769e FIR: do not read a Java nested class if the outer class is Kotlin
Example: if C is a Kotlin class and there is an import of C.Companion.f,
a call to f will need to check if it is a constructor, for which
it will attempt to load C.Companion.f as a Java class. This involves
loading all outer classes, including C itself, as BinaryJavaClass - see
KotlinCliJavaFileManagerImpl - despite the fact that C and C.Companion
have both already been loaded from their Metadata annotations as Kotlin
classes, wasting cycles and polluting caches.

Thus the theoretical motivation for this change is to marginally speed
up FIR.

The real motivation is that with the -Xemit-jvm-type-annotations option,
kotlinc sometimes generates invalid annotations, and reading them with
BinaryJavaClass throws an exception (the Kotlin metadata however is
valid):

    // MODULE: lib
    // FILE: C.kt
    // The constructor has an argument of type
    //   List<? extends Function1<? super String, Integer>>
    // and a ParameterName type annotation with path
    //   TYPE_ARGUMENT(0), TYPE_ARGUMENT(0)
    // which is missing a WILDCARD between the two TYPE_ARGUMENTs
    class C(val x: List<(name: String) -> Int>) {
      companion object {
        fun foo() {}
      }
    }
    // MODULE: main(lib)
    // FILE: main.kt
    import C.Companion.f

    fun bar() = foo() // crashes FIR

The parameter annotation should obviously be fixed too, but invalid
bytecode may already exist in the wild. Also, did I mention that this
change marginally speeds up FIR?
2022-09-16 08:44:15 +00:00
Arseniy Terekhov 539e5f82e2 [FIR] DeprecationProvider: inline builder, fix named arguments, cosmetic 2022-08-19 07:37:55 +00:00
Arseniy Terekhov a80870bc8f [FIR] DeprecationsProvider: caching results 2022-08-19 07:37:54 +00:00
Arseniy Terekhov 25fc948d95 [FIR] DeprecationsProvider: make evaluation of deprecations on demand 2022-08-19 07:37:54 +00:00
Vsevolod Tolstopyatov 93f17a2b86 [FIR] Support static getters along with fake Enum.entries declaration in FIR
#KT-48872
2022-08-12 09:35:18 +00:00
Dmitriy Novozhilov fd4aafdb75 [Lombok K2] Support @Builder and @Singular annotations
^KT-46959 Fixed
2022-08-11 15:22:36 +03:00
Ilya Kirillov 0748f28efe [FIR] rename ensureResolve -> lazyResolveToPhase as it better describes function semantics 2022-08-10 22:49:18 +02:00
Mikhail Glukhikh 2598ecf23f Revert "K2: fix internal visibility checks for overrides #KT-53197 Fixed"
This reverts commit 166965e559.
2022-08-05 18:26:59 +02:00
Mikhail Glukhikh 166965e559 K2: fix internal visibility checks for overrides #KT-53197 Fixed 2022-08-03 07:52:14 +00:00
Victor Petukhov 7d945d9bdc [FIR] Support loading rxjava3 nullability annotations on bounded wildcards
^KT-53041 Fixed
2022-07-11 12:44:08 +00:00
Mikhail Glukhikh 730a5d1a88 FIR: introduce Java vs Kotlin class conflicts checker #KT-44441 Fixed 2022-07-04 13:28:58 +00:00
Ilya Kirillov da43062a46 [FIR] do not swallow PCE 2022-06-24 10:50:31 +02:00
Dmitriy Novozhilov a84ece7233 [Lombok] Add implementation of plugin for FIR 2022-06-07 14:12:25 +00:00
Dmitriy Novozhilov fb57e1ecd5 [FIR] Add two kinds of Java origin to distinguish source and library declarations 2022-06-07 14:12:23 +00:00
Dmitriy Novozhilov 399aaeca9d [FIR] Implement proper copy utility for FirDeclarationStatus 2022-06-07 14:12:13 +00:00
Nikolay Lunyak d2a8942353 [FIR] Extract FirJvmConstDeserializer
Attempts to separate JVM and non-JVM entities more clearly.
2022-06-02 13:47:23 +00:00
Denis.Zharkov 461d91a10e FIR: Rework checking dispatch receivers applicability
Using `ownerLookupTag` might be wrong in case of private constuctors
 of inner classes: their owner is an Inner class, but expected
 dispach receiver is Outer
2022-06-01 16:02:31 +00:00
Ivan Kochurkin 5fdf365ac4 [FIR] Use lazy initialization for OptionalAnnotationClassesProvider 2022-05-29 23:41:26 +03:00
Ivan Kochurkin e69250a9fe [FIR] Microoptimizations and clearing 2022-05-29 23:41:24 +03:00
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