From 1a8f93c02a68d7b3968916c14155a391871d6340 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Tue, 9 Apr 2019 00:40:21 -0400 Subject: Fixed a host-related type-checking bug in the old compiler. --- luxc/src/lux/type/host.clj | 44 ++++++++++++++++++-------------------------- 1 file changed, 18 insertions(+), 26 deletions(-) diff --git a/luxc/src/lux/type/host.clj b/luxc/src/lux/type/host.clj index 3b9017d6d..038111c84 100644 --- a/luxc/src/lux/type/host.clj +++ b/luxc/src/lux/type/host.clj @@ -74,36 +74,28 @@ ;; [Utils] (defn ^:private trace-lineage* [^Class super-class ^Class sub-class] "(-> Class Class (List Class))" - ;; Either they're both interfaces, of they're both classes + ;; Either they're both interfaces, or they're both classes (let [valid-sub? #(if (or (= super-class %) (.isAssignableFrom super-class %)) % nil)] - (cond (.isInterface sub-class) - (loop [sub-class sub-class - stack (&/|list)] - (let [super-interface (some valid-sub? (.getInterfaces sub-class))] - (if (= super-class super-interface) - (&/$Cons super-interface stack) - (recur super-interface (&/$Cons super-interface stack))))) - - (.isInterface super-class) - (loop [sub-class sub-class - stack (&/|list)] - (if-let [super-interface (some valid-sub? (.getInterfaces sub-class))] - (if (= super-class super-interface) - (&/$Cons super-interface stack) - (recur super-interface (&/$Cons super-interface stack))) - (let [super* (.getSuperclass sub-class)] - (recur super* (&/$Cons super* stack))))) - - :else - (loop [sub-class sub-class - stack (&/|list)] - (let [super* (.getSuperclass sub-class)] - (if (= super* super-class) - (&/$Cons super* stack) - (recur super* (&/$Cons super* stack)))))))) + (if (or (.isInterface sub-class) + (.isInterface super-class)) + (loop [sub-class sub-class + stack (&/|list)] + (if-let [super-interface (some valid-sub? (.getInterfaces sub-class))] + (if (= super-class super-interface) + (&/$Cons super-interface stack) + (recur super-interface (&/$Cons super-interface stack))) + (if-let [super* (.getSuperclass sub-class)] + (recur super* (&/$Cons super* stack)) + stack))) + (loop [sub-class sub-class + stack (&/|list)] + (let [super* (.getSuperclass sub-class)] + (if (= super* super-class) + (&/$Cons super* stack) + (recur super* (&/$Cons super* stack)))))))) (defn ^:private trace-lineage [^Class sub-class ^Class super-class] "(-> Class Class (List Class))" -- cgit v1.2.3