-- Main class

class TESTCOCON
creation make
feature

    u: U;
    v: D;
    w: U;

    t: TT;
    m: M;
    b: B;

    make is
      do
        !!u;
        !!v;
        w := v;

        !!t; !!m; !!b;

        io.put_string("-- first test suite");
        io.put_new_line;
        u.cv(t);
        u.cv(m);
        u.cv(b);
        -- u.ctv(t);
        io.put_string("u.ctv(t); Type error: non-conforming actual
                                    argument in feature call. ");
        io.put_new_line;
        -- u.ctv(m);
        io.put_string("u.ctv(m); Type error: non-conforming actual
                                    argument in feature call. ");
        io.put_new_line;
        u.ctv(b);

        io.put_string("-- second test suite");
        io.put_new_line;
        -- v.cv(t);
        io.put_string("v.cv(t); Type error: non-conforming actual
                                    argument in feature call. ");
        io.put_new_line;
        v.cv(m);
        v.cv(b);
        -- v.ctv(t);
        io.put_string("v.ctv(t); Type error: non-conforming actual
                                    argument in feature call. ");
        io.put_new_line;
        -- v.ctv(m);
        io.put_string("v.ctv(m); Type error: non-conforming actual
                                    argument in feature call. ");
        io.put_new_line;
        v.ctv(b);

        io.put_string("-- third test suite");
        w.cv(t);
        w.cv(m);
        w.cv(b);
        -- w.ctv(t);
        io.put_string("w.ctv(t); Type error: non-conforming actual
                                    argument in feature call. ");
        io.put_new_line;
        -- w.ctv(m);
        io.put_string("w.ctv(m); Type error: non-conforming actual
                                    argument in feature call. ");
        io.put_new_line;
        w.ctv(b);
   end;
end

-- U class
class U

feature
   cv(t: TT) is
      do
         io.put_string("cv(T) in U");
         io.put_new_line;
      end;
   ctv(b: B) is
      do
        io.put_string("ctv(B) in U");
        io.put_new_line;
      end;
end

-- D class
class D
inherit U
    redefine
        cv
    end
feature
   cv(m: M) is
   -- try covariance
      do
         io.put_string("cv(M) in D ");
         io.put_new_line;
      end;
   -- ctv(m: M) is
   -- try contravariance ; fails
   --   do
   --       io.put_string("ctv(M) in D ");
   --   end;
end

-- TT class (since T is reserved)
class TT
feature
end

-- M class
class M
inherit TT
feature
end

-- B class
class B
inherit M
feature
end

-- run
-- first test suite
cv(T) in U
cv(T) in U
cv(T) in U
u.ctv(t); Type error: non-conforming actual argument in feature call.
u.ctv(m); Type error: non-conforming actual argument in feature call.
ctv(B) in U

-- second test suite
v.cv(t); Type error: non-conforming actual argument in feature call.
cv(M) in D
cv(M) in D
v.ctv(t); Type error: non-conforming actual argument in feature call.
v.ctv(m); Type error: non-conforming actual argument in feature call.
ctv(B) in U

-- third test suite
cv(M) in D
cv(M) in D
cv(M) in D
w.ctv(t); Type error: non-conforming actual argument in feature call.
w.ctv(m); Type error: non-conforming actual argument in feature call.
ctv(B) in U