Skip to content

Avoid creation of @SplicedType quote local refrences #17051

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

Merged
merged 1 commit into from
Mar 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions compiler/src/dotty/tools/dotc/staging/HealType.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package staging
import dotty.tools.dotc.core.Contexts._
import dotty.tools.dotc.core.Decorators._
import dotty.tools.dotc.core.Flags._
import dotty.tools.dotc.core.StdNames._
import dotty.tools.dotc.core.Symbols._
import dotty.tools.dotc.core.Types._
import dotty.tools.dotc.staging.QuoteContext.*
Expand Down Expand Up @@ -68,13 +69,14 @@ class HealType(pos: SrcPos)(using Context) extends TypeMap {
* reference to a type alias containing the equivalent of `${summon[quoted.Type[T]]}`.
* Emits an error if `T` cannot be healed and returns `T`.
*/
protected def tryHeal(sym: Symbol, tp: TypeRef, pos: SrcPos): TypeRef = {
protected def tryHeal(sym: Symbol, tp: TypeRef, pos: SrcPos): Type = {
val reqType = defn.QuotedTypeClass.typeRef.appliedTo(tp)
val tag = ctx.typer.inferImplicitArg(reqType, pos.span)
tag.tpe match
case tp: TermRef =>
ctx.typer.checkStable(tp, pos, "type witness")
getQuoteTypeTags.getTagRef(tp)
if levelOf(tp.symbol) > 0 then tp.select(tpnme.Underlying)
else getQuoteTypeTags.getTagRef(tp)
case _: SearchFailureType =>
report.error(
ctx.typer.missingArgMsg(tag, reqType, "")
Expand Down
3 changes: 3 additions & 0 deletions tests/pos-macros/i17026.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import scala.quoted.*
def macroImpl(using Quotes) =
'{ def weird[A: Type](using Quotes) = Type.of[A] }
7 changes: 7 additions & 0 deletions tests/pos-macros/i17026b.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import scala.quoted.*

def macroImpl(using Quotes) =
'{
def weird[A: ToExpr: Type](a: A)(using quotes: Quotes) =
'{ Some(${ Expr(a) }) }
}