diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index f288c1ae38fb..4d9192746ab8 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -556,6 +556,7 @@ class Typer extends Namer def typeSelectOnTerm(using Context): Tree = typedSelect(tree, pt, typedExpr(tree.qualifier, selectionProto(tree.name, pt, this))) + .withSpan(tree.span) .computeNullable() def typeSelectOnType(qual: untpd.Tree)(using Context) = diff --git a/tests/neg/i6762b.check b/tests/neg/i6762b.check index 54d75a793056..7311f21adb33 100644 --- a/tests/neg/i6762b.check +++ b/tests/neg/i6762b.check @@ -1,5 +1,5 @@ --- [E007] Type Mismatch Error: tests/neg/i6762b.scala:4:39 ------------------------------------------------------------- +-- [E007] Type Mismatch Error: tests/neg/i6762b.scala:4:44 ------------------------------------------------------------- 4 |def f(word: String): Expr[G[String]] = word.toExpr // error - | ^^^^ + | ^^^^^^^^^^^ | Found: Expr[String] | Required: Expr[G[String]] diff --git a/tests/neg/i6779.check b/tests/neg/i6779.check index 0a34f2a47321..8f5055eee857 100644 --- a/tests/neg/i6779.check +++ b/tests/neg/i6779.check @@ -3,9 +3,9 @@ | ^^^^^^^^^^^^^^^^^^^^^^^^ | Found: F[T] | Required: F[G[T]] --- [E007] Type Mismatch Error: tests/neg/i6779.scala:11:27 ------------------------------------------------------------- +-- [E007] Type Mismatch Error: tests/neg/i6779.scala:11:29 ------------------------------------------------------------- 11 |def g2[T](x: T): F[G[T]] = x.f // error - | ^ + | ^^^ | Found: F[T] | Required: F[G[T]] -- [E007] Type Mismatch Error: tests/neg/i6779.scala:13:41 ------------------------------------------------------------- diff --git a/tests/run-macros/i10011/Macro_1.scala b/tests/run-macros/i10011/Macro_1.scala new file mode 100644 index 000000000000..38ca19989cc1 --- /dev/null +++ b/tests/run-macros/i10011/Macro_1.scala @@ -0,0 +1,8 @@ +import scala.quoted._ + +inline def printPos[T](inline expr: T): (Int, Int) = + ${ printPos('expr) } + +private def printPos[T](expr: Expr[T])(using QuoteContext): Expr[(Int, Int)] = + val pos = expr.unseal.pos + Expr((pos.start, pos.end)) diff --git a/tests/run-macros/i10011/Test_2.scala b/tests/run-macros/i10011/Test_2.scala new file mode 100644 index 000000000000..7b6ef74fe90a --- /dev/null +++ b/tests/run-macros/i10011/Test_2.scala @@ -0,0 +1,6 @@ + +extension [T](a: T) def foo: Any = ??? + +@main def Test = + val foo = printPos(Some(1).foo) + assert(foo == (79, 90))