Skip to content

Wrong navigation for a delegate field inside a 'with' closure #363

@mauromol

Description

@mauromol

Consider the following:

package test

class Test {
  static class Foo {
	  String someString = 'foo'
	  String other = 'other'
  }
  
  static class Bar {
	  String someString = 'bar'
	  Foo foo = new Foo()
	  
	  void doSomething() {
		  foo.with {
			  println "someString inside with closure = $someString"
			  println "other inside with closure = $other"
		  }
	  }
  }
  
  static main(args) {
	  Bar b = new Bar()
	  println "b.someString = $b.someString"
	  println "b.foo.someString = $b.foo.someString"
	  b.doSomething()
  }
}

Run the main method. You'll see that doSomething() prints foo, i.e. the someString reference within the with closure refers to Foo.someString. However, Greclipse thinks that is Bar.someString, as you can see by all of these facilities:

  • F3 over $someString
  • Ctrl+Click over $someString
  • "mark occurences" highlighting when you select $someString

Maybe it's just a problem of "precedence" between this/owner and delegate properties, because Greclipse behaves correctly with the other property (which is defined only in Foo class).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions