Skip to content

Instantly share code, notes, and snippets.

@dt
Created July 22, 2011 16:25
Show Gist options
  • Save dt/1099787 to your computer and use it in GitHub Desktop.
Save dt/1099787 to your computer and use it in GitHub Desktop.
I want line 15 to typecheck
package demo
trait Bar
abstract class Foo[T] {}
object Foo {
implicit def FooFromBar[T <: Bar : Manifest]: Foo[T] = new Foo[T] { }
def apply[T : Foo] = implicitly[Foo[T]]
def baz[T : Foo](arg: T): Unit = { println("ha!")}
}
abstract class BaseBar(val a:String) extends Bar
abstract class Base {
type T <: BaseBar
def getBar(a:String) : T
// def send(a:String) = Foo.baz(getBar(a)) // Dear typechecker, why do you hate me?
}
class ConcreteBar(a:String) extends BaseBar(a)
object Concrete extends Base {
type T = ConcreteBar
def getBar(a:String) = new ConcreteBar(a)
def send(a:String) = Foo.baz(getBar(a)) // I want to remove this line
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment