diff --git a/compiler/src/dotty/tools/dotc/typer/Implicits.scala b/compiler/src/dotty/tools/dotc/typer/Implicits.scala index 352b2c8f39c2..62664e38df3b 100644 --- a/compiler/src/dotty/tools/dotc/typer/Implicits.scala +++ b/compiler/src/dotty/tools/dotc/typer/Implicits.scala @@ -409,13 +409,13 @@ object Implicits: } object SearchFailure { - def apply(tpe: SearchFailureType)(using Context): SearchFailure = { + def apply(tpe: SearchFailureType, span: Span)(using Context): SearchFailure = { val id = tpe match case tpe: AmbiguousImplicits => untpd.SearchFailureIdent(nme.AMBIGUOUS, s"/* ambiguous: ${tpe.explanation} */") case _ => untpd.SearchFailureIdent(nme.MISSING, "/* missing */") - SearchFailure(id.withTypeUnchecked(tpe)) + SearchFailure(id.withTypeUnchecked(tpe).withSpan(span)) } } @@ -483,7 +483,7 @@ object Implicits: @sharable object NoMatchingImplicits extends NoMatchingImplicits(NoType, EmptyTree, OrderingConstraint.empty) @sharable val NoMatchingImplicitsFailure: SearchFailure = - SearchFailure(NoMatchingImplicits)(using NoContext) + SearchFailure(NoMatchingImplicits, NoSpan)(using NoContext) /** An ambiguous implicits failure */ class AmbiguousImplicits(val alt1: SearchSuccess, val alt2: SearchSuccess, val expectedType: Type, val argument: Tree) extends SearchFailureType { @@ -1022,7 +1022,7 @@ trait Implicits: } else result case NoMatchingImplicitsFailure => - SearchFailure(new NoMatchingImplicits(pt, argument, ctx.typerState.constraint)) + SearchFailure(new NoMatchingImplicits(pt, argument, ctx.typerState.constraint), span) case _ => result0 } @@ -1123,7 +1123,7 @@ trait Implicits: */ def tryImplicit(cand: Candidate, contextual: Boolean): SearchResult = if checkDivergence(cand) then - SearchFailure(new DivergingImplicit(cand.ref, wideProto, argument)) + SearchFailure(new DivergingImplicit(cand.ref, wideProto, argument), span) else { val history = ctx.searchHistory.nest(cand, pt) val result = @@ -1174,7 +1174,7 @@ trait Implicits: if diff < 0 then alt2 else if diff > 0 then alt1 - else SearchFailure(new AmbiguousImplicits(alt1, alt2, pt, argument)) + else SearchFailure(new AmbiguousImplicits(alt1, alt2, pt, argument), span) case _: SearchFailure => alt2 /** Try to find a best matching implicit term among all the candidates in `pending`. diff --git a/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala b/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala index 08485bf9799e..3ef8b979c22c 100644 --- a/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala +++ b/compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala @@ -132,7 +132,7 @@ object ProtoTypes { // equals comes from case class; no need to redefine end IgnoredProto - + final class CachedIgnoredProto(ignored: Type) extends IgnoredProto(ignored) object IgnoredProto: diff --git a/tests/neg-macros/i9972/Macro_1.scala b/tests/neg-macros/i9972/Macro_1.scala new file mode 100644 index 000000000000..65e69f8ccab3 --- /dev/null +++ b/tests/neg-macros/i9972/Macro_1.scala @@ -0,0 +1,7 @@ +package notmacro + +import scala.util.Not + +object Main extends App { + summon[Not[T[Int]]] // error +} diff --git a/tests/neg-macros/i9972/Test_2.scala b/tests/neg-macros/i9972/Test_2.scala new file mode 100644 index 000000000000..6ba96eddec4e --- /dev/null +++ b/tests/neg-macros/i9972/Test_2.scala @@ -0,0 +1,12 @@ +package notmacro + +import scala.quoted._ + +case class T[A <: AnyKind](s: String) + +object T { + implicit inline def derived[A <: AnyKind]: T[A] = ${ reprImpl[A] } + + def reprImpl[A <: AnyKind](using t: Type[A])(using ctx: QuoteContext): Expr[T[A]] = + '{ T[A]("") } +} diff --git a/tests/neg-macros/i9972b/Macro_1.scala b/tests/neg-macros/i9972b/Macro_1.scala new file mode 100644 index 000000000000..ecb22a0b3755 --- /dev/null +++ b/tests/neg-macros/i9972b/Macro_1.scala @@ -0,0 +1,3 @@ + +def test: Unit = + summon[scala.util.Not[T[Int]]] // error diff --git a/tests/neg-macros/i9972b/Test_2.scala b/tests/neg-macros/i9972b/Test_2.scala new file mode 100644 index 000000000000..1f94ccf18ee8 --- /dev/null +++ b/tests/neg-macros/i9972b/Test_2.scala @@ -0,0 +1,5 @@ + +class T[A] + +object T: + implicit inline def derived[A]: T[A] = new T[A]