ceylon/ceylon-compiler — Issue #270: Toplevel attributes of parameterized typed using named arguments
Author: gavinking
Created: 2011-12-08 22:15:11+00:00
State: open

The following:

Entry entry = Entry {
item="hello";
key=1;
};

Results in this Java:

private static final ceylon.language.Entry value = (let ceylon.language.String $arg$0$1 = .ceylon.language.String.instance("hello"),ceylon.language.Natural $arg$0$0 = .ceylon.language.Natural.instance(1L) in new ceylon.language.Entry($arg$0$0, $arg$0$1));

Which causes an NPE in javac:

[checking entry]
An exception has occurred in the compiler (1.6.0_ceylon). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report. Thank you.
java.lang.AssertionError: java.lang.NullPointerException
at com.sun.tools.javac.code.Symbol$VarSymbol.getConstValue(Symbol.java:979)
at com.sun.tools.javac.comp.Attr.visitVarDef(Attr.java:719)
at com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:712)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:373)
at com.sun.tools.javac.comp.Attr.attribStat(Attr.java:410)
at com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:2784)
at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2710)
at com.sun.tools.javac.comp.Attr.attribClass(Attr.java:2646)
at com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1131)
at com.redhat.ceylon.compiler.tools.LanguageCompiler.attribute(LanguageCompiler.java:416)
at com.sun.tools.javac.main.JavaCompiler.compile2(JavaCompiler.java:851)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:810)
at com.redhat.ceylon.compiler.launcher.Main.compile(Main.java:392)
at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:132)
at com.redhat.ceylon.eclipse.imp.builder.CeylonBuilder.generateBinaries(CeylonBuilder.java:732)
at com.redhat.ceylon.eclipse.imp.builder.CeylonBuilder.build(CeylonBuilder.java:502)
at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:728)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:239)
at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:292)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:295)
at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:351)
at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:374)
at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143)
at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Caused by: java.lang.NullPointerException
at com.sun.tools.javac.comp.Check$Validator.visitSelect(Check.java:845)
at com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:1658)
at com.sun.tools.javac.comp.Check.validate(Check.java:752)
at com.sun.tools.javac.comp.Attr.visitVarDef(Attr.java:706)
at com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:712)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:373)
at com.sun.tools.javac.comp.Attr.visitLetExpr(Attr.java:2611)
at com.sun.tools.javac.tree.JCTree$LetExpr.accept(JCTree.java:2041)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:373)
at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:390)
at com.sun.tools.javac.code.Symbol$VarSymbol$1.call(Symbol.java:942)
at com.sun.tools.javac.code.Symbol$VarSymbol.getConstValue(Symbol.java:977)
... 27 more

Something to do with the type of the let variables being `ceylon.language.String` instead of `.ceylon.language.String` I believe...