Files
kotlin-fork/compiler/testData/diagnostics/tests/Bounds.jet
T
Andrey Breslav 41fd43b5e5 GreatSyntacticShift: Syntax for function types, function literals, when and tuples
Bug:
fun loop(var times : Int) {
   while(times > 0) {
        val u : (value : Int) -> Unit = { // This arrow is confusing the lookahead
            System.out?.println(it)
        }
        u(times--)
   }
}
2011-12-20 22:55:25 +04:00

41 lines
1.1 KiB
Plaintext

package boundsWithSubstitutors {
open class A<T>
class B<X : A<X>>()
class C : A<C>
val a = B<C>()
val a1 = B<<!UPPER_BOUND_VIOLATED!>Int<!>>()
class X<A, B : A>()
val b = X<Any, X<A<C>, C>>
val b0 = X<Any, <!UPPER_BOUND_VIOLATED!>Any?<!>>
val b1 = X<Any, X<A<C>, <!UPPER_BOUND_VIOLATED!>String<!>>>
}
open class A {}
open class B<T : A>()
abstract class C<T : B<<!UPPER_BOUND_VIOLATED!>Int<!>>, X : (B<<!UPPER_BOUND_VIOLATED!>Char<!>>) -> #(B<<!UPPER_BOUND_VIOLATED!>Any<!>>, B<A>)>() : B<<!UPPER_BOUND_VIOLATED, UPPER_BOUND_VIOLATED!>Any<!>>() { // 2 errors
val a = B<<!UPPER_BOUND_VIOLATED!>Char<!>>() // error
abstract val x : (B<<!UPPER_BOUND_VIOLATED!>Char<!>>) -> B<<!UPPER_BOUND_VIOLATED!>Any<!>>
}
fun test() {
foo<<!UPPER_BOUND_VIOLATED!>Int?<!>>()
foo<Int>()
bar<Int?>()
bar<Int>()
bar<<!UPPER_BOUND_VIOLATED!>Double?<!>>()
bar<<!UPPER_BOUND_VIOLATED!>Double<!>>()
1.buzz<<!UPPER_BOUND_VIOLATED!>Double<!>>()
}
fun foo<T : Any>() {}
fun bar<T : Int?>() {}
fun <T : <!FINAL_UPPER_BOUND!>Int<!>> Int.buzz() : Unit {}