Skip to content

Commit

Permalink
Address review comments (remove dead/debug code, +comments)
Browse files Browse the repository at this point in the history
  • Loading branch information
retronym committed Jun 17, 2020
1 parent 0e27334 commit ae91a3c
Show file tree
Hide file tree
Showing 16 changed files with 16 additions and 30 deletions.
5 changes: 2 additions & 3 deletions src/compiler/scala/tools/nsc/Global.scala
Expand Up @@ -579,7 +579,7 @@ class Global(var currentSettings: Settings, reporter0: Reporter)
object async extends {
val global: Global.this.type = Global.this
val runsAfter = List("posterasure")
val runsRightAfter = Some("posterasure")
val runsRightAfter = None
} with AsyncPhase

// phaseName = "lambdalift"
Expand Down Expand Up @@ -1013,7 +1013,7 @@ class Global(var currentSettings: Settings, reporter0: Reporter)
definitions.isDefinitionsInitialized
&& rootMirror.isMirrorInitialized
)
override def isPastTyper = globalPhase != null && isPast(currentRun.typerPhase)
override def isPastTyper = isPast(currentRun.typerPhase)
def isPast(phase: Phase) = (
(curRun ne null)
&& isGlobalInitialized // defense against init order issues
Expand Down Expand Up @@ -1350,7 +1350,6 @@ class Global(var currentSettings: Settings, reporter0: Reporter)
def runIsAt(ph: Phase) = globalPhase.id == ph.id
def runIsAtOptimiz = runIsAt(jvmPhase)

firstPhase.iterator.foreach(_.init())
isDefined = true

// ----------- Units and top-level classes and objects --------
Expand Down
Expand Up @@ -21,7 +21,6 @@ import scala.tools.asm.Opcodes._
import scala.tools.asm.Type
import scala.tools.asm.tree._
import scala.tools.nsc.backend.jvm.BTypes.InternalName
import scala.tools.nsc.backend.jvm.analysis.BackendUtils
import scala.tools.nsc.backend.jvm.opt.BytecodeUtils._

abstract class BoxUnbox {
Expand Down
1 change: 0 additions & 1 deletion src/compiler/scala/tools/nsc/transform/UnCurry.scala
Expand Up @@ -20,7 +20,6 @@ import scala.collection.mutable
import scala.collection.mutable.ListBuffer
import scala.reflect.internal.util.ListOfNil
import PartialFunction.cond
import scala.reflect.NameTransformer

/*<export> */
/** - uncurry all symbol and tree types (@see UnCurryPhase) -- this includes normalizing all proper types.
Expand Down
Expand Up @@ -13,7 +13,6 @@
package scala.tools.nsc.transform.async

import scala.collection.mutable.ListBuffer
import scala.reflect.NameTransformer

trait AsyncAnalysis extends TransformUtils {
import global._
Expand Down
Expand Up @@ -35,6 +35,7 @@ abstract class AsyncPhase extends Transform with TypingTransformers with AnfTran

/**
* Mark the given method as requiring an async transform.
* Refer to documentation in the public API that forwards to this method in src/reflect/scala/reflect/api/Internals.scala
*/
final def markForAsyncTransform(owner: Symbol, method: DefDef, awaitMethod: Symbol,
config: Map[String, AnyRef]): DefDef = {
Expand Down
5 changes: 1 addition & 4 deletions src/compiler/scala/tools/nsc/typechecker/Implicits.scala
Expand Up @@ -327,10 +327,7 @@ trait Implicits {
*/
def memberWildcardType(name: Name, tp: Type) = {
val result = refinedType(List(WildcardType), NoSymbol)
val owner = result.typeSymbol orElse { // TODO async (when after erasure?)...
val clazz = NoSymbol.newRefinementClass(NoPosition)
clazz setInfo RefinedType(Nil, newScope, clazz)
}
val owner = result.typeSymbol
(name match {
case x: TermName => owner.newMethod(x)
case x: TypeName => owner.newAbstractType(x)
Expand Down
3 changes: 0 additions & 3 deletions src/compiler/scala/tools/reflect/FastTrack.scala
Expand Up @@ -44,9 +44,6 @@ class FastTrack[MacrosAndAnalyzer <: Macros with Analyzer](val macros: MacrosAnd
private def makeWhitebox(sym: Symbol)(pf: PartialFunction[Applied, MacroContext => Tree]) =
sym -> new FastTrackEntry(pf, isBlackbox = false)

private def makeBlackBoxIfExists(sym_pf: (Symbol, PartialFunction[Applied, MacroContext => Tree])) =
sym_pf match { case (sym, _) if !sym.exists => Map.empty case (sym, pf) => Map(makeBlackbox(sym)(pf))}

final class FastTrackEntry(pf: PartialFunction[Applied, MacroContext => Tree], val isBlackbox: Boolean) extends (MacroArgs => Any) {
def validate(tree: Tree) = pf isDefinedAt Applied(tree)
def apply(margs: MacroArgs): margs.c.Expr[Nothing] = {
Expand Down
1 change: 0 additions & 1 deletion src/partest-extras/scala/tools/partest/async/Async.scala
Expand Up @@ -18,7 +18,6 @@ import scala.language.experimental.macros
import scala.annotation.compileTimeOnly
import scala.concurrent.{ExecutionContext, Future, Promise}
import scala.reflect.macros.blackbox
import scala.tools.nsc.transform.async.StateAssigner
import scala.util.{Failure, Success, Try}

object Async {
Expand Down
Expand Up @@ -19,7 +19,6 @@ import java.util.function.BiConsumer
import scala.annotation.compileTimeOnly
import scala.language.experimental.macros
import scala.reflect.macros.blackbox
import scala.tools.nsc.transform.async.StateAssigner
import scala.util.{Failure, Success, Try}

object CompletableFutureAwait {
Expand Down
Expand Up @@ -17,7 +17,6 @@ import scala.collection.immutable.HashMap
import scala.collection.mutable
import scala.language.experimental.macros
import scala.reflect.macros.blackbox
import scala.tools.nsc.transform.async.StateAssigner

object OutputAwait {
def writing[T](body: T): Output[T] = macro impl
Expand Down
11 changes: 11 additions & 0 deletions src/reflect/scala/reflect/api/Internals.scala
Expand Up @@ -374,6 +374,17 @@ trait Internals { self: Universe =>
*/
def boundedWildcardType(bounds: TypeBounds): BoundedWildcardType

/** Mark the given `DefDef` for later processing by the `async` phase of the compiler
*
* @param owner current owner the owner of the call site being transformed into an async state machine
* @param method A method of the form `def $name($paramName: $ParamType): $T = $CODE`, where calls to `$CODE`
* `awaitSymbol` in `$CODE` mark continuation points.
* @param awaitSymbol The `await` method, of a typically of a type like `[T](Future[T): T`
* @param config Untyped channel for additional configuration parameters. This currently allows
* - "postAnfTransform" : A function from `Block => Block`
* - "stateDiagram" : A function from `(Symbol, Tree) => Option[String => Unit]` that can
* opt to receive a .dot diagram of the state machine.
*/
def markForAsyncTransform(owner: Symbol, method: DefDef, awaitSymbol: Symbol, config: Map[String, AnyRef]): DefDef = method

/** Syntactic conveniences for additional internal APIs for trees, symbols and types */
Expand Down
1 change: 0 additions & 1 deletion src/reflect/scala/reflect/internal/Phase.scala
Expand Up @@ -64,7 +64,6 @@ abstract class Phase(val prev: Phase) extends Ordered[Phase] {
* overridden to false in parser, namer, typer, and erasure. (And NoPhase.)
*/
def keepsTypeParams = true
def init(): Unit = ()
def run(): Unit

override def toString() = name
Expand Down
2 changes: 0 additions & 2 deletions src/reflect/scala/reflect/internal/StdAttachments.scala
Expand Up @@ -122,6 +122,4 @@ trait StdAttachments {

// When typing a Def with this attachment, change the owner of its RHS from origalOwner to the symbol of the Def
case class ChangeOwnerAttachment(originalOwner: Symbol)

case object SuppressPureExpressionWarning extends PlainAttachment
}
1 change: 0 additions & 1 deletion src/reflect/scala/reflect/internal/TreeInfo.scala
Expand Up @@ -232,7 +232,6 @@ abstract class TreeInfo {
( !tree.isErrorTyped
&& (isExprSafeToInline(tree) || isWarnableRefTree)
&& isWarnableSymbol
&& !tree.hasAttachment[SuppressPureExpressionWarning.type]
)
}

Expand Down
10 changes: 1 addition & 9 deletions src/reflect/scala/reflect/internal/Trees.scala
Expand Up @@ -478,14 +478,7 @@ trait Trees extends api.Trees {
case class ArrayValue(elemtpt: Tree, elems: List[Tree]) extends TermTree

case class Function(vparams: List[ValDef], body: Tree)
extends SymTree with TermTree with FunctionApi {

override def tpe_=(tp: Type): Unit = {
if (!definitions.isFunctionType(tp))
new Throwable().printStackTrace()
super.setType(tp)
}
}
extends SymTree with TermTree with FunctionApi
object Function extends FunctionExtractor

case class Assign(lhs: Tree, rhs: Tree)
Expand Down Expand Up @@ -1538,7 +1531,6 @@ trait Trees extends api.Trees {
}

class ChangeOwnerTraverser(val oldowner: Symbol, val newowner: Symbol) extends Traverser {
assert(newowner != NoSymbol, oldowner)
final def change(sym: Symbol) = {
if (sym != NoSymbol && sym.owner == oldowner) {
sym.owner = newowner
Expand Down
1 change: 0 additions & 1 deletion src/reflect/scala/reflect/runtime/JavaUniverseForce.scala
Expand Up @@ -64,7 +64,6 @@ trait JavaUniverseForce { self: runtime.JavaUniverse =>
this.TypeParamVarargsAttachment
this.KnownDirectSubclassesCalled
this.ChangeOwnerAttachment
this.SuppressPureExpressionWarning
this.noPrint
this.typeDebug
// inaccessible: this.posAssigner
Expand Down

0 comments on commit ae91a3c

Please sign in to comment.