Commit 2bf3d979 authored by Matthias Berndt's avatar Matthias Berndt Committed by Rico Tzschichholz

vala: Check type arguments in DataType.equals

https://bugzilla.gnome.org/show_bug.cgi?id=641418
parent 566ff81b
......@@ -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 \
......
Invalid Code
interface Foo {
public abstract GenericArray<string> baz ();
}
class Bar : Object, Foo {
public GenericArray<int> baz () {
return null;
}
}
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;
}
}
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 ();
}
}
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment