]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Check inferred generic-types of MemberAccess
authorRico Tzschichholz <ricotz@ubuntu.com>
Thu, 8 Dec 2016 12:30:10 +0000 (13:30 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sat, 10 Dec 2016 11:51:27 +0000 (12:51 +0100)
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
codegen/valaccodemethodcallmodule.vala
tests/Makefile.am
tests/methods/bug775466.test [new file with mode: 0644]

index 4898a5f13fb12a498f8e58f832fc40eaab846bdd..1b9856c48a981bfd5a0fd6f516d72d5fe15eb6e6 100644 (file)
@@ -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
index 31e1839e67d8b427a3a5b28079c56ca30ac32cf1..dce947f9118fa310e96fbac9de4bfb378d786e83 100644 (file)
@@ -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;
index 0eb96a3933ad1a6f839fe916092f58813cfbfb21..7431ac60ba298931a01224cbf28cff0f5e8bf2fa 100644 (file)
@@ -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 (file)
index 0000000..47d0628
--- /dev/null
@@ -0,0 +1,9 @@
+Invalid Code
+
+void foo<T> (T a) {
+}
+
+void main () {
+       Value v = Value (typeof (int));
+       foo (v);
+}