File tree Expand file tree Collapse file tree 3 files changed +15
-2
lines changed
compiler/src/dotty/tools/dotc/ast Expand file tree Collapse file tree 3 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -147,6 +147,11 @@ abstract class Positioned(implicit @constructorOnly src: SourceFile) extends Pro
147
147
}
148
148
}
149
149
150
+ /** A hook that can be overridden if overlap checking in `checkPos` should be
151
+ * disabled for this node.
152
+ */
153
+ def disableOverlapChecks = false
154
+
150
155
/** Check that all positioned items in this tree satisfy the following conditions:
151
156
* - Parent spans contain child spans
152
157
* - If item is a non-empty tree, it has a position
@@ -169,7 +174,7 @@ abstract class Positioned(implicit @constructorOnly src: SourceFile) extends Pro
169
174
s " position error: position not set for $tree # ${tree.uniqueId}" )
170
175
case _ =>
171
176
}
172
- if (nonOverlapping) {
177
+ if (nonOverlapping && ! disableOverlapChecks ) {
173
178
this match {
174
179
case _ : XMLBlock =>
175
180
// FIXME: Trees generated by the XML parser do not satisfy `checkPos`
Original file line number Diff line number Diff line change @@ -746,6 +746,10 @@ object Trees {
746
746
assert(tpt != genericEmptyTree)
747
747
def unforced : LazyTree = preRhs
748
748
protected def force (x : AnyRef ): Unit = preRhs = x
749
+
750
+ override def disableOverlapChecks = rawMods.is(Flags .Implied )
751
+ // disable order checks for implicit aliases since their given clause follows
752
+ // their for clause, but the two appear swapped in the DefDef.
749
753
}
750
754
751
755
class BackquotedDefDef [- T >: Untyped ] private [ast] (name : TermName , tparams : List [TypeDef [T ]],
@@ -783,6 +787,10 @@ object Trees {
783
787
784
788
def parents : List [Tree [T ]] = parentsOrDerived // overridden by DerivingTemplate
785
789
def derived : List [untpd.Tree ] = Nil // overridden by DerivingTemplate
790
+
791
+ override def disableOverlapChecks = true
792
+ // disable overlaps checks since templates of instance definitions have their
793
+ // `given` clause come last, which means that the constructor span can contain the parent spans.
786
794
}
787
795
788
796
Original file line number Diff line number Diff line change @@ -132,7 +132,7 @@ object Instances extends Common {
132
132
println(the[D [Int ]])
133
133
}
134
134
locally {
135
- implied given Context for D [Int ]
135
+ implied for D [Int ] given Context
136
136
println(the[D [Int ]])
137
137
}
138
138
}
You can’t perform that action at this time.
0 commit comments