Skip to content

Compiler error on code that compiles with groovyc #863

@mauromol

Description

@mauromol

Today I found GROOVY-9058, but I also found that the following variation compiles with groovyc but still generates an error with Greclipse:

Consider this Java class:

package test51;

import java.util.List;

public class Foo {
	public List bar() { return null; }
}

and this Groovy class:

package test51

import groovy.transform.CompileStatic

@CompileStatic
class Test51 {
	protected void foo() {
		List<Object[]> foo = new Foo().bar() // (A)
		foo.each { Object[] row -> 
			def o = row[0]  // (B)
		}
	}
	
	List bar() {
	}
}

No compiler error in (A), although, strictly speaking, it should. However groovyc does not complain either. I would assume foo to be inferred as List<Object[]>, given its declaration. Hovering the mouse pointer over row seems to confirm this and groovyc can compile this code. However, in Greclipse I get an error at (B), because row is inferred as Object even if foo is declared as List<Object[]> and row is declared as Object[].

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions