diff options
author | Jürg Billeter <j@bitron.ch> | 2010-02-01 12:18:31 +0100 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2010-02-01 12:18:31 +0100 |
commit | 6f42cc9b284f1258698c9f64222df407457a3395 (patch) | |
tree | 2e6c952d28172ec9df0643d0634c4e66ce000db9 /vala | |
parent | 62390c74df590c0f20033e987ef015d8362ed148 (diff) | |
download | vala-6f42cc9b284f1258698c9f64222df407457a3395.tar.gz |
Do not consider struct creation as chain-up
Fixes bug 608548.
Diffstat (limited to 'vala')
-rw-r--r-- | vala/valamethodcall.vala | 38 |
1 files changed, 31 insertions, 7 deletions
diff --git a/vala/valamethodcall.vala b/vala/valamethodcall.vala index 55b6bff86..10bd8fae1 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; |