Skip to content

Commit

Permalink
test from stef for ceylon#485
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinking committed Nov 6, 2012
1 parent f64f55d commit 2548c5b
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions test/main/typing/BrokenSelfTypes.ceylon
@@ -0,0 +1,32 @@
@error abstract class Tree() satisfies Summable<Tree|Integer>{
shared actual Tree plus(Tree|Integer other) {
return Addition(this, other);
}
shared formal Integer evaluate();
}

class BinaryOperator(Tree|Integer left, Tree|Integer right, Integer f(Integer a, Integer b)) extends Tree(){
Integer resolve(Tree|Integer node){
switch(node)
case (is Tree){
return node.evaluate();
}
case (is Integer){
return node;
}
}

shared actual Integer evaluate() {
return f(resolve(left), resolve(right));
}

shared actual default String string = "Binary(" left ", " right ")";
}

class Multiplication(Tree|Integer left, Tree|Integer right) extends BinaryOperator(left, right, (Integer a, Integer b) a * b) {
shared actual default String string = "(" left " * " right ")";
}

class Addition(Tree|Integer left, Tree|Integer right) extends BinaryOperator(left, right, (Integer a, Integer b) a + b) {
shared actual default String string = "(" left " + " right ")";
}

0 comments on commit 2548c5b

Please sign in to comment.