This fixes class with multiple interfaces which require implementations of
methods with conflicting naming while the explicit interface-type reference
is not present yet.
Extend the present test-case for runtime checking. This will still silently
connect matching base-class methods as before as introduced in
e1a3ff9470763e7c6ff5a887036390bd418f4e46
Fixes https://gitlab.gnome.org/GNOME/vala/issues/548
objects/gsource.vala \
objects/interface_only.vala \
objects/interfaces.vala \
+ objects/interface-generics.vala \
objects/methods.vala \
objects/paramspec.vala \
objects/properties.vala \
semantic/class-compact-property-baseaccess.test \
semantic/class-missing-implement-interface-method.test \
semantic/class-missing-implement-interface-property.test \
+ semantic/class-missing-implement-interfaces-methods.test \
+ semantic/class-missing-implement-interfaces-methods3.test \
semantic/class-missing-implement-method.test \
semantic/class-missing-implement-property.test \
semantic/class-missing-prerequisites.test \
}
class Base : Object {
- public void foo () {
+ public int foo () {
+ return 42;
}
}
interface Iface : Object {
- public abstract void foo ();
+ public abstract int foo ();
}
class Concrete : Base, Iface {
assert (iface1.foo () == 1);
assert (iface2.foo () == 2);
-}
\ No newline at end of file
+
+ var concrete = new Concrete ();
+ assert (((Iface) concrete).foo () == 42);
+}
--- /dev/null
+interface IFoo<G> : Object {
+ public abstract G get ();
+}
+
+class Foo<G> : Object, IFoo<G> {
+ public new G get () {
+ return null;
+ }
+}
+
+void main() {
+}
--- /dev/null
+Invalid Code
+
+interface IFoo : Object {
+ public abstract string foo ();
+}
+
+interface IBar : Object {
+ public abstract int foo ();
+}
+
+class Manam : Object, IFoo, IBar {
+ public string foo () {
+ return "foo";
+ }
+}
+
+void main() {
+}
--- /dev/null
+Invalid Code
+
+class Base : Object {
+ public void foo () {
+ }
+}
+
+interface IFoo : Base {
+ public abstract string foo ();
+}
+
+interface IBar : Base {
+ public abstract int foo ();
+}
+
+class Manam : Base, IFoo, IBar {
+ public int IBar.foo () {
+ return 23;
+ }
+}
+
+void main () {
+}
var base_class = this;
while (base_class != null) {
foreach (var impl in base_class.get_methods ()) {
- if (impl.name == m.name && (impl.base_interface_type == null || impl.base_interface_type.data_type == iface)) {
+ if (impl.base_interface_method == m || (base_class != this
+ && impl.base_interface_method == null && impl.name == m.name
+ && (impl.base_interface_type == null || impl.base_interface_type.data_type == iface)
+ && impl.compatible_no_error (m))) {
// method is used as interface implementation, so it is not unused
impl.version.check (source_reference);
impl.used = true;