aboutsummaryrefslogtreecommitdiff
path: root/tests/pos/zoo.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-02-12 11:28:35 +0100
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2015-03-18 11:09:43 +0100
commit61cb51acaedbe603add8c4af9e390a27f8b33f09 (patch)
tree2e6f7d2410b96b208b3f6be5c5465a320751d7f0 /tests/pos/zoo.scala
parent3f5d15defa7481da1b9d1f20e91569a340c71e8e (diff)
downloaddotty-61cb51acaedbe603add8c4af9e390a27f8b33f09.tar.gz
dotty-61cb51acaedbe603add8c4af9e390a27f8b33f09.tar.bz2
dotty-61cb51acaedbe603add8c4af9e390a27f8b33f09.zip
Disallow refinements of types or methods that do not appear in parent.
We planned this for a long time but never implemented it. Instead, we sometimes issued an erro in Splitter, namely if reflection would have been needed to access the member. It turns out that some tests (e.g. neg/t625) fail -Ycheck (we knew that before and disabled) but also fail Pickling because they generate orhpan PolyParams. So rather than patching this up it seems now is a good time to enforce the restriction for real.
Diffstat (limited to 'tests/pos/zoo.scala')
-rw-r--r--tests/pos/zoo.scala27
1 files changed, 12 insertions, 15 deletions
diff --git a/tests/pos/zoo.scala b/tests/pos/zoo.scala
index 08f7eba63..02dac8f5b 100644
--- a/tests/pos/zoo.scala
+++ b/tests/pos/zoo.scala
@@ -1,40 +1,37 @@
object Test {
-type Meat = {
+trait FoodStuff
+trait Meat extends FoodStuff {
type IsMeat = Any
}
-type Grass = {
+trait Grass extends FoodStuff {
type IsGrass = Any
}
-type Animal = {
- type Food
+trait Animal {
+ type Food <: FoodStuff
def eats(food: Food): Unit
def gets: Food
}
-type Cow = {
+trait Cow extends Animal {
type IsMeat = Any
type Food <: Grass
def eats(food: Grass): Unit
- def gets: Grass
+ def gets: Food
}
-type Lion = {
+trait Lion extends Animal {
type Food = Meat
def eats(food: Meat): Unit
def gets: Meat
}
-def newMeat: Meat = new {
- type IsMeat = Any
+def newMeat: Meat = new Meat {
}
-def newGrass: Grass = new {
- type IsGrass = Any
+def newGrass: Grass = new Grass {
}
-def newCow: Cow = new {
- type IsMeat = Any
+def newCow: Cow = new Cow {
type Food = Grass
def eats(food: Grass) = ()
def gets = newGrass
}
-def newLion: Lion = new {
- type Food = Meat
+def newLion: Lion = new Lion {
def eats(food: Meat) = ()
def gets = newMeat
}