From: Rico Tzschichholz Date: Thu, 8 Dec 2016 12:30:10 +0000 (+0100) Subject: vala: Check inferred generic-types of MemberAccess X-Git-Tag: 0.35.2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eda719e54762a41fece37dee835f177ef338a431;p=thirdparty%2Fvala.git 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 --- diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala index 4898a5f13..1b9856c48 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 31e1839e6..dce947f91 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 0eb96a393..7431ac60b 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 000000000..47d062892 --- /dev/null +++ b/tests/methods/bug775466.test @@ -0,0 +1,9 @@ +Invalid Code + +void foo (T a) { +} + +void main () { + Value v = Value (typeof (int)); + foo (v); +}