[vala] Check type arguments recursively
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] Check type arguments recursively
- Date: Sat, 25 Jun 2016 13:57:11 +0000 (UTC)
commit 3850736455f02ed3ecc5fb3e10dba171f78be1f5
Author: Matthias Berndt <matthias_berndt gmx de>
Date: Mon May 16 12:21:06 2016 +0200
Check type arguments recursively
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 | 1 +
tests/objects/bug767092.test | 8 ++++++++
vala/valaobjecttype.vala | 6 ++++++
3 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 1666826..3d264a6 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -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
index 0000000..a063a4d
--- /dev/null
+++ b/tests/objects/bug767092.test
@@ -0,0 +1,8 @@
+Invalid Code
+
+class Foo<T> {
+}
+
+void main(string[] args) {
+ Foo<Foo<string, string>> foo = null;
+}
diff --git a/vala/valaobjecttype.vala b/vala/valaobjecttype.vala
index 7019719..eccdbbd 100644
--- a/vala/valaobjecttype.vala
+++ b/vala/valaobjecttype.vala
@@ -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;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]