scala-macros

    0熱度

    1回答

    所以我有一個擴展方法應擴展爲宏的方法。我遇到的問題是如何在宏實現調用中包含擴展方法的接收方? implicit class ExtensionTest(xs: List[Int]) { def foo(fun: Int => Int)(implicit ord: Ordering[Int]): List[Int] = macro ExtensionTest.fooImpl //

    1熱度

    1回答

    下應該顯示的問題: class Container[A](val xs: List[A]) { def foo(fun: A => A)(implicit ord: Ordering[A]): List[A] = macro ContainerMacros.fooImpl // how to pass `xs`? } object ContainerMacros {

    1熱度

    1回答

    我需要生成: case class Foo(param: Bar = BarEnum.SomeCaseObject) 但這代碼: val term = TermName("BarEnum.SomeCaseObject") showCode(q"""case class Foo(val param : Bar = ${term})""") 輸出參數默認由反引號所包圍,不編譯: case c

    1熱度

    1回答

    我正在使用macroparadise在我的項目中生成方法和案例類(宏本身在我的核心文件中使用它們的單獨項目中定義)。 所有內容都按預期編譯並運行,但Eclipse無法解析由我的宏生成的變量和方法。但是,當我關閉並重新打開Eclipse時,它可以完美地識別所有內容;我可以將鼠標懸停在類和方法上並獲取正確的信息。但是,只要我改變任何東西,甚至關閉並重新打開引用generate方法的文件,Eclipse

    3熱度

    1回答

    我想使用scalameta註釋宏在Scala中自動生成REST API模型。具體地,給出: @Resource case class User( @get id : Int, @get @post @patch name : String, @get @post email : String, registeredOn : Long ) 我要生成:

    3熱度

    1回答

    我使用Scalameta(v1.8.0)註釋到DEF聲明: trait MyTrait { @MyDeclDef def f2(): Int } 定義只是返回輸入註解類,因爲這: import scala.meta._ class MyDeclDef extends scala.annotation.StaticAnnotation { inline def

    -1熱度

    1回答

    我有一個對象 object Helper{ val fieldName = "fooBar } 這對於一個字段提供的名稱。 和殼體類 case class BarBaz(fieldOne:Int, fieldTwo:String) 但不是fieldTwo,我想是指Helper.fieldname爲案件類的參數名稱。 這怎麼能在斯卡拉完成?也許通過宏?還是有更簡單的可能性? 也就是說 c

    2熱度

    1回答

    在被稱爲scala(2.11)宏的方法中,有沒有一種方法可以通過編程來確定Type是否爲case class? 對我通過工作方法的API歸結爲: def typeIsCaseClass(c: Context)(targetType: c.universe.Type): Boolean = { // targetType "is case class?" } 我願意改變API如果需要

    0熱度

    1回答

    我正在使用來自Spotify的Scio庫的宏註釋。我想定義String類型的變量和註釋是這樣的: val schemaString = """schema here""" @BigQueryType.fromSchema(outputString) class BigQuery 然而,這並不編譯,如果我直接註釋String,它的工作原理: @BigQueryType.fromSchema("

    1熱度

    1回答

    我有一個宏註釋{類型T}: import language.experimental.macros import reflect.macros.whitebox.Context class annot extends StaticAnnotation { def macroTransform(annottees: Any*): Any = macro annot.impl }