]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Check type arguments recursively
authorMatthias Berndt <matthias_berndt@gmx.de>
Mon, 16 May 2016 10:21:06 +0000 (12:21 +0200)
committerJürg Billeter <j@bitron.ch>
Sat, 25 Jun 2016 13:53:54 +0000 (15:53 +0200)
This fixes error checking for code like this:

class Foo<T> {}
void main(string[] args) {
  Foo<Foo<string, string>> foo = null;
}

Fixes bug 767092.

tests/Makefile.am
tests/objects/bug767092.test [new file with mode: 0644]
vala/valaobjecttype.vala

index 1666826cb2e1a144e4dba8fb74cb7ecd0d3d0596..3d264a65b557e3024647e580809a3addcc596a3b 100644 (file)
@@ -165,6 +165,7 @@ TESTS = \
        objects/bug702736.vala \
        objects/bug702846.vala \
        objects/bug751338.vala \
+       objects/bug767092.test \
        errors/errors.vala \
        errors/bug567181.vala \
        errors/bug579101.vala \
diff --git a/tests/objects/bug767092.test b/tests/objects/bug767092.test
new file mode 100644 (file)
index 0000000..a063a4d
--- /dev/null
@@ -0,0 +1,8 @@
+Invalid Code
+
+class Foo<T> {
+}
+
+void main(string[] args) {
+       Foo<Foo<string, string>> foo = null;
+}
index 7019719b37743da13e3e2695b5e7c70e05735718..eccdbbddf14360885fd8b2d3fbe3632dcda8e119 100644 (file)
@@ -109,6 +109,12 @@ public class Vala.ObjectType : ReferenceType {
                        return false;
                }
 
+               foreach (DataType type in get_type_arguments ()) {
+                       if (!type.check (context)) {
+                               return false;
+                       }
+               }
+
                return true;
        }
 }