Skip to content

Commit deebffc

Browse files
committed
Fix #10011: Set missing span of extension selection
1 parent f6c169f commit deebffc

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,7 @@ class Typer extends Namer
556556

557557
def typeSelectOnTerm(using Context): Tree =
558558
typedSelect(tree, pt, typedExpr(tree.qualifier, selectionProto(tree.name, pt, this)))
559+
.withSpan(tree.span)
559560
.computeNullable()
560561

561562
def typeSelectOnType(qual: untpd.Tree)(using Context) =

tests/run-macros/i10011/Macro_1.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import scala.quoted._
2+
3+
inline def printPos[T](inline expr: T): (Int, Int) =
4+
${ printPos('expr) }
5+
6+
private def printPos[T](expr: Expr[T])(using QuoteContext): Expr[(Int, Int)] =
7+
val pos = expr.unseal.pos
8+
Expr((pos.start, pos.end))

tests/run-macros/i10011/Test_2.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
extension [T](a: T) def foo: Any = ???
3+
4+
@main def Test =
5+
val foo = printPos(Some(1).foo)
6+
assert(foo == (79, 90))

0 commit comments

Comments
 (0)