Skip to content

Commit 0b432ed

Browse files
committed
Fix missing position exception
Otherwise, the compile crashes when there are macros. Encountered in testing ScalaTest macros.
1 parent 0dc2172 commit 0b432ed

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
898898
def cast(tp: Type)(implicit ctx: Context): Tree = {
899899
assert(tp.isValueType, i"bad cast: $tree.asInstanceOf[$tp]")
900900
tree.select(if (ctx.erasedTypes) defn.Any_asInstanceOf else defn.Any_typeCast)
901-
.appliedToType(tp)
901+
.appliedToType(tp).withSpan(tree.span)
902902
}
903903

904904
/** cast `tree` to `tp` (or its box/unbox/cast equivalent when after
@@ -908,7 +908,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
908908
def ensureConforms(tp: Type)(implicit ctx: Context): Tree =
909909
if (tree.tpe <:< tp) tree
910910
else if (!ctx.erasedTypes) cast(tp)
911-
else Erasure.Boxing.adaptToType(tree, tp)
911+
else Erasure.Boxing.adaptToType(tree, tp).withSpan(tree.span)
912912

913913
/** `tree ne null` (might need a cast to be type correct) */
914914
def testNotNull(implicit ctx: Context): Tree = {
@@ -918,7 +918,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
918918
Typed(tree, TypeTree(defn.AnyRefType))
919919
}
920920
else tree.ensureConforms(defn.ObjectType)
921-
receiver.select(defn.Object_ne).appliedTo(nullLiteral)
921+
receiver.select(defn.Object_ne).appliedTo(nullLiteral).withSpan(tree.span)
922922
}
923923

924924
/** If inititializer tree is `_', the default value of its type,
@@ -929,11 +929,11 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
929929

930930
/** `this && that`, for boolean trees `this`, `that` */
931931
def and(that: Tree)(implicit ctx: Context): Tree =
932-
tree.select(defn.Boolean_&&).appliedTo(that)
932+
tree.select(defn.Boolean_&&).appliedTo(that).withSpan(tree.span)
933933

934934
/** `this || that`, for boolean trees `this`, `that` */
935935
def or(that: Tree)(implicit ctx: Context): Tree =
936-
tree.select(defn.Boolean_||).appliedTo(that)
936+
tree.select(defn.Boolean_||).appliedTo(that).withSpan(tree.span)
937937

938938
/** The translation of `tree = rhs`.
939939
* This is either the tree as an assignment, or a setter call.

0 commit comments

Comments
 (0)