summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRico Tzschichholz <ricotz@ubuntu.com>2016-12-08 13:30:10 +0100
committerRico Tzschichholz <ricotz@ubuntu.com>2016-12-10 12:51:27 +0100
commiteda719e54762a41fece37dee835f177ef338a431 (patch)
treedace65f333f0a2e40f9a96ab48882f320b819545
parent03a2baee6383c2b14542719734ed4e3a6376b709 (diff)
downloadvala-eda719e54762a41fece37dee835f177ef338a431.tar.gz
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
-rw-r--r--codegen/valaccodebasemodule.vala7
-rw-r--r--codegen/valaccodemethodcallmodule.vala5
-rw-r--r--tests/Makefile.am1
-rw-r--r--tests/methods/bug775466.test9
4 files changed, 22 insertions, 0 deletions
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> (T a) {
+}
+
+void main () {
+ Value v = Value (typeof (int));
+ foo (v);
+}