Skip to content

Commit 31e9464

Browse files
alternative position correction
1 parent c3432ff commit 31e9464

File tree

4 files changed

+19
-24
lines changed

4 files changed

+19
-24
lines changed

compiler/src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1665,7 +1665,7 @@ object desugar {
16651665
case t => t
16661666
}
16671667
// This is a deliberate departure from scalac, where StringContext is not rooted (See #4732)
1668-
Apply(Select(Apply(scalaDot(nme.StringContext).withSpan(tree.span), strs), id), elems)
1668+
Apply(Select(Apply(scalaDot(nme.StringContext), strs), id).withSpan(tree.span), elems)
16691669
case PostfixOp(t, op) =>
16701670
if ((ctx.mode is Mode.Type) && !isBackquoted(op) && op.name == tpnme.raw.STAR) {
16711671
val seqType = if (ctx.compilationUnit.isJava) defn.ArrayType else defn.SeqType

tests/semanticdb/expect/Givens.expect.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ package b
44
object Givens/*<-a::b::Givens.*/:
55

66
extension on [A](any: A):
7-
def /*<-a::b::Givens.extension_sayHello_A.*//*<-a::b::Givens.extension_sayHello_A.sayHello().[A]*//*<-a::b::Givens.extension_sayHello_A.sayHello().(any)*//*->a::b::Givens.extension_sayHello_A.sayHello().[A]*/sayHello/*<-a::b::Givens.extension_sayHello_A.sayHello().*/ = s"Hello, I am $any"/*->scala::StringContext.*//*->a::b::Givens.extension_sayHello_A.sayHello().(any)*//*->scala::StringContext#s().*//*->scala::StringContext.apply().*/
7+
def /*<-a::b::Givens.extension_sayHello_A.*//*<-a::b::Givens.extension_sayHello_A.sayHello().[A]*//*<-a::b::Givens.extension_sayHello_A.sayHello().(any)*//*->a::b::Givens.extension_sayHello_A.sayHello().[A]*/sayHello/*<-a::b::Givens.extension_sayHello_A.sayHello().*/ = s"/*->scala::StringContext.apply().*/Hello, I am $any/*->a::b::Givens.extension_sayHello_A.sayHello().(any)*/"/*->scala::StringContext#s().*/
88

99
extension on [B](any: B):
10-
def sa/*<-a::b::Givens.extension_sayGoodbye_B.*//*<-a::b::Givens.extension_sayGoodbye_B.sayGoodbye().[B]*//*<-a::b::Givens.extension_sayGoodbye_B.saySoLong().[B]*//*<-a::b::Givens.extension_sayGoodbye_B.sayGoodbye().(any)*//*<-a::b::Givens.extension_sayGoodbye_B.saySoLong().(any)*//*->a::b::Givens.extension_sayGoodbye_B.sayGoodbye().[B]*//*->a::b::Givens.extension_sayGoodbye_B.saySoLong().[B]*/yGoodbye/*<-a::b::Givens.extension_sayGoodbye_B.sayGoodbye().*/ = s"Goodbye, from $any"/*->scala::StringContext.*//*->a::b::Givens.extension_sayGoodbye_B.sayGoodbye().(any)*//*->scala::StringContext#s().*//*->scala::StringContext.apply().*/
11-
def saySoLong/*<-a::b::Givens.extension_sayGoodbye_B.saySoLong().*/ = s"So Long, from $any"/*->scala::StringContext.*//*->a::b::Givens.extension_sayGoodbye_B.saySoLong().(any)*//*->scala::StringContext#s().*//*->scala::StringContext.apply().*/
10+
def sa/*<-a::b::Givens.extension_sayGoodbye_B.*//*<-a::b::Givens.extension_sayGoodbye_B.sayGoodbye().[B]*//*<-a::b::Givens.extension_sayGoodbye_B.saySoLong().[B]*//*<-a::b::Givens.extension_sayGoodbye_B.sayGoodbye().(any)*//*<-a::b::Givens.extension_sayGoodbye_B.saySoLong().(any)*//*->a::b::Givens.extension_sayGoodbye_B.sayGoodbye().[B]*//*->a::b::Givens.extension_sayGoodbye_B.saySoLong().[B]*/yGoodbye/*<-a::b::Givens.extension_sayGoodbye_B.sayGoodbye().*/ = s"/*->scala::StringContext.apply().*/Goodbye, from $any/*->a::b::Givens.extension_sayGoodbye_B.sayGoodbye().(any)*/"/*->scala::StringContext#s().*/
11+
def saySoLong/*<-a::b::Givens.extension_sayGoodbye_B.saySoLong().*/ = s"/*->scala::StringContext.apply().*/So Long, from $any/*->a::b::Givens.extension_sayGoodbye_B.saySoLong().(any)*/"/*->scala::StringContext#s().*/
1212

1313
val hello1/*<-a::b::Givens.hello1.*/ = /*->a::b::Givens.extension_sayHello_A.sayHello().*/1.sayHello
1414
val goodbye1/*<-a::b::Givens.goodbye1.*/ = /*->a::b::Givens.extension_sayGoodbye_B.sayGoodbye().*/1.sayGoodbye

tests/semanticdb/expect/ImplicitConversion.expect.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ class ImplicitConversion/*<-example::ImplicitConversion#*/ {
2121
val x/*<-example::ImplicitConversion#x.*/: Int/*->scala::Int#*/ = /*->example::ImplicitConversion#string2Number().*/message/*->example::ImplicitConversion#message.*/
2222

2323
// interpolators
24-
s"Hello $message/*->example::ImplicitConversion#message.*/ $number"/*->scala::StringContext.*//*->example::ImplicitConversion#number.*//*->scala::StringContext#s().*//*->scala::StringContext.apply().*/
25-
/*->scala::Predef.augmentString().*/s"""Hello
24+
s"/*->scala::StringContext.apply().*/Hello $message/*->example::ImplicitConversion#message.*/ $number/*->example::ImplicitConversion#number.*/"/*->scala::StringContext#s().*/
25+
/*->scala::Predef.augmentString().*/s"""/*->scala::StringContext.apply().*/Hello
2626
|$message/*->example::ImplicitConversion#message.*/
27-
|$number"""/*->scala::StringContext.*//*->example::ImplicitConversion#number.*//*->scala::StringContext#s().*//*->scala::StringContext.apply().*/.stripMargin/*->scala::collection::StringOps#stripMargin(+1).*/
27+
|$number/*->example::ImplicitConversion#number.*/"""/*->scala::StringContext#s().*/.stripMargin/*->scala::collection::StringOps#stripMargin(+1).*/
2828

2929
val a/*<-example::ImplicitConversion#a.*/: Int/*->scala::Int#*/ = /*->scala::Char.char2int().*/char/*->example::ImplicitConversion#char.*/
3030
val b/*<-example::ImplicitConversion#b.*/: Long/*->scala::Long#*/ = /*->scala::Char.char2long().*/char/*->example::ImplicitConversion#char.*/

tests/semanticdb/metac.expect

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1269,7 +1269,7 @@ Uri => Givens.scala
12691269
Text => empty
12701270
Language => Scala
12711271
Symbols => 31 entries
1272-
Occurrences => 75 entries
1272+
Occurrences => 72 entries
12731273

12741274
Symbols:
12751275
a/b/Givens. => final object Givens
@@ -1313,10 +1313,9 @@ Occurrences:
13131313
[5:19..5:22): any <- a/b/Givens.extension_sayHello_A.sayHello().(any)
13141314
[5:24..5:25): A -> a/b/Givens.extension_sayHello_A.sayHello().[A]
13151315
[6:8..6:16): sayHello <- a/b/Givens.extension_sayHello_A.sayHello().
1316-
[6:25..6:38): o, I am $any" -> scala/StringContext.
1316+
[6:21..6:21): -> scala/StringContext.apply().
13171317
[6:34..6:37): any -> a/b/Givens.extension_sayHello_A.sayHello().(any)
1318-
[6:38..6:38): -> scala/StringContext#s().
1319-
[6:38..6:38): -> scala/StringContext.apply().
1318+
[6:37..6:38): " -> scala/StringContext#s().
13201319
[8:16..9:10): <- a/b/Givens.extension_sayGoodbye_B.
13211320
[8:16..8:17): B <- a/b/Givens.extension_sayGoodbye_B.sayGoodbye().[B]
13221321
[8:16..8:17): B <- a/b/Givens.extension_sayGoodbye_B.saySoLong().[B]
@@ -1325,15 +1324,13 @@ Occurrences:
13251324
[8:24..8:25): B -> a/b/Givens.extension_sayGoodbye_B.sayGoodbye().[B]
13261325
[8:24..8:25): B -> a/b/Givens.extension_sayGoodbye_B.saySoLong().[B]
13271326
[9:8..9:18): sayGoodbye <- a/b/Givens.extension_sayGoodbye_B.sayGoodbye().
1328-
[9:29..9:42): e, from $any" -> scala/StringContext.
1327+
[9:23..9:23): -> scala/StringContext.apply().
13291328
[9:38..9:41): any -> a/b/Givens.extension_sayGoodbye_B.sayGoodbye().(any)
1330-
[9:42..9:42): -> scala/StringContext#s().
1331-
[9:42..9:42): -> scala/StringContext.apply().
1329+
[9:41..9:42): " -> scala/StringContext#s().
13321330
[10:8..10:17): saySoLong <- a/b/Givens.extension_sayGoodbye_B.saySoLong().
1333-
[10:28..10:41): g, from $any" -> scala/StringContext.
1331+
[10:22..10:22): -> scala/StringContext.apply().
13341332
[10:37..10:40): any -> a/b/Givens.extension_sayGoodbye_B.saySoLong().(any)
1335-
[10:41..10:41): -> scala/StringContext#s().
1336-
[10:41..10:41): -> scala/StringContext.apply().
1333+
[10:40..10:41): " -> scala/StringContext#s().
13371334
[12:6..12:12): hello1 <- a/b/Givens.hello1.
13381335
[12:15..12:15): -> a/b/Givens.extension_sayHello_A.sayHello().
13391336
[13:6..13:14): goodbye1 <- a/b/Givens.goodbye1.
@@ -1390,7 +1387,7 @@ Uri => ImplicitConversion.scala
13901387
Text => empty
13911388
Language => Scala
13921389
Symbols => 23 entries
1393-
Occurrences => 64 entries
1390+
Occurrences => 62 entries
13941391

13951392
Symbols:
13961393
example/ImplicitConversion# => class ImplicitConversion
@@ -1445,17 +1442,15 @@ Occurrences:
14451442
[20:9..20:12): Int -> scala/Int#
14461443
[20:15..20:15): -> example/ImplicitConversion#string2Number().
14471444
[20:15..20:22): message -> example/ImplicitConversion#message.
1445+
[23:4..23:4): -> scala/StringContext.apply().
14481446
[23:11..23:18): message -> example/ImplicitConversion#message.
1449-
[23:14..23:27): sage $number" -> scala/StringContext.
14501447
[23:20..23:26): number -> example/ImplicitConversion#number.
1451-
[23:27..23:27): -> scala/StringContext#s().
1452-
[23:27..23:27): -> scala/StringContext.apply().
1448+
[23:26..23:27): " -> scala/StringContext#s().
14531449
[24:2..24:2): -> scala/Predef.augmentString().
1450+
[24:6..24:6): -> scala/StringContext.apply().
14541451
[25:7..25:14): message -> example/ImplicitConversion#message.
1455-
[26:3..26:16): |$number""" -> scala/StringContext.
14561452
[26:7..26:13): number -> example/ImplicitConversion#number.
1457-
[26:16..26:16): -> scala/StringContext#s().
1458-
[26:16..26:16): -> scala/StringContext.apply().
1453+
[26:15..26:16): " -> scala/StringContext#s().
14591454
[26:17..26:28): stripMargin -> scala/collection/StringOps#stripMargin(+1).
14601455
[28:6..28:7): a <- example/ImplicitConversion#a.
14611456
[28:9..28:12): Int -> scala/Int#

0 commit comments

Comments
 (0)