Skip to content

Commit 972ae73

Browse files
authored
Merge pull request #10024 from dotty-staging/fix-10011
Fix #10011: Set missing span of extension selection
2 parents 8994a84 + 915fffa commit 972ae73

File tree

5 files changed

+19
-4
lines changed

5 files changed

+19
-4
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/neg/i6762b.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
-- [E007] Type Mismatch Error: tests/neg/i6762b.scala:4:39 -------------------------------------------------------------
1+
-- [E007] Type Mismatch Error: tests/neg/i6762b.scala:4:44 -------------------------------------------------------------
22
4 |def f(word: String): Expr[G[String]] = word.toExpr // error
3-
| ^^^^
3+
| ^^^^^^^^^^^
44
| Found: Expr[String]
55
| Required: Expr[G[String]]

tests/neg/i6779.check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
| ^^^^^^^^^^^^^^^^^^^^^^^^
44
| Found: F[T]
55
| Required: F[G[T]]
6-
-- [E007] Type Mismatch Error: tests/neg/i6779.scala:11:27 -------------------------------------------------------------
6+
-- [E007] Type Mismatch Error: tests/neg/i6779.scala:11:29 -------------------------------------------------------------
77
11 |def g2[T](x: T): F[G[T]] = x.f // error
8-
| ^
8+
| ^^^
99
| Found: F[T]
1010
| Required: F[G[T]]
1111
-- [E007] Type Mismatch Error: tests/neg/i6779.scala:13:41 -------------------------------------------------------------

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)