summaryrefslogtreecommitdiff
path: root/vala/valasemanticanalyzer.vala
diff options
context:
space:
mode:
authorRico Tzschichholz <ricotz@ubuntu.com>2017-12-09 00:19:06 +0100
committerRico Tzschichholz <ricotz@ubuntu.com>2017-12-09 00:36:59 +0100
commitd7faafd980b8413041c5dc5a5ca29367f1b2a946 (patch)
treec536199631e5cb72e10a0d2c96a6306f81c58ca3 /vala/valasemanticanalyzer.vala
parent2741f1ad5130977a0c8b0b517476bfcd9eec6f0d (diff)
downloadvala-d7faafd980b8413041c5dc5a5ca29367f1b2a946.tar.gz
Improve error message for missing type-parameter on enclosing type
https://bugzilla.gnome.org/show_bug.cgi?id=587905
Diffstat (limited to 'vala/valasemanticanalyzer.vala')
-rw-r--r--vala/valasemanticanalyzer.vala25
1 files changed, 24 insertions, 1 deletions
diff --git a/vala/valasemanticanalyzer.vala b/vala/valasemanticanalyzer.vala
index f4d86d0df..122f411a3 100644
--- a/vala/valasemanticanalyzer.vala
+++ b/vala/valasemanticanalyzer.vala
@@ -379,6 +379,28 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
return type;
}
+ public static Symbol? get_symbol_for_data_type (DataType type) {
+ Symbol? sym = null;
+
+ if (type is ObjectType) {
+ sym = ((ObjectType) type).type_symbol;
+ } else if (type is ClassType) {
+ sym = ((ClassType) type).class_symbol;
+ } else if (type is InterfaceType) {
+ sym = ((InterfaceType) type).interface_symbol;
+ } else if (type is MethodType) {
+ sym = ((MethodType) type).method_symbol;
+ } else if (type is SignalType) {
+ sym = ((SignalType) type).signal_symbol;
+ } else if (type is DelegateType) {
+ sym = ((DelegateType) type).delegate_symbol;
+ } else if (type is ValueType) {
+ sym = ((ValueType) type).type_symbol;
+ }
+
+ return sym;
+ }
+
public bool check_arguments (Expression expr, DataType mtype, List<Parameter> params, List<Expression> args) {
Expression prev_arg = null;
Iterator<Expression> arg_it = args.iterator ();
@@ -823,7 +845,8 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
var instance_type = get_instance_base_type_for_member (derived_instance_type, (TypeSymbol) generic_type.type_parameter.parent_symbol, node_reference);
if (instance_type == null) {
- Report.error (node_reference.source_reference, "The type-parameter `%s' must be defined on enclosing type".printf (generic_type.to_string ()));
+ CodeNode? reference = get_symbol_for_data_type (derived_instance_type);
+ Report.error ((reference ?? node_reference).source_reference, "The type-parameter `%s' is missing".printf (generic_type.to_string ()));
node_reference.error = true;
return new InvalidType ();
}