added 'class has Kotlin analog' error

to existing diagnostic tests
This commit is contained in:
Svetlana Isakova
2012-08-29 15:55:39 +04:00
parent a3194e9a46
commit 31831f2433
10 changed files with 24 additions and 24 deletions
@@ -8,7 +8,7 @@ fun test() {
val <!UNUSED_VARIABLE!>a<!> : java.util.Collection<String>? = java.util.Collections.emptyList()
}
fun test(<!UNUSED_PARAMETER!>a<!> : java.lang.Comparable<Int>) {
fun test(<!UNUSED_PARAMETER!>a<!> : <!CLASS_HAS_KOTLIN_ANALOG!>java.lang.Comparable<Int><!>) {
}
@@ -5,14 +5,14 @@ import java.util.*
import <!UNRESOLVED_REFERENCE!>utils<!>.*
import java.io.PrintStream
import java.lang.Comparable as Com
import <!CLASS_HAS_KOTLIN_ANALOG!>java.lang.Comparable<!> as Com
val l : List<in Int> = ArrayList<Int>()
fun test(<!UNUSED_PARAMETER!>l<!> : java.util.List<Int>) {
val <!UNUSED_VARIABLE!>x<!> : java.<!UNRESOLVED_REFERENCE!>List<!>
val <!UNUSED_VARIABLE!>y<!> : java.util.List<Int>
val <!UNUSED_VARIABLE!>b<!> : java.lang.Object
val <!UNUSED_VARIABLE!>b<!> : <!CLASS_HAS_KOTLIN_ANALOG!>java.lang.Object<!>
val <!UNUSED_VARIABLE!>a<!> : util.List<Int>
val <!UNUSED_VARIABLE!>z<!> : java.<!UNRESOLVED_REFERENCE!>utils<!>.List<Int>
@@ -29,7 +29,7 @@ fun test(<!UNUSED_PARAMETER!>l<!> : java.util.List<Int>) {
<!UNRESOLVED_REFERENCE!>List<!><Int>
val <!UNUSED_VARIABLE!>o<!> = "sdf" <!CAST_NEVER_SUCCEEDS!>as<!> Object
val <!UNUSED_VARIABLE!>o<!> = "sdf" <!CAST_NEVER_SUCCEEDS!>as<!> <!CLASS_HAS_KOTLIN_ANALOG!>Object<!>
try {
// ...
@@ -40,9 +40,9 @@ fun test(<!UNUSED_PARAMETER!>l<!> : java.util.List<Int>) {
PrintStream("sdf")
val c : Com<Int>? = null
val c : <!CLASS_HAS_KOTLIN_ANALOG!>Com<Int><!>? = null
c : java.lang.Comparable<Int>?
c : <!CLASS_HAS_KOTLIN_ANALOG!>java.lang.Comparable<Int><!>?
// Collections.sort<Integer>(ArrayList<Integer>())
xxx.<!UNRESOLVED_REFERENCE!>Class<!>()
@@ -4,7 +4,7 @@ package i
import java.util.*
fun <T, R> Collection<T>.map1(<!UNUSED_PARAMETER!>f<!> : (T) -> R) : List<R> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
fun <T, R> java.lang.Iterable<T>.map1(<!UNUSED_PARAMETER!>f<!> : (T) -> R) : List<R> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
fun <T, R> <!CLASS_HAS_KOTLIN_ANALOG!>java.lang.Iterable<T><!>.map1(<!UNUSED_PARAMETER!>f<!> : (T) -> R) : List<R> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
fun test(list: List<Int>) {
val res = list.map1 { it }
@@ -13,7 +13,7 @@ fun test(list: List<Int>) {
}
fun <T> Collection<T>.foo() {}
fun <T> java.lang.Iterable<T>.foo() {}
fun <T> <!CLASS_HAS_KOTLIN_ANALOG!>java.lang.Iterable<T><!>.foo() {}
fun test1(list: List<Int>) {
val res = list.foo()
@@ -3,7 +3,7 @@ package kt1778
fun main(args : Array<String>) {
val x = args[0]: Any
if(x is java.lang.CharSequence) {
if(x is <!CLASS_HAS_KOTLIN_ANALOG!>java.lang.CharSequence<!>) {
if ("a" == x) x.length() else x.length() // OK
if ("a" == x || "b" == x) x.length() else x.length() // < THEN ERROR
if ("a" == x && "a" == x) x.length() else x.length() // < ELSE ERROR
@@ -2,16 +2,16 @@
import java.util.ArrayList
abstract class Item(val room: Object) {
abstract class Item(val room: <!CLASS_HAS_KOTLIN_ANALOG!>Object<!>) {
abstract val name : String
}
val items: ArrayList<Item> = ArrayList<Item>()
fun test(room : Object) {
fun test(room : <!CLASS_HAS_KOTLIN_ANALOG!>Object<!>) {
for(val item: Item? in items) {
if (item?.room === room) {
System.out.println("You see " + item?.name)
}
}
}
}
@@ -3,5 +3,5 @@
class IdUnavailableException() : Exception() {}
fun <T : Any> T.getJavaClass() : Class<T> {
return <!UNCHECKED_CAST!>((this <!CAST_NEVER_SUCCEEDS!>as<!> Object).getClass()) as Class<T><!> // Some error here, because of Exception() used above. ?!!!
}
return <!UNCHECKED_CAST!>((this <!CAST_NEVER_SUCCEEDS!>as<!> <!CLASS_HAS_KOTLIN_ANALOG!>Object<!>).getClass()) as Class<T><!> // Some error here, because of Exception() used above. ?!!!
}
@@ -5,7 +5,7 @@ class TypeInfo<T>
fun <T> typeinfo() : TypeInfo<T> = null <!CAST_NEVER_SUCCEEDS!>as<!> TypeInfo<T>
fun <T> TypeInfo<T>.getJavaClass() : java.lang.Class<T> {
val t : java.lang.Object = this <!CAST_NEVER_SUCCEEDS!>as<!> java.lang.Object
val t : <!CLASS_HAS_KOTLIN_ANALOG!>java.lang.Object<!> = this <!CAST_NEVER_SUCCEEDS!>as<!> <!CLASS_HAS_KOTLIN_ANALOG!>java.lang.Object<!>
return <!UNCHECKED_CAST!>t.getClass() as java.lang.Class<T><!> // inferred type is Object but Serializable was expected
}
@@ -13,4 +13,4 @@ fun getJavaClass<T>() = typeinfo<T>().getJavaClass()
fun main(args : Array<String>) {
System.out.println(getJavaClass<String>())
}
}
@@ -42,6 +42,6 @@ class Q {
}
//check that 'toString' can be invoked without specifying return type
class NewClass : java.util.ArrayList<Integer>() {
class NewClass : java.util.ArrayList<<!CLASS_HAS_KOTLIN_ANALOG!>Integer<!>>() {
public override fun toString() = "a"
}
+5 -5
View File
@@ -3,14 +3,14 @@ import java.util.*
import <error>utils</error>.*
import java.io.PrintStream
import java.lang.Comparable as Com
import <warning>java.lang.Comparable</warning> as Com
val l : List<in Int> = ArrayList<Int>()
fun test(<warning>l</warning> : java.util.List<Int>) {
val <warning>x</warning> : java.<error>List</error>
val <warning>y</warning> : java.util.List<Int>
val <warning>b</warning> : java.lang.Object
val <warning>b</warning> : <warning>java.lang.Object</warning>
val <warning>a</warning> : util.List<Int>
val <warning>z</warning> : java.<error>utils</error>.<error>List</error><Int>
@@ -27,7 +27,7 @@ fun test(<warning>l</warning> : java.util.List<Int>) {
<error>List</error><Int>
val <warning>o</warning> = "sdf" <warning>as</warning> Object
val <warning>o</warning> = "sdf" <warning>as</warning> <warning>Object</warning>
try {
// ...
@@ -38,9 +38,9 @@ fun test(<warning>l</warning> : java.util.List<Int>) {
PrintStream("sdf")
val c : Com<Int>? = null
val c : <warning>Com<Int></warning>? = null
c : java.lang.Comparable<Int>?
c : <warning>java.lang.Comparable<Int></warning>?
// Collections.sort<Integer>(ArrayList<Integer>())
}
+2 -2
View File
@@ -2,13 +2,13 @@
import java.util.ArrayList
abstract class Item(val room: Object) {
abstract class Item(val room: <warning>Object</warning>) {
abstract val name : String
}
val items: ArrayList<Item> = ArrayList<Item>()
fun test(room : Object) {
fun test(room : <warning>Object</warning>) {
for(val item: Item in items) {
if (item.room === room) {
System.out.println("You see " + item.name)