File tree Expand file tree Collapse file tree 2 files changed +8
-3
lines changed
compiler/src/dotty/tools/dotc/transform/linker Expand file tree Collapse file tree 2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import core.Contexts._
77import core .NameOps ._
88import core .StdNames ._
99import core .Symbols ._
10+ import dotty .tools .dotc .core .Flags
1011
1112object 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
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments