1

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)
Renato
  • 12,940
  • 3
  • 54
  • 85
  • Using iterable syntax, ie. `value x = {[1, Color(0)]};` instead of `value x = [[1, Color(0)]];`, solves the problem... but still, I think it should work regardless. – Renato Nov 26 '13 at 19:55
  • I tried this with Ceylon-only code and the problem goes away... seems to be some Java-interop problem (notice the Color refers to java.awt.Color). – Renato Nov 26 '13 at 20:35

1 Answers1

1

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.

Gavin King
  • 3,182
  • 1
  • 13
  • 11
  • Ok, I created the ticket... I couldn't find it after I created it, does it need to be "approved" before it becomes publicly visible? – Renato Nov 27 '13 at 08:22