From 8e52dc0f5c21765c1448dd6e2bbbaffb04ed0afe Mon Sep 17 00:00:00 2001 From: AmberGraceSoftware Date: Fri, 11 Aug 2023 19:57:19 -0600 Subject: [PATCH] Follow intersection type in getMetatable helper fn --- Analysis/src/Type.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Analysis/src/Type.cpp b/Analysis/src/Type.cpp index fb72bc12..89c0c428 100644 --- a/Analysis/src/Type.cpp +++ b/Analysis/src/Type.cpp @@ -263,6 +263,17 @@ std::optional getMetatable(TypeId type, NotNull builtinTyp { type = follow(type); + if (const IntersectionType* itv = get(type)) + { + for (TypeId part : itv->parts) + { + auto partMT = getMetatable(part, builtinTypes); + if (partMT != std::nullopt) + return partMT; + } + return std::nullopt; + } + if (const MetatableType* mtType = get(type)) return mtType->metatable; else if (const ClassType* classType = get(type))