當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。