diff --git a/analysis/analysis-api/testData/symbols/symbolByPsi/outerAndInnerTypeAlias.pretty.txt b/analysis/analysis-api/testData/symbols/symbolByPsi/outerAndInnerTypeAlias.pretty.txt index 68fdf38e8a6..4f91108078e 100644 --- a/analysis/analysis-api/testData/symbols/symbolByPsi/outerAndInnerTypeAlias.pretty.txt +++ b/analysis/analysis-api/testData/symbols/symbolByPsi/outerAndInnerTypeAlias.pretty.txt @@ -4,4 +4,6 @@ typealias TopLevelAlias = X class A { fun check() + + typealias NestedLevelAlias = X } \ No newline at end of file diff --git a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirNestedClassifierScope.kt b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirNestedClassifierScope.kt index f5e21ebe12c..23fdbd1c4df 100644 --- a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirNestedClassifierScope.kt +++ b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirNestedClassifierScope.kt @@ -8,11 +8,13 @@ package org.jetbrains.kotlin.fir.scopes.impl import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.declarations.FirClass import org.jetbrains.kotlin.fir.declarations.FirRegularClass +import org.jetbrains.kotlin.fir.declarations.FirTypeAlias import org.jetbrains.kotlin.fir.declarations.FirTypeParameterRef import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutorByMap import org.jetbrains.kotlin.fir.scopes.FirContainingNamesAwareScope import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterLookupTag +import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirClassifierSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol @@ -21,7 +23,7 @@ import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl import org.jetbrains.kotlin.name.Name abstract class FirNestedClassifierScope(val klass: FirClass, val useSiteSession: FirSession) : FirContainingNamesAwareScope() { - protected abstract fun getNestedClassSymbol(name: Name): FirRegularClassSymbol? + protected abstract fun getNestedClassSymbol(name: Name): FirClassLikeSymbol<*>? override fun processClassifiersByNameWithSubstitution( name: Name, @@ -40,17 +42,19 @@ abstract class FirNestedClassifierScope(val klass: FirClass, val useSiteSession: } class FirNestedClassifierScopeImpl(klass: FirClass, useSiteSession: FirSession) : FirNestedClassifierScope(klass, useSiteSession) { - private val classIndex: Map = run { - val result = mutableMapOf() + private val classIndex: Map> = run { + val result = mutableMapOf>() for (declaration in klass.declarations) { - if (declaration is FirRegularClass) { - result[declaration.name] = declaration.symbol + when (declaration) { + is FirRegularClass -> result[declaration.name] = declaration.symbol + is FirTypeAlias -> result[declaration.name] = declaration.symbol + else -> {} } } result } - override fun getNestedClassSymbol(name: Name): FirRegularClassSymbol? { + override fun getNestedClassSymbol(name: Name): FirClassLikeSymbol<*>? { return classIndex[name] } diff --git a/compiler/testData/diagnostics/tests/typealias/exposedExpandedType.fir.kt b/compiler/testData/diagnostics/tests/typealias/exposedExpandedType.fir.kt deleted file mode 100644 index b84ce5d45c7..00000000000 --- a/compiler/testData/diagnostics/tests/typealias/exposedExpandedType.fir.kt +++ /dev/null @@ -1,45 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER -TOPLEVEL_TYPEALIASES_ONLY - -typealias L = List - -class Outer { - private class Private - protected class Protected - internal class Internal - - typealias TestPrivate1 = Private - protected typealias TestPrivate2 = Private - internal typealias TestPrivate3 = Private - private typealias TestPrivate4 = Private - typealias TestPrivate5 = L - typealias TestPrivate6 = L - - typealias TestProtected1 = Protected - protected typealias TestProtected2 = Protected - internal typealias TestProtected3 = Protected - private typealias TestProtected4 = Protected - typealias TestProtected5 = L - typealias TestProtected6 = L<TestProtected1> - - typealias TestInternal1 = Internal - protected typealias TestInternal2 = Internal - internal typealias TestInternal3 = Internal - private typealias TestInternal4 = Internal - typealias TestInternal5 = L - typealias TestInternal6 = L -} - -private class Private -internal class Internal - -typealias TestPrivate1 = Private -internal typealias TestPrivate2 = Private -private typealias TestPrivate3 = Private -typealias TestPrivate4 = L -typealias TestPrivate5 = L - -typealias TestInternal1 = Internal -internal typealias TestInternal2 = Internal -private typealias TestInternal3 = Internal -typealias TestInternal4 = L -typealias TestInternal5 = L diff --git a/compiler/testData/diagnostics/tests/typealias/exposedExpandedType.kt b/compiler/testData/diagnostics/tests/typealias/exposedExpandedType.kt index 16215b33aea..ba3c3fa6198 100644 --- a/compiler/testData/diagnostics/tests/typealias/exposedExpandedType.kt +++ b/compiler/testData/diagnostics/tests/typealias/exposedExpandedType.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER -TOPLEVEL_TYPEALIASES_ONLY typealias L = List diff --git a/compiler/testData/diagnostics/tests/typealias/innerTypeAliasAsType.fir.kt b/compiler/testData/diagnostics/tests/typealias/innerTypeAliasAsType.fir.kt index cc100a53247..38b340f6a24 100644 --- a/compiler/testData/diagnostics/tests/typealias/innerTypeAliasAsType.fir.kt +++ b/compiler/testData/diagnostics/tests/typealias/innerTypeAliasAsType.fir.kt @@ -11,12 +11,12 @@ class Outer { typealias InnerAlias = Inner typealias GenericInnerAlias = GenericInner - fun test1(x: NestedAlias) = x - fun test2(x: GenericNestedAlias) = x - fun test3(x: GenericNestedAlias) = x - fun test4(x: InnerAlias) = x - fun test5(x: GenericInnerAlias) = x - fun test6(x: GenericInnerAlias) = x + fun test1(x: NestedAlias) = x + fun test2(x: GenericNestedAlias) = x + fun test3(x: GenericNestedAlias) = x + fun test4(x: InnerAlias) = x + fun test5(x: GenericInnerAlias) = x + fun test6(x: GenericInnerAlias) = x } fun test1(x: Outer.NestedAlias) = x fun test2(x: Outer.NestedAlias) = x diff --git a/compiler/testData/diagnostics/tests/typealias/innerTypeAliasConstructor.fir.kt b/compiler/testData/diagnostics/tests/typealias/innerTypeAliasConstructor.fir.kt index cd666e9285d..a6c88362372 100644 --- a/compiler/testData/diagnostics/tests/typealias/innerTypeAliasConstructor.fir.kt +++ b/compiler/testData/diagnostics/tests/typealias/innerTypeAliasConstructor.fir.kt @@ -10,14 +10,14 @@ class C { // C<...>.P[<...>]() syntax doesn't work due to the way qualified expressions are resolved now. // This restriction can be removed later. -val test0 = C.P(1, 1) -val test1 = C.P1("", 1) -val test2 = C.P2(1, "") -val test3 = C.P1("", 1) -val test4 = C.P2(1, "") +val test0 = C.P(1, 1) +val test1 = C.P1("", 1) +val test2 = C.P2(1, "") +val test3 = C.P1("", 1) +val test4 = C.P2(1, "") // C.P() syntax could work if we add captured type parameters as type variables in a constraint system for corresponding call. // However, this should be consistent with inner classes capturing type parameters. -val test5 = C.P(1, 1) -val test6 = C.P1("", 1) -val test7 = C.P2(1, "") +val test5 = C.P(1, 1) +val test6 = C.P1("", 1) +val test7 = C.P2(1, "") diff --git a/compiler/testData/diagnostics/tests/typealias/nested.fir.kt b/compiler/testData/diagnostics/tests/typealias/nested.fir.kt deleted file mode 100644 index 4e49e8fa406..00000000000 --- a/compiler/testData/diagnostics/tests/typealias/nested.fir.kt +++ /dev/null @@ -1,24 +0,0 @@ -// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER -TOPLEVEL_TYPEALIASES_ONLY - -class Pair(val x1: T1, val x2: T2) - -class C { - typealias P2 = Pair - - fun p() = P2(1, 1) - fun first(p: P2) = p.x1 - fun second(p: P2) = p.x2 -} - -val p1 = Pair(1, 1) - -val test1: Int = C().first(p1) -val test2: Int = C().second(p1) - -fun C.testExtFun1(x: C.P2) = x - -fun C.testExtFun2(): C.P2 { - val x: C.P2 = p() - val y = C.P2(1, 1) - return x -} diff --git a/compiler/testData/diagnostics/tests/typealias/nested.kt b/compiler/testData/diagnostics/tests/typealias/nested.kt index b895319f19a..f9004e22fd5 100644 --- a/compiler/testData/diagnostics/tests/typealias/nested.kt +++ b/compiler/testData/diagnostics/tests/typealias/nested.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL // !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER -TOPLEVEL_TYPEALIASES_ONLY class Pair(val x1: T1, val x2: T2) diff --git a/compiler/testData/diagnostics/tests/typealias/nestedCapturingTypeParameters.fir.kt b/compiler/testData/diagnostics/tests/typealias/nestedCapturingTypeParameters.fir.kt index 580fe6ce826..a90267d5051 100644 --- a/compiler/testData/diagnostics/tests/typealias/nestedCapturingTypeParameters.fir.kt +++ b/compiler/testData/diagnostics/tests/typealias/nestedCapturingTypeParameters.fir.kt @@ -6,18 +6,18 @@ class C { typealias P2 = Pair typealias PT2 = Pair - fun first(p: P2) = p.x1 - fun second(p: P2) = p.x2 + fun first(p: P2) = p.x1 + fun second(p: P2) = p.x2 - fun first2(p: PT2) = p.x1 - fun second2(p: PT2) = p.x2 + fun first2(p: PT2) = p.x1 + fun second2(p: PT2) = p.x2 } val p1 = Pair(1, 1) val p2 = Pair(1, "") -val test1: Int = C().first(p1) -val test2: Int = C().second(p1) +val test1: Int = C().first(p1) +val test2: Int = C().second(p1) -val test3: Int = C().first2(p2) -val test4: String = C().second2(p2) +val test3: Int = C().first2(p2) +val test4: String = C().second2(p2) diff --git a/compiler/testData/diagnostics/tests/typealias/typeAliasAsQualifier.fir.kt b/compiler/testData/diagnostics/tests/typealias/typeAliasAsQualifier.fir.kt index 507eb93606a..5837ccf1e4a 100644 --- a/compiler/testData/diagnostics/tests/typealias/typeAliasAsQualifier.fir.kt +++ b/compiler/testData/diagnostics/tests/typealias/typeAliasAsQualifier.fir.kt @@ -13,9 +13,9 @@ class C { } } -val c = C.Self.Self() -val n = C.Self.Nested() -val x = C.Self.X -val n2 = C.Nested.Root.Nested.N2() -val ic = C.Self.InCompanion() -val ok = C.Self.ok +val c = C.Self.Self() +val n = C.Self.Nested() +val x = C.Self.X +val n2 = C.Nested.Root.Nested.N2() +val ic = C.Self.InCompanion() +val ok = C.Self.ok diff --git a/compiler/testData/diagnostics/tests/typealias/typeAliasAsSuperQualifier.fir.kt b/compiler/testData/diagnostics/tests/typealias/typeAliasAsSuperQualifier.fir.kt index 2689a2a135c..2a8a0bdd843 100644 --- a/compiler/testData/diagnostics/tests/typealias/typeAliasAsSuperQualifier.fir.kt +++ b/compiler/testData/diagnostics/tests/typealias/typeAliasAsSuperQualifier.fir.kt @@ -22,7 +22,7 @@ class TestSuperForBase : B() { override fun foo() { super.foo() super.foo() - super<MyBase>.foo() + super.foo() super<U>.foo() } } @@ -34,7 +34,7 @@ class TestSuperForGenericBase : GB() { override fun foo() { super.foo() super.foo() - super<MyBase>.foo() + super.foo() super<MyBaseInt>.foo() // Type arguments don't matter here super<U>.foo() } diff --git a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorWrongClass.fir.kt b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorWrongClass.fir.kt index b0e70e79bc1..80f924ea575 100644 --- a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorWrongClass.fir.kt +++ b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorWrongClass.fir.kt @@ -28,7 +28,7 @@ typealias Test5 = Outer.Inner val test5 = Test5() val test5a = Outer.Inner() -val test5b = Outer.TestInner() +val test5b = Outer.TestInner() val test5c = Outer().TestInner() val test5d = Outer().Inner() val test5e = Outer().Test5()