-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
119 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
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,7 @@ | ||
Inlined(None, Nil, Literal(StringConstant("hello"))) | ||
ConstantType(StringConstant("hello")) | ||
|
||
Inlined(None, Nil, Apply(Select(Literal(StringConstant("world")), "trim"), Nil)) | ||
FlexibleType(TypeRef(ThisType(TypeRef(NoPrefix(), "lang")), "String")) | ||
|
||
FlexibleType(TypeRef(TermRef(ThisType(TypeRef(NoPrefix(), "java")), "lang"), "String")) |
34 changes: 34 additions & 0 deletions
34
tests/explicit-nulls/run/tasty-flexible-type/quoted_1.scala
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,34 @@ | ||
import scala.quoted.* | ||
|
||
object Macros { | ||
|
||
implicit inline def printTree[T](inline x: T): Unit = | ||
${ impl('x) } | ||
|
||
def impl[T](x: Expr[T])(using Quotes) : Expr[Unit] = { | ||
import quotes.reflect.* | ||
|
||
val tree = x.asTerm | ||
val treeStr = Expr(tree.show(using Printer.TreeStructure)) | ||
val treeTpeStr = Expr(tree.tpe.show(using Printer.TypeReprStructure)) | ||
|
||
'{ | ||
println(${treeStr}) | ||
println(${treeTpeStr}) | ||
println() | ||
} | ||
} | ||
|
||
inline def theTestBlock : Unit = ${ theTestBlockImpl } | ||
|
||
def theTestBlockImpl(using qctx : Quotes) : Expr[Unit] = { | ||
import quotes.reflect.* | ||
|
||
val ft1 = FlexibleType(TypeRepr.of[String]) | ||
val ft1e = Expr(ft1.show(using Printer.TypeReprStructure)) | ||
|
||
'{ | ||
println(${ft1e}) | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
tests/explicit-nulls/run/tasty-flexible-type/quoted_2.scala
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,10 @@ | ||
|
||
import Macros.* | ||
|
||
object Test { | ||
def main(args: Array[String]): Unit = { | ||
printTree("hello") | ||
printTree("world".trim()) | ||
theTestBlock | ||
} | ||
} |