summaryrefslogtreecommitdiff
path: root/vala/valadatatype.vala
diff options
context:
space:
mode:
Diffstat (limited to 'vala/valadatatype.vala')
-rw-r--r--vala/valadatatype.vala18
1 files changed, 18 insertions, 0 deletions
diff --git a/vala/valadatatype.vala b/vala/valadatatype.vala
index 352885bfd..02b4cf13f 100644
--- a/vala/valadatatype.vala
+++ b/vala/valadatatype.vala
@@ -462,6 +462,24 @@ public abstract class Vala.DataType : CodeNode {
return result;
}
+ /**
+ * Search for the type parameter in this formal type and match it in
+ * value_type.
+ */
+ public virtual DataType? infer_type_argument (TypeParameter type_param, DataType value_type) {
+ var value_type_arg_it = value_type.get_type_arguments ().iterator ();
+ foreach (var formal_type_arg in this.get_type_arguments ()) {
+ if (value_type_arg_it.next ()) {
+ var inferred_type = formal_type_arg.infer_type_argument (type_param, value_type_arg_it.get ());
+ if (inferred_type != null) {
+ return inferred_type;
+ }
+ }
+ }
+
+ return null;
+ }
+
public bool is_weak () {
if (this.value_owned) {
return false;