形势
我有一个Java类的Groovy子类。Java类来自依赖项,而不是我自己的本地包:
// A basic idea of the Java class' construction
public class JavaArea<PS, S> {
public JavaArea(PS initialStyle, BiConsumer, S otheStyle, Biconsumer) {
// constructs class...
}
}
class GroovyArea extends JavaArea<Collection<String>, Collection<String>> {
GroovyArea(Object unrelated arguments) {
super(Collections.emptyList(), defaultBiConsumer, otherStyle, defaultBiConsumer)
// do some other stuff to GroovyArea's fields
}
}由于某种原因,尽管构造函数调用是第一个语句,但类的编译还是失败了:Constructor call must be the first statement in a constructor.
Exception executing
org.gradle.api.internal.tasks.compile.ApiGroovyCompiler@7a1c5b43
in compiler daemon:
org.gradle.api.internal.tasks.compile.CompilationFailedException:
Compilation failed; see the compiler error output for details..
super(Collections.emptyList(), otherParams)
^Gradle构建文件
我有以下根项目的构建文件:
subprojects {
apply plugin: 'groovy'
repositories {
mavenCentral()
}
dependencies {
compile 'org.codehaus.groovy:groovy-all:2.4.6'
testCompile "org.spockframework:spock-core:1.0-groovy-2.4"
testRuntime "cglib:cglib-nodep:3.2.3"
testRuntime "org.objenesis:objenesis:2.4"
}
}..。以及包含错误的实际模块的以下构建文件:
version '1.0-SNAPSHOT'
apply plugin: 'groovy'
repositories {
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
}
dependencies {
compile 'org.codehaus.groovyfx:groovyfx:0.4.0'
compile project(':diagrammer')
compile group: 'org.reactfx', name: 'reactfx', version: '2.0-M5'
compile group: 'org.fxmisc.wellbehaved', name: 'wellbehavedfx', version: '0.3'
compile (group: 'org.fxmisc.richtext', name: 'richtextfx', version: '1.0.0-SNAPSHOT') {
exclude group:'org.reactfx', module: 'reactfx'
}
}我的问题
是什么导致了这个问题,我该如何解决呢?这是Groovy的一个bug吗?还是我的构建环境出了问题?
IDE: IntelliJ 2016.1.3
我不认为它是IDE,因为它正确地执行语法突出显示,并提供了正确的文档时,我悬停在'super‘关键字
级: 2.12级
Groovy: Groovy 2.4.6
我试过的
我尝试过更改Gradle (通过sdkman)和Groovy (通过构建文件)的版本。所有这些都没有解决问题:
2.12,2.14 2.4.5、2.4.6、2.4.7
更新
gradle build时将失败,但也会出现相同的异常。发布于 2016-06-19 00:11:19
看起来是Groovy中的一个bug。作为GROOVY-7868提交
https://stackoverflow.com/questions/37902304
复制相似问题