[Issue 1978] Wrong vtable call
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Apr 8 03:18:02 PDT 2008
http://d.puremagic.com/issues/show_bug.cgi?id=1978
------- Comment #1 from benoit at tionex.de 2008-04-08 05:18 -------
I reduced it more...
Now the example prints:
remove
ready
It does not block, but remove() is called without call.
extern(C) int printf(char*,...);
public interface View(T){
// changing duplicate return type to View!(T) make it work
public Dispenser!(T) duplicate ();
public uint mutation ();
}
public interface Dispenser(T) : View!(T){
public void removeAll (Iterator!(T) e);
public void remove (Iterator!(T) e);
public void removeAll (T element);
public void remove (T element);
}
public interface Seq(T) :
View!(T), // removing View!(T) interface make it work.
Dispenser!(T)
{
}
public interface Iterator(V) {
int opApply (int delegate (inout V value) dg);
}
public abstract class AbstractIterator(T) : Iterator!(T) {
protected this (View!(T) v) {
v.mutation();
}
}
class ArrayIterator(T) : AbstractIterator!(T) {
public this (ArraySeq!(T) seq) {
super (seq);
}
int opApply (int delegate (inout T value) dg) {
return 0;
}
}
public abstract class Collection(T) : Dispenser!(T)
{
public final uint mutation() {
return 0;
}
}
// removing this intermediate class makes it work
public abstract class SeqCollection(T) : Collection!(T), Seq!(T) {
}
public class ArraySeq(T) : SeqCollection!(T)
, Dispenser!(T) // removing this makes it work, dispenser is already
derived from SeqCollection
{
//
public final Dispenser!(T) duplicate() {
return null;
}
public final override void remove(T element){}
public final override void removeAll(T element){}
public void removeAll (Iterator!(T) e) {
printf( "removeAll\n" );
}
public void remove (Iterator!(T) e) {
printf( "remove\n" );
}
}
//import tango.util.collection.model.Seq;
//import tango.util.collection.ArraySeq;
// removing this variable decl will make it work
Seq!(Object) seq;
void main(){
auto alist = new ArraySeq!(Object);
auto scope iterator = new ArrayIterator!(Object)(alist);
foreach( el; iterator ){
printf( "shall not come here.\n" );
}
printf( "ready\n" );
}
--
More information about the Digitalmars-d-bugs
mailing list