File tree 1 file changed +10
-5
lines changed
src/dotty/tools/dotc/transform 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -91,11 +91,16 @@ class IsInstanceOfEvaluator extends MiniPhaseTransform { thisTransformer =>
91
91
*
92
92
* `scrutinee.isInstanceOf[Selector]` if `scrutinee eq null`
93
93
*/
94
- def rewrite (tree : Select , to : Boolean ): Tree =
95
- if (! to || ! tree.qualifier.tpe.widen.derivesFrom(defn.AnyRefAlias ))
96
- Literal (Constant (to))
97
- else
98
- Apply (tree.qualifier.select(defn.Object_ne ), List (Literal (Constant (null ))))
94
+ def rewrite (tree : Select , to : Boolean ): Tree = {
95
+ val expr =
96
+ if (! to || ! tree.qualifier.tpe.widen.derivesFrom(defn.AnyRefAlias ))
97
+ Literal (Constant (to))
98
+ else
99
+ Apply (tree.qualifier.select(defn.Object_ne ), List (Literal (Constant (null ))))
100
+
101
+ if (! isPureExpr(tree.qualifier)) Block (List (tree.qualifier), expr)
102
+ else expr
103
+ }
99
104
100
105
/** Attempts to rewrite TypeApply to either `scrutinee ne null` or a
101
106
* constant
You can’t perform that action at this time.
0 commit comments