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
147147 }
148148 }
149149
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+
150155 /** Check that all positioned items in this tree satisfy the following conditions:
151156 * - Parent spans contain child spans
152157 * - If item is a non-empty tree, it has a position
@@ -169,7 +174,7 @@ abstract class Positioned(implicit @constructorOnly src: SourceFile) extends Pro
169174 s " position error: position not set for $tree # ${tree.uniqueId}" )
170175 case _ =>
171176 }
172- if (nonOverlapping) {
177+ if (nonOverlapping && ! disableOverlapChecks ) {
173178 this match {
174179 case _ : XMLBlock =>
175180 // 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 {
746746 assert(tpt != genericEmptyTree)
747747 def unforced : LazyTree = preRhs
748748 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.
749753 }
750754
751755 class BackquotedDefDef [- T >: Untyped ] private [ast] (name : TermName , tparams : List [TypeDef [T ]],
@@ -783,6 +787,10 @@ object Trees {
783787
784788 def parents : List [Tree [T ]] = parentsOrDerived // overridden by DerivingTemplate
785789 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.
786794 }
787795
788796
Original file line number Diff line number Diff line change @@ -132,7 +132,7 @@ object Instances extends Common {
132132 println(the[D [Int ]])
133133 }
134134 locally {
135- implied given Context for D [Int ]
135+ implied for D [Int ] given Context
136136 println(the[D [Int ]])
137137 }
138138 }
You can’t perform that action at this time.
0 commit comments