aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2021-09-17 17:51:23 +0100
committerPhilip Herron <philip.herron@embecosm.com>2021-09-17 17:51:23 +0100
commita6e15ff5f052801180b3e56c4579ea555f2f0c50 (patch)
tree4d4b57f71b4af940056a979b213f44167a820ddd
parentc674e168ebc29c061a8a936e064c2e3d556ab326 (diff)
downloadgcc-a6e15ff5f052801180b3e56c4579ea555f2f0c50.zip
gcc-a6e15ff5f052801180b3e56c4579ea555f2f0c50.tar.gz
gcc-a6e15ff5f052801180b3e56c4579ea555f2f0c50.tar.bz2
Add method resolution to Dynamic objects
Support method resolution via probe of the type bound on the dynamic objects. This acts the same way as when we probe for methods like this: ```rust trait Foo { fn bar(&self); } fn test<T: Foo>(a:T) { a.bar(); } ``` Addresses: #197
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-expr.h11
1 files changed, 7 insertions, 4 deletions
diff --git a/gcc/rust/typecheck/rust-hir-type-check-expr.h b/gcc/rust/typecheck/rust-hir-type-check-expr.h
index 07d4f90..fe8973a 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-expr.h
+++ b/gcc/rust/typecheck/rust-hir-type-check-expr.h
@@ -227,10 +227,13 @@ public:
// which is simple. There will need to be adjustments to ensure we can turn
// the receiver into borrowed references etc
- bool reciever_is_generic = root->get_kind () == TyTy::TypeKind::PARAM;
+ bool receiver_is_type_param = root->get_kind () == TyTy::TypeKind::PARAM;
+ bool receiver_is_dyn = root->get_kind () == TyTy::TypeKind::DYNAMIC;
+
+ bool receiver_is_generic = receiver_is_type_param || receiver_is_dyn;
bool probe_bounds = true;
- bool probe_impls = !reciever_is_generic;
- bool ignore_mandatory_trait_items = !reciever_is_generic;
+ bool probe_impls = !receiver_is_generic;
+ bool ignore_mandatory_trait_items = !receiver_is_generic;
auto candidates
= PathProbeType::Probe (root, expr.get_method_name ().get_segment (),
@@ -345,7 +348,7 @@ public:
}
}
- if (!reciever_is_generic)
+ if (!receiver_is_type_param)
{
// apply any remaining generic arguments
if (expr.get_method_name ().has_generic_args ())