Type alias: resolve type alias RHS during force-resolve.
This commit is contained in:
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.descriptors.annotations.AnnotationWithTarget;
|
|||||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope;
|
import org.jetbrains.kotlin.resolve.scopes.MemberScope;
|
||||||
|
import org.jetbrains.kotlin.serialization.ProtoBuf;
|
||||||
import org.jetbrains.kotlin.types.*;
|
import org.jetbrains.kotlin.types.*;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -85,6 +86,10 @@ public class ForceResolveUtil {
|
|||||||
forceResolveAllContents(callableDescriptor.getReturnType());
|
forceResolveAllContents(callableDescriptor.getReturnType());
|
||||||
forceResolveAllContents(callableDescriptor.getAnnotations());
|
forceResolveAllContents(callableDescriptor.getAnnotations());
|
||||||
}
|
}
|
||||||
|
else if (object instanceof TypeAliasDescriptor) {
|
||||||
|
TypeAliasDescriptor typeAliasDescriptor = (TypeAliasDescriptor) object;
|
||||||
|
forceResolveAllContents(typeAliasDescriptor.getUnderlyingType());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|||||||
@@ -1 +1,6 @@
|
|||||||
typealias S = String
|
typealias S = String
|
||||||
|
|
||||||
|
class C {
|
||||||
|
typealias SS = String
|
||||||
|
typealias SF<T> = (T) -> String
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,3 +1,12 @@
|
|||||||
package
|
package
|
||||||
|
|
||||||
public typealias S = kotlin.String
|
public typealias S = kotlin.String
|
||||||
|
|
||||||
|
public final class C {
|
||||||
|
public typealias SF</*0*/ T> = (T) -> kotlin.String
|
||||||
|
public typealias SS = kotlin.String
|
||||||
|
public constructor C()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|||||||
+2
-1
@@ -121,7 +121,8 @@ private object KotlinResolveDataProvider {
|
|||||||
KtTypeConstraint::class.java,
|
KtTypeConstraint::class.java,
|
||||||
KtSuperTypeList::class.java,
|
KtSuperTypeList::class.java,
|
||||||
KtTypeParameter::class.java,
|
KtTypeParameter::class.java,
|
||||||
KtParameter::class.java
|
KtParameter::class.java,
|
||||||
|
KtTypeAlias::class.java
|
||||||
)
|
)
|
||||||
|
|
||||||
fun findAnalyzableParent(element: KtElement): KtElement {
|
fun findAnalyzableParent(element: KtElement): KtElement {
|
||||||
|
|||||||
@@ -217,7 +217,8 @@ class ResolveElementCache(
|
|||||||
KtTypeParameter::class.java,
|
KtTypeParameter::class.java,
|
||||||
KtTypeConstraint::class.java,
|
KtTypeConstraint::class.java,
|
||||||
KtPackageDirective::class.java,
|
KtPackageDirective::class.java,
|
||||||
KtCodeFragment::class.java) as KtElement?
|
KtCodeFragment::class.java,
|
||||||
|
KtTypeAlias::class.java) as KtElement?
|
||||||
|
|
||||||
when (elementOfAdditionalResolve) {
|
when (elementOfAdditionalResolve) {
|
||||||
null -> {
|
null -> {
|
||||||
@@ -306,6 +307,8 @@ class ResolveElementCache(
|
|||||||
|
|
||||||
is KtClass -> constructorAdditionalResolve(resolveSession, resolveElement, file)
|
is KtClass -> constructorAdditionalResolve(resolveSession, resolveElement, file)
|
||||||
|
|
||||||
|
is KtTypeAlias -> typealiasAdditionalResolve(resolveSession, resolveElement)
|
||||||
|
|
||||||
is KtTypeParameter -> typeParameterAdditionalResolve(resolveSession, resolveElement)
|
is KtTypeParameter -> typeParameterAdditionalResolve(resolveSession, resolveElement)
|
||||||
|
|
||||||
is KtTypeConstraint -> typeConstraintAdditionalResolve(resolveSession, resolveElement)
|
is KtTypeConstraint -> typeConstraintAdditionalResolve(resolveSession, resolveElement)
|
||||||
@@ -503,6 +506,14 @@ class ResolveElementCache(
|
|||||||
return trace
|
return trace
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun typealiasAdditionalResolve(resolveSession: ResolveSession, typeAlias: KtTypeAlias): BindingTrace {
|
||||||
|
val trace = createDelegatingTrace(typeAlias)
|
||||||
|
val typeAliasDescriptor = resolveSession.resolveToDescriptor(typeAlias)
|
||||||
|
ForceResolveUtil.forceResolveAllContents(typeAliasDescriptor)
|
||||||
|
forceResolveAnnotationsInside(typeAlias)
|
||||||
|
return trace
|
||||||
|
}
|
||||||
|
|
||||||
private fun initializerAdditionalResolve(resolveSession: ResolveSession, anonymousInitializer: KtAnonymousInitializer, file: KtFile, statementFilter: StatementFilter): BindingTrace {
|
private fun initializerAdditionalResolve(resolveSession: ResolveSession, anonymousInitializer: KtAnonymousInitializer, file: KtFile, statementFilter: StatementFilter): BindingTrace {
|
||||||
val trace = createDelegatingTrace(anonymousInitializer)
|
val trace = createDelegatingTrace(anonymousInitializer)
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
class C
|
||||||
|
|
||||||
|
typealias CA = C
|
||||||
|
|
||||||
|
val x: <caret>CA = CA()
|
||||||
|
|
||||||
|
// REF: typealias CA = C
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
class C
|
||||||
|
|
||||||
|
typealias CA = <caret>C
|
||||||
|
|
||||||
|
// REF: (test).C
|
||||||
@@ -383,6 +383,18 @@ public class ReferenceResolveTestGenerated extends AbstractReferenceResolveTest
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("TypeAlias.kt")
|
||||||
|
public void testTypeAlias() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/resolve/references/TypeAlias.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("TypeAliasRHS.kt")
|
||||||
|
public void testTypeAliasRHS() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/resolve/references/TypeAliasRHS.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("TypeArgumentBeforeDot.kt")
|
@TestMetadata("TypeArgumentBeforeDot.kt")
|
||||||
public void testTypeArgumentBeforeDot() throws Exception {
|
public void testTypeArgumentBeforeDot() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/resolve/references/TypeArgumentBeforeDot.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/resolve/references/TypeArgumentBeforeDot.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user