[vala/staging: 1/3] vala: Perform arguments-check against actual .end() method-signature



commit ad0530ec6d02290d1dfe8715cb2d000edc69711d
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Wed Mar 22 14:13:26 2017 +0100

    vala: Perform arguments-check against actual .end() method-signature
    
    This results in error message referring to the actual expected signature.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=684208

 vala/valamethod.vala     |   19 +++++++++++++++++++
 vala/valamethodcall.vala |    7 +++++++
 2 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/vala/valamethod.vala b/vala/valamethod.vala
index 8789468..9988c66 100644
--- a/vala/valamethod.vala
+++ b/vala/valamethod.vala
@@ -196,6 +196,7 @@ public class Vala.Method : Subroutine, Callable {
        private bool base_methods_valid;
 
        Method? callback_method;
+       Method? end_method;
 
        // only valid for closures
        List<LocalVariable> captured_variables;
@@ -957,6 +958,24 @@ public class Vala.Method : Subroutine, Callable {
                return n;
        }
 
+       public Method get_end_method () {
+               assert (this.coroutine);
+
+               if (end_method == null) {
+                       end_method = new Method ("end", return_type, source_reference);
+                       end_method.access = SymbolAccessibility.PUBLIC;
+                       end_method.external = true;
+                       end_method.owner = scope;
+                       foreach (var param in get_async_end_parameters ()) {
+                               end_method.add_parameter (param.copy ());
+                       }
+                       foreach (var param in get_type_parameters ()) {
+                               end_method.add_type_parameter (param);
+                       }
+               }
+               return end_method;
+       }
+
        public Method get_callback_method () {
                assert (this.coroutine);
 
diff --git a/vala/valamethodcall.vala b/vala/valamethodcall.vala
index f620316..cefc651 100644
--- a/vala/valamethodcall.vala
+++ b/vala/valamethodcall.vala
@@ -573,6 +573,13 @@ public class Vala.MethodCall : Expression {
                                        value_type = formal_value_type.get_actual_type (target_object_type, 
method_type_args, this);
                                }
                        }
+                       // replace method-type if needed for proper argument-check in semantic-analyser
+                       if (m != null && m.coroutine) {
+                               var ma = (MemberAccess) call;
+                               if (ma.member_name == "end") {
+                                       mtype = new MethodType (m.get_end_method ());
+                               }
+                       }
                } else if (mtype is ObjectType) {
                        // constructor
                        var cl = (Class) ((ObjectType) mtype).type_symbol;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]