Update TyTy::can_eq interface for pointers and references

It is valid for pointers and references to unify against inference
variables.
This commit is contained in:
Philip Herron 2022-08-03 12:32:33 +01:00
parent 405d9f1d13
commit da31b651da
1 changed files with 100 additions and 6 deletions

View File

@ -36,12 +36,7 @@ public:
if (other->get_kind () == TypeKind::PARAM)
{
const ParamType *p = static_cast<const ParamType *> (other);
if (p->can_resolve ())
{
const BaseType *resolved = p->resolve ();
resolved->accept_vis (*this);
return ok;
}
other = p->resolve ();
}
if (other->get_kind () == TypeKind::PLACEHOLDER)
{
@ -861,6 +856,17 @@ public:
: BaseCmp (base, emit_errors), base (base)
{}
void visit (const InferType &type) override
{
if (type.get_infer_kind () != InferType::InferTypeKind::GENERAL)
{
BaseCmp::visit (type);
return;
}
ok = true;
}
private:
const BaseType *get_base () const override { return base; }
const ClosureType *base;
@ -889,6 +895,17 @@ public:
ok = true;
}
void visit (const InferType &type) override
{
if (type.get_infer_kind () != InferType::InferTypeKind::GENERAL)
{
BaseCmp::visit (type);
return;
}
ok = true;
}
private:
const BaseType *get_base () const override { return base; }
const ArrayType *base;
@ -917,6 +934,17 @@ public:
ok = true;
}
void visit (const InferType &type) override
{
if (type.get_infer_kind () != InferType::InferTypeKind::GENERAL)
{
BaseCmp::visit (type);
return;
}
ok = true;
}
private:
const BaseType *get_base () const override { return base; }
const SliceType *base;
@ -1074,6 +1102,17 @@ public:
ok = true;
}
void visit (const InferType &type) override
{
if (type.get_infer_kind () != InferType::InferTypeKind::GENERAL)
{
BaseCmp::visit (type);
return;
}
ok = true;
}
private:
const BaseType *get_base () const override { return base; }
const ADTType *base;
@ -1111,6 +1150,17 @@ public:
ok = true;
}
void visit (const InferType &type) override
{
if (type.get_infer_kind () != InferType::InferTypeKind::GENERAL)
{
BaseCmp::visit (type);
return;
}
ok = true;
}
private:
const BaseType *get_base () const override { return base; }
const TupleType *base;
@ -1209,6 +1259,17 @@ public:
ok = true;
}
void visit (const InferType &type) override
{
if (type.get_infer_kind () != InferType::InferTypeKind::GENERAL)
{
BaseCmp::visit (type);
return;
}
ok = true;
}
private:
const BaseType *get_base () const override { return base; }
const ReferenceType *base;
@ -1246,6 +1307,17 @@ public:
ok = true;
}
void visit (const InferType &type) override
{
if (type.get_infer_kind () != InferType::InferTypeKind::GENERAL)
{
BaseCmp::visit (type);
return;
}
ok = true;
}
private:
const BaseType *get_base () const override { return base; }
const PointerType *base;
@ -1344,6 +1416,17 @@ public:
void visit (const StrType &type) override { ok = true; }
void visit (const InferType &type) override
{
if (type.get_infer_kind () != InferType::InferTypeKind::GENERAL)
{
BaseCmp::visit (type);
return;
}
ok = true;
}
private:
const BaseType *get_base () const override { return base; }
const StrType *base;
@ -1360,6 +1443,17 @@ public:
void visit (const NeverType &type) override { ok = true; }
void visit (const InferType &type) override
{
if (type.get_infer_kind () != InferType::InferTypeKind::GENERAL)
{
BaseCmp::visit (type);
return;
}
ok = true;
}
private:
const BaseType *get_base () const override { return base; }
const NeverType *base;