Skip to content

Fix #6535: Add missing span #6541

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")))
}
}