You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class Parent {
var x =1;
procrefincrement() { x +=1; }
}
class Child: Parent { }
var c =new Child();
c.increment();
writeln(c);
doesn't resolve with:
$CHPL_HOME/refIntentInherit.chpl:1: In module 'refIntentInherit':
$CHPL_HOME/refIntentInherit.chpl:9: error: unresolved call 'unmanaged Child.increment()'
$CHPL_HOME/refIntentInherit.chpl:3: note: this candidate did not match: ref Parent.increment() [319122]
$CHPL_HOME/refIntentInherit.chpl:9: note: because method call receiver with type 'unmanaged Child'
$CHPL_HOME/refIntentInherit.chpl:3: note: is passed to formal 'ref this: borrowed Parent [319124]'
$CHPL_HOME/refIntentInherit.chpl:9: note: unresolved call had id 319166
You don't literally have to modify the field to reproduce. A method that just writeln doesn't work either, as long as it has ref this intent.
The text was updated successfully, but these errors were encountered:
My initial guess is that this could be a correctness issue, for the same reason we disallow subtyping with ref arguments in general. Specifically, it's the object slicing problem.
I think Daniel's probably right, but for me this case raises a question as to whether—to support inheritance-like behavior and productivity—we should have the compiler stamp out
procref Child.increment() { super.x +=1; }
The only sticky issue I can think of is whether this causes problems if Child has a tertiary method named increment() (which we couldn't necessarily know when compiling the module it was defined in).
doesn't resolve with:
You don't literally have to modify the field to reproduce. A method that just
writeln
doesn't work either, as long as it hasref
this intent.The text was updated successfully, but these errors were encountered: