forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The previous formulation broke for named parameters. Test case in flowops1.scala.
- Loading branch information
Showing
3 changed files
with
43 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |