mirror of
https://github.com/luau-lang/luau.git
synced 2025-05-04 10:33:46 +01:00
Follow intersection type in getMetatable helper fn
This commit is contained in:
parent
de3c7f3348
commit
8e52dc0f5c
1 changed files with 11 additions and 0 deletions
|
@ -263,6 +263,17 @@ std::optional<TypeId> getMetatable(TypeId type, NotNull<BuiltinTypes> builtinTyp
|
||||||
{
|
{
|
||||||
type = follow(type);
|
type = follow(type);
|
||||||
|
|
||||||
|
if (const IntersectionType* itv = get<IntersectionType>(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<MetatableType>(type))
|
if (const MetatableType* mtType = get<MetatableType>(type))
|
||||||
return mtType->metatable;
|
return mtType->metatable;
|
||||||
else if (const ClassType* classType = get<ClassType>(type))
|
else if (const ClassType* classType = get<ClassType>(type))
|
||||||
|
|
Loading…
Add table
Reference in a new issue