Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,6 @@ class InterceptedMethods extends MiniPhase {

override def phaseName: String = InterceptedMethods.name

private[this] var primitiveGetClassMethods: Set[Symbol] = _

/** perform context-dependant initialization */
override def prepareForUnit(tree: Tree)(implicit ctx: Context) = {
primitiveGetClassMethods = Set[Symbol]() ++ defn.ScalaValueClasses().map(x => x.requiredMethod(nme.getClass_))
ctx
}

// this should be removed if we have guarantee that ## will get Apply node
override def transformSelect(tree: tpd.Select)(implicit ctx: Context): Tree = {
if (tree.symbol.isTerm && (defn.Any_## eq tree.symbol.asTerm)) {
Expand Down Expand Up @@ -105,7 +97,7 @@ class InterceptedMethods extends MiniPhase {
List(qual, typer.resolveClassTag(tree.pos, qual.tpe.widen))))
}*/
*/
case t if primitiveGetClassMethods.contains(t) =>
case t if t.name == nme.getClass_ && defn.ScalaValueClasses().contains(t.owner) =>
// if we got here then we're trying to send a primitive getClass method to either
// a) an Any, in which cage Object_getClass works because Any erases to object. Or
//
Expand Down
24 changes: 13 additions & 11 deletions compiler/src/dotty/tools/dotc/transform/localopt/Simplify.scala
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,19 @@ class Simplify extends MiniPhase with IdentityDenotTransformer {
var fuel: Int = -1

override def prepareForUnit(tree: Tree)(implicit ctx: Context) = {
SeqFactoryClass = ctx.requiredClass("scala.collection.generic.SeqFactory")
CommutativePrimitiveOperations = Set(defn.Boolean_&&, defn.Boolean_||, defn.Int_+, defn.Int_*, defn.Long_+, defn.Long_*)

val maxFuel = ctx.settings.YoptFuel.value
if (fuel < 0 && maxFuel > 0) // Both defaults are at -1
fuel = maxFuel

optimisations = {
val o = if (ctx.erasedTypes) afterErasure else beforeErasure
val p = ctx.settings.YoptPhases.value
if (p.isEmpty) o else o.filter(x => p.contains(x.name))
if (ctx.settings.optimise.value) {
SeqFactoryClass = ctx.requiredClass("scala.collection.generic.SeqFactory")
CommutativePrimitiveOperations = Set(defn.Boolean_&&, defn.Boolean_||, defn.Int_+, defn.Int_*, defn.Long_+, defn.Long_*)

val maxFuel = ctx.settings.YoptFuel.value
if (fuel < 0 && maxFuel > 0) // Both defaults are at -1
fuel = maxFuel

optimisations = {
val o = if (ctx.erasedTypes) afterErasure else beforeErasure
val p = ctx.settings.YoptPhases.value
if (p.isEmpty) o else o.filter(x => p.contains(x.name))
}
}

ctx
Expand Down