File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change
1
+ import scala.language.higherKinds
2
+
3
+ trait LogDSL[L]
4
+
5
+ object LogDSL {
6
+ implicit object LogRecsLogDSL extends LogDSL[String]
7
+ def runLog(ls: String): String = ???
8
+ }
9
+
10
+ trait Direction[D] {
11
+ def north: D
12
+ }
13
+
14
+ object Direction {
15
+ // needs both instances to trigger the bug
16
+ implicit def logDirection[L](implicit L: LogDSL[L]): Direction[L] = ???
17
+ implicit def RotateDirection[D](implicit D: Direction[D]): Direction[Rotate.Rotation[D]] = ???
18
+ }
19
+
20
+ trait Rotate[R] {
21
+ def rotate(r: R): R
22
+ }
23
+
24
+ object Rotate {
25
+ implicit def logRotate[L](implicit L: LogDSL[L]): Rotate[L] = ???
26
+
27
+ opaque type Rotation[T] = Int => T
28
+ }
29
+
30
+ object Main {
31
+ // the instances have to be acquired through implicit resolution to cause the crash
32
+ def north[D](implicit D: Direction[D]): D = ???
33
+ def rotate[R](r: R)(implicit RR: Rotate[R]): R = ???
34
+
35
+ def main(args: Array[String]): Unit = {
36
+ // commenting out either the first or the second of these lines removes the compiler crash
37
+ // removing the wrapping println call abolishes the crash
38
+ println(LogDSL.runLog(rotate(north)))
39
+ println(LogDSL.runLog(rotate(north)))
40
+ }
41
+ }
You can’t perform that action at this time.
0 commit comments