aboutsummaryrefslogtreecommitdiff
path: root/tests/pos
diff options
context:
space:
mode:
authorodersky <odersky@gmail.com>2017-02-01 18:21:58 +1100
committerGitHub <noreply@github.com>2017-02-01 18:21:58 +1100
commitaf7fdb32df34b352bf39f01a26653b169e0d55cf (patch)
tree4307381bb799db513dd07a0f40aec968ae99e877 /tests/pos
parentbb2e99cdfa9876561df912d26e9870526de3dd5d (diff)
parent678e8e47b630786df7548c1be5bee744342f826c (diff)
downloaddotty-af7fdb32df34b352bf39f01a26653b169e0d55cf.tar.gz
dotty-af7fdb32df34b352bf39f01a26653b169e0d55cf.tar.bz2
dotty-af7fdb32df34b352bf39f01a26653b169e0d55cf.zip
Merge pull request #1881 from dotty-staging/add-structural-select
Implement structural type member access
Diffstat (limited to 'tests/pos')
-rw-r--r--tests/pos/i1866.scala5
-rw-r--r--tests/pos/zoo2.scala45
2 files changed, 50 insertions, 0 deletions
diff --git a/tests/pos/i1866.scala b/tests/pos/i1866.scala
new file mode 100644
index 000000000..918d2e182
--- /dev/null
+++ b/tests/pos/i1866.scala
@@ -0,0 +1,5 @@
+import scala.reflect.Selectable.reflectiveSelectable
+object Test {
+ def f(g: { val update: Unit }) = g.update
+ def main(update: Array[String]) = {}
+}
diff --git a/tests/pos/zoo2.scala b/tests/pos/zoo2.scala
new file mode 100644
index 000000000..06210fe67
--- /dev/null
+++ b/tests/pos/zoo2.scala
@@ -0,0 +1,45 @@
+import scala.reflect.Selectable.reflectiveSelectable
+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)
+}