Question

What's wrong with this code?

value x = [[1, Color(0)]];

//Exception thrown here
value y = x.map(([Integer, Color] elem) => "``elem[0]`` -> ``elem[1]``");

... the last line could be replaced with this:

value y = { for(elem in x) "``elem[0]`` -> ``elem[1]``" };

... I believe these should run fine, but in both cases I get this error:

Ceylon run: java.awt.Color cannot be cast to com.redhat.ceylon.compiler.java.
runtime.model.ReifiedType
java.lang.ClassCastException: java.awt.Color cannot be cast to com.redhat.ceylon.compiler.java.runtime.model.ReifiedType
    at ceylon.language.Tuple.$getElementType(Tuple.java:286)
    at ceylon.language.Tuple.$getUnionOfAllType(Tuple.java:279)
    at ceylon.language.Tuple.$getType(Tuple.java:266)
    at ceylon.language.Tuple.$getType$(Tuple.java:257)
    at ceylon.language.Tuple.$getElementType(Tuple.java:287)
    at ceylon.language.Tuple.$getUnionOfAllType(Tuple.java:279)
    at ceylon.language.Tuple.$getReifiedElement$(Tuple.java:102)
    at ceylon.language.ArraySequence.map(ArraySequence.java:612)
    at firstModule.run_.run(run.ceylon:11)
    at firstModule.run_.main(run.ceylon)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at ceylon.modules.api.runtime.SecurityActions.invokeRunInternal(SecurityActions.java:61)
    at ceylon.modules.api.runtime.SecurityActions.invokeRun(SecurityActions.java:51)
    at ceylon.modules.api.runtime.AbstractRuntime.invokeRun(AbstractRuntime.java:89)
    at ceylon.modules.api.runtime.AbstractRuntime.execute(AbstractRuntime.java:141)
    at ceylon.modules.api.runtime.AbstractRuntime.execute(AbstractRuntime.java:126)
    at ceylon.modules.Main.execute(Main.java:69)
    at ceylon.modules.Main.main(Main.java:42)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.jboss.modules.Module.run(Module.java:270)
    at org.jboss.modules.Main.main(Main.java:294)
    at ceylon.modules.bootstrap.CeylonRunTool.run(CeylonRunTool.java:208)
    at com.redhat.ceylon.common.tools.CeylonTool.run(CeylonTool.java:343)
    at com.redhat.ceylon.common.tools.CeylonTool.execute(CeylonTool.java:283)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.redhat.ceylon.launcher.Launcher.run(Launcher.java:89)
    at com.redhat.ceylon.launcher.Launcher.main(Launcher.java:21)
Was it helpful?

Solution

Please report this as a bug against the Ceylon language module, here:

https://github.com/ceylon/ceylon.language/issues

The bug is indeed a result of the fact that Color is a Java class, not a Ceylon class.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top