Skip to content

Commit 60c4bf8

Browse files
Merge pull request #5953 from dotty-staging/add-missing-pattern-positions
Add missing position to pattern constructors
2 parents 715e221 + c2fd8d9 commit 60c4bf8

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

compiler/src/dotty/tools/dotc/tastyreflect/PatternOpsImpl.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import dotty.tools.dotc.core.Contexts
55
import dotty.tools.dotc.core.Decorators._
66
import dotty.tools.dotc.core.StdNames.nme
77

8-
trait PatternOpsImpl extends scala.tasty.reflect.PatternOps with CoreImpl {
8+
trait PatternOpsImpl extends scala.tasty.reflect.PatternOps with RootPositionImpl {
99

1010
def ValueDeco(value: Value): Pattern.ValueAPI = new Pattern.ValueAPI {
1111
def value(implicit ctx: Context): Term = value
@@ -74,7 +74,7 @@ trait PatternOpsImpl extends scala.tasty.reflect.PatternOps with CoreImpl {
7474
object Bind extends BindModule {
7575

7676
def copy(original: Bind)(name: String, pattern: Pattern)(implicit ctx: Context): Bind =
77-
tpd.cpy.Bind(original)(name.toTermName, pattern)
77+
withDefaultPos(ctx => tpd.cpy.Bind(original)(name.toTermName, pattern)(ctx))
7878

7979
def unapply(pattern: Pattern)(implicit ctx: Context): Option[(String, Pattern)] = pattern match {
8080
case IsBind(pattern) => Some((pattern.name.toString, pattern.body))
@@ -93,7 +93,7 @@ trait PatternOpsImpl extends scala.tasty.reflect.PatternOps with CoreImpl {
9393
object Unapply extends UnapplyModule {
9494

9595
def copy(original: Unapply)(fun: Term, implicits: List[Term], patterns: List[Pattern])(implicit ctx: Context): Unapply =
96-
tpd.cpy.UnApply(original)(fun, implicits, patterns)
96+
withDefaultPos(ctx => tpd.cpy.UnApply(original)(fun, implicits, patterns)(ctx))
9797

9898
def unapply(x: Pattern)(implicit ctx: Context): Option[(Term, List[Term], List[Pattern])] = x match {
9999
case IsUnapply(x) => Some((x.fun, x.implicits, UnapplyDeco(x).patterns))
@@ -110,7 +110,7 @@ trait PatternOpsImpl extends scala.tasty.reflect.PatternOps with CoreImpl {
110110

111111
object Alternatives extends AlternativesModule {
112112
def apply(patterns: List[Pattern])(implicit ctx: Context): Alternatives =
113-
tpd.Alternative(patterns)
113+
withDefaultPos(ctx => tpd.Alternative(patterns)(ctx))
114114

115115
def copy(original: Alternatives)(patterns: List[Pattern])(implicit ctx: Context): Alternatives =
116116
tpd.cpy.Alternative(original)(patterns)
@@ -131,10 +131,10 @@ trait PatternOpsImpl extends scala.tasty.reflect.PatternOps with CoreImpl {
131131

132132
object TypeTest extends TypeTestModule {
133133
def apply(tpt: TypeTree)(implicit ctx: Context): TypeTest =
134-
tpd.Typed(untpd.Ident(nme.WILDCARD).withType(tpt.tpe), tpt)
134+
withDefaultPos(ctx => tpd.Typed(untpd.Ident(nme.WILDCARD)(ctx.source).withType(tpt.tpe)(ctx), tpt)(ctx))
135135

136136
def copy(original: TypeTest)(tpt: TypeTree)(implicit ctx: Context): TypeTest =
137-
tpd.cpy.Typed(original)(untpd.Ident(nme.WILDCARD).withType(tpt.tpe), tpt)
137+
tpd.cpy.Typed(original)(untpd.Ident(nme.WILDCARD).withSpan(original.span).withType(tpt.tpe), tpt)
138138

139139
def unapply(x: Pattern)(implicit ctx: Context): Option[TypeTree] = x match {
140140
case Trees.Typed(Trees.UnApply(_, _, _), _) => None

0 commit comments

Comments
 (0)