Skip to content

Commit cb2e767

Browse files
committed
Synthetic applies created during infix op desugaring should have original span
1 parent 0ae343f commit cb2e767

File tree

7 files changed

+21
-20
lines changed

7 files changed

+21
-20
lines changed

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -1655,7 +1655,7 @@ object desugar {
16551655
val sel = Select(fn, op.name).withSpan(selectPos)
16561656
if (left.sourcePos.endLine < op.sourcePos.startLine)
16571657
sel.pushAttachment(MultiLineInfix, ())
1658-
arg match
1658+
val apply = arg match
16591659
case Parens(arg) =>
16601660
Apply(sel, assignToNamedArg(arg) :: Nil)
16611661
case Tuple(args) if args.exists(_.isInstanceOf[Assign]) =>
@@ -1664,6 +1664,7 @@ object desugar {
16641664
Apply(sel, arg :: Nil).setApplyKind(ApplyKind.InfixTuple)
16651665
case _ =>
16661666
Apply(sel, arg :: Nil)
1667+
apply.withSpan(Span(left.span.start, right.span.end, point = op.span.start))
16671668

16681669
if op.name.isRightAssocOperatorName then
16691670
makeOp(right, left, Span(op.span.start, right.span.end))

tests/explicit-nulls/neg/byname-nullables1.check

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
-- Error: tests/explicit-nulls/neg/byname-nullables1.scala:10:6 --------------------------------------------------------
1+
-- Error: tests/explicit-nulls/neg/byname-nullables1.scala:10:12 -------------------------------------------------------
22
10 | f(x.fld != null) // error
33
| ^^^^^^^^^^^^^
44
| This argument was typed using flow assumptions about mutable variables

tests/neg-custom-args/captures/sepchecks2.check

+12-12
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@
44
| Separation failure: Illegal access to {c} which is hidden by the previous definition
55
| of value xs with type List[box () => Unit].
66
| This type hides capabilities {c}
7-
-- Error: tests/neg-custom-args/captures/sepchecks2.scala:13:7 ---------------------------------------------------------
7+
-- Error: tests/neg-custom-args/captures/sepchecks2.scala:13:25 --------------------------------------------------------
88
13 | foo((() => println(c)) :: Nil, c) // error
9-
| ^^^^^^^^^^^^^^^^^^^^^^^^
10-
| Separation failure: argument of type List[box () ->{c} Unit]
11-
| to method foo: (xs: List[box () => Unit], y: Object^): Nothing
12-
| corresponds to capture-polymorphic formal parameter xs of type List[box () => Unit]
13-
| and hides capabilities {c}.
14-
| Some of these overlap with the captures of the second argument with type (c : Object^).
9+
| ^^^^^^^^^^^^^^^^^^^^^^^^^
10+
| Separation failure: argument of type List[box () ->{c} Unit]
11+
| to method foo: (xs: List[box () => Unit], y: Object^): Nothing
12+
| corresponds to capture-polymorphic formal parameter xs of type List[box () => Unit]
13+
| and hides capabilities {c}.
14+
| Some of these overlap with the captures of the second argument with type (c : Object^).
1515
|
16-
| Hidden set of current argument : {c}
17-
| Hidden footprint of current argument : {c}
18-
| Capture set of second argument : {c}
19-
| Footprint set of second argument : {c}
20-
| The two sets overlap at : {c}
16+
| Hidden set of current argument : {c}
17+
| Hidden footprint of current argument : {c}
18+
| Capture set of second argument : {c}
19+
| Footprint set of second argument : {c}
20+
| The two sets overlap at : {c}
2121
-- Error: tests/neg-custom-args/captures/sepchecks2.scala:14:10 --------------------------------------------------------
2222
14 | val x1: (Object^, Object^) = (c, c) // error
2323
| ^^^^^^^^^^^^^^^^^^

tests/run/typeCheckErrors.check

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
List(Error(value check is not a member of Unit,compileError("1" * 2).check(""),22,Typer), Error(argument to compileError must be a statically known String but was: augmentString("1") * 2,compileError("1" * 2).check(""),13,Typer))
1+
List(Error(value check is not a member of Unit,compileError("1" * 2).check(""),22,Typer), Error(argument to compileError must be a statically known String but was: augmentString("1") * 2,compileError("1" * 2).check(""),17,Typer))

tests/warn/21557.check

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
-- [E190] Potential Issue Warning: tests/warn/21557.scala:9:16 ---------------------------------------------------------
1+
-- [E190] Potential Issue Warning: tests/warn/21557.scala:9:18 ---------------------------------------------------------
22
9 | val x: Unit = 1 + 1 // warn
33
| ^^^^^
44
| Discarded non-Unit value of type Int. Add `: Unit` to discard silently.
55
|
66
| longer explanation available when compiling with `-explain`
7-
-- [E176] Potential Issue Warning: tests/warn/21557.scala:10:2 ---------------------------------------------------------
7+
-- [E176] Potential Issue Warning: tests/warn/21557.scala:10:4 ---------------------------------------------------------
88
10 | 1 + 1 // warn
99
| ^^^^^
1010
| unused value of type (2 : Int)

tests/warn/nonunit-statement.check

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
30 | copy() // warn
1515
| ^^^^^^
1616
| unused value of type K
17-
-- [E176] Potential Issue Warning: tests/warn/nonunit-statement.scala:37:2 ---------------------------------------------
17+
-- [E176] Potential Issue Warning: tests/warn/nonunit-statement.scala:37:5 ---------------------------------------------
1818
37 | 27 +: xs // warn
1919
| ^^^^^^^^
2020
| unused value of type List[Int]
@@ -63,7 +63,7 @@
6363
101 | println("false")
6464
102 | j
6565
103 | }
66-
-- [E176] Potential Issue Warning: tests/warn/nonunit-statement.scala:116:4 --------------------------------------------
66+
-- [E176] Potential Issue Warning: tests/warn/nonunit-statement.scala:116:8 --------------------------------------------
6767
116 | set += a // warn because cannot know whether the `set` was supposed to be consumed or assigned
6868
| ^^^^^^^^
6969
| unused value of type scala.collection.mutable.LinkedHashSet[A]

tests/warn/warn-value-discard.check

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
39 | mutable.Set.empty[String].subtractOne("") // warn
77
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
88
| discarded non-Unit value of type scala.collection.mutable.Set[String]. Add `: Unit` to discard silently.
9-
-- [E175] Potential Issue Warning: tests/warn/warn-value-discard.scala:59:4 --------------------------------------------
9+
-- [E175] Potential Issue Warning: tests/warn/warn-value-discard.scala:59:30 -------------------------------------------
1010
59 | mutable.Set.empty[String] += "" // warn
1111
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1212
| discarded non-Unit value of type scala.collection.mutable.Set[String]. Add `: Unit` to discard silently.

0 commit comments

Comments
 (0)