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");
|
throw new CompilationException("primitive array constructor requires one argument");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gen(args.get(0).getArgumentExpression(), Type.INT_TYPE);
|
|
||||||
|
|
||||||
if(isArray) {
|
if(isArray) {
|
||||||
JetType elementType = typeMapper.getGenericsElementType(arrayType);
|
JetType elementType = typeMapper.getGenericsElementType(arrayType);
|
||||||
if(elementType != null) {
|
if(elementType != null) {
|
||||||
generateTypeInfo(elementType);
|
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 {
|
else {
|
||||||
|
gen(args.get(0).getArgumentExpression(), Type.INT_TYPE);
|
||||||
v.newarray(JetTypeMapper.boxType(typeMapper.mapType(arrayType.getArguments().get(0).getType())));
|
v.newarray(JetTypeMapper.boxType(typeMapper.mapType(arrayType.getArguments().get(0).getType())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Type type = typeMapper.mapType(arrayType, OwnerKind.IMPLEMENTATION);
|
Type type = typeMapper.mapType(arrayType, OwnerKind.IMPLEMENTATION);
|
||||||
|
gen(args.get(0).getArgumentExpression(), Type.INT_TYPE);
|
||||||
v.newarray(type.getElementType());
|
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<String> NULLABLE_STRING_TYPE_INFO = getTypeInfo(String.class, true);
|
||||||
public static final TypeInfo<Tuple0> NULLABLE_TUPLE0_TYPE_INFO = getTypeInfo(Tuple0.class, true);
|
public static final TypeInfo<Tuple0> NULLABLE_TUPLE0_TYPE_INFO = getTypeInfo(Tuple0.class, true);
|
||||||
|
|
||||||
public static Object [] newArray(int length, TypeInfo typeInfo) {
|
public abstract Object [] newArray(int length);
|
||||||
return (Object[]) Array.newInstance(((TypeInfoImpl)typeInfo).signature.klazz, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static <T> TypeInfoProjection invariantProjection(final TypeInfo<T> typeInfo) {
|
public static <T> TypeInfoProjection invariantProjection(final TypeInfo<T> typeInfo) {
|
||||||
return (TypeInfoProjection) typeInfo;
|
return (TypeInfoProjection) typeInfo;
|
||||||
@@ -126,6 +124,11 @@ public abstract class TypeInfo<T> implements JetObject {
|
|||||||
this.varIndex = varIndex;
|
this.varIndex = varIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object[] newArray(int length) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getClassObject() {
|
public Object getClassObject() {
|
||||||
throw new UnsupportedOperationException("Abstract TypeInfo");
|
throw new UnsupportedOperationException("Abstract TypeInfo");
|
||||||
@@ -209,6 +212,11 @@ public abstract class TypeInfo<T> implements JetObject {
|
|||||||
return projections[index];
|
return projections[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object[] newArray(int length) {
|
||||||
|
return (Object[]) Array.newInstance(signature.klazz, length);
|
||||||
|
}
|
||||||
|
|
||||||
public final Object getClassObject() {
|
public final Object getClassObject() {
|
||||||
try {
|
try {
|
||||||
final Class implClass = signature.klazz.getClassLoader().loadClass(signature.klazz.getCanonicalName());
|
final Class implClass = signature.klazz.getClassLoader().loadClass(signature.klazz.getCanonicalName());
|
||||||
|
|||||||
Reference in New Issue
Block a user