KT-130
This commit is contained in:
@@ -1867,20 +1867,22 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
throw new CompilationException("primitive array constructor requires one argument");
|
||||
}
|
||||
}
|
||||
gen(args.get(0).getArgumentExpression(), Type.INT_TYPE);
|
||||
|
||||
if(isArray) {
|
||||
JetType elementType = typeMapper.getGenericsElementType(arrayType);
|
||||
if(elementType != null) {
|
||||
generateTypeInfo(elementType);
|
||||
v.invokestatic("jet/typeinfo/TypeInfo", "newArray", "(ILjet/typeinfo/TypeInfo;)[Ljava/lang/Object;");
|
||||
gen(args.get(0).getArgumentExpression(), Type.INT_TYPE);
|
||||
v.invokevirtual("jet/typeinfo/TypeInfo", "newArray", "(I)[Ljava/lang/Object;");
|
||||
}
|
||||
else {
|
||||
gen(args.get(0).getArgumentExpression(), Type.INT_TYPE);
|
||||
v.newarray(JetTypeMapper.boxType(typeMapper.mapType(arrayType.getArguments().get(0).getType())));
|
||||
}
|
||||
}
|
||||
else {
|
||||
Type type = typeMapper.mapType(arrayType, OwnerKind.IMPLEMENTATION);
|
||||
gen(args.get(0).getArgumentExpression(), Type.INT_TYPE);
|
||||
v.newarray(type.getElementType());
|
||||
}
|
||||
|
||||
|
||||
@@ -49,9 +49,7 @@ public abstract class TypeInfo<T> implements JetObject {
|
||||
public static final TypeInfo<String> NULLABLE_STRING_TYPE_INFO = getTypeInfo(String.class, true);
|
||||
public static final TypeInfo<Tuple0> NULLABLE_TUPLE0_TYPE_INFO = getTypeInfo(Tuple0.class, true);
|
||||
|
||||
public static Object [] newArray(int length, TypeInfo typeInfo) {
|
||||
return (Object[]) Array.newInstance(((TypeInfoImpl)typeInfo).signature.klazz, length);
|
||||
}
|
||||
public abstract Object [] newArray(int length);
|
||||
|
||||
public static <T> TypeInfoProjection invariantProjection(final TypeInfo<T> typeInfo) {
|
||||
return (TypeInfoProjection) typeInfo;
|
||||
@@ -126,6 +124,11 @@ public abstract class TypeInfo<T> implements JetObject {
|
||||
this.varIndex = varIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] newArray(int length) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClassObject() {
|
||||
throw new UnsupportedOperationException("Abstract TypeInfo");
|
||||
@@ -209,6 +212,11 @@ public abstract class TypeInfo<T> implements JetObject {
|
||||
return projections[index];
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] newArray(int length) {
|
||||
return (Object[]) Array.newInstance(signature.klazz, length);
|
||||
}
|
||||
|
||||
public final Object getClassObject() {
|
||||
try {
|
||||
final Class implClass = signature.klazz.getClassLoader().loadClass(signature.klazz.getCanonicalName());
|
||||
|
||||
Reference in New Issue
Block a user