Fix CCE when typealias is used in a class reference ('TA::class')

This commit is contained in:
Dmitry Petrov
2016-07-04 08:43:55 +03:00
parent 5dfbaede4f
commit d45330c184
6 changed files with 41 additions and 3 deletions
@@ -355,7 +355,7 @@ class TypeResolver(
type(resolveTypeForTypeParameter(c, annotations, descriptor, qualifierPart.expression, qualifierPart.typeArguments))
}
is ClassDescriptor -> resolveTypeForClass(c, annotations, descriptor, element, qualifierResolutionResult)
is TypeAliasDescriptor -> resolveTypeForTypeAlias(c, annotations, descriptor, element as KtUserType, qualifierResolutionResult)
is TypeAliasDescriptor -> resolveTypeForTypeAlias(c, annotations, descriptor, element, qualifierResolutionResult)
else -> error("Unexpected classifier type: ${descriptor.javaClass}")
}
}
@@ -434,7 +434,7 @@ class TypeResolver(
c: TypeResolutionContext,
annotations: Annotations,
descriptor: TypeAliasDescriptor,
type: KtUserType,
type: KtElement,
qualifierResolutionResult: QualifiedExpressionResolver.TypeQualifierResolutionResult
): PossiblyBareType {
val typeConstructor = descriptor.typeConstructor
@@ -487,7 +487,7 @@ class TypeResolver(
private class TracingTypeAliasExpansionReportStrategy(
val trace: BindingTrace,
val type: KtUserType?,
val type: KtElement?,
val typeArgumentsOrTypeName: KtElement?,
val typeAliasDescriptor: TypeAliasDescriptor,
typeParameters: List<TypeParameterDescriptor>,
@@ -0,0 +1,3 @@
typealias S = String
val s = S::class
@@ -0,0 +1,4 @@
package
public typealias S = kotlin.String
public val s: kotlin.reflect.KClass<S /* = kotlin.String */>
@@ -0,0 +1,7 @@
class C {
fun foo() {}
}
typealias CA = C
val cf = CA::foo
@@ -0,0 +1,12 @@
package
public typealias CA = C
public val cf: kotlin.reflect.KFunction1<CA /* = C */, kotlin.Unit>
public final class C {
public constructor C()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final fun foo(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -19647,6 +19647,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("classReference.kt")
public void testClassReference() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/classReference.kt");
doTest(fileName);
}
@TestMetadata("conflictingProjections.kt")
public void testConflictingProjections() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/conflictingProjections.kt");
@@ -19731,6 +19737,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("methodReference.kt")
public void testMethodReference() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/methodReference.kt");
doTest(fileName);
}
@TestMetadata("nested.kt")
public void testNested() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/nested.kt");