Skip to content

Type inference problem on sort { }.each { } #387

@mauromol

Description

@mauromol

This seems to be some sort of regression, because it was fixed with GRECLIPSE-1695.

Consider the following Groovy class:

package test10

class Bar {
	void bar() {
		List<String> myList = new ArrayList<String>()
		myList.each {  
			it.trim() // it detected as String correctly here
		}
		myList.sort {  a, b ->
			a.trim() <=> b.trim() // a and b detected as String correctly here
		}

		myList.sort {  a, b ->
			a.trim() <=> b.trim() // a and b detected as String correctly here
		}.each {   
			it.trim() // it not detected as String here!
		}
	}
}

As you can see, the last it.trim() is underlined because it is not recognized as String. Probably this is because the call to myList.sort { } is wrongly recognized as a call to Java 8 java.util.List.sort(Comparator<? super E>), which returns void.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions