Skip to content

Commit 8220305

Browse files
committed
Simplify: drop more stuff in dropNoEffects.
1 parent d09dbd6 commit 8220305

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

compiler/src/dotty/tools/dotc/transform/linker/Analysis.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import core.Contexts._
77
import core.NameOps._
88
import core.StdNames._
99
import core.Symbols._
10+
import dotty.tools.dotc.core.Flags
1011

1112
object Analysis {
1213
import tpd._
@@ -35,6 +36,8 @@ object Analysis {
3536
"scala.Some"
3637
)
3738

39+
private val moduleWhiteList = constructorWhiteList.map(x => x + "$")
40+
3841
private val methodsWhiteList = List(
3942
"java.lang.Math.min",
4043
"java.lang.Math.max",
@@ -56,6 +59,8 @@ object Analysis {
5659
true
5760
case Apply(fun, args) if methodsWhiteList.contains(fun.symbol.fullName.toString) =>
5861
true
62+
case Ident(_) if t.symbol.is(Flags.Module) && (t.symbol.is(Flags.Synthetic) || moduleWhiteList.contains(t.symbol.fullName.toString)) =>
63+
true
5964
case _ =>
6065
false
6166
// analisys

compiler/src/dotty/tools/dotc/transform/linker/Simplify.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -849,10 +849,10 @@ class Simplify extends MiniPhaseTransform with IdentityDenotTransformer {
849849
case _ => keepOnlySideEffects(expr).orElse(unitLiteral)
850850
}
851851
tpd.cpy.Block(bl)(stats2, expr2)
852-
case t: Ident if !t.symbol.is(Method | Lazy) && !t.symbol.info.isInstanceOf[ExprType] =>
852+
case t: Ident if !t.symbol.is(Method | Lazy) && !t.symbol.info.isInstanceOf[ExprType] || Analysis.effectsDontEscape(t) =>
853853
desugarIdent(t) match {
854-
case Some(t) => t
855-
case None => EmptyTree
854+
case Some(t) if !(t.qualifier.symbol.is(Flags.JavaDefined) && t.qualifier.symbol.is(Flags.Package)) => t
855+
case _ => EmptyTree
856856
}
857857
case app: Apply if app.fun.symbol.is(Label) && !app.tpe.finalResultType.derivesFrom(defn.UnitClass) =>
858858
// This is "the scary hack". It changes the return type to Unit, then

0 commit comments

Comments
 (0)