Skip to content

Fix #5765: Add regression test #6489

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 10, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions tests/pos/i5765.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import scala.language.higherKinds

trait LogDSL[L]

object LogDSL {
implicit object LogRecsLogDSL extends LogDSL[String]
def runLog(ls: String): String = ???
}

trait Direction[D] {
def north: D
}

object Direction {
// needs both instances to trigger the bug
implicit def logDirection[L](implicit L: LogDSL[L]): Direction[L] = ???
implicit def RotateDirection[D](implicit D: Direction[D]): Direction[Rotate.Rotation[D]] = ???
}

trait Rotate[R] {
def rotate(r: R): R
}

object Rotate {
implicit def logRotate[L](implicit L: LogDSL[L]): Rotate[L] = ???

opaque type Rotation[T] = Int => T
}

object Main {
// the instances have to be acquired through implicit resolution to cause the crash
def north[D](implicit D: Direction[D]): D = ???
def rotate[R](r: R)(implicit RR: Rotate[R]): R = ???

def main(args: Array[String]): Unit = {
// commenting out either the first or the second of these lines removes the compiler crash
// removing the wrapping println call abolishes the crash
println(LogDSL.runLog(rotate(north)))
println(LogDSL.runLog(rotate(north)))
}
}