From 1dd608294a378cbf56ca845794ed03bf2604e1c5 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Mon, 14 Jun 2021 23:42:40 -0700 Subject: [PATCH] 13.2 Inheriting Methods --- src/com/craftinginterpreters/lox/LoxClass.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/com/craftinginterpreters/lox/LoxClass.java b/src/com/craftinginterpreters/lox/LoxClass.java index c9261b9..5d1c136 100644 --- a/src/com/craftinginterpreters/lox/LoxClass.java +++ b/src/com/craftinginterpreters/lox/LoxClass.java @@ -19,6 +19,10 @@ class LoxClass implements LoxCallable { return methods.get(name); } + if (superclass != null) { + return superclass.findMethod(name); + } + return null; } @@ -37,6 +41,7 @@ class LoxClass implements LoxCallable { return instance; } + @Override public int arity() { LoxFunction initializer = findMethod("init");