Compiling @Immutable classes in IDEA 8.1.3 and 9.1.
Would be great to have some idea of what's happening with the following compilation issues
1) Here's what I get when compiling immutable classes in 8.1.3
Eg,
@Immutable final class ImmutableExample {
int a
int b
int getSum(){a+b}
}
and another with a field referencing the former:
@Immutable final class ImmutableCompositeEg {
ImmutableExample example
int c
int getSum(){example.sum+c }
}
I think this should be legal in Groovy? However, when I run
def eg= new ImmutableExample(a: 2, b:3)
def egComposit = new ImmutableCompositeEg(c: 4, example: eg)
I get the error.
"Caught: groovy.lang.MissingMethodException: No signature of method: static org.codehaus.groovy.transform.ImmutableASTTransformation.checkImmutable() is applicable for argument types: (java.lang.String, java.lang.String, designgui.ImmutableExample) values: [designgui.ImmutableCompositeEg, example, designgui.ImmutableExample(a:2, b:3)]
at designgui.ImmutableCompositeEg.<init>(ImmutableCompositeEg.groovy)
at Explore.run(Explore.groovy:14)
2). In 9.1, it is the same problem. Besides, when I rebuild the project I get the following errors
C:\Users\pcw\.IntelliJIdea9M1\system\compiler\optnew.OptNew8d7cbdbe\.generated\Groovy_to_java_source_code_generator\designgui.f53ada3a\production\designgui\ImmutableCompositeEg.java
Error:Error:line (4)illegal combination of modifiers: public and private
ie, in the java code,
public final class ImmutableExample implements groovy.lang.GroovyObject {
public private final int getSum() {
return 0;
}
Any feedback would be appreciated
Message was edited by: Oleg Volkov
Oops, forgot the builds: 8.1.3 is #9886 and 9.1 is # 10372
请先登录再写评论。
Update:
Problem 1 is possibly OK. I tried the example in Idea 8.13 by starting a new project from scratch. Everything seemed to work. So perhaps there's some problem
with the original project structure.
However, a new project in 9.1 would still produce the same error about the illegal public/private partnership.
Please try the latest Maia EAP
(http://www.jetbrains.net/confluence/display/IDEADEV/Maia+EAP). If the
problem persists (I can't reproduce it BTW) please file a JIRA issue
with a self-contained not compiling example.