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
This seems to be a more general problem, because the following program
#lang rhombus
class Secret(secret):
nonfinal
constructor ():
super("not secret")
class TopSecret():
extends Secret
doesn’t trigger any static error, either. Actually, this is a documented behavior (keeping in mind that private fields are not visible to subclasses):
If a superclass has a custom constructor, the default constructor of a subclass assumes that the superclass constructor accepts the same argument as the default superclass constructor.
However, I think a best-effort static error can still help a lot in such cases.
usaoc
changed the title
Requirement for custom constructor should propagate to subclasses
Improve static error for incorrect arities of subclass constructors
May 7, 2024
Classes with private immutable fields are currently required to have custom constructors. For example,
this triggers “class needs a custom constructor to initialize private immutable fields”, while
this works. However, this requirement doesn’t seem to properly propagate. For example,
this does not trigger “class needs a custom constructor to initialize private immutable fields”, but it simply cannot work.
The text was updated successfully, but these errors were encountered: