3
내부 유형에 TypeTag
또는 ClassTag
을 입력하여 유형 매개 변수가있는 메소드에 ClassTag
을 제공하려고합니다. Specicfically, 나는스칼라 : 내부 유형에 TypeTag 가져 오기
trait Baz
trait Foo { type Bar <: Baz }
을하고 난
import scala.reflect.runtime.universe._
import scala.reflect._
typeTag[Foo#Bar] // or maybe
classTag[Foo#Bar]
처럼 뭔가를하고 싶지만 나는 '더 typetag 가능한'오류가 발생하지 않습니다. 나의 궁극적 인 목표는 일반적으로 당신이 잘 내부 유형에서 유형 태그와 클래스 태그를 얻을 수있는이
import scala.reflect.ClassTag
class Doer[A,B]()(implicit ctA:ClassTag[A], ctB:ClassTag[B])
object Fooer extends Doer[Foo, Foo#Bar]()(classTag[Foo], classTag[Foo#Bar])