Skip to content

Commit

Permalink
Merge pull request #6541 from dotty-staging/fix-#6535
Browse files Browse the repository at this point in the history
Fix #6535: Add missing span
  • Loading branch information
liufengyun authored May 21, 2019
2 parents 2b6c757 + a633601 commit 3bcaf1d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/transform/PostTyper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
case pkg: PackageClassDenotation =>
val pobj = pkg.packageObjFor(tree.symbol)
if (pobj.exists)
return transformSelect(cpy.Select(tree)(qual.select(pobj), tree.name), targs)
return transformSelect(cpy.Select(tree)(qual.select(pobj).withSpan(qual.span), tree.name), targs)
case _ =>
}
val tree1 = super.transform(tree)
Expand Down
29 changes: 29 additions & 0 deletions tests/pos-macros/i6535/Macro_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import scala.quoted._
import scala.tasty._

object scalatest {

inline def assert(condition: => Boolean): Unit = ${ assertImpl('condition) }

def assertImpl(cond: Expr[Boolean])(implicit refl: Reflection): Expr[Unit] = {
import refl._
import util._

cond.unseal.underlyingArgument match {
case t @ Apply(Select(lhs, op), rhs :: Nil) =>
let(lhs) { left =>
let(rhs) { right =>
val app = Select.overloaded(left, op, Nil, right :: Nil)
let(app) { result =>
val l = left.seal
val r = right.seal
val b = result.seal.cast[Boolean]
val code = '{ scala.Predef.assert($b) }
code.unseal
}
}
}.seal.cast[Unit]
}
}

}
9 changes: 9 additions & 0 deletions tests/pos-macros/i6535/Test_2.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
object Test {
import scalatest._

def neverRuns(f: => Unit): Boolean = true

def main(args: Array[String]): Unit = {
assert(this.neverRuns(sys.error("Sad times 1")))
}
}

0 comments on commit 3bcaf1d

Please sign in to comment.