KT-12054 J2K generates obj is Type<Any> instead of obj is Type<*>

#KT-12054 Fixed
This commit is contained in:
Valentin Kipyatkov
2016-04-28 18:48:40 +03:00
parent a8eef5effc
commit 76e067c43a
11 changed files with 34 additions and 23 deletions
@@ -3,8 +3,8 @@
import java.util.HashSet
internal class Foo {
fun foo(o: HashSet<Any?>?) {
val o2: HashSet<Any?>? = o
fun foo(o: HashSet<*>?) {
val o2: HashSet<*>? = o
var foo: Int = 0
foo = o2!!.size
}
@@ -1,7 +1,7 @@
import java.util.HashSet
internal class Foo {
fun foo(o: HashSet<Any>) {
fun foo(o: HashSet<*>) {
val o2 = o
var foo = 0
foo = o2.size
+8
View File
@@ -0,0 +1,8 @@
import java.util.Collection;
import java.util.List;
class C {
boolean bar(Object o, Collection<String> collection) {
return o instanceof Collection && collection instanceof List;
}
}
+5
View File
@@ -0,0 +1,5 @@
internal class C {
fun bar(o: Any, collection: Collection<String>): Boolean {
return o is Collection<*> && collection is List<*>
}
}
@@ -1,3 +1,4 @@
//TODO: uncomment this test when KT-12133 fixed
class JavaClass1<T extends JavaClass2> {
}
+2 -2
View File
@@ -1,9 +1,9 @@
// ERROR: Type inference failed. Expected type mismatch: inferred type is HashMap<Any!, Any!> but Map<String, String> was expected
// ERROR: Type inference failed. Expected type mismatch: inferred type is HashMap<Any?, Any?> but Map<String, String> was expected
import java.util.*
internal object A {
fun foo(): Map<String, String> {
val props = Properties()
return HashMap(props as Map<Any, Any>)
return HashMap(props as Map<*, *>)
}
}