Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

test from stef for #485

  • Loading branch information...
commit 1e4eeaf172e7b7718756b25bfc3c7e38554a1e82 1 parent 89371a2
@gavinking gavinking authored
Showing with 32 additions and 0 deletions.
  1. +32 −0 test/main/typing/BrokenSelfTypes.ceylon
View
32 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 ")";
+}
Please sign in to comment.
Something went wrong with that request. Please try again.