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

16852, “lydia-duncan”, “How should inheritance interact with listing a type in a use/import limitation clause?”, “2020-12-10T23:41:10Z”

This is an edge case of #16710

Say we have a module structure as follows, where a parent type and a child type are defined in one module, and a method on the parent type is defined in another module:

module definesClass {
  class Parent {
    var a: int;
  }

  class Child: Parent {
    var b: int;
  }
}

module definesTertiary {
  use definesClass;

  proc Parent.tertiaryMethod() {
    writeln("In inherited tertiary method");
  }
}

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

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

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

var x = new owned Child(2, 3);
x.tertiaryMethod(); // Should this resolve?

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

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

var x = new owned Child(2, 3);
x.tertiaryMethod(); // Should this resolve?

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

use definesClass;
use definesTertiary only Parent; // Should this bring in tertiaryMethod for instances of Child?

var x = new owned Child(2, 3);
x.tertiaryMethod(); // Should this resolve?

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

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

var x = new owned Child(2, 3);
x.tertiaryMethod(); // Should this resolve?

This scenarios interplay in interesting ways in my mind. I can see arguing for both sides on each of the cases, and find myself a bit inconsistent in the reasoning since the method simultaneously is only defined on Parent but impacts both Parent and Child’s behavior.