diff options
author | Nada Amin <namin@alum.mit.edu> | 2014-07-20 18:15:58 +0200 |
---|---|---|
committer | Nada Amin <namin@alum.mit.edu> | 2014-07-20 18:15:58 +0200 |
commit | e1aecf1bd75fc4a1ff0e0c3a422b799adf0c9f64 (patch) | |
tree | f16f2cec2a479cee197e54b7abee310c6c923b12 /tests | |
parent | bdb63619119bf25c32c881fdf3c97ae7a40ec1e5 (diff) | |
parent | 65658a4d0c3250d0d27f7af51632b2356f829464 (diff) | |
download | dotty-e1aecf1bd75fc4a1ff0e0c3a422b799adf0c9f64.tar.gz dotty-e1aecf1bd75fc4a1ff0e0c3a422b799adf0c9f64.tar.bz2 dotty-e1aecf1bd75fc4a1ff0e0c3a422b799adf0c9f64.zip |
Merge pull request #149 from dotty-staging/fix/#148
fix/#148
Diffstat (limited to 'tests')
-rw-r--r-- | tests/neg/zoo.scala | 44 | ||||
-rw-r--r-- | tests/pos/zoo.scala | 44 |
2 files changed, 88 insertions, 0 deletions
diff --git a/tests/neg/zoo.scala b/tests/neg/zoo.scala new file mode 100644 index 000000000..6a3e4ca0b --- /dev/null +++ b/tests/neg/zoo.scala @@ -0,0 +1,44 @@ +object Test { +type Meat = { + type IsMeat = Any +} +type Grass = { + type IsGrass = Any +} +type Animal = { + type Food + def eats(food: Food): Unit + def gets: Food +} +type Cow = { + type IsMeat = Any + type Food <: Grass + def eats(food: Grass): Unit + def gets: Grass +} +type Lion = { + type Food = Meat + def eats(food: Meat): Unit + def gets: Meat +} +def newMeat: Meat = new { + type IsMeat = Any +} +def newGrass: Grass = new { + type IsGrass = Any +} +def newCow: Cow = new { + type IsMeat = Any + type Food = Grass + def eats(food: Grass) = () + def gets = newGrass +} +def newLion: Lion = new { + type Food = Meat + def eats(food: Meat) = () + def gets = newMeat +} +val milka = newCow +val leo = newLion +leo.eats(milka) // structural select not supported +} diff --git a/tests/pos/zoo.scala b/tests/pos/zoo.scala new file mode 100644 index 000000000..08f7eba63 --- /dev/null +++ b/tests/pos/zoo.scala @@ -0,0 +1,44 @@ +object Test { +type Meat = { + type IsMeat = Any +} +type Grass = { + type IsGrass = Any +} +type Animal = { + type Food + def eats(food: Food): Unit + def gets: Food +} +type Cow = { + type IsMeat = Any + type Food <: Grass + def eats(food: Grass): Unit + def gets: Grass +} +type Lion = { + type Food = Meat + def eats(food: Meat): Unit + def gets: Meat +} +def newMeat: Meat = new { + type IsMeat = Any +} +def newGrass: Grass = new { + type IsGrass = Any +} +def newCow: Cow = new { + type IsMeat = Any + type Food = Grass + def eats(food: Grass) = () + def gets = newGrass +} +def newLion: Lion = new { + type Food = Meat + def eats(food: Meat) = () + def gets = newMeat +} +val milka = newCow +val leo = newLion +//leo.eats(milka) // structural select not supported +} |