Skip to content

Fix type inferencing and syntax highlighting for dynamic variable set within if and else blocks #1086

@eric-milles

Description

@eric-milles

Consider the following:

File findFile(boolean condition) {
  def file
  if (condition) {
    file = new File(System.getProperty('user.home'), '.groovy')
  } else {
    file = new File(System.getProperty('groovy.root'))
  }
  file.canonicalFile
}

The last occurrence of "file" is showing as unknown (underlined). Since the variable is initialized to a java.io.File in both conditional branches, the type should propagate to the outer block.

image

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions