feat: 增加函数类型表达式支持,更新解析器和分析器

This commit is contained in:
2026-03-18 17:30:09 +08:00
parent e1d9812f92
commit 570a87c3cd
10 changed files with 228 additions and 35 deletions

View File

@@ -39,10 +39,15 @@ namespace Fig
bool Type::isAssignableTo(const Type &target) const
{
if (target.is(TypeTag::Any) || this->is(TypeTag::Any))
return true; // Any 逃逸通道
{
return true; // Any 逃逸
}
if (this->is(TypeTag::Null) && target.isNullable)
{
return true; // Null 安全赋值
return this->base == target.base && (!this->isNullable || target.isNullable);
}
return *this->base == *target.base && (!this->isNullable || target.isNullable);
}
TypeContext::TypeContext()
@@ -65,7 +70,9 @@ namespace Fig
TypeContext::~TypeContext()
{
for (auto t : allTypes)
{
delete t;
}
}
Type TypeContext::GetBasic(TypeTag tag, bool nullable)