diff options
author | Martin Odersky <odersky@gmail.com> | 2016-03-19 19:46:47 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-03-30 09:51:02 +0200 |
commit | b49034715ac5dc5d3f8427b39e497d3e20c4c192 (patch) | |
tree | e0bfb21b474dc2b37e7a3d43b39ab8df0c1a32bc /tests | |
parent | 0855b071d913e7acd5271ab34062c69e25cd93cd (diff) | |
download | dotty-b49034715ac5dc5d3f8427b39e497d3e20c4c192.tar.gz dotty-b49034715ac5dc5d3f8427b39e497d3e20c4c192.tar.bz2 dotty-b49034715ac5dc5d3f8427b39e497d3e20c4c192.zip |
Simplify and fix avoid logic
The previous formulation broke for named parameters.
Test case in flowops1.scala.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/pos/flowops1.scala | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/pos/flowops1.scala b/tests/pos/flowops1.scala new file mode 100644 index 000000000..2acd515af --- /dev/null +++ b/tests/pos/flowops1.scala @@ -0,0 +1,33 @@ +object Test { + class NotUsed + + trait FO[type +Out, type +Mat] { self => + type Repr <: FO[Mat = self.Mat] { + type Repr = self.Repr + } + def map[T](f: Out => T): Repr[Out = T] = ??? + } + + class Source[type +Out, type +Mat] extends FO[Out, Mat] { + type Repr <: Source[Out, Mat] + } + + class Flow[type -In, type +Out, type +Mat] extends FO[Out, Mat] { + type Repr <: Flow[In, Out, Mat] + } + + implicit class x[O, M, F <: FO](val f: F[Out = O, Mat = M]) extends AnyVal { + def xx(i: Int): f.Repr[Out = O] = f.map(identity) + } + + val s1 = new Source[Int, NotUsed].xx(12) + val s2: Source[Int, NotUsed] = s1 + val f1 = x[Int, NotUsed, Flow[In = Int]](new Flow[Int, Int, NotUsed]).xx(12) + val f2: Flow[Int, Int, NotUsed] = f1 + + + val f3 = x(new Flow[Int, Int, NotUsed]).xx(12) + val f4: Flow[Int, Int, NotUsed] = f3 + val f5 = new Flow[Int, Int, NotUsed].xx(12) + val f6: Flow[Int, Int, NotUsed] = f5 +} |