KT-1048 Need to replace missed generics parameters by theirs upper bounds

This commit is contained in:
Sergey Ignatov
2012-01-16 18:44:33 +04:00
parent 3fa6882c8c
commit 0ed16b5c9c
12 changed files with 61 additions and 17 deletions
@@ -9,6 +9,13 @@ public class StarProjectionType extends Type {
@NotNull
@Override
public String toKotlin() {
G g = new G("");
G<String> g2 = new G<String>("");
return STAR;
}
}
class G <T extends String> {
public <T> G(T t) {
}
}
@@ -116,8 +116,13 @@ public class TypeVisitor extends PsiTypeVisitor<Type> {
if (resolve != null) {
if (resolve instanceof PsiClass)
//noinspection UnusedDeclaration
for (PsiTypeParameter p : ((PsiClass) resolve).getTypeParameters())
typeParams.add(new StarProjectionType());
for (PsiTypeParameter p : ((PsiClass) resolve).getTypeParameters()) {
Type boundType = p.getSuperTypes().length > 0 ?
new ClassType(new IdentifierImpl(getClassTypeName(p.getSuperTypes()[0])), typesToTypeList(p.getSuperTypes()[0].getParameters()), true) :
new StarProjectionType();
typeParams.add(boundType);
}
}
}
return typeParams;
+2 -2
View File
@@ -14,8 +14,8 @@ return __
}
open class User() {
open fun main() : Unit {
var m : HashMap<*, *>? = HashMap(1)
var m2 : HashMap<*, *>? = HashMap(10)
var m : HashMap<Any?, Any?>? = HashMap(1)
var m2 : HashMap<Any?, Any?>? = HashMap(10)
var t1 : Test? = Test.init()
var t2 : Test? = Test.init("")
}
@@ -30,8 +30,8 @@ public open class User() {
class object {
open public fun main() : Unit {
var i1 : Identifier<*>? = Identifier.init<String?>("name", false, true)
var i2 : Identifier<*>? = Identifier.init<String?>("name", false)
var i3 : Identifier<*>? = Identifier.init<String?>("name")
var i2 : Identifier<Any?>? = Identifier.init<String?>("name", false)
var i3 : Identifier<Any?>? = Identifier.init<String?>("name")
}
}
}
+18
View File
@@ -0,0 +1,18 @@
import java.util.HashMap;
class G <T extends String> {
public <T> G(T t) {
}
}
public class Java {
void test() {
HashMap m = new HashMap();
m.put(1, 1);
}
void test2() {
HashMap<?, ?> m = new HashMap();
G g = new G("");
G<String> g2 = new G<String>("");
}
}
+14
View File
@@ -0,0 +1,14 @@
import java.util.HashMap
open class G<T : String?>(t : T?) {
}
public open class Java() {
open fun test() : Unit {
var m : HashMap<Any?, Any?>? = HashMap()
m?.put(1, 1)
}
open fun test2() : Unit {
var m : HashMap<*, *>? = HashMap()
var g : G<String?>? = G("")
var g2 : G<String?>? = G<String?>("")
}
}
+2 -2
View File
@@ -30,8 +30,8 @@ public open class User() {
class object {
open public fun main(args : Array<String?>?) : Unit {
var i1 : Identifier<*>? = Identifier.init<String?>("name", false, true)
var i2 : Identifier<*>? = Identifier.init<String?>("name", false)
var i3 : Identifier<*>? = Identifier.init<String?>("name")
var i2 : Identifier<Any?>? = Identifier.init<String?>("name", false)
var i3 : Identifier<Any?>? = Identifier.init<String?>("name")
}
}
}
@@ -2,6 +2,6 @@ package test
import java.util.List
open class User() {
open fun main() : Unit {
var list : List<*>? = java.util.LinkedList()
var list : List<Any?>? = java.util.LinkedList()
}
}
@@ -1,6 +1,6 @@
package test
open class User() {
open fun main() : Unit {
var list : java.util.List<*>? = java.util.LinkedList()
var list : java.util.List<Any?>? = java.util.LinkedList()
}
}
+2 -2
View File
@@ -3,7 +3,7 @@ import java.util.HashMap
open class Test() {
open fun main() : Unit {
var commonMap : HashMap<String?, Int?>? = HashMap<String?, Int?>()
var rawMap : HashMap<*, *>? = HashMap<String?, Int?>()
var superRawMap : HashMap<*, *>? = HashMap()
var rawMap : HashMap<Any?, Any?>? = HashMap<String?, Int?>()
var superRawMap : HashMap<Any?, Any?>? = HashMap()
}
}
@@ -6,8 +6,8 @@ System.out?.println(e)
}
open class Test() {
open fun main() : Unit {
var raw1 : Collection<*>? = Collection(1)
var raw2 : Collection<*>? = Collection<Int?>(1)
var raw3 : Collection<*>? = Collection<String?>("1")
var raw1 : Collection<Any?>? = Collection(1)
var raw2 : Collection<Any?>? = Collection<Int?>(1)
var raw3 : Collection<Any?>? = Collection<String?>("1")
}
}
+2 -2
View File
@@ -4,7 +4,7 @@ import java.util.LinkedList
open class Test() {
open fun main() : Unit {
var common : List<String?>? = LinkedList<String?>()
var raw : List<*>? = LinkedList<String?>()
var superRaw : List<*>? = LinkedList()
var raw : List<Any?>? = LinkedList<String?>()
var superRaw : List<Any?>? = LinkedList()
}
}