[vala] Do not consider struct creation as chain-up
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [vala] Do not consider struct creation as chain-up
- Date: Mon, 1 Feb 2010 11:21:55 +0000 (UTC)
commit 6f42cc9b284f1258698c9f64222df407457a3395
Author: Jürg Billeter <j bitron ch>
Date: Mon Feb 1 12:18:31 2010 +0100
Do not consider struct creation as chain-up
Fixes bug 608548.
vala/valamethodcall.vala | 38 +++++++++++++++++++++++++++++++-------
1 files changed, 31 insertions(+), 7 deletions(-)
---
diff --git a/vala/valamethodcall.vala b/vala/valamethodcall.vala
index 55b6bff..10bd8fa 100644
--- a/vala/valamethodcall.vala
+++ b/vala/valamethodcall.vala
@@ -106,6 +106,28 @@ public class Vala.MethodCall : Expression {
return false;
}
+ bool is_chainup () {
+ if (!(call.symbol_reference is CreationMethod)) {
+ return false;
+ }
+
+ var expr = call;
+
+ var ma = (MemberAccess) call;
+ if (ma.inner != null) {
+ expr = ma.inner;
+ }
+
+ ma = expr as MemberAccess;
+ if (ma != null && ma.member_name == "this") {
+ return true;
+ } else if (expr is BaseAccess) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
public override bool check (SemanticAnalyzer analyzer) {
if (checked) {
return !error;
@@ -186,14 +208,16 @@ public class Vala.MethodCall : Expression {
((call.symbol_reference is CreationMethod
&& call.symbol_reference.parent_symbol is Struct)
|| call.symbol_reference is Struct)) {
- var cm = analyzer.find_current_method () as CreationMethod;
- if (cm != null) {
- if (cm.chain_up) {
- error = true;
- Report.error (source_reference, "Multiple constructor calls in the same constructor are not permitted");
- return false;
+ if (is_chainup ()) {
+ var cm = analyzer.find_current_method () as CreationMethod;
+ if (cm != null) {
+ if (cm.chain_up) {
+ error = true;
+ Report.error (source_reference, "Multiple constructor calls in the same constructor are not permitted");
+ return false;
+ }
+ cm.chain_up = true;
}
- cm.chain_up = true;
}
var struct_creation_expression = new ObjectCreationExpression ((MemberAccess) call, source_reference);
struct_creation_expression.struct_creation = true;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]