Skip to content

Commit

Permalink
[Test] Reproduce KT-73765 (Prohibit nested type aliases with inner RH…
Browse files Browse the repository at this point in the history
…S...

...if it captures outer type parameters)
  • Loading branch information
KvanTTT authored and Space Team committed Jan 8, 2025
1 parent cf01e08 commit 695e523
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 0 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
FILE: innerRHSandTypeArguments.kt
public final class Outer<T> : R|kotlin/Any| {
public constructor<T>(): R|Outer<T>| {
super<R|kotlin/Any|>()
}

public final inner class Inner<Outer(T)> : R|kotlin/Any| {
public Outer<T>.constructor(): R|Outer.Inner<T>| {
super<R|kotlin/Any|>()
}

}

public final inner class InnerWithParameter<K, Outer(T)> : R|kotlin/Any| {
public Outer<T>.constructor<K>(): R|Outer.InnerWithParameter<K, T>| {
super<R|kotlin/Any|>()
}

public final inner class InnerInsideInner<Outer(K), Outer(T)> : R|kotlin/Any| {
public Outer.InnerWithParameter<K, T>.constructor(): R|Outer.InnerWithParameter.InnerInsideInner<K, T>| {
super<R|kotlin/Any|>()
}

}

public final typealias TAtoInnerInsideInner = R|Outer.InnerWithParameter.InnerInsideInner<K, T>|

}

public final typealias TAtoExplicitInner = R|Outer.Inner<ERROR CLASS: Symbol not found for T>|

public final typealias TAToInner = R|Outer.Inner<T>|

public final typealias TAToIntInner = R|Outer.Inner<kotlin/Int>|

public final typealias TAWithTypeParameterToInner<K> = R|Outer.Inner<K>|

public final typealias TAtoInnerWithTypeParameters = R|Outer.InnerWithParameter<kotlin/String, T>|

public final typealias TAtoIntInnerWithTypeParameters = R|Outer.InnerWithParameter<kotlin/String, kotlin/Int>|

public final typealias TAtoTA = R|{Outer.TAToInner=} Outer.Inner<T>|

public final fun test(): R|kotlin/Unit| {
this@R|/Outer|.R|/Outer.Inner.Inner|()
this@R|/Outer|.R|/Outer.Inner.Inner|()
this@R|/Outer|.R|/Outer.Inner.Inner<None of the following candidates is applicable because of receiver type mismatch: [/Outer.Inner.Inner]>#|()
this@R|/Outer|.R|/Outer.Inner.Inner<None of the following candidates is applicable because of receiver type mismatch: [/Outer.Inner.Inner]>#|<R|kotlin/String|>()
this@R|/Outer|.R|/Outer.InnerWithParameter.InnerWithParameter|()
this@R|/Outer|.R|/Outer.InnerWithParameter.InnerWithParameter<None of the following candidates is applicable because of receiver type mismatch: [/Outer.InnerWithParameter.InnerWithParameter]>#|()
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// RUN_PIPELINE_TILL: FRONTEND
// ISSUE: KT-73765

class Outer<T> {
inner class Inner

inner class InnerWithParameter<K> {
inner class InnerInsideInner

typealias TAtoInnerInsideInner = InnerInsideInner // Error, type alias RHS can't capture outer type parameters (they are implicit)
}

typealias TAtoExplicitInner = Outer<<!UNRESOLVED_REFERENCE!>T<!>>.Inner // Error, UNRESOLVED_REFERENCE `T`
typealias TAToInner = Inner // Error, type alias RHS can't capture outer type parameters (they are implicit)
typealias TAToIntInner = Outer<Int>.Inner // OK
typealias TAWithTypeParameterToInner<K> = Outer<K>.Inner // OK
typealias TAtoInnerWithTypeParameters = InnerWithParameter<String> // Error, type alias RHS can't capture outer type parameters (they are implicit)
typealias TAtoIntInnerWithTypeParameters = Outer<Int>.InnerWithParameter<String> // OK

typealias TAtoTA = TAToInner // Error, type alias RHS can't capture outer type parameters

fun test() {
TAtoExplicitInner()
TAToInner()
<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>TAToIntInner<!>() // Error (different dispath receivers `Outer<T>` and `Outer<Int>`)
<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>TAWithTypeParameterToInner<!><String>() // Error (different dispath receivers `Outer<T>` and `Outer<String>`)
TAtoInnerWithTypeParameters()
<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>TAtoIntInnerWithTypeParameters<!>() // Error (different dispath receivers `Outer<T>` and `Outer<Int>`)
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 695e523

Please sign in to comment.