Fix type parameter list for local classes
Add captured parameters from enclosing functions #KT-9584 Fixed
This commit is contained in:
+33
@@ -0,0 +1,33 @@
|
||||
// !CHECK_TYPE
|
||||
private class Outer<E> {
|
||||
private inner class Inner<out F> {
|
||||
private fun <G> foo() = {
|
||||
fun baz() = {
|
||||
class Local {
|
||||
val e: E = magic()
|
||||
val f: F = magic()
|
||||
val g: G = magic()
|
||||
}
|
||||
Local()
|
||||
}
|
||||
baz()()
|
||||
}
|
||||
|
||||
private var doubleCharSequenceInt = Outer<Double>().Inner<CharSequence>().foo<Int>()()
|
||||
private var doubleStringNumber = Outer<Double>().Inner<String>().foo<Number>()()
|
||||
private var doubleStringInt = Outer<Double>().Inner<String>().foo<Int>()()
|
||||
|
||||
private fun bar() {
|
||||
doubleCharSequenceInt = <!TYPE_MISMATCH!>doubleStringNumber<!>
|
||||
doubleCharSequenceInt = doubleStringInt
|
||||
|
||||
doubleStringInt = Outer<Double>().Inner<String>().foo<Int>()()
|
||||
|
||||
doubleStringInt.e.checkType { _<Double>() }
|
||||
doubleStringInt.f.checkType { _<String>() }
|
||||
doubleStringInt.g.checkType { _<Int>() }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun <T> magic(): T = null!!
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ T> magic(): T
|
||||
|
||||
private final class Outer</*0*/ E> {
|
||||
public constructor Outer</*0*/ E>()
|
||||
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
|
||||
|
||||
private final inner class Inner</*0*/ out F> /*captured type parameters: /*1*/ E*/ {
|
||||
public constructor Inner</*0*/ out F>()
|
||||
private final var doubleCharSequenceInt: Outer.Inner.foo.<anonymous>.baz.<anonymous>.Local<kotlin.Int, kotlin.CharSequence, kotlin.Double>
|
||||
private final var doubleStringInt: Outer.Inner.foo.<anonymous>.baz.<anonymous>.Local<kotlin.Int, kotlin.String, kotlin.Double>
|
||||
private final var doubleStringNumber: Outer.Inner.foo.<anonymous>.baz.<anonymous>.Local<kotlin.Number, kotlin.String, kotlin.Double>
|
||||
private final fun bar(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
private final fun </*0*/ G> foo(): () -> Outer.Inner.foo.<anonymous>.baz.<anonymous>.Local<G, F, E>
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
fun <T> magic(): T = null!!
|
||||
|
||||
class Q {
|
||||
private fun <E> foo() = {
|
||||
class C {
|
||||
val prop: E = magic()
|
||||
}
|
||||
C()
|
||||
}
|
||||
|
||||
private var x = foo<CharSequence>()()
|
||||
private var y = foo<String>()()
|
||||
|
||||
fun bar() {
|
||||
x = <!TYPE_MISMATCH!>y<!>
|
||||
x = foo<CharSequence>()()
|
||||
y = foo<String>()()
|
||||
|
||||
x.prop.checkType { _<CharSequence>() }
|
||||
y.prop.checkType { _<String>() }
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ T> magic(): T
|
||||
|
||||
public final class Q {
|
||||
public constructor Q()
|
||||
private final var x: Q.foo.<anonymous>.C<kotlin.CharSequence>
|
||||
private final var y: Q.foo.<anonymous>.C<kotlin.String>
|
||||
public final fun bar(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
private final fun </*0*/ E> foo(): () -> Q.foo.<anonymous>.C<E>
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
fun <T> magic(): T = null!!
|
||||
|
||||
class Q {
|
||||
private fun <E, F> foo() = {
|
||||
class C<G> {
|
||||
val e: E = magic()
|
||||
val f: F = magic()
|
||||
val g: G = magic()
|
||||
}
|
||||
C<F>()
|
||||
}
|
||||
|
||||
private var x = foo<CharSequence, Number>()()
|
||||
|
||||
fun bar() {
|
||||
x.e.checkType { _<CharSequence>() }
|
||||
x.f.checkType { _<Number>() }
|
||||
x.g.checkType { _<Number>() }
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ T> magic(): T
|
||||
|
||||
public final class Q {
|
||||
public constructor Q()
|
||||
private final var x: Q.foo.<anonymous>.C<kotlin.Number, kotlin.CharSequence, kotlin.Number>
|
||||
public final fun bar(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
private final fun </*0*/ E, /*1*/ F> foo(): () -> Q.foo.<anonymous>.C<F, E, F>
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
fun <T> magic(): T = null!!
|
||||
|
||||
class Q {
|
||||
private fun <E> foo() =
|
||||
object {
|
||||
val prop: E = magic()
|
||||
}
|
||||
|
||||
private var x = foo<CharSequence>()
|
||||
private var y = foo<String>()
|
||||
|
||||
fun bar() {
|
||||
x = <!TYPE_MISMATCH!>y<!>
|
||||
x = foo<CharSequence>()
|
||||
y = foo<String>()
|
||||
|
||||
x.prop.checkType { _<CharSequence>() }
|
||||
y.prop.checkType { _<String>() }
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ T> magic(): T
|
||||
|
||||
public final class Q {
|
||||
public constructor Q()
|
||||
private final var x: Q.foo.<no name provided><kotlin.CharSequence>
|
||||
private final var y: Q.foo.<no name provided><kotlin.String>
|
||||
public final fun bar(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
private final fun </*0*/ E> foo(): Q.foo.<no name provided><E>
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
fun <E> foo(x: Any, y: Any) : Any {
|
||||
class C
|
||||
// without E?
|
||||
if(x is <!CANNOT_CHECK_FOR_ERASED!>C<!>) {
|
||||
return x
|
||||
}
|
||||
|
||||
if (1 == 2) {
|
||||
<!UNCHECKED_CAST!>x as C<!>
|
||||
}
|
||||
|
||||
if (2 == 3) {
|
||||
<!UNCHECKED_CAST!>x as? C<!>
|
||||
}
|
||||
|
||||
class Outer<F> {
|
||||
inner class Inner
|
||||
}
|
||||
|
||||
// bare type
|
||||
if (y is <!NO_TYPE_ARGUMENTS_ON_RHS!>Outer.Inner<!>) {
|
||||
return y
|
||||
}
|
||||
|
||||
<!UNCHECKED_CAST!>y as Outer<*>.Inner<!>
|
||||
|
||||
return C()
|
||||
}
|
||||
|
||||
fun noTypeParameters(x: Any) : Any {
|
||||
class C
|
||||
if(x is C) {
|
||||
return x
|
||||
}
|
||||
|
||||
return C()
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ E> foo(/*0*/ x: kotlin.Any, /*1*/ y: kotlin.Any): kotlin.Any
|
||||
public fun noTypeParameters(/*0*/ x: kotlin.Any): kotlin.Any
|
||||
Reference in New Issue
Block a user