Groovy web console

subscribe to the feed Subscribe
to this
site

Possible @Delegate bug?

Published 3 months ago by Felix Scheinst
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
import groovy.transform.CompileStatic

class Base {
  Map<Integer, Integer> getMap() {
    [:]
  }
}

class Impl extends Base {
  Map<String, String> map = [:]
}

class Delegating {
  @Delegate
  Impl sub = new Impl()
}

@CompileStatic
class CompileStaticTest {

  void func(Map<String, String> dummy) {}

  def main() {
    // Expecting ew Delegating().map to be Map<String, String>
    // CompileStatic complains that func canot be called with Map<Integer, Integer>
    func(new Delegating().map)
  }
}