File tree 3 files changed +6
-4
lines changed
compiler/src/dotty/tools/dotc
3 files changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -820,13 +820,15 @@ object Trees {
820
820
821
821
class EmptyTree [T >: Untyped ] extends Thicket (Nil )(NoSource ) {
822
822
// assert(uniqueId != 1492)
823
+ override def withSpan (span : Span ) = throw new AssertionError (" Cannot change span of EmptyTree" )
823
824
}
824
825
825
826
class EmptyValDef [T >: Untyped ] extends ValDef [T ](
826
827
nme.WILDCARD , genericEmptyTree[T ], genericEmptyTree[T ])(NoSource ) with WithoutTypeOrPos [T ] {
827
828
myTpe = NoType .asInstanceOf [T ]
828
- override def isEmpty : Boolean = true
829
829
setMods(untpd.Modifiers (PrivateLocal ))
830
+ override def isEmpty : Boolean = true
831
+ override def withSpan (span : Span ) = throw new AssertionError (" Cannot change span of EmptyValDef" )
830
832
}
831
833
832
834
@ sharable val theEmptyTree : EmptyTree [Type ] = new EmptyTree [Type ]
Original file line number Diff line number Diff line change @@ -2419,7 +2419,7 @@ object Parsers {
2419
2419
makeTypeDef(typeBounds())
2420
2420
case _ =>
2421
2421
syntaxErrorOrIncomplete(ExpectedTypeBoundOrEquals (in.token))
2422
- EmptyTree
2422
+ return EmptyTree // return to avoid setting the span to EmptyTree
2423
2423
}
2424
2424
}
2425
2425
}
Original file line number Diff line number Diff line change @@ -144,8 +144,8 @@ class Staging extends MacroTransform {
144
144
else if (enclosingInlineds.nonEmpty) { // level 0 in an inlined call
145
145
val spliceCtx = ctx.outer // drop the last `inlineContext`
146
146
val pos : SourcePosition = spliceCtx.source.atSpan(enclosingInlineds.head.span)
147
- val evaluatedSplice = Splicer .splice(splice.qualifier, pos, macroClassLoader)(spliceCtx).withSpan(splice.span)
148
- if (ctx.reporter.hasErrors) splice else transform(evaluatedSplice)
147
+ val evaluatedSplice = Splicer .splice(splice.qualifier, pos, macroClassLoader)(spliceCtx)
148
+ if (ctx.reporter.hasErrors) splice else transform(evaluatedSplice.withSpan(splice.span) )
149
149
}
150
150
else if (! ctx.owner.isInlineMethod) { // level 0 outside an inline method
151
151
ctx.error(i " splice outside quotes or inline method " , splice.sourcePos)
You can’t perform that action at this time.
0 commit comments