Commit Graph

52 Commits

Author SHA1 Message Date
Tianyu Geng f217bb94de Use more consistent names for inheritors of BooleanIsMissing 2021-11-04 23:04:35 +01:00
Tianyu Geng 2c2851af6e Analysis API: add test covering get missing when branches
Also fix FIR implementation to generate boolean branches in the same
order as FE1.0.
2021-11-04 23:04:35 +01:00
Tianyu Geng 7de0937031 FIR IDE: get unstable smartcast from FE1.0-based analysis API
Note that the current FE1.0 implementation still has some limitations

1. only references used as receiver are being considered for smartcast.
2. Somehow the smartcast information is not retained if the for generic
typed receivers. See multiSmartcastAsReceiver_stable.descriptors.txt
2021-11-04 16:00:37 +01:00
Tianyu Geng 197079c85c FIR IDE: make smartcast API return unstable smartcasts 2021-11-04 16:00:37 +01:00
Jinseong Jeon c3c79b874d FIR IDE: make constant evaluator robust to arithmetic exception 2021-11-01 22:50:47 +01: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
Jinseong Jeon 3f2c86afb8 FIR IDE/LC: introduce/use delegated member scope 2021-10-27 17:06:32 +02:00
Jinseong Jeon 700f8ac287 FIR IDE: relocate scope-related test data 2021-10-27 17:06:32 +02:00
Jinseong Jeon 4266ffa274 FIR IDE: fix typo in test directory (overridden) 2021-10-27 17:06:32 +02:00
Jinseong Jeon b52912162f FIR IDE: API to indicate delegated property 2021-10-27 17:06:30 +02:00
Tianyu Geng e195f0426e FIR IDE: add KtExtensionReceiverSymbol
This symbol represents the extension receiver of a callable and
currently is used as the resolution target of `this` in a callable with
extension.
2021-10-26 08:50:38 +00:00
Tianyu Geng d3c91ee9be FIR IDE: align resolution behavior of super with FE1.0
That is, for a labeled `super`, the keyword should resolve to the super
type and the label should be resolved to the current type.
2021-10-26 08:50:37 +00:00
Tianyu Geng 0d966ec65a FIR IDE: resolve implicit invoke to callable property 2021-10-26 08:50:37 +00:00
Jinseong Jeon 9524825662 FIR LC: approximate local type only if it's necessary and out of scope 2021-10-25 20:24:48 +03:00
Jinseong Jeon 9ed2c9d371 FIR LC: add tests about type approximation in PsiType provider 2021-10-25 20:24:48 +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
Yan Zhulanow e06a75c197 [FIR IDE] Add separate test data for descriptor-based Analysis API implementation 2021-10-20 19:41:26 +03:00
Yan Zhulanow 1272c6aa33 [FIR IDE] Update Analysis API test data, untie it from the FIR implementation 2021-10-20 19:41:25 +03:00
Tianyu Geng 825be3588a FIR IDE: tolerate KtFirBackingFieldSymbol when getting overridden symbols 2021-10-18 08:29:22 +02:00
Tianyu Geng ba359fb296 FIR IDE: render captured type 2021-10-16 14:16:26 +02:00
Tianyu Geng 8b44a4685f FIR IDE: add API to get super types of a KtType 2021-10-16 14:16:25 +02:00
Tianyu Geng 68e70769c8 FIR IDE: return error type for expressions if needed
It seems unnatural to filter out error types, given that KtType does
have a way to represent unresolved types.
2021-10-16 14:16:24 +02:00
Tianyu Geng 80b3e2eb69 FIR IDE: move helpers for HasCommonSubtypeTestGenerated 2021-10-16 14:16:23 +02:00
Jinseong Jeon 8023e7fb02 FIR IDE: add a test for resolution of @Retention value 2021-10-15 19:45:04 +00:00
Mark Punzalan 167dc81d3b FIR/Analysis API: Get parameter name from function type notation or
`@ParameterName` annotation, which is also now added during type
resolution.
2021-10-15 16:19:00 +03:00
Tianyu Geng c10879be43 FIR IDE: get type of unresovled super
FIR does not provide any type for unresolved super so we manually
synthesize such types for completion to work.
2021-10-15 14:12:43 +02:00
Tianyu Geng e6d9098bec FIR IDE: Disable some tests in depended mode due to failures
The following error code path only runs in depended mode.

Test succeeded in normal analysis mode but failed in depended analysis mode.
java.lang.Exception: Test succeeded in normal analysis mode but failed in depended analysis mode.
	at org.jetbrains.kotlin.analysis.low.level.api.fir.test.base.AbstractLowLevelApiTest.runTest(AbstractLowLevelApiTest.kt:126)
	at org.jetbrains.kotlin.analysis.api.fir.components.OverriddenDeclarationProviderTestGenerated.testOnEnumEntry(OverriddenDeclarationProviderTestGenerated.java:72)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:688)
	at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
	at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:149)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140)
	at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:84)
	at org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
	at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
	at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:210)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:206)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:131)
	at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:65)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:129)
	at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:127)
	at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:126)
	at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:84)
	at org.junit.platform.engine.support.hierarchical.ForkJoinPoolHierarchicalTestExecutorService$ExclusiveTask.compute(ForkJoinPoolHierarchicalTestExecutorService.java:185)
	at java.util.concurrent.RecursiveAction.exec(RecursiveAction.java:189)
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
	at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:175)
Caused by: java.util.concurrent.ExecutionException: java.lang.IllegalStateException: No designation of local declaration public final static enum entry MyEntry: R|MyEnum|
	at java.util.concurrent.FutureTask.report(FutureTask.java:122)
	at java.util.concurrent.FutureTask.get(FutureTask.java:192)
	at org.jetbrains.kotlin.analysis.api.fir.components.AbstractOverriddenDeclarationProviderTest.doTestByFileStructure(AbstractOverriddenDeclarationProviderTest.kt:79)
	at org.jetbrains.kotlin.analysis.api.fir.test.framework.AbstractHLApiSingleModuleTest.doTestByFileStructure(AbstractHLApiSingleModuleTest.kt:16)
	at org.jetbrains.kotlin.analysis.low.level.api.fir.test.base.AbstractLowLevelApiTest.runTest(AbstractLowLevelApiTest.kt:117)
	... 38 more
Caused by: java.lang.IllegalStateException: No designation of local declaration public final static enum entry MyEntry: R|MyEnum|
	at org.jetbrains.kotlin.analysis.low.level.api.fir.api.FirDeclarationDesignationKt.collectDesignation(FirDeclarationDesignation.kt:90)
	at org.jetbrains.kotlin.analysis.low.level.api.fir.api.LowLevelFirApiFacadeForResolveOnAir.runBodyResolveOnAir(LowLevelFirApiFacadeForResolveOnAir.kt:239)
	at org.jetbrains.kotlin.analysis.low.level.api.fir.api.LowLevelFirApiFacadeForResolveOnAir.getResolveStateForDependentCopy(LowLevelFirApiFacadeForResolveOnAir.kt:175)
	at org.jetbrains.kotlin.analysis.api.fir.KtFirAnalysisSession.createContextDependentCopy(KtFirAnalysisSession.kt:102)
	at org.jetbrains.kotlin.analysis.low.level.api.fir.test.base.AbstractLowLevelApiTest.analyse(AbstractLowLevelApiTest.kt:203)
	at org.jetbrains.kotlin.analysis.api.fir.components.AbstractOverriddenDeclarationProviderTest.access$analyse(AbstractOverriddenDeclarationProviderTest.kt:22)
	at org.jetbrains.kotlin.analysis.api.fir.components.AbstractOverriddenDeclarationProviderTest$doTestByFileStructure$$inlined$executeOnPooledThreadInReadAction$1$1.compute(AbstractLowLevelApiTest.kt:183)
	at com.intellij.mock.MockApplication.runReadAction(MockApplication.java:183)
	at org.jetbrains.kotlin.analysis.api.fir.components.AbstractOverriddenDeclarationProviderTest$doTestByFileStructure$$inlined$executeOnPooledThreadInReadAction$1.call(AbstractLowLevelApiTest.kt:183)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:652)
	at java.util.concurrent.Executors$PrivilegedThreadFactory$1$1.run(Executors.java:649)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.util.concurrent.Executors$PrivilegedThreadFactory$1.run(Executors.java:649)
	at java.lang.Thread.run(Thread.java:748)
2021-10-14 06:05:32 +03:00
Mikhail Glukhikh 7243d30869 Split property use-site targets during FIR building 2021-10-12 16:22:58 +03:00
Roman Golyshev 9113ccb8fc [FIR IDE] Properly support loop variables in KtFirSymbolProvider 2021-10-07 18:30:21 +03:00
Nikolay Lunyak e5d5e5be44 [FIR] Reorder scopes for KT-34822 2021-10-05 19:37:53 +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
Mark Punzalan 56cc40f639 FIR: Rename SAM constructor parameter name from "block" to "function".
This matches FE 1.0 (see
core/descriptors/src/org/jetbrains/kotlin/resolve/sam/samConstructorUtils.kt).
2021-10-04 19:38:44 +03:00
Mark Punzalan d16454b9af FIR: Set resolve phase to BODY_RESOLVE for SAM constructor value
parameters.

This was causing exceptions with analysis API trying to resolve the
synthetic FirValueParameter because it could not find a KtDeclaration
for it. Using BODY_RESOLVE should be safe; the SAM constructor function
is also on BODY_RESOLVE and the type of the value parameter is known.
2021-10-04 19:38:43 +03:00
Jinseong Jeon 8f3b06ac06 RAW FIR: record annotations on destructuring declarations 2021-10-01 18:54:16 +03:00
Jinseong Jeon 464eecef03 FIR IDE: add more tests about annotation resolution 2021-10-01 18:54:14 +03:00
Tianyu Geng 43257f7688 FIR IDE: rename SymbolKind: MEMBER -> CLASS_MEMBER 2021-09-29 22:24:27 +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
Mark Punzalan 7425986bf0 Analysis API: Don't resolve references to @Deprecated(HIDDEN)
declarations.
2021-09-29 19:39:16 +03:00
Jinseong Jeon 414881403b FIR IDE: handle annotation array values properly 2021-09-23 00:11:26 +02:00
Jinseong Jeon ffd0a5ed14 FIR IDE: make constant values symbol-free 2021-09-23 00:11:26 +02:00
Jinseong Jeon 0f16a2cb92 FIR IDE: rename some of constant values for consistency 2021-09-23 00:11:25 +02:00
Jinseong Jeon 6ef2dad895 FIR IDE: more comprehensive abstractions of annotation values 2021-09-23 00:11:25 +02:00
Jinseong Jeon 744961bd00 FIR IDE: test resolution of various annotation values 2021-09-23 00:11:25 +02:00
Tianyu Geng 9ca8d39240 FIR IDE: use KtVariableWithInvokeFunctionCall for extension invoke 2021-09-17 17:27:53 +02:00
Tianyu Geng d2ed203528 FIR IDE: Add substitutor to KtCall 2021-09-17 17:27:52 +02:00
Tianyu Geng 765cad8448 FIR checker: substitute type parameters in dispatch receiver type
Consider the following code:

```
fun test(a: List<String>) {
  a.first()
}
```

The dispatch receiver type of `first` in this case is `List<T>` before
this change. After this change, it's `List<String>`.

In addition, this change also replace the dispatch receiver type with
the more specific type if available. For example, consider the following

```
class MyList: ArrayList<String>()

fun test(a: MyList) {
  a.get(0)
}
```
The dispatch receiver type of `get` is `MyList`, instead of
`ArrayList<String>`. That is, a fake override is created in this case.
2021-09-17 01:59:06 +03:00
Tianyu Geng d77db2cda6 FIR checker: expose API to check if two types are compatible
This is useful for quickfixes offering casts. We don't want to offer
user to cast incompatible types.

Also, explicitly allow compare to `Nothing` and handle `Nothing` from intersection
2021-09-17 01:59:05 +03:00
Jinseong Jeon 35409fdb8d FIR IDE: resolve arrayOf calls in annotations 2021-09-15 22:33:20 +02:00