Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Laying groundwork for a followup ticket.

To solve SI-5304, we should change `isQualifierSafeToElide`.
  • Loading branch information...
commit 2580a51bbaccb31ad88679874d6ad626f8d4491c 1 parent 412ad57
@retronym retronym authored
View
10 src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
@@ -835,16 +835,16 @@ abstract class GenICode extends SubComponent {
generatedType = toTypeKind(sym.info)
val hostClass = findHostClass(qualifier.tpe, sym)
log(s"Host class of $sym with qual $qualifier (${qualifier.tpe}) is $hostClass")
- val qualSafeToInline = treeInfo isExprSafeToInline qualifier
+ val qualSafeToElide = treeInfo isQualifierSafeToElide qualifier
- def genLoadQualUnlessInlinable: Context =
- if (qualSafeToInline) ctx else genLoadQualifier(tree, ctx)
+ def genLoadQualUnlessElidable: Context =
+ if (qualSafeToElide) ctx else genLoadQualifier(tree, ctx)
if (sym.isModule) {
- genLoadModule(genLoadQualUnlessInlinable, tree)
+ genLoadModule(genLoadQualUnlessElidable, tree)
}
else if (sym.isStaticMember) {
- val ctx1 = genLoadQualUnlessInlinable
+ val ctx1 = genLoadQualUnlessElidable
ctx1.bb.emit(LOAD_FIELD(sym, true) setHostClass hostClass, tree.pos)
ctx1
} else {
View
4 src/compiler/scala/tools/nsc/transform/Flatten.scala
@@ -12,7 +12,7 @@ import scala.collection.mutable.ListBuffer
abstract class Flatten extends InfoTransform {
import global._
- import treeInfo.isExprSafeToInline
+ import treeInfo.isQualifierSafeToElide
/** the following two members override abstract members in Transform */
val phaseName: String = "flatten"
@@ -121,7 +121,7 @@ abstract class Flatten extends InfoTransform {
exitingFlatten {
atPos(tree.pos) {
val ref = gen.mkAttributedRef(sym)
- if (isExprSafeToInline(qual)) ref
+ if (isQualifierSafeToElide(qual)) ref
else Block(List(qual), ref).setType(tree.tpe) // need to execute the qualifier but refer directly to the lifted module.
}
}
View
2  src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
@@ -1391,7 +1391,7 @@ abstract class RefChecks extends InfoTransform with scala.reflect.internal.trans
case Select(module, apply) =>
( // SI-4859 `CaseClass1().InnerCaseClass2()` must not be rewritten to `new InnerCaseClass2()`;
// {expr; Outer}.Inner() must not be rewritten to `new Outer.Inner()`.
- treeInfo.isExprSafeToInline(module) &&
+ treeInfo.isQualifierSafeToElide(module) &&
// SI-5626 Classes in refinement types cannot be constructed with `new`. In this case,
// the companion class is actually not a ClassSymbol, but a reference to an abstract type.
module.symbol.companionClass.isClass
View
3  src/reflect/scala/reflect/internal/TreeInfo.scala
@@ -65,6 +65,9 @@ abstract class TreeInfo {
false
}
+ // TODO SI-5304 tighten this up so we don't elide side effect in module loads
+ def isQualifierSafeToElide(tree: Tree): Boolean = isExprSafeToInline(tree)
+
/** Is tree an expression which can be inlined without affecting program semantics?
*
* Note that this is not called "isExprPure" since purity (lack of side-effects)
Please sign in to comment.
Something went wrong with that request. Please try again.