Skip to content

Commit

Permalink
Introduce MirroredTypeConstructor
Browse files Browse the repository at this point in the history
  • Loading branch information
odersky authored and milessabin committed May 30, 2019
1 parent 6d3c2f9 commit c02861f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions compiler/src/dotty/tools/dotc/core/StdNames.scala
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ object StdNames {
val MirroredElemLabels: N = "MirroredElemLabels"
val MirroredLabel: N = "MirroredLabel"
val MirroredMonoType: N = "MirroredMonoType"
val MirroredTypeConstructor: N = "MirroredTypeConstructor"
val Modifiers: N = "Modifiers"
val NestedAnnotArg: N = "NestedAnnotArg"
val NoFlags: N = "NoFlags"
Expand Down
16 changes: 14 additions & 2 deletions compiler/src/dotty/tools/dotc/typer/Implicits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import ProtoTypes._
import ErrorReporting._
import reporting.diagnostic.Message
import Inferencing.fullyDefinedType
import TypeApplications.EtaExpansion
import Trees._
import transform.SymUtils._
import transform.TypeUtils._
Expand Down Expand Up @@ -861,12 +862,23 @@ trait Implicits { self: Typer =>

/** The mirror type
*
* <parent> { MirroredMonoType = <monoType; MirroredLabel = <label> }
* <parent> {
* MirroredMonoType = <monoType>
* MirroredTypeConstrictor = <tycon>
* MirroredLabel = <label> }
*/
private def mirrorCore(parent: Type, monoType: Type, label: Name)(implicit ctx: Context) =
private def mirrorCore(parent: Type, monoType: Type, label: Name)(implicit ctx: Context) = {
val mirroredType = monoType match {
case monoType @ AppliedType(tycon, targs) if targs.forall(_.isInstanceOf[TypeBounds]) =>
EtaExpansion(tycon)
case _ =>
monoType
}
parent
.refinedWith(tpnme.MirroredMonoType, TypeAlias(monoType))
.refinedWith(tpnme.MirroredTypeConstructor, TypeAlias(mirroredType))
.refinedWith(tpnme.MirroredLabel, TypeAlias(ConstantType(Constant(label.toString))))
}

/** A path referencing the companion of class type `clsType` */
private def companionPath(clsType: Type, span: Span)(implicit ctx: Context) = {
Expand Down

0 comments on commit c02861f

Please sign in to comment.