New Issue: Can't forward const methods directly

20795, "lydia-duncan", "Can't forward const methods directly", "2022-10-07T21:29:03Z"

Summary of Problem

Forwarding const methods does not work. Trying to do so generates the message:

foo.chpl:11: In function 'main':
foo.chpl:13: error: unresolved call 'Foo.whatever()'
foo.chpl:6: note: this candidate did not match: Bar.const whatever()
foo.chpl:13: note: because method call receiver with type 'Foo'
foo.chpl:6: note: is passed to formal 'const this: borrowed Bar'

Defining an overriding method on the outer type only works if you exclude the inner
type's method when forwarding, but it does work then. Still, it seems like const
methods should get brought in in such a way that they work.

Steps to Reproduce

Source Code:

record Foo {
  forwarding var b: shared Bar?;
}

class Bar {
  proc const whatever() {
    return 16;
  }
}

proc main() {
  var f = new Foo();
  writeln(f.whatever());
}

Compile command:
chpl foo.chpl

Execution command:
N/A

Associated Future Test(s):
test/classes/forwarding/constMethodBug.chpl #TBD

Configuration Information

  • Output of chpl --version: 1.29.0 pre-release
  • Output of $CHPL_HOME/util/printchplenv --anonymize: N/A
  • Back-end compiler and version, e.g. gcc --version or clang --version: N/A
  • (For Cray systems only) Output of module list: N/A