You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The JVM compiler outputs some rather cryptic compile errors in an IDE project where higher order generics were successfully compiled as JavaScript only.
This issue requests the implementation of clearer compile errors along the lines of "JVM compiler does not currently support Higher Order Generics feature" as opposed to the compile errors below.
Please see #2358 for the actual implementation of the feature on the JVM.
Apologies for the lengthly sample, but I figured this is good to capture the broad range of possible compile errors. Please note that this occurred on a production 1.2.0 Eclipse IDE, not one recently built from github sources.
Look for "JVM compile errors comments in the code below:
importceylon.collection {
LinkedList
}
sharedvoidgenericFunctionDefinitions() {
aliasValueToValueValue => <Value> => [Value,Value];
aliasPair<Value> => [Value,Value];
// JVM compile error:// package SecondOrder does not existinterfaceSecondOrder<Box> givenBox<Value> {
sharedformalBox<Float> createBox(Floatfloat);
}
//apply to a generic type aliasSecondOrder<Pair> something;
//apply to a generic interface// List *is* a Type Function even though it already exists as something elseSecondOrder<List> somethingElse;
//apply to an anonymous type functionSecondOrder<<Value> => [Value,Value]> somethingScaryLookin;
Anypipe<Any>(Anyanything) => anything;
Numberadd<Number>(Numberx, Numbery)
givenNumbersatisfiesSummable<Number>
=> x+y;
// Are these both the same thing?aliasAnyAnyAny => <Any> => Any(Any);
aliasAnyAny<Any> => Any(Any);
aliasAdditionLikeOperation
=> <Number> givenNumbersatisfiesSummable<Number>
=> Number(Number,Number);
aliasAdditionLikeOperationSimple<Number>
givenNumbersatisfiesSummable<Number>
=> Number(Number,Number);
}
voidgenericFunctionReferences() {
// generic function definitionAnypipe<Any>(Anyanything) => anything;
// generic function reference
<Any> => Any(Any) pipeFun = pipe;
// generic function definitionNumberadd<Number>(Numberx, Numbery)
givenNumbersatisfiesSummable<Number>
=> x+y;
// generic function aliasaliasAdditionLikeOperation
=> <Number> givenNumbersatisfiesSummable<Number>
=> Number(Number,Number);
// generic function reference with raw function type
<Number> givenNumbersatisfiesSummable<Number>
=> Number(Number,Number) addFun = add;
// generic function reference with aliasAdditionLikeOperationaddFunWithAlias = add;
// Simply pass the type to the generic function to create a function with the types setString(String) pipeString = pipeFun<String>;
Object(Object) pipeObject = pipeFun<Object>;
// Call the functions using type inference to obtain the resulting valueStringhi = pipeFun("hello");
Integerzero = pipeFun(0);
// generic function general form:// <TypeParameters> => ReturnType(ParameterTypes)// Take a Stream of elements and produce another Stream of elements// Define the Stream of elements returned in terms on the type constructor of the// Stream<Elem> paramStream<Elem> scan<Elem,Stream>
(inputStream, newStream)
//Note: Stream is a reference to a type function!givenStream<Elem> satisfies {Elem*} {
// This is the original StreamStream<Elem> inputStream;
// This it the function type that will return a stream for a Stream of elementsStream<Elem> newStream<Elem>(Stream<Elem> elements);
returnnothing;
}
// Note: I need Stream as well as Elem as a type parameter or this won't compileStream<Elem> newStream<Stream,Elem>({Elem*} elements)
givenStream<Elem> satisfies {Elem*};
// 1) Iterable case:
{Integer*} iterableInput = {1,2,3};
scan<Integer,Iterable>(iterableInput, <Elem>({Elem*} elems) => elems);
// 2) LinkedList case:LinkedList<Integer> linkedListInput = LinkedList{1,2,3};
// JVM compile errors:// compiler bug: unhandled declaration unknown with type UnknownType at com.redhat.ceylon.compiler.java.codegen.AbstractTransformer.makeReifiedTypeArgumentResolved(AbstractTransformer.java:5245)// compiler bug: visitor didn't yield any result at com.redhat.ceylon.compiler.java.codegen.ExpressionTransformer.transformExpression(ExpressionTransformer.java:340)// compiler bug: visitor didn't yield any result at unknownscan<Integer,LinkedList>(linkedListInput, LinkedList);
Stream<Elem> newScan<Elem,Stream>
(inputStream, newStream)
//Note: Stream is a reference to a type function!givenStream<Elem> satisfies {Elem*} {
// This is the original StreamStream<Elem> inputStream;
// This it the function type that will return a stream for a Stream of elementsStream<Elem> newStream<Elem>({Elem*} elements);
returnnothing;
}
// 1) Iterable case:
{String*} iterableInput2 = {"1","2","3"};
newScan<String,Iterable>(iterableInput2, <Elem>({Elem*} elems) => elems);
// 2) LinkedList case:LinkedList<String> linkedListInput2 = LinkedList{"1","2","3"};
// JVM compile errors:// compiler bug: unhandled declaration unknown with type UnknownType at com.redhat.ceylon.compiler.java.codegen.AbstractTransformer.makeReifiedTypeArgumentResolved(AbstractTransformer.java:5245)// compiler bug: visitor didn't yield any result at com.redhat.ceylon.compiler.java.codegen.ExpressionTransformer.transformExpression(ExpressionTransformer.java:340)// compiler bug: visitor didn't yield any result at unknownnewScan<String,LinkedList>(linkedListInput2, LinkedList);
}
The text was updated successfully, but these errors were encountered:
The JVM compiler outputs some rather cryptic compile errors in an IDE project where higher order generics were successfully compiled as JavaScript only.
This issue requests the implementation of clearer compile errors along the lines of "JVM compiler does not currently support Higher Order Generics feature" as opposed to the compile errors below.
Please see #2358 for the actual implementation of the feature on the JVM.
Apologies for the lengthly sample, but I figured this is good to capture the broad range of possible compile errors. Please note that this occurred on a production 1.2.0 Eclipse IDE, not one recently built from github sources.
Look for "JVM compile errors comments in the code below:
The text was updated successfully, but these errors were encountered: