Like nested classes, it is not possible to reference inherited nested type alias by a child class.

This commit is contained in:
Dmitry Petrov
2016-06-10 14:13:14 +03:00
parent 7b6c1c092c
commit c414f456a4
4 changed files with 39 additions and 1 deletions
@@ -717,7 +717,7 @@ class DeclarationsChecker(
}
private fun checkImplicitCallableType(declaration: KtCallableDeclaration, descriptor: CallableDescriptor) {
descriptor.returnType?.let {
descriptor.returnType?.unwrap()?.let {
val target = declaration.nameIdentifier ?: declaration
if (declaration.typeReference == null) {
if (it.isNothing() && !declaration.hasModifier(KtTokens.OVERRIDE_KEYWORD)) {
@@ -0,0 +1,13 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER
open class Base {
typealias Nested = String
}
class Derived : Base()
fun test(x: Derived.<!UNRESOLVED_REFERENCE!>Nested<!>) = <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>x<!>
fun Base.testWithImplicitReceiver(x: <!UNRESOLVED_REFERENCE!>Nested<!>) {
val y: <!UNRESOLVED_REFERENCE!>Nested<!> = <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>x<!>
}
@@ -0,0 +1,19 @@
package
public fun test(/*0*/ x: [ERROR : Derived.Nested]): [ERROR : Derived.Nested]
public fun Base.testWithImplicitReceiver(/*0*/ x: [ERROR : Nested]): kotlin.Unit
public open class Base {
public typealias Nested = kotlin.String
public constructor Base()
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 final class Derived : Base {
public constructor Derived()
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
}
@@ -19539,6 +19539,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("inhreritedTypeAliasQualifiedByDerivedClass.kt")
public void testInhreritedTypeAliasQualifiedByDerivedClass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/inhreritedTypeAliasQualifiedByDerivedClass.kt");
doTest(fileName);
}
@TestMetadata("isAsWithTypeAlias.kt")
public void testIsAsWithTypeAlias() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/isAsWithTypeAlias.kt");