File tree 2 files changed +8
-3
lines changed
compiler/src/dotty/tools/dotc/transform/linker
2 files changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import core.Contexts._
7
7
import core .NameOps ._
8
8
import core .StdNames ._
9
9
import core .Symbols ._
10
+ import dotty .tools .dotc .core .Flags
10
11
11
12
object Analysis {
12
13
import tpd ._
@@ -35,6 +36,8 @@ object Analysis {
35
36
" scala.Some"
36
37
)
37
38
39
+ private val moduleWhiteList = constructorWhiteList.map(x => x + " $" )
40
+
38
41
private val methodsWhiteList = List (
39
42
" java.lang.Math.min" ,
40
43
" java.lang.Math.max" ,
@@ -56,6 +59,8 @@ object Analysis {
56
59
true
57
60
case Apply (fun, args) if methodsWhiteList.contains(fun.symbol.fullName.toString) =>
58
61
true
62
+ case Ident (_) if t.symbol.is(Flags .Module ) && (t.symbol.is(Flags .Synthetic ) || moduleWhiteList.contains(t.symbol.fullName.toString)) =>
63
+ true
59
64
case _ =>
60
65
false
61
66
// analisys
Original file line number Diff line number Diff line change @@ -849,10 +849,10 @@ class Simplify extends MiniPhaseTransform with IdentityDenotTransformer {
849
849
case _ => keepOnlySideEffects(expr).orElse(unitLiteral)
850
850
}
851
851
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) =>
853
853
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
856
856
}
857
857
case app : Apply if app.fun.symbol.is(Label ) && ! app.tpe.finalResultType.derivesFrom(defn.UnitClass ) =>
858
858
// 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