psiTypeToAsm() handles type parameters

This commit is contained in:
Dmitry Jemerov
2011-05-26 14:36:17 +04:00
parent e6bc303345
commit 0b08815960
3 changed files with 20 additions and 2 deletions
@@ -796,6 +796,13 @@ public class ExpressionCodegen extends JetVisitor {
}
if (type instanceof PsiClassType) {
PsiClass psiClass = ((PsiClassType) type).resolve();
if (psiClass instanceof PsiTypeParameter) {
final PsiClassType[] extendsListTypes = psiClass.getExtendsListTypes();
if (extendsListTypes.length > 0) {
throw new UnsupportedOperationException("should return common supertype");
}
return OBJECT_TYPE;
}
if (psiClass == null) {
throw new UnsupportedOperationException("unresolved PsiClassType: " + type);
}
@@ -3,7 +3,6 @@ package org.jetbrains.jet.codegen;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiElement;
import jet.typeinfo.TypeInfo;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.resolve.BindingContext;
@@ -33,7 +32,11 @@ public class JetTypeMapper {
}
static String jvmName(PsiClass psiClass) {
return psiClass.getQualifiedName().replace(".", "/");
final String qName = psiClass.getQualifiedName();
if (qName == null) {
throw new UnsupportedOperationException("can't evaluate JVM name for anonymous class " + psiClass);
}
return qName.replace(".", "/");
}
public String jvmName(ClassDescriptor jetClass, OwnerKind kind) {
@@ -385,4 +385,12 @@ public class NamespaceGenTest extends CodegenTestCase {
assertTrue(result.contains(10));
assertFalse(result.contains(11));
}
public void testSubstituteJavaMethodTypeParameters() throws Exception {
loadText("import java.util.*; fun foo(l: ArrayList<Int>) { l.add(10) }");
final Method main = generateFunction();
final ArrayList<Integer> l = new ArrayList<Integer>();
main.invoke(null, l);
assertEquals(10, l.get(0).intValue());
}
}