当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Scala TypeReprMethods.asType用法及代码示例


asType 方法(或属性)属于 scala.quoted.Quotes.reflectModule.TypeReprMethods 特性(trait),其相关用法说明如下。

用法:

def asType: Type[_ <: AnyKind]

将此 TypeRepr 转换为 Type[?]

用法:

package scala.quoted
trait Snippet0 { self: runtime.QuoteUnpickler & scala.quoted.runtime.QuoteMatching &    scala.quoted.Quotes =>
  val QuoteUnpickler = self
  val QuoteMatching = self
  val Quotes = self
  trait Snippet1 { self: Quotes.reflect.type /*Quotes.reflectModule*/ &    Quotes.reflectModule =>
    val reflect = self
    val reflectModule = self
    trait Snippet2 { self: reflectModule.TypeReprMethods =>
      val TypeReprMethods = self
      def f(using Quotes) = {
      val typeRepr: TypeRepr = ???
      typeRepr.asType match
        case '[t] =>
          '{ val x: t = ??? }
      }
    }
  }
}

源码:

Quotes.scala

相关用法


注:本文由纯净天空筛选整理自scala-lang.org大神的英文原创作品 TypeReprMethods.asType。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。