-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Disallow phase inconsistent inline parameters #8061
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 |
---|---|---|
|
@@ -18,6 +18,14 @@ class Expr[+T] private[scala] { | |
*/ | ||
final def getValue[U >: T](given qctx: QuoteContext, valueOf: ValueOfExpr[U]): Option[U] = valueOf(this) | ||
|
||
/** Return the value of this expression. | ||
* | ||
* Emits an error error and throws if the expression does not contain a value or contains side effects. | ||
* Otherwise returns the value. | ||
*/ | ||
final def value[U >: T](given qctx: QuoteContext, valueOf: ValueOfExpr[U]): U = | ||
valueOf(this).getOrElse(qctx.throwError(s"Expected a known value. \n\nThe value of: $show\ncould not be recovered using $valueOf", this)) | ||
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. It seems this method only invites errors in meta-programming, maybe we should just remove it. 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. Without it we would end up writing |
||
|
||
/** Pattern matches `this` against `that`. Effectively performing a deep equality check. | ||
* It does the equivalent of | ||
* ``` | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package scala.quoted | ||
|
||
/** Stop code generation after an error has been reported */ | ||
class StopQuotedContext extends Throwable |
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 find
getValue
is a little misleading, if what it does is to get the literal out. MaybegetLiteralValue
?Uh oh!
There was an error while loading. Please reload this page.
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.
It is not necessarily a literal value.