Added tests for obsolete tasks
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
class One {
|
||||
val a1 = arrayOf(
|
||||
object { val fy = "text"}
|
||||
)}
|
||||
|
||||
fun box() = if (One().a1[0].fy == "text") "OK" else "fail"
|
||||
@@ -0,0 +1,11 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
import java.util.ArrayList
|
||||
|
||||
fun <T> foo(a : T, b : Collection<T>, c : Int) {
|
||||
}
|
||||
|
||||
fun arrayListOf<T>(vararg values: T): ArrayList<T> = throw Exception("$values")
|
||||
|
||||
val bar = foo("", arrayListOf(),<!SYNTAX!><!> )
|
||||
val bar2 = foo<String>("", arrayListOf(),<!SYNTAX!><!> )
|
||||
@@ -0,0 +1,6 @@
|
||||
package
|
||||
|
||||
internal val bar: kotlin.Unit
|
||||
internal val bar2: kotlin.Unit
|
||||
internal fun </*0*/ T> arrayListOf(/*0*/ vararg values: T /*kotlin.Array<out T>*/): java.util.ArrayList<T>
|
||||
internal fun </*0*/ T> foo(/*0*/ a: T, /*1*/ b: kotlin.Collection<T>, /*2*/ c: kotlin.Int): kotlin.Unit
|
||||
@@ -0,0 +1,18 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
//T-2588 Allow to specify exact super type (expected) in inference if many
|
||||
|
||||
import java.util.HashSet
|
||||
|
||||
class MyClass<T>()
|
||||
|
||||
interface A
|
||||
interface D
|
||||
class B : A, D
|
||||
class C : A, D
|
||||
|
||||
fun hashSetOf<T>(vararg values: T): HashSet<T> = throw Exception("$values")
|
||||
|
||||
fun foo(b: MyClass<B>, c: MyClass<C>) {
|
||||
val set1 : Set<MyClass<out D>> = hashSetOf(b, c) //type inference expected type mismatch
|
||||
val set2 = hashSetOf(b, c) //Set<MyClass<out Any>> is inferred
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package
|
||||
|
||||
internal fun foo(/*0*/ b: MyClass<B>, /*1*/ c: MyClass<C>): kotlin.Unit
|
||||
internal fun </*0*/ T> hashSetOf(/*0*/ vararg values: T /*kotlin.Array<out T>*/): java.util.HashSet<T>
|
||||
|
||||
internal interface 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
|
||||
}
|
||||
|
||||
internal final class B : A, D {
|
||||
public constructor B()
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
internal final class C : A, D {
|
||||
public constructor C()
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
internal interface D {
|
||||
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
|
||||
}
|
||||
|
||||
internal final class MyClass</*0*/ T> {
|
||||
public constructor MyClass</*0*/ T>()
|
||||
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
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
// T is the immutable type
|
||||
interface Builder<out T> {
|
||||
fun build(): T
|
||||
}
|
||||
|
||||
// T is the immutable type, U is the builder
|
||||
interface Copyable<out T, out U : Builder<T>> {
|
||||
fun builder(): U
|
||||
}
|
||||
|
||||
fun <T : Copyable<T, U>, U : Builder<T>> T.copy(fn: U.() -> Unit): T = throw Exception()
|
||||
|
||||
open class Foo(val x: Int, val y: Int) : Copyable<Foo, Foo.FooBuilder> {
|
||||
override fun builder(): FooBuilder = FooBuilder(x, y)
|
||||
|
||||
open class FooBuilder(var x: Int, var y: Int): Builder<Foo> {
|
||||
override fun build(): Foo = Foo(x, y)
|
||||
}
|
||||
}
|
||||
|
||||
fun test() {
|
||||
val foo1 = Foo(x = 1, y = 2)
|
||||
val foo2 = foo1.copy { y = 3 } // this doesn't work
|
||||
foo2 checkType { _<Foo>() }
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package
|
||||
|
||||
internal fun test(): kotlin.Unit
|
||||
internal fun </*0*/ T : Copyable<T, U>, /*1*/ U : Builder<T>> T.copy(/*0*/ fn: U.() -> kotlin.Unit): T
|
||||
|
||||
internal interface Builder</*0*/ out T> {
|
||||
internal abstract fun build(): T
|
||||
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
|
||||
}
|
||||
|
||||
internal interface Copyable</*0*/ out T, /*1*/ out U : Builder<T>> {
|
||||
internal abstract fun builder(): U
|
||||
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
|
||||
}
|
||||
|
||||
internal open class Foo : Copyable<Foo, Foo.FooBuilder> {
|
||||
public constructor Foo(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.Int)
|
||||
internal final val x: kotlin.Int
|
||||
internal final val y: kotlin.Int
|
||||
internal open override /*1*/ fun builder(): Foo.FooBuilder
|
||||
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
|
||||
|
||||
internal open class FooBuilder : Builder<Foo> {
|
||||
public constructor FooBuilder(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.Int)
|
||||
internal final var x: kotlin.Int
|
||||
internal final var y: kotlin.Int
|
||||
internal open override /*1*/ fun build(): Foo
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
// KT-3496 Type inference bug on y[""]
|
||||
|
||||
class B<T> {
|
||||
fun <S> x (y: B<Iterable<S>>) {
|
||||
val z: S = y[""] // does not work with [], but works with .get()
|
||||
}
|
||||
fun <S> get(s : String): S = throw Exception()
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package
|
||||
|
||||
internal final class B</*0*/ T> {
|
||||
public constructor B</*0*/ T>()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
internal final fun </*0*/ S> get(/*0*/ s: kotlin.String): S
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
internal final fun </*0*/ S> x(/*0*/ y: B<kotlin.Iterable<S>>): kotlin.Unit
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
|
||||
import java.util.ArrayList
|
||||
|
||||
class F<T> {
|
||||
fun <T, V> x (y: F<ArrayList<T>>, w: ArrayList<V>) {
|
||||
val z: ArrayList<T> = y["", w]
|
||||
}
|
||||
}
|
||||
fun <V, T> Any.get(s: String, w: ArrayList<V>): ArrayList<T> = throw Exception()
|
||||
@@ -0,0 +1,11 @@
|
||||
package
|
||||
|
||||
internal fun </*0*/ V, /*1*/ T> kotlin.Any.get(/*0*/ s: kotlin.String, /*1*/ w: java.util.ArrayList<V>): java.util.ArrayList<T>
|
||||
|
||||
internal final class F</*0*/ T> {
|
||||
public constructor F</*0*/ T>()
|
||||
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
|
||||
internal final fun </*0*/ T, /*1*/ V> x(/*0*/ y: F<java.util.ArrayList<T>>, /*1*/ w: java.util.ArrayList<V>): kotlin.Unit
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
// KT-3559 Strange inference failure error message
|
||||
|
||||
public inline fun <T:Any, R> let(subj: T?, body: (T) -> R): R<!BASE_WITH_NULLABLE_UPPER_BOUND!>?<!> {
|
||||
return if (subj != null) body(<!DEBUG_INFO_SMARTCAST!>subj<!>) else null
|
||||
}
|
||||
|
||||
|
||||
fun test(s: String?): String? {
|
||||
return let(s) {s} // Reports: "Inference failed. Expected jet.String? but found jet.String?"
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
kotlin.inline() public fun </*0*/ T : kotlin.Any, /*1*/ R> let(/*0*/ subj: T?, /*1*/ body: (T) -> R): R?
|
||||
internal fun test(/*0*/ s: kotlin.String?): kotlin.String?
|
||||
@@ -0,0 +1,10 @@
|
||||
// !CHECK_TYPE
|
||||
//KT-4420 Type inference with type projections
|
||||
|
||||
class Foo<T>
|
||||
fun <T> Foo<T>.bar(): T = throw Exception()
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val f: Foo<out String> = Foo()
|
||||
f.bar() checkType { _<String>() }
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package
|
||||
|
||||
internal fun main(/*0*/ args: kotlin.Array<kotlin.String>): kotlin.Unit
|
||||
internal fun </*0*/ T> Foo<T>.bar(): T
|
||||
|
||||
internal final class Foo</*0*/ T> {
|
||||
public constructor Foo</*0*/ T>()
|
||||
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
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
fun foo(s : String?, b : Boolean) {
|
||||
if (s == null) return
|
||||
|
||||
val s1 = if (b) "" else <!DEBUG_INFO_SMARTCAST!>s<!>
|
||||
s1 checkType { _<String>() }
|
||||
|
||||
val s2 = s
|
||||
<!DEBUG_INFO_SMARTCAST!>s2<!> checkType { _<String>() }
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
package
|
||||
|
||||
internal fun foo(/*0*/ s: kotlin.String?, /*1*/ b: kotlin.Boolean): kotlin.Unit
|
||||
@@ -0,0 +1,9 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
import java.io.File
|
||||
|
||||
fun test() {
|
||||
val dir = File("dir")
|
||||
val files = dir.listFiles()?.toList() ?: listOf() // error
|
||||
files checkType { _<List<File>>() }
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
package
|
||||
|
||||
internal fun test(): kotlin.Unit
|
||||
@@ -0,0 +1,10 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
fun <T> bar(f: () -> T) : T = f()
|
||||
|
||||
fun test(map: MutableMap<Int, Int>) {
|
||||
val r = bar {
|
||||
map[1] = 2
|
||||
}
|
||||
r checkType { _<Unit>() }
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
internal fun </*0*/ T> bar(/*0*/ f: () -> T): T
|
||||
internal fun test(/*0*/ map: kotlin.MutableMap<kotlin.Int, kotlin.Int>): kotlin.Unit
|
||||
@@ -6896,6 +6896,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt2057.kt")
|
||||
public void testKt2057() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/regressions/kt2057.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt2179.kt")
|
||||
public void testKt2179() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/regressions/kt2179.kt");
|
||||
@@ -6974,12 +6980,24 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt2588.kt")
|
||||
public void testKt2588() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/regressions/kt2588.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt2741.kt")
|
||||
public void testKt2741() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/regressions/kt2741.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt2754.kt")
|
||||
public void testKt2754() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/regressions/kt2754.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt2838.kt")
|
||||
public void testKt2838() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/regressions/kt2838.kt");
|
||||
@@ -7058,6 +7076,30 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt3496.kt")
|
||||
public void testKt3496() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/regressions/kt3496.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt3496_2.kt")
|
||||
public void testKt3496_2() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/regressions/kt3496_2.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt3559.kt")
|
||||
public void testKt3559() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/regressions/kt3559.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt4420.kt")
|
||||
public void testKt4420() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/regressions/kt4420.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt702.kt")
|
||||
public void testKt702() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/regressions/kt702.kt");
|
||||
@@ -12344,6 +12386,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt1275.kt")
|
||||
public void testKt1275() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/inference/kt1275.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt1355.kt")
|
||||
public void testKt1355() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/inference/kt1355.kt");
|
||||
|
||||
+12
@@ -531,6 +531,18 @@ public class JetDiagnosticsTestWithStdLibGenerated extends AbstractJetDiagnostic
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/inference/kt1558.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt3458.kt")
|
||||
public void testKt3458() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/inference/kt3458.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt4975.kt")
|
||||
public void testKt4975() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithStdLib/inference/kt4975.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/testsWithStdLib/kotlinSignature")
|
||||
|
||||
+6
@@ -3301,6 +3301,12 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
|
||||
doTestWithStdlib(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt3850.kt")
|
||||
public void testKt3850() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/regressions/kt3850.kt");
|
||||
doTestWithStdlib(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kt4142.kt")
|
||||
public void testKt4142() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/regressions/kt4142.kt");
|
||||
|
||||
Reference in New Issue
Block a user