Skip to content

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

Conversation

nicolasstucki
Copy link
Contributor

  • Avoids leaking implementation details of scala.internal.quoted.CompileTime.exprQuote,
    such as exprQuote returning a ?=> function argument

Same as #8244 but on quotes

* Avoids leaking implementation details of scala.internal.quoted.CompileTime.exprQuote,
such as exprQuote returning a ?=> function argument
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)
Copy link
Contributor

Choose a reason for hiding this comment

The 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 .select(nme.apply).appliedTo(qctx), and it worked.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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 CompileTime.quotedExpr in some situations.

@@ -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)
Copy link
Contributor

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.

Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants