forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
81 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import scala.quoted.* | ||
|
||
inline def myMacro = ${ myMacroImpl } | ||
def myMacroImpl(using Quotes) = | ||
import quotes.reflect.* | ||
|
||
val valSym = Symbol.newVal(Symbol.spliceOwner, "foo", TypeRepr.of[Int], Flags.EmptyFlags, Symbol.noSymbol) | ||
val vdef = ValDef(valSym, None) | ||
vdef match | ||
case _: ValDef => | ||
assert(vdef.tpt.tpe =:= TypeRepr.of[Int]) | ||
assert(vdef.rhs == None) | ||
vdef match | ||
case vdef: ValOrDefDef => | ||
assert(vdef.tpt.tpe =:= TypeRepr.of[Int]) | ||
assert(vdef.rhs == None) | ||
|
||
val methSym = Symbol.newMethod(Symbol.spliceOwner, "bar", ByNameType(TypeRepr.of[Int])) | ||
val ddef = DefDef(methSym, _ => None) | ||
ddef match | ||
case _: DefDef => | ||
assert(ddef.tpt.tpe =:= TypeRepr.of[Int]) | ||
assert(ddef.rhs == None) | ||
ddef match | ||
case ddef: ValOrDefDef => | ||
assert(ddef.tpt.tpe =:= TypeRepr.of[Int]) | ||
assert(ddef.rhs == None) | ||
|
||
'{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
def test = myMacro |