-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix interpretation of Typed trees #3852
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
true | ||
false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How can I be sure the output is from compile-time, not run-time? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because the |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import dotty.tools.dotc.ast.Trees.Import | ||
|
||
import scala.quoted._ | ||
object Macros { | ||
sealed trait Nat | ||
case object Z extends Nat | ||
case class S[N <: Nat]() extends Nat | ||
|
||
inline def isZero(inline n: Int): Boolean = ~{ | ||
if (n == 0) (true: Expr[Boolean]) | ||
else (false: Expr[Boolean]) | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import Macros._ | ||
object Test { | ||
def main(args: Array[String]): Unit = { | ||
println(isZero(0)) | ||
println(isZero(1)) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need a check here? Maybe not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What kind of check? This is a fully typed tree, we evaluate it's erased version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking to check the type, but it's not the semantics of the language. So ignore the comment.