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

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

There is a newer version: 3.6.4-RC1-bin-20241220-0bfa1af-NIGHTLY
Show newest version
package dotty.tools.dotc
package transform

import core.*
import MegaPhase.MiniPhase
import Contexts.*
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.name

  override def description: String = ElimOuterSelect.description

  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)(using Context): Tree =
    tree.name match {
      case OuterSelectName(_, nhops) =>
        val SkolemType(tp) = tree.tpe: @unchecked
        ExplicitOuter.outer.path(start = tree.qualifier, count = nhops).ensureConforms(tp)
      case _ => tree
    }
}

object ElimOuterSelect:
  val name: String = "elimOuterSelect"
  val description: String = "expand outer selections"




© 2015 - 2025 Weber Informatics LLC | Privacy Policy