File tree Expand file tree Collapse file tree 3 files changed +30
-2
lines changed
compiler/src/dotty/tools/dotc/ast
tests/run-with-compiler/i5715 Expand file tree Collapse file tree 3 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -1018,9 +1018,9 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
10181018 */
10191019 class MapToUnderlying extends TreeMap {
10201020 override def transform (tree : Tree )(implicit ctx : Context ): Tree = tree match {
1021- case tree : Ident if tree.symbol.exists && ! tree.symbol.owner.isClass && skipLocal(tree.symbol) =>
1021+ case tree : Ident if tree.symbol.exists && ! tree.symbol.owner.isClass && ! tree.symbol.isAnonymousFunction && skipLocal(tree.symbol) =>
10221022 tree.symbol.defTree match {
1023- case defTree : ValOrDefDef => transform(defTree.rhs)
1023+ case defTree : ValOrDefDef if ! defTree.rhs.isEmpty => transform(defTree.rhs)
10241024 case _ => tree
10251025 }
10261026 case Inlined (_, _, arg) => transform(arg)
Original file line number Diff line number Diff line change 1+ import scala .quoted ._
2+ import scala .tasty ._
3+
4+ object scalatest {
5+
6+ inline def assert (condition : => Boolean ): Unit = $ { assertImpl(' condition , ' {" " }) }
7+
8+ def assertImpl (cond : Expr [Boolean ], clue : Expr [Any ])(implicit refl : Reflection ): Expr [Unit ] = {
9+ import refl ._
10+
11+ cond.unseal.underlyingArgument match {
12+ case app @ Term .Apply (sel @ Term .Select (lhs, op), rhs :: Nil ) =>
13+ val Term .IsSelect (select) = sel
14+ val cond = Term .Apply (Term .Select .copy(select)(lhs, " exists" ), rhs :: Nil ).seal[Boolean ]
15+ ' { scala.Predef .assert($cond) }
16+ case _ =>
17+ ' { scala.Predef .assert($cond) }
18+ }
19+ }
20+ }
Original file line number Diff line number Diff line change 1+ object Test {
2+ import scalatest ._
3+
4+ def main (args : Array [String ]): Unit = {
5+ val l = List (3 , 4 )
6+ assert(l.exists(_ == 3 ))
7+ }
8+ }
You can’t perform that action at this time.
0 commit comments