KT-11588 Type aliases
Type alias companion object
This commit is contained in:
@@ -638,6 +638,7 @@ class QualifiedExpressionResolver(val symbolUsageValidator: SymbolUsageValidator
|
|||||||
is PackageViewDescriptor -> PackageQualifier(referenceExpression, descriptor)
|
is PackageViewDescriptor -> PackageQualifier(referenceExpression, descriptor)
|
||||||
is ClassDescriptor -> ClassQualifier(referenceExpression, descriptor)
|
is ClassDescriptor -> ClassQualifier(referenceExpression, descriptor)
|
||||||
is TypeParameterDescriptor -> TypeParameterQualifier(referenceExpression, descriptor)
|
is TypeParameterDescriptor -> TypeParameterQualifier(referenceExpression, descriptor)
|
||||||
|
is TypeAliasDescriptor -> ClassQualifier(referenceExpression, descriptor.classDescriptor ?: return null)
|
||||||
else -> return null
|
else -> return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -243,9 +243,16 @@ private fun ResolutionScope.getContributedVariablesAndObjects(name: Name, locati
|
|||||||
|
|
||||||
|
|
||||||
private fun getFakeDescriptorForObject(classifier: ClassifierDescriptor?): FakeCallableDescriptorForObject? {
|
private fun getFakeDescriptorForObject(classifier: ClassifierDescriptor?): FakeCallableDescriptorForObject? {
|
||||||
if (classifier !is ClassDescriptor || !classifier.hasClassValueDescriptor) return null // todo
|
return when (classifier) {
|
||||||
|
is TypeAliasDescriptor ->
|
||||||
return FakeCallableDescriptorForObject(classifier)
|
getFakeDescriptorForObject(classifier.classDescriptor)
|
||||||
|
is ClassDescriptor ->
|
||||||
|
if (classifier.hasClassValueDescriptor)
|
||||||
|
FakeCallableDescriptorForObject(classifier)
|
||||||
|
else
|
||||||
|
null
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getClassWithConstructors(classifier: ClassifierDescriptor?): ClassDescriptor? {
|
private fun getClassWithConstructors(classifier: ClassifierDescriptor?): ClassDescriptor? {
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
object AnObject {
|
||||||
|
val ok = "OK"
|
||||||
|
fun foo() = "OK"
|
||||||
|
}
|
||||||
|
|
||||||
|
typealias GenericTestObject<T> = AnObject
|
||||||
|
|
||||||
|
val test11: AnObject = GenericTestObject
|
||||||
|
val test12: GenericTestObject<*> = GenericTestObject
|
||||||
|
val test13: String = GenericTestObject.ok
|
||||||
|
val test14: String = GenericTestObject.foo()
|
||||||
|
|
||||||
|
class GenericClassWithCompanion<T> {
|
||||||
|
companion object {
|
||||||
|
val ok = "OK"
|
||||||
|
fun foo() = "OK"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
typealias TestGCWC<T> = GenericClassWithCompanion<T>
|
||||||
|
|
||||||
|
val test25: GenericClassWithCompanion.Companion = TestGCWC
|
||||||
|
val test26 = TestGCWC
|
||||||
|
val test27: String = TestGCWC.ok
|
||||||
|
val test28: String = TestGCWC.foo()
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public typealias GenericTestObject</*0*/ T> = AnObject
|
||||||
|
public typealias TestGCWC</*0*/ T> = GenericClassWithCompanion<T>
|
||||||
|
public val test11: AnObject
|
||||||
|
public val test12: GenericTestObject<*> [= AnObject]
|
||||||
|
public val test13: kotlin.String = "OK"
|
||||||
|
public val test14: kotlin.String
|
||||||
|
public val test25: GenericClassWithCompanion.Companion
|
||||||
|
public val test26: GenericClassWithCompanion.Companion
|
||||||
|
public val test27: kotlin.String = "OK"
|
||||||
|
public val test28: kotlin.String
|
||||||
|
|
||||||
|
public object AnObject {
|
||||||
|
private constructor AnObject()
|
||||||
|
public final val ok: kotlin.String = "OK"
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public final fun foo(): kotlin.String
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class GenericClassWithCompanion</*0*/ T> {
|
||||||
|
public constructor GenericClassWithCompanion</*0*/ T>()
|
||||||
|
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
|
||||||
|
|
||||||
|
public companion object Companion {
|
||||||
|
private constructor Companion()
|
||||||
|
public final val ok: kotlin.String = "OK"
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public final fun foo(): kotlin.String
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
object AnObject {
|
||||||
|
val ok = "OK"
|
||||||
|
fun foo() = "OK"
|
||||||
|
}
|
||||||
|
|
||||||
|
typealias TestObject = AnObject
|
||||||
|
|
||||||
|
val test11: AnObject = TestObject
|
||||||
|
val test12: TestObject = TestObject
|
||||||
|
val test13: String = TestObject.ok
|
||||||
|
val test14: String = TestObject.foo()
|
||||||
|
|
||||||
|
typealias TestObject2 = TestObject
|
||||||
|
|
||||||
|
val test21: AnObject = TestObject2
|
||||||
|
val test22: TestObject2 = TestObject2
|
||||||
|
val test23: String = TestObject2.ok
|
||||||
|
val test24: String = TestObject2.foo()
|
||||||
|
|
||||||
|
class ClassWithCompanion {
|
||||||
|
companion object {
|
||||||
|
val ok = "OK"
|
||||||
|
fun foo() = "OK"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
typealias TestCWC = ClassWithCompanion
|
||||||
|
|
||||||
|
val test35: ClassWithCompanion.Companion = TestCWC
|
||||||
|
val test36 = TestCWC
|
||||||
|
val test37: String = TestCWC.ok
|
||||||
|
val test38: String = TestCWC.foo()
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public typealias TestCWC = ClassWithCompanion
|
||||||
|
public typealias TestObject = AnObject
|
||||||
|
public typealias TestObject2 = TestObject
|
||||||
|
public val test11: AnObject
|
||||||
|
public val test12: TestObject [= AnObject]
|
||||||
|
public val test13: kotlin.String = "OK"
|
||||||
|
public val test14: kotlin.String
|
||||||
|
public val test21: AnObject
|
||||||
|
public val test22: TestObject2 [= AnObject]
|
||||||
|
public val test23: kotlin.String = "OK"
|
||||||
|
public val test24: kotlin.String
|
||||||
|
public val test35: ClassWithCompanion.Companion
|
||||||
|
public val test36: ClassWithCompanion.Companion
|
||||||
|
public val test37: kotlin.String = "OK"
|
||||||
|
public val test38: kotlin.String
|
||||||
|
|
||||||
|
public object AnObject {
|
||||||
|
private constructor AnObject()
|
||||||
|
public final val ok: kotlin.String = "OK"
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public final fun foo(): kotlin.String
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public final class ClassWithCompanion {
|
||||||
|
public constructor ClassWithCompanion()
|
||||||
|
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
|
||||||
|
|
||||||
|
public companion object Companion {
|
||||||
|
private constructor Companion()
|
||||||
|
public final val ok: kotlin.String = "OK"
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public final fun foo(): kotlin.String
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19131,6 +19131,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
|||||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/typealias"), Pattern.compile("^(.+)\\.kt$"), true);
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/typealias"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("genericTypeAliasObject.kt")
|
||||||
|
public void testGenericTypeAliasObject() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/genericTypeAliasObject.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("inSupertypesList.kt")
|
@TestMetadata("inSupertypesList.kt")
|
||||||
public void testInSupertypesList() throws Exception {
|
public void testInSupertypesList() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/inSupertypesList.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/inSupertypesList.kt");
|
||||||
@@ -19166,6 +19172,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
|||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/substitutionVariance.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/substitutionVariance.kt");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("typeAliasObject.kt")
|
||||||
|
public void testTypeAliasObject() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/typeAliasObject.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/diagnostics/tests/unit")
|
@TestMetadata("compiler/testData/diagnostics/tests/unit")
|
||||||
|
|||||||
Reference in New Issue
Block a user