[FIR-TEST] Add new testdata generated after changes in previous commit
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
fun foo(n: Number) = n
|
||||
|
||||
fun test() {
|
||||
<!INAPPLICABLE_CANDIDATE!>foo<!>('a')
|
||||
|
||||
val c = 'c'
|
||||
<!INAPPLICABLE_CANDIDATE!>foo<!>(c)
|
||||
|
||||
val d: Char? = 'd'
|
||||
<!INAPPLICABLE_CANDIDATE!>foo<!>(d!!)
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !CHECK_TYPE
|
||||
|
||||
package a
|
||||
|
||||
fun <T> id(t: T): T = t
|
||||
|
||||
fun <T> either(t1: T, t2: T): T = t1
|
||||
|
||||
fun test() {
|
||||
val a: Float = id(2.0.toFloat())
|
||||
|
||||
val b = id(2.0)
|
||||
checkSubtype<Double>(b)
|
||||
|
||||
val c = either<Number>(1, 2.3)
|
||||
checkSubtype<Number>(c)
|
||||
|
||||
val d = either(11, 2.3)
|
||||
checkSubtype<Any>(d)
|
||||
|
||||
val e: Float = id(1)
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
package a
|
||||
|
||||
fun foo(i: Int) = i
|
||||
|
||||
fun bar(l: Long) = l
|
||||
|
||||
fun main() {
|
||||
val i = <!ILLEGAL_CONST_EXPRESSION, INFERENCE_ERROR, INFERENCE_ERROR!>111111111111111777777777777777<!>
|
||||
|
||||
//todo add diagnostic text messages
|
||||
//report only 'The value is out of range'
|
||||
//not 'An integer literal does not conform to the expected type Int/Long'
|
||||
val l: Long = <!ILLEGAL_CONST_EXPRESSION, INFERENCE_ERROR!>1111111111111117777777777777777<!>
|
||||
foo(<!ILLEGAL_CONST_EXPRESSION, INFERENCE_ERROR!>11111111111111177777777777777<!>)
|
||||
bar(<!ILLEGAL_CONST_EXPRESSION, INFERENCE_ERROR!>11111111111111177777777777777<!>)
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun test(numbers: List<Number>) {
|
||||
|
||||
// Short <: R, ILT <: R => CST(Short, ILT) = Short
|
||||
// => we should pick Short in such situation as it more specific
|
||||
shortExpected { getShort() ?: 1 }
|
||||
|
||||
// Short <: R, ILT <: R, R <: Comparable<R> =>
|
||||
// Short <: Comparable<R>, ILT <: Comparable<R> =>
|
||||
// Comparable<Short> <: Comparable<R>, Comparable<ILT> <: Comparable<R> =>
|
||||
// R <: Short, R <: ILT =>
|
||||
// R := Short, R := ILT
|
||||
// => we should pick Short as it more specific
|
||||
shortComparable { getShort() ?: 1 }
|
||||
}
|
||||
|
||||
fun <R> shortExpected(f: () -> R) {}
|
||||
fun <R : Comparable<R>> shortComparable(f: () -> R) {}
|
||||
|
||||
fun getShort(): Short? = 1
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !CHECK_TYPE
|
||||
package a
|
||||
|
||||
fun <T> id(t: T): T = t
|
||||
|
||||
fun <T> either(t1: T, t2: T): T = t1
|
||||
|
||||
fun other(s: String) {}
|
||||
|
||||
fun <T> otherGeneric(l: List<T>) {}
|
||||
|
||||
fun test() {
|
||||
val a: Byte = id(1)
|
||||
|
||||
val b: Byte = id(300)
|
||||
|
||||
val c: Int = id(9223372036854775807)
|
||||
|
||||
val d = id(22)
|
||||
checkSubtype<Int>(d)
|
||||
|
||||
val e = id(9223372036854775807)
|
||||
e checkType { <!UNRESOLVED_REFERENCE!>_<!><Long>() }
|
||||
|
||||
val f: Byte = either(1, 2)
|
||||
|
||||
val g: Byte = either(1, 300)
|
||||
|
||||
<!INAPPLICABLE_CANDIDATE!>other<!>(11)
|
||||
|
||||
<!INAPPLICABLE_CANDIDATE!>otherGeneric<!>(1)
|
||||
|
||||
val r = either(1, "")
|
||||
r checkType { <!UNRESOLVED_REFERENCE!>_<!><Any>() }
|
||||
|
||||
use(a, b, c, d, e, f, g, r)
|
||||
}
|
||||
|
||||
fun use(vararg a: Any?) = a
|
||||
|
||||
interface Inv<T>
|
||||
|
||||
fun <T> exactBound(t: T, l: Inv<T>): T = throw Exception("$t $l")
|
||||
|
||||
fun testExactBound(invS: Inv<String>, invI: Inv<Int>, invB: Inv<Byte>) {
|
||||
<!INAPPLICABLE_CANDIDATE!>exactBound<!>(1, invS)
|
||||
exactBound(1, invI)
|
||||
|
||||
val b = exactBound(1, invB)
|
||||
b checkType { <!UNRESOLVED_REFERENCE!>_<!><Byte>() }
|
||||
}
|
||||
|
||||
interface Cov<out T>
|
||||
|
||||
fun <T> lowerBound(t: T, l : Cov<T>): T = throw Exception("$t $l")
|
||||
|
||||
fun testLowerBound(cov: Cov<String>, covN: Cov<Number>) {
|
||||
val r = lowerBound(1, cov)
|
||||
r checkType { <!UNRESOLVED_REFERENCE!>_<!><Any>() }
|
||||
|
||||
val n = lowerBound(1, covN)
|
||||
n checkType { <!UNRESOLVED_REFERENCE!>_<!><Number>() }
|
||||
}
|
||||
|
||||
interface Contr<in T>
|
||||
|
||||
fun <T> upperBound(t: T, l: Contr<T>): T = throw Exception("$t $l")
|
||||
|
||||
fun testUpperBound(contrS: Contr<String>, contrB: Contr<Byte>, contrN: Contr<Number>) {
|
||||
<!INAPPLICABLE_CANDIDATE!>upperBound<!>(1, contrS)
|
||||
|
||||
val n = upperBound(1, contrN)
|
||||
n checkType { <!UNRESOLVED_REFERENCE!>_<!><Int>() }
|
||||
|
||||
val b = upperBound(1, contrB)
|
||||
b checkType { <!UNRESOLVED_REFERENCE!>_<!><Byte>() }
|
||||
}
|
||||
Reference in New Issue
Block a user