All Downloads are FREE. Search and download functionalities are using the official Maven repository.

dotty.tools.dotc.transform.ElimOuterSelect.scala Maven / Gradle / Ivy

The newest version!
package dotty.tools.dotc
package transform

import core._
import MegaPhase.MiniPhase
import Contexts.Context
import Types._
import NameKinds.OuterSelectName

/** This phase rewrites outer selects `E.n_` which were introduced by
 *  inlining to outer paths.
 */
class ElimOuterSelect extends MiniPhase {
  import ast.tpd._

  override def phaseName: String = "elimOuterSelect"

  override def runsAfterGroupsOf: Set[String] = Set(ExplicitOuter.name)
    // ExplicitOuter needs to have run to completion before so that all classes
    // that need an outer accessor have one.

  /** Convert a selection of the form `qual.n_` to an outer path from `qual` of
   *  length `n`.
   */
  override def transformSelect(tree: Select)(implicit ctx: Context): Tree =
    tree.name match {
      case OuterSelectName(_, nhops) =>
        val SkolemType(tp) = tree.tpe
        ExplicitOuter.outer.path(start = tree.qualifier, count = nhops).ensureConforms(tp)
      case _ => tree
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy