diff options
author | Philip Herron <philip.herron@embecosm.com> | 2021-05-12 17:44:03 +0100 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2021-05-12 17:44:03 +0100 |
commit | 17258c94f8c996c26ccde103afd1c0a8a343301b (patch) | |
tree | 6873a159f54d69e673fdb9191a751705872b7656 /gcc | |
parent | decdb126e54b0c45b31ba1fa1d1c96262cafb8e0 (diff) | |
download | gcc-17258c94f8c996c26ccde103afd1c0a8a343301b.zip gcc-17258c94f8c996c26ccde103afd1c0a8a343301b.tar.gz gcc-17258c94f8c996c26ccde103afd1c0a8a343301b.tar.bz2 |
Enhance TyTy::ParamType::is_equal
ParamTypes are a strange case because we can say a type parameter T
was substituted by an i32 so if you do an is_equal for:
T:i32 vs i32
The type kinds won't match but they are equal in the actual type they
represent. The missing piece was that Type parameters can match each other
if their symbols match.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/typecheck/rust-tyty.cc | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/gcc/rust/typecheck/rust-tyty.cc b/gcc/rust/typecheck/rust-tyty.cc index cb7d17a..551042a 100644 --- a/gcc/rust/typecheck/rust-tyty.cc +++ b/gcc/rust/typecheck/rust-tyty.cc @@ -1390,10 +1390,22 @@ ParamType::resolve () const bool ParamType::is_equal (const BaseType &other) const { - if (!can_resolve ()) - return BaseType::is_equal (other); + if (get_kind () != other.get_kind ()) + { + if (!can_resolve ()) + return false; + + return resolve ()->is_equal (other); + } + + auto other2 = static_cast<const ParamType &> (other); + if (can_resolve () != other2.can_resolve ()) + return false; + + if (can_resolve ()) + return resolve ()->can_eq (other2.resolve ()); - return resolve ()->is_equal (other); + return get_symbol ().compare (other2.get_symbol ()) == 0; } ParamType * |