Commit Graph

87184 Commits

Author SHA1 Message Date
Alexander Udalov dbd28142d0 Fix callable reference adaptation for vararg in fake override
`mappedVarargElements` are populated with parameters from
`argumentMapping`, which is computed using `ArgumentsToParametersMapper`
which calls `original` on all value parameters (see
ArgumentsToParametersMapper.kt:136).

So the code that adds empty lists for unassigned vararg parameters
should also call `original`. Otherwise, in the added test, we ended up
with two arguments for the parameter `s` in `id(::base1)`, one for
`Base.s` containing the correct value, and another for `Derived.s`
containing the empty list. Psi2ir took the last one, which resulted in
empty array being passed to the vararg parameter.

Note that all of this is caused by the fact that `original` of a fake
override parameter is the parameter of the base function. This seems
suspicious because `original` of a fake override _function_ is that fake
override itself (NOT the base function), but this would probably be very
risky to change at this point.

 #KT-48835 Fixed
2021-09-30 14:08:38 +02:00
Alexander Udalov 9857af7823 Psi2ir: fix function type check for fun interface conversion
Parameter of a synthetic SAM adapter always has a function type (not a
subtype). Checking for the subtypes broke the case from KT-46908, where
fun interface is itself a subtype of a function type.

 #KT-46908 Fixed
2021-09-30 14:07:07 +02:00
Alexander Udalov e6a160e115 Minor, uncomment passing IR text test 2021-09-30 14:07:07 +02:00
Mikhail Glukhikh d3662b48a2 FIR: fix OPT_IN_MARKER_ON_WRONG_TARGET (setter via parameter case)
This commit fixes FIR bootstrap compilation
2021-09-30 14:58:14 +03:00
Alexander Udalov aa247726b6 Prohibit using old JVM backend with LV >= 1.6
#KT-48928 Fixed
2021-09-30 13:56:34 +02:00
Dmitriy Novozhilov e933c7b6d9 [Build] Remove testApi(intellijDep()) dependencies from all modules
Since IDEA moved most of it's jars to java 11 it's illegal to use them
  in our dependencies, so all modules which use `intellijDep()` should
  carefully specify which jars they use
2021-09-30 14:41:31 +03:00
Roman Artemev 504ccbad88 [IR] Copy bound parameters value in Callable reference in inliner
Fix KT-47767
2021-09-30 14:39:05 +03:00
Roman Artemev f644f47360 [IR] Add test for KT-47767 2021-09-30 14:39:01 +03:00
Denis.Zharkov 4733a0d970 Refine naming: *TypeVariable -> *TypeParameter 2021-09-30 14:36:27 +03:00
Denis.Zharkov 7c3383bb39 Fix warnings after KT-48899
All API ToolingModelBuilder is marked as NonNullApi
https://github.com/gradle/gradle/commit/f93bf949486e73655810ab49ad316100b1c2804c#diff-76e89b92025ccef4e2763c5ee8d30bde939c4a9db26bfc913eac88069cbf5d36
2021-09-30 14:36:27 +03:00
Denis.Zharkov f7ef551f99 Report warnings on overrides with wrong types nullability
^KT-48899 Fixed
2021-09-30 14:36:26 +03:00
Denis.Zharkov ec97dab6cd Simplify OverridingUtil
Do not use NewKotlinTypeCheckerImpl
2021-09-30 14:36:25 +03:00
Alexander Udalov b821b26cfe JVM IR: do not try to optimize casts in TypeOperatorLowering
In case the cast value is used as a receiver to a private method call,
the cast is actually necessary, see KT-48927. Also, this optimization
has backfired once already (see kt48659_identityEqualsWithCastToAny.kt).
It seems that the best way to optimize these casts is not to generate
them in the first place, and/or use bytecode postprocessing.

Apparently the only kind of casts which need to be eliminated are those
which occur on an inline class to its supertype. Otherwise the
unsafe-coerce intrinsic is inserted at the incorrect place, and several
tests fail (uncastInlineClassToAnyAndBack.kt, genericOverride.kt,
classGenericOverride.kt).

 #KT-48927 Fixed
2021-09-30 13:32:36 +02:00
Roman Artemev aaa0b41416 [JS IR TEST] Pass recompiled files into backend
NOTE: Temporary disabled until IC codegen is merged
2021-09-30 14:30:14 +03:00
Roman Artemev ebf17188cb [JS IR] Fix backend to make it possible lower partially loaded IR 2021-09-30 14:30:13 +03:00
Roman Artemev 2ca74174d3 [JS IR] Nullify body of declaration on it shouldn't be loaded 2021-09-30 14:30:13 +03:00
Roman Artemev 4bd6e8a034 [JS IR] Pass dirty files into backend and load IR for them only 2021-09-30 14:30:12 +03:00
Sergej Jaskiewicz 43bfe2333c Add Kotlin/JS test data to the Compiler Test Helper config 2021-09-30 10:02:53 +00:00
Nikolay Lunyak 1363a49d30 [FIR] KT-44939: report REDUNDANT_VISIBILITY for explicit public overriding public 2021-09-30 09:09:19 +00:00
Ilya Kirillov 5c3ce67648 Analysis API: introduce KtIntegerLiteralType 2021-09-30 01:46:00 +03:00
Ilya Kirillov 30b1487afc LL API: add checks to the compiler based tests to ensure ConeTypeVariableType are not leaked 2021-09-30 01:45:59 +03:00
Ilya Kirillov 7ed4984d11 Test infra: allow adding new AnalysisHandler's when existing ones present 2021-09-30 01:45:58 +03:00
Ilya Kirillov 451464d635 FIR: do not leak ConeTypeVariableType via diagnostics
ConeTypeVariableType is an internal part of type inference
and should not be leaked outside it
2021-09-30 01:45:57 +03:00
Ilya Kirillov cdde765ad9 FIR: precise lookupTag parameter of ConeTypeVariableType as it always accepts ConeTypeVariableTypeConstructor 2021-09-30 01:45:55 +03:00
Ilya Kirillov d3913b85cf FIR: fix mixed up expected and actual types in ArgumentTypeMismatch reporting 2021-09-30 01:45:54 +03:00
Ilya Kirillov 8d15e0e824 Analysis API: use FirSession from star importing scope for resolving classifiers
Resolve should happen from the use-site of the file to which importing scope belongs to
2021-09-29 22:24:27 +02:00
Tianyu Geng 43257f7688 FIR IDE: rename SymbolKind: MEMBER -> CLASS_MEMBER 2021-09-29 22:24:27 +02:00
Tianyu Geng d968b2ba49 FIR IDE: fix getClosestAvailableParentContext
File could be physical yet the state is `FirModuleResolveStateDepended`
2021-09-29 22:24:27 +02:00
Tianyu Geng 0ade231898 FIR IDE: make KtSymbolProvider.getSymbol work for library symbols 2021-09-29 22:24:27 +02:00
Tianyu Geng 954926e0de FIR IDE: get containing symbol of KtTypeParameterSymbol
As part of this change, we now also allow HL API to get containing
symbol for any KtSymbols.
2021-09-29 22:24:26 +02:00
Tianyu Geng 7c3754f516 FIR IDE: output substitutor from checkExtensionIsSuitable 2021-09-29 22:24:26 +02:00
Tianyu Geng 18a23f26f5 FIR IDE: allow getting overridden symbols on any callable symbols
This way caller don't need to first check if the symbol is allowed to
override. The current API throws for cases like Java field, or enum
entry, which is not very user-friendly.
2021-09-29 22:24:26 +02:00
Tianyu Geng 54b32f6911 FIR IDE: allow get overriding symbols of members in anonymous object 2021-09-29 22:24:26 +02:00
Tianyu Geng 50166c776c FIR IDE: add KtClassInitializerSymbol 2021-09-29 22:24:26 +02:00
Tianyu Geng 6f9712a812 FIR IDE: get property as containing symbol for default accessors 2021-09-29 22:24:26 +02:00
Tianyu Geng 3b48103cd2 FIR IDE: Add API to get implicit receiver types at a position
This will be used in completion contribution.
2021-09-29 22:24:25 +02:00
Tianyu Geng 14452661cc FIR IDE: makes HL ref shortener tolerate missing type arg in type refs 2021-09-29 22:24:25 +02:00
Tianyu Geng 72a4687990 FIR IDE: fix KtFirNonStarImportingScope 2021-09-29 22:24:25 +02:00
Tianyu Geng 211544e790 FIR: rename FirResolvedImport.resolvedClassId|relativeClassName
These two fields references the parent of the import rather than the
classes that are imported. For example

```
import java.util.Map // resolvedClassId -> null
import java.util.Map.Entry // resolvedClassId -> java.util.Map
import java.util.Map.* // resolvedClassId -> java.util.Map
import java.util.Map.someStaticMethod // resolvedClassId -> java.util.Map
import kotlin.package.someTopLevelFuntion // resolvedClassId -> null
import kotlin.package.MyObject.someObjectFuntion // resolvedClassId -> kotlin.package.MyObject
```
2021-09-29 22:24:25 +02:00
Tianyu Geng e5b9d667c0 FIR IDE: collect snapshot of FirTowerDataContext for statements
ImplicitReceiverValue is mutable and FIR body resolve could alter it
while analysing code with smartcast. Hence, previously the IDE may see
inconsistent receiver values for a local scope. For example

```
open class A
interface Foo {
    fun foo()
}
fun A.bar() {
    if (this is Foo) {
        // scope here has implicit receiver type to be `A` rather than `it<A, Foo>`
    }
}
```

This change creates snapshots for local statements so later changes
during body resolve won't affect the collected context.
2021-09-29 22:24:25 +02:00
Jinseong Jeon aad02c1259 FIR LC: introduce modifier list for members
to simulate `default` modifier of methods in interface
2021-09-29 22:02:48 +02:00
Ilya Gorbunov ec5c06238d Split language and api version lifetimes, restore apiVersion 1.3 support
KT-49007
2021-09-29 21:46:53 +03:00
Ilya Gorbunov 47adc4fdaa Prolong -no-stdlib option lifetime and regenerate Gradle compilation options
-no-stdlib may still be required internally for kotlin gradle plugin
to launch the compiler with the correct options.
2021-09-29 21:46:52 +03:00
Ilya Gorbunov bd856ad726 Propagate option deprecation to options impl class
This is to avoid the new warning OVERRIDE_DEPRECATION that is reported
when a base method is deprecated and an overriding method is not.
2021-09-29 21:46:51 +03:00
Dmitriy Novozhilov 7917e511ed [FE 1.0] Disable INTEGER_OPERATOR_RESOLVE_WILL_CHANGE warning by default
Also remove sinceVersion parameter from
  ApproximateIntegerLiteralTypesInReceiverPosition language feature

^KT-48992 Fixed
2021-09-29 21:23:22 +03:00
Mikhail Glukhikh 212c3e8d51 FIR: fix OPT_IN_MARKER_ON_WRONG_TARGET for constructor properties 2021-09-29 19:39:28 +03:00
Mikhail Glukhikh e9bff861dd FIR: report OPT_IN_MARKER_ON_OVERRIDE diagnostic
This diagnostic works in accordance with KT-45844 and KT-49002
2021-09-29 19:39:27 +03:00
Mikhail Glukhikh ad20d78a63 Add necessary optIn arguments to FIR full pipeline tests 2021-09-29 19:39:27 +03:00
Mikhail Glukhikh 11459aced6 Replace UseExperimental with OptIn in BB builder inference tests 2021-09-29 19:39:26 +03:00
Mikhail Glukhikh ac3b738d9b FIR: report OPT_IN_OVERRIDE(_ERROR) diagnostics 2021-09-29 19:39:25 +03:00