Skip to content

Commit b892b31

Browse files
committed
Synthetic applies created during infix op desugaring should have original span
1 parent 91985db commit b892b31

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -1656,7 +1656,7 @@ object desugar {
16561656
val sel = Select(fn, op.name).withSpan(selectPos)
16571657
if (left.sourcePos.endLine < op.sourcePos.startLine)
16581658
sel.pushAttachment(MultiLineInfix, ())
1659-
arg match
1659+
val apply = arg match
16601660
case Parens(arg) =>
16611661
Apply(sel, assignToNamedArg(arg) :: Nil)
16621662
case Tuple(args) if args.exists(_.isInstanceOf[Assign]) =>
@@ -1665,6 +1665,7 @@ object desugar {
16651665
Apply(sel, arg :: Nil).setApplyKind(ApplyKind.InfixTuple)
16661666
case _ =>
16671667
Apply(sel, arg :: Nil)
1668+
apply.withSpan(apply.span.union(arg.span))
16681669

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

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

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/reaches.scala:22:11 --------------------------------------
22
22 | cur = (() => f.write()) :: Nil // error
3-
| ^^^^^^^^^^^^^^^^^^^^^^^
4-
| Found: List[box () ->{f} Unit]
5-
| Required: List[box () ->{xs*} Unit]
3+
| ^^^^^^^^^^^^^^^^^^^^^^^^
4+
| Found: List[box () ->{f} Unit]
5+
| Required: List[box () ->{xs*} Unit]
66
|
77
| longer explanation available when compiling with `-explain`
88
-- [E007] Type Mismatch Error: tests/neg-custom-args/captures/reaches.scala:33:7 ---------------------------------------
99
33 | (() => f.write()) :: Nil // error
10-
| ^^^^^^^^^^^^^^^^^^^^^^^
11-
| Found: List[box () ->{f} Unit]
12-
| Required: box List[box () ->{xs*} Unit]^?
10+
| ^^^^^^^^^^^^^^^^^^^^^^^^
11+
| Found: List[box () ->{f} Unit]
12+
| Required: box List[box () ->{xs*} Unit]^?
1313
|
14-
| Note that reference (f : File^), defined in method $anonfun
15-
| cannot be included in outer capture set {xs*} of value cur
14+
| Note that reference (f : File^), defined in method $anonfun
15+
| cannot be included in outer capture set {xs*} of value cur
1616
|
1717
| longer explanation available when compiling with `-explain`
1818
-- Error: tests/neg-custom-args/captures/reaches.scala:36:6 ------------------------------------------------------------

0 commit comments

Comments
 (0)