//Code

class Top {
}

class Middle extends Top {
}

class Bottom extends Middle {
}

class Up {
  void cv(Top t);
  /*** .\cocon\cocon.nice: line 12, column 8: Warning:
   * Ambiguity for method nice.lang.void ctv(cocon.Up this, Bottom b)For parameters of type (cocon.Down, cocon.Bottom)
   * both cocon.ctv:(cocon.Up, cocon.Bottom)->nice.lang.void(u@cocon.Up, b@cocon.Bottom)
   * and  cocon.ctv:(cocon.Up, cocon.Bottom)->nice.lang.void(u@cocon.Down, b@cocon.Middle) match
   *
   ** Devrait détecter la non conformance de limplantation ctv(D,M) ligne 48 !!! Agit ligne 48...
   *
   ***/
  void ctv(Bottom b);
}

class Down extends Up {
  /* There is an ambiguity about which version  of the overloaded method "cv" this
   * alternative belongs to.
   * Try to use more patterns.
   *
   * Possible methods:
   * nice.lang.void cv(cocon.Down this, Middle m) defined .\cocon\cocon.nice: line 16, column 8
   * nice.lang.void cv(cocon.Up this, Top t) defined .\cocon\cocon.nice: line 11, column 8
   */
  //void cv(Middle m);
  //void ctv(Middle m);/*** error variant no overloading of ctv
}

cv(u@Up, t@Top) {
  System.out.println("Up");
}

ctv(u@Up, b@Bottom) {
  System.out.println("Up");
}

cv(d@Down, t@Middle) {
  System.out.println("Down");
}

ctv(u@Down, b@Bottom) { // instead of Down, Middle
  System.out.println("Down");
}

main(args){
  Up u = new Up(), ud = new Down();
  Down d = new Down();

  Top t = new Top();
  Middle m = new Middle();
  Bottom b = new Bottom();

  System.out.println("-- first test suite");
  u.cv(t);
  u.cv(m);
  u.cv(b);
  /*** Arguments (cocon.Up, cocon.Top) do not fit:
   * nice.lang.void ctv(cocon.Up this, Bottom b)
   ***/
  //u.ctv(t);
  System.out.println("Error: no match");
  /*** Arguments (cocon.Up, cocon.Middle) do not fit:
   * nice.lang.void ctv(cocon.Up this, Bottom b)
   ***/
  System.out.println("Error: no match");
  //u.ctv(m);
  u.ctv(b);
  System.out.println("-- second test suite");
  d.cv(t);
  d.cv(m);
  d.cv(b);
  /*** Arguments (cocon.Down, cocon.Top) do not fit:
   * nice.lang.void ctv(cocon.Up this, Bottom b)
   ***/
  //d.ctv(t);
  System.out.println("Error: no match");
  /*** Arguments (cocon.Down, cocon.Middle) do not fit:
   * nice.lang.void ctv(cocon.Up this, Bottom b)
   ***/
  //d.ctv(m);
  System.out.println("Error: no match");
  d.ctv(b);
  System.out.println("-- third test suite");
  ud.cv(t);
  ud.cv(m);
  ud.cv(b);
  /*** Arguments (cocon.Up, cocon.Top) do not fit:
   * nice.lang.void ctv(cocon.Up this, Bottom b)
   ***/
  //ud.ctv(t);
  System.out.println("Error: no match");
  /*** Arguments (cocon.Up, cocon.Middle) do not fit:
   * nice.lang.void ctv(cocon.Up this, Bottom b)
   ***/
  //ud.ctv(m);
  System.out.println("Error: no match");
  ud.ctv(b);
}
 

// run
-- first test suite
Up
Up
Up
Error: no match
Error: no match
Up
-- second test suite
Up
Down
Down
Error: no match
Error: no match
Down
-- third test suite
Up
Down
Down
Error: no match
Error: no match
Down