Skip to content

Instantly share code, notes, and snippets.

@jorgeortiz85
Forked from dt/please_typecheck.scala
Created July 22, 2011 16:40
Show Gist options
  • Save jorgeortiz85/1099811 to your computer and use it in GitHub Desktop.
Save jorgeortiz85/1099811 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
implicit def manifestT: Manifest[T]
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
implicit def manifestT = manifest[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