]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Check type arguments in DataType.equals
authorMatthias Berndt <matthias_berndt@gmx.de>
Fri, 30 Sep 2016 08:36:14 +0000 (10:36 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Thu, 6 Oct 2016 07:34:06 +0000 (09:34 +0200)
https://bugzilla.gnome.org/show_bug.cgi?id=641418

tests/Makefile.am
tests/objects/bug641418-1.test [new file with mode: 0644]
tests/objects/bug641418-2.test [new file with mode: 0644]
tests/objects/bug641418-3.test [new file with mode: 0644]
vala/valadatatype.vala

index 7f46a2b0b47e5acf113b9b3ebfc5e75a3c3a75f1..8fcf079f3a5d9a1e27ed73845c3069d40f14d777 100644 (file)
@@ -158,6 +158,9 @@ TESTS = \
        objects/bug626038.vala \
        objects/bug628639.vala \
        objects/bug634782.vala \
+       objects/bug641418-1.test \
+       objects/bug641418-2.test \
+       objects/bug641418-3.test \
        objects/bug642809.vala \
        objects/bug643711.vala \
        objects/bug646362.vala \
diff --git a/tests/objects/bug641418-1.test b/tests/objects/bug641418-1.test
new file mode 100644 (file)
index 0000000..5d0e8f6
--- /dev/null
@@ -0,0 +1,11 @@
+Invalid Code
+
+interface Foo {
+       public abstract GenericArray<string> baz ();
+}
+
+class Bar : Object, Foo {
+       public GenericArray<int> baz () {
+               return null;
+       }
+}
diff --git a/tests/objects/bug641418-2.test b/tests/objects/bug641418-2.test
new file mode 100644 (file)
index 0000000..0488b8a
--- /dev/null
@@ -0,0 +1,16 @@
+Invalid Code
+
+class Foo<K,V> {
+}
+
+class Bar {
+       public virtual Foo<K,V> f<K,V> () {
+               return null;
+       }
+}
+
+class Baz : Bar {
+       public override Foo<A,B> f<B,A> () {
+               return null;
+       }
+}
diff --git a/tests/objects/bug641418-3.test b/tests/objects/bug641418-3.test
new file mode 100644 (file)
index 0000000..3966df2
--- /dev/null
@@ -0,0 +1,16 @@
+Invalid Code
+
+class Foo<A,B> {
+}
+
+class Bar<A> {
+       public virtual Foo<A,B> f<B> () {
+               return f ();
+       }
+}
+
+class Baz<A> : Bar<A> {
+       public override Foo<B,A> f<B> () {
+               return f ();
+       }
+}
index 5fe8c7b7928e7204405049c43a6a4fe7d16c42d6..f3f9bf92a4fea649d8628a93cae7d23c792cbe01 100644 (file)
@@ -208,6 +208,17 @@ public abstract class Vala.DataType : CodeNode {
                if (type2.floating_reference != floating_reference) {
                        return false;
                }
+
+               var type_args = get_type_arguments ();
+               var type2_args = type2.get_type_arguments ();
+               if (type2_args.size != type_args.size) {
+                       return false;
+               }
+
+               for (int i = 0; i < type_args.size; i++) {
+                       if (!type2_args[i].equals (type_args[i]))
+                               return false;
+               }
        
                return true;
        }