Skip to content

Outer references proposed before self references in Code Assist within 'with' closure #787

@mauromol

Description

@mauromol

Follow up of #364. Related to the discussion made on #674.

Consider this Groovy class:

package test45

class Test45 {
  static class Foo {
	  String someString = 'foo'
  }
  
  static class Bar {
	  String someString = 'bar'
	  Foo foo = new Foo()
	  
	  void doSomething() {
		  foo.with {
			  println "someString inside with closure = $someString"
			  println "someString of owner inside with closure = $owner.someString"
			  someS|
		  }
	  }
  }
  
  static main(args) {
	  Bar b = new Bar()
	  println "b.someString = $b.someString"
	  println "b.foo.someString = $b.foo.someString"
	  b.doSomething()
  }
}

Invoke code assist at "|": I would expect to see Foo.someString proposed before Bar.someString, because in this context (closure with delegation to self) it is reasonably the most natural choice.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions