New Issue: How should forwarding interact with listing a type in a use/import limitation clause?

16858, “lydia-duncan”, “How should forwarding interact with listing a type in a use/import limitation clause?”, “2020-12-11T21:18:45Z”

This is similar to #16852. Note that due to the implementation of owned and shared, there are likely choices that must be made to allow them to work as implemented.

Say we have a module structure as follows, where a type is defined that contains a forwarded field of another type in one module, and a tertiary method on the forwarded field type is defined in another module:

module definesType {
  record Container {
    forwarding var x: OtherType;
  }
  record OtherType {
     var foo: int;
  }
}
module definesTertiary {
  use definesType;

  proc OtherType.tertiaryMethod() {
    writeln("In forwarded tertiary method");
  }
}

Under what use and import scenarios should tertiaryMethod be available to instances of Container?

Case 1a:
Should listing the Container type in an only list or import list on the module enable it to be found? E.g.

use definesType;
use definesTertiary only Container; // Should this bring in tertiaryMethod for instances of Container?

var x = new Container(new OtherType(2));
x.tertiaryMethod(); // Should this resolve?

Case 1b:
Should listing the Container type in an except list on the module prevent it from being found? E.g.

use definesClass;
use definesTertiary except Container; // Should this prevent calls to tertiaryMethod for instances of Container?

var x = new Container(new OtherType(2));
x.tertiaryMethod(); // Should this resolve?

Case 2a:
Should listing the OtherType type in an only list or import list on the module enable it to be found? E.g.

use definesClass;
use definesTertiary only OtherType; // Should this bring in tertiaryMethod for instances of Container?

var x = new Container(new OtherType(2));
x.tertiaryMethod(); // Should this resolve?

Case 2b:
Should listing the OtherType type in an except list on the module prevent it from being found? E.g.

use definesClass;
use definesTertiary except OtherType; // Should this prevent calls to tertiaryMethod for instances of Container?

var x = new Container(new OtherType(2));
x.tertiaryMethod(); // Should this resolve?

Based on discussion in the inheritance thread, my guess is that the result will similarly be 1a no 1b yes 2a yes 2b no.