[vala] Warn about mismatched parameter direction before mismatched type
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] Warn about mismatched parameter direction before mismatched type
- Date: Thu, 13 Oct 2016 14:27:27 +0000 (UTC)
commit 4bed25c2fe2a081537cb17f62a965ffa55937115
Author: Sam Thursfield <ssssam gmail com>
Date: Wed Nov 30 17:26:00 2011 +0100
Warn about mismatched parameter direction before mismatched type
https://bugzilla.gnome.org/show_bug.cgi?id=664049
vala/valasemanticanalyzer.vala | 25 ++++++++++++++-----------
1 files changed, 14 insertions(+), 11 deletions(-)
---
diff --git a/vala/valasemanticanalyzer.vala b/vala/valasemanticanalyzer.vala
index ef023e1..f3b1a63 100644
--- a/vala/valasemanticanalyzer.vala
+++ b/vala/valasemanticanalyzer.vala
@@ -483,17 +483,6 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
Report.error (arg.source_reference, "Invalid type for argument %d".printf (i
+ 1));
return false;
}
- } else if (arg.target_type != null
- && (direction == ParameterDirection.IN || direction == ParameterDirection.REF)
- && !arg.value_type.compatible (arg.target_type)) {
- Report.error (arg.source_reference, "Argument %d: Cannot convert from `%s' to
`%s'".printf (i + 1, arg.value_type.to_string (), arg.target_type.to_string ()));
- return false;
- } else if (arg.target_type != null
- && (direction == ParameterDirection.REF || direction == ParameterDirection.OUT)
- && !arg.target_type.compatible (arg.value_type)
- && !(arg is NullLiteral)) {
- Report.error (arg.source_reference, "Argument %d: Cannot convert from `%s' to
`%s'".printf (i + 1, arg.target_type.to_string (), arg.value_type.to_string ()));
- return false;
} else {
// 0 => null, 1 => in, 2 => ref, 3 => out
int arg_type = 1;
@@ -559,6 +548,20 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
}
}
}
+
+ if (arg.target_type != null) {
+ if ((direction == ParameterDirection.IN || direction == ParameterDirection.REF)
+ && !arg.value_type.compatible (arg.target_type)) {
+ Report.error (arg.source_reference, "Argument %d: Cannot convert from `%s' to
`%s'".printf (i + 1, arg.value_type.to_string (), arg.target_type.to_string ()));
+ return false;
+ } else if ((direction == ParameterDirection.REF || direction ==
ParameterDirection.OUT)
+ && !arg.target_type.compatible (arg.value_type)
+ && !(arg is NullLiteral)) {
+ Report.error (arg.source_reference, "Argument %d: Cannot convert from `%s' to
`%s'".printf (i + 1, arg.target_type.to_string (), arg.value_type.to_string ()));
+ return false;
+ }
+ }
+
var ma = arg as MemberAccess;
if (ma != null && ma.prototype_access) {
// allow prototype access if target type is delegate without target
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]