1

这段代码有什么问题?

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

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

...最后一行可以替换为:

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

...我相信这些应该可以正常运行,但是在这两种情况下我都会收到此错误:

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)
4

1 回答 1

1

请在此处将其报告为针对 Ceylon 语言模块的错误:

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

该错误确实Color是Java类而不是Ceylon类的结果。

于 2013-11-27T03:13:06.197 回答