[vala] Fix type checking for ref and out arguments
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Subject: [vala] Fix type checking for ref and out arguments
- Date: Sat, 6 Jun 2009 14:21:35 -0400 (EDT)
commit 3fdb77a0ee8fd3295b35ab33b49499e5806e1562
Author: Jürg Billeter <j bitron ch>
Date: Sat Jun 6 20:15:34 2009 +0200
Fix type checking for ref and out arguments
Fixes bug 570058.
---
vala/valasemanticanalyzer.vala | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/vala/valasemanticanalyzer.vala b/vala/valasemanticanalyzer.vala
index cf3c1e6..755b0ae 100644
--- a/vala/valasemanticanalyzer.vala
+++ b/vala/valasemanticanalyzer.vala
@@ -386,10 +386,17 @@ 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 && !arg.value_type.compatible (arg.target_type)
- && !(arg is NullLiteral && direction == ParameterDirection.OUT)) {
+ } 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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]