aboutsummaryrefslogtreecommitdiff
path: root/tests/pickling/zoo.scala
diff options
context:
space:
mode:
Diffstat (limited to 'tests/pickling/zoo.scala')
-rw-r--r--tests/pickling/zoo.scala41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/pickling/zoo.scala b/tests/pickling/zoo.scala
new file mode 100644
index 000000000..02dac8f5b
--- /dev/null
+++ b/tests/pickling/zoo.scala
@@ -0,0 +1,41 @@
+object Test {
+trait FoodStuff
+trait Meat extends FoodStuff {
+ type IsMeat = Any
+}
+trait Grass extends FoodStuff {
+ type IsGrass = Any
+}
+trait Animal {
+ type Food <: FoodStuff
+ def eats(food: Food): Unit
+ def gets: Food
+}
+trait Cow extends Animal {
+ type IsMeat = Any
+ type Food <: Grass
+ def eats(food: Grass): Unit
+ def gets: Food
+}
+trait Lion extends Animal {
+ type Food = Meat
+ def eats(food: Meat): Unit
+ def gets: Meat
+}
+def newMeat: Meat = new Meat {
+}
+def newGrass: Grass = new Grass {
+}
+def newCow: Cow = new Cow {
+ type Food = Grass
+ def eats(food: Grass) = ()
+ def gets = newGrass
+}
+def newLion: Lion = new Lion {
+ def eats(food: Meat) = ()
+ def gets = newMeat
+}
+val milka = newCow
+val leo = newLion
+//leo.eats(milka) // structural select not supported
+}