-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Explicitly search the given QuoteContext of the quotes #8262
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 |
---|---|---|
|
@@ -45,10 +45,16 @@ trait QuotesAndSplices { | |
ctx.warning("Canceled splice directly inside a quote. '[ ${ XYZ } ] is equivalent to XYZ.", tree.sourcePos) | ||
case _ => | ||
} | ||
val qctx = inferImplicitArg(defn.QuoteContextClass.typeRef, tree.span) | ||
if (level == 0 && qctx.tpe.isInstanceOf[SearchFailureType]) | ||
ctx.error(missingArgMsg(qctx, defn.QuoteContextClass.typeRef, ""), ctx.source.atSpan(tree.span)) | ||
val tree1 = | ||
if (ctx.mode.is(Mode.Pattern) && level == 0) typedQuotePattern(tree, pt) | ||
else if (tree.quoted.isType) typedTypeApply(untpd.TypeApply(untpd.ref(defn.InternalQuoted_typeQuote.termRef), tree.quoted :: Nil), pt)(quoteContext) | ||
else typedApply(untpd.Apply(untpd.ref(defn.InternalQuoted_exprQuote.termRef), tree.quoted), pt)(quoteContext) | ||
if ctx.mode.is(Mode.Pattern) && level == 0 then | ||
typedQuotePattern(tree, pt, qctx) | ||
else if (tree.quoted.isType) | ||
typedTypeApply(untpd.TypeApply(untpd.ref(defn.InternalQuoted_typeQuote.termRef), tree.quoted :: Nil), pt)(quoteContext) | ||
else | ||
typedApply(untpd.Apply(untpd.ref(defn.InternalQuoted_exprQuote.termRef), tree.quoted), pt)(quoteContext).select(nme.apply).appliedTo(qctx) | ||
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. I'm not sure about this line, as previously, we don't need to 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. Previously we were letting typer find and apply it. But as we know it we can just add it explicitly. In the previous case, it did not find the implicit it emitted an error mentioning |
||
tree1.withSpan(tree.span) | ||
} | ||
|
||
|
@@ -326,11 +332,7 @@ trait QuotesAndSplices { | |
* ) => ... | ||
* ``` | ||
*/ | ||
private def typedQuotePattern(tree: untpd.Quote, pt: Type)(implicit ctx: Context): Tree = { | ||
val qctx = inferImplicitArg(defn.QuoteContextClass.typeRef, tree.span) | ||
if (level == 0 && qctx.tpe.isInstanceOf[SearchFailureType]) | ||
ctx.error(missingArgMsg(qctx, defn.QuoteContextClass.typeRef, ""), ctx.source.atSpan(tree.span)) | ||
|
||
private def typedQuotePattern(tree: untpd.Quote, pt: Type, qctx: Tree)(implicit ctx: Context): Tree = { | ||
val quoted = tree.quoted | ||
val exprPt = pt.baseType(if quoted.isType then defn.QuotedTypeClass else defn.QuotedExprClass) | ||
val quotedPt = exprPt.argInfos.headOption match { | ||
|
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.
Inferring implicit args for implicit function types complicate existing typing rules. It's better to avoid the special case and only use it as a last resort.
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.
Will be required in #8281