// !WITH_NEW_INFERENCE // !CHECK_TYPE package a import checkType import _ import checkSubtype fun id(t: T): T = t fun either(t1: T, t2: T): T = t1 fun other(s: String) {} fun otherGeneric(l: List) {} fun test() { val a: Byte = id(1) val b: Byte = id(300) val c: Int = id(9223372036854775807) val d = id(22) checkSubtype(d) val e = id(9223372036854775807) e checkType { _() } val f: Byte = either(1, 2) val g: Byte = either(1, 300) other(11) otherGeneric(1) val r = either(1, "") r checkType { _() } use(a, b, c, d, e, f, g, r) } fun use(vararg a: Any?) = a interface Inv fun exactBound(t: T, l: Inv): T = throw Exception("$t $l") fun testExactBound(invS: Inv, invI: Inv, invB: Inv) { exactBound(1, invS) exactBound(1, invI) val b = exactBound(1, invB) b checkType { _() } } interface Cov fun lowerBound(t: T, l : Cov): T = throw Exception("$t $l") fun testLowerBound(cov: Cov, covN: Cov) { val r = lowerBound(1, cov) r checkType { _() } val n = lowerBound(1, covN) n checkType { _() } } interface Contr fun upperBound(t: T, l: Contr): T = throw Exception("$t $l") fun testUpperBound(contrS: Contr, contrB: Contr, contrN: Contr) { upperBound(1, contrS) val n = upperBound(1, contrN) n checkType { _() } val b = upperBound(1, contrB) b checkType { _() } }