[vala/staging: 2/12] Improve error message for missing type-parameter on enclosing type
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging: 2/12] Improve error message for missing type-parameter on enclosing type
- Date: Fri, 8 Dec 2017 23:38:12 +0000 (UTC)
commit d7faafd980b8413041c5dc5a5ca29367f1b2a946
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Sat Dec 9 00:19:06 2017 +0100
Improve error message for missing type-parameter on enclosing type
https://bugzilla.gnome.org/show_bug.cgi?id=587905
vala/valasemanticanalyzer.vala | 25 ++++++++++++++++++++++++-
1 files changed, 24 insertions(+), 1 deletions(-)
---
diff --git a/vala/valasemanticanalyzer.vala b/vala/valasemanticanalyzer.vala
index f4d86d0..122f411 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 ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]