Regression test #KT-7804 Obsolete

This commit is contained in:
Mikhail Glukhikh
2016-01-29 17:12:47 +03:00
parent 505dc61611
commit dcc6262f47
3 changed files with 85 additions and 0 deletions
@@ -0,0 +1,64 @@
// See also KT-7804 (Wrong type inference of kotlin.Any? was for 'a' without explicit type)
fun <T> foo(a: T) = a
class A
fun <T> test(v: T): T {
val a = if (v !is A) {
foo(v) <!USELESS_CAST!>as T<!>
}
else {
v
}
val t: T = a
return t
}
fun <T> test2(v: T): T {
val a = if (v !is A) {
foo(v) <!USELESS_CAST!>as T<!>
}
else {
v <!USELESS_CAST!>as T<!>
}
val t: T = a
return t
}
fun <T> test3(v: T): T {
val a = if (v !is A) {
foo(v)
}
else {
v
}
val t: T = a
return t
}
fun <T> test4(v: T): T {
val a: T = if (v !is A) {
foo(v) <!USELESS_CAST!>as T<!>
}
else {
v
}
val t: T = a
return t
}
fun <T> test5(v: T): T {
val a: T = if (v !is A) {
foo(v)
}
else {
v
}
val t: T = a
return t
}
@@ -0,0 +1,15 @@
package
public fun </*0*/ T> foo(/*0*/ a: T): T
public fun </*0*/ T> test(/*0*/ v: T): T
public fun </*0*/ T> test2(/*0*/ v: T): T
public fun </*0*/ T> test3(/*0*/ v: T): T
public fun </*0*/ T> test4(/*0*/ v: T): T
public fun </*0*/ T> test5(/*0*/ v: T): T
public final class A {
public constructor A()
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
}
@@ -13899,6 +13899,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("kt7804.kt")
public void testKt7804() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/regressions/kt7804.kt");
doTest(fileName);
}
@TestMetadata("kt847.kt")
public void testKt847() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/regressions/kt847.kt");