ceylon
ceylon copied to clipboard
Can't Instantiate Array using Metamodel apply() method.
It is not possible to instantiate Array<Integer>
, by using 'Array<Integer>'.apply({1,2,3})
.
I made four unit test, which should in my opinion all pass but the last one fails, two are for ArrayList
and two for Array
to have proof I'm doing it right.
shared test
void shouldCreateArrayListByConstructor(){
ArrayList<Integer>{
elements = {1,2,3};
};
}
shared test
void shouldCreateArrayListUsingMetamodelApply(){
`ArrayList<Integer>`.apply(0,1.5,{1,2,3});
}
shared test
void shouldCreateArrayByConstructor(){
Array<Integer>({1,2,3});
}
shared test
void shouldCreateArrayUsingMetamodelApplyFAIL(){
`Array<Integer>`.apply({1,2,3});
}
It fails badly:
java.lang.ClassCastException: com.redhat.ceylon.compiler.java.language.ConstantIterable cannot be cast to [J
at ceylon.language.Array.<init>(Array.java:614)
at com.redhat.ceylon.compiler.java.runtime.metamodel.ConstructorDispatch.$call$(ConstructorDispatch.java:610)
at com.redhat.ceylon.compiler.java.Util.apply(Util.java:1634)
at com.redhat.ceylon.compiler.java.runtime.metamodel.Metamodel.apply(Metamodel.java:1891)
at com.redhat.ceylon.compiler.java.runtime.metamodel.ConstructorDispatch.apply(ConstructorDispatch.java:762)
at com.redhat.ceylon.compiler.java.runtime.metamodel.meta.ClassImpl.apply(ClassImpl.java:410)
at ...
I think the same happens for other types like String
, Float
.