aboutsummaryrefslogtreecommitdiff
path: root/tests/pending/pos/t7190.scala
blob: 449e5c83f1837b51e5854c980a98f5758c17ab10 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import scala.language.experimental.macros
import scala.reflect.macros._

trait A[T] {
  def min[U >: T](implicit ord: Numeric[U]): T = macro A.min[T, U]
}

object A {
  def min[T: c.WeakTypeTag, U >: T: c.WeakTypeTag](c: Context)(ord: c.Expr[Numeric[U]]): c.Expr[T] = {
    c.universe.reify {
      ord.splice.zero.asInstanceOf[T]
    }
  }
}

class B extends A[Int] {
  override def min[U >: Int](implicit ord: Numeric[U]): Int = macro B.min[U]
}

object B {
  def min[U >: Int: c.WeakTypeTag](c: Context)(ord: c.Expr[Numeric[U]]): c.Expr[Int] = {
    c.universe.reify {
      ord.splice.zero.asInstanceOf[Int]
    }
  }
}