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



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

    vala: Check inferred generic-types of MemberAccess
    
    Although avoid this check for simple-generic accesses where this would be
    too strict and not wanted.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=775466

 codegen/valaccodebasemodule.vala       |    7 +++++++
 codegen/valaccodemethodcallmodule.vala |    5 +++++
 tests/Makefile.am                      |    1 +
 tests/methods/bug775466.test           |    9 +++++++++
 4 files changed, 22 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..dce947f 100644
--- a/codegen/valaccodemethodcallmodule.vala
+++ b/codegen/valaccodemethodcallmodule.vala
@@ -44,6 +44,11 @@ public class Vala.CCodeMethodCallModule : CCodeAssignmentModule {
                if (itype is MethodType) {
                        assert (ma != null);
                        m = ((MethodType) itype).method_symbol;
+
+                       if (!get_ccode_simple_generics (m)) {
+                               check_type_arguments (ma);
+                       }
+
                        if (ma.inner != null && ma.inner.value_type is EnumValueType && ((EnumValueType) 
ma.inner.value_type).get_to_string_method() == m) {
                                // Enum.VALUE.to_string()
                                var en = (Enum) ma.inner.value_type.data_type;
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]