Skip to content

Instantly share code, notes, and snippets.

@crater2150
Created December 19, 2017 11:15
Show Gist options
  • Save crater2150/73824328b4cc005a631a706623a8ccc0 to your computer and use it in GitHub Desktop.
Save crater2150/73824328b4cc005a631a706623a8ccc0 to your computer and use it in GitHub Desktop.
trait Element[+R]
class NullElement[+R] extends Element[R]
trait BugRepro {
def combineElements(actions: Element[_]*): Element[Unit]
def sequence[R, M[+_] <: TraversableOnce[_]](in: M[Element[R]]): Element[M[R]]
val mySeq = Seq(1,2,3)
// bugRepro.scala:13: error: inferred type arguments [Nothing,Any] do not conform to method sequence's type parameter bounds [R,M[+_] <: TraversableOnce[_]]
// sequence(mySeq.map(i => new NullElement[Int]))
// ^
// bugRepro.scala:13: error: type mismatch;
// found : Any
// required: M[Element[R]]
// sequence(mySeq.map(i => new NullElement[Int]))
def typeError = {
combineElements(
sequence(mySeq.map(_ => new NullElement[Int]))
)
}
// compiles fine, although equivalent to above code
def compiles = {
val outlined = mySeq.map(_ => new NullElement[Int])
combineElements(
sequence(outlined)
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment