13.2 Inheriting Methods

This commit is contained in:
Tom Willemse 2021-06-14 23:42:40 -07:00
parent db403da4b2
commit 1dd608294a

View file

@ -19,6 +19,10 @@ class LoxClass implements LoxCallable {
return methods.get(name); return methods.get(name);
} }
if (superclass != null) {
return superclass.findMethod(name);
}
return null; return null;
} }
@ -37,6 +41,7 @@ class LoxClass implements LoxCallable {
return instance; return instance;
} }
@Override @Override
public int arity() { public int arity() {
LoxFunction initializer = findMethod("init"); LoxFunction initializer = findMethod("init");