[vala/staging: 2/2] vala: Check inferred generic-types of MemberAccess



commit 1b83cab4ed0a0987651f787ba6a3c219f5aa4008
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Thu Dec 8 13:30:10 2016 +0100

    vala: Check inferred generic-types of MemberAccess
    
    https://bugzilla.gnome.org/show_bug.cgi?id=775466

 codegen/valaccodebasemodule.vala       |    7 +++++++
 codegen/valaccodemethodcallmodule.vala |    3 +++
 tests/Makefile.am                      |    1 +
 tests/methods/bug775466.test           |    9 +++++++++
 4 files changed, 20 insertions(+), 0 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 4898a5f..1b9856c 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -4427,6 +4427,13 @@ public abstract class Vala.CCodeBaseModule : CodeGenerator {
                }
        }
 
+       public void check_type_arguments (MemberAccess access) {
+               foreach (var type_arg in access.get_type_arguments ()) {
+                       check_type (type_arg);
+                       check_type_argument (type_arg);
+               }
+       }
+
        void check_type_argument (DataType type_arg) {
                if (type_arg is GenericType
                    || type_arg is PointerType
diff --git a/codegen/valaccodemethodcallmodule.vala b/codegen/valaccodemethodcallmodule.vala
index 31e1839..1db6921 100644
--- a/codegen/valaccodemethodcallmodule.vala
+++ b/codegen/valaccodemethodcallmodule.vala
@@ -43,6 +43,9 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
                
                if (itype is MethodType) {
                        assert (ma != null);
+
+                       check_type_arguments (ma);
+
                        m = ((MethodType) itype).method_symbol;
                        if (ma.inner != null && ma.inner.value_type is EnumValueType && ((EnumValueType) 
ma.inner.value_type).get_to_string_method() == m) {
                                // Enum.VALUE.to_string()
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 0eb96a3..7431ac6 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -79,6 +79,7 @@ TESTS = \
        methods/bug743877.vala \
        methods/bug771964.vala \
        methods/bug774060.vala \
+       methods/bug775466.test \
        methods/generics.vala \
        methods/printf-invalid.test \
        methods/printf-constructor.vala \
diff --git a/tests/methods/bug775466.test b/tests/methods/bug775466.test
new file mode 100644
index 0000000..47d0628
--- /dev/null
+++ b/tests/methods/bug775466.test
@@ -0,0 +1,9 @@
+Invalid Code
+
+void foo<T> (T a) {
+}
+
+void main () {
+       Value v = Value (typeof (int));
+       foo (v);
+}


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