[vala] GObject: Check arguments of Object constructor chain up
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [vala] GObject: Check arguments of Object constructor chain up
- Date: Wed, 21 Oct 2009 21:19:42 +0000 (UTC)
commit 505ac59834b818a89d44c56b3560924ba2afe0e7
Author: Jürg Billeter <j bitron ch>
Date: Wed Oct 21 23:17:54 2009 +0200
GObject: Check arguments of Object constructor chain up
codegen/valagobjectmodule.vala | 25 +++++++++++++++++++++++++
1 files changed, 25 insertions(+), 0 deletions(-)
---
diff --git a/codegen/valagobjectmodule.vala b/codegen/valagobjectmodule.vala
index cc1e7bf..462c38a 100644
--- a/codegen/valagobjectmodule.vala
+++ b/codegen/valagobjectmodule.vala
@@ -711,5 +711,30 @@ internal class Vala.GObjectModule : GTypeModule {
return true;
}
+
+ public override void visit_method_call (MethodCall expr) {
+ if (expr.call is MemberAccess && expr.call.symbol_reference == gobject_type) {
+ // Object (...) chain up
+ // check it's only used with valid properties
+ foreach (var arg in expr.get_argument_list ()) {
+ var named_argument = arg as NamedArgument;
+ if (named_argument == null) {
+ Report.error (arg.source_reference, "Named argument expected");
+ break;
+ }
+ var prop = SemanticAnalyzer.symbol_lookup_inherited (current_class, named_argument.name) as Property;
+ if (prop == null) {
+ Report.error (arg.source_reference, "Property `%s' not found in `%s'".printf (named_argument.name, current_class.get_full_name ()));
+ break;
+ }
+ if (!arg.value_type.compatible (prop.property_type)) {
+ Report.error (arg.source_reference, "Cannot convert from `%s' to `%s'".printf (arg.value_type.to_string (), prop.property_type.to_string ()));
+ break;
+ }
+ }
+ }
+
+ base.visit_method_call (expr);
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]