Skip to content

Commit c02861f

Browse files
oderskymilessabin
authored andcommitted
Introduce MirroredTypeConstructor
1 parent 6d3c2f9 commit c02861f

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

compiler/src/dotty/tools/dotc/core/StdNames.scala

+1
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ object StdNames {
343343
val MirroredElemLabels: N = "MirroredElemLabels"
344344
val MirroredLabel: N = "MirroredLabel"
345345
val MirroredMonoType: N = "MirroredMonoType"
346+
val MirroredTypeConstructor: N = "MirroredTypeConstructor"
346347
val Modifiers: N = "Modifiers"
347348
val NestedAnnotArg: N = "NestedAnnotArg"
348349
val NoFlags: N = "NoFlags"

compiler/src/dotty/tools/dotc/typer/Implicits.scala

+14-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import ProtoTypes._
2626
import ErrorReporting._
2727
import reporting.diagnostic.Message
2828
import Inferencing.fullyDefinedType
29+
import TypeApplications.EtaExpansion
2930
import Trees._
3031
import transform.SymUtils._
3132
import transform.TypeUtils._
@@ -861,12 +862,23 @@ trait Implicits { self: Typer =>
861862

862863
/** The mirror type
863864
*
864-
* <parent> { MirroredMonoType = <monoType; MirroredLabel = <label> }
865+
* <parent> {
866+
* MirroredMonoType = <monoType>
867+
* MirroredTypeConstrictor = <tycon>
868+
* MirroredLabel = <label> }
865869
*/
866-
private def mirrorCore(parent: Type, monoType: Type, label: Name)(implicit ctx: Context) =
870+
private def mirrorCore(parent: Type, monoType: Type, label: Name)(implicit ctx: Context) = {
871+
val mirroredType = monoType match {
872+
case monoType @ AppliedType(tycon, targs) if targs.forall(_.isInstanceOf[TypeBounds]) =>
873+
EtaExpansion(tycon)
874+
case _ =>
875+
monoType
876+
}
867877
parent
868878
.refinedWith(tpnme.MirroredMonoType, TypeAlias(monoType))
879+
.refinedWith(tpnme.MirroredTypeConstructor, TypeAlias(mirroredType))
869880
.refinedWith(tpnme.MirroredLabel, TypeAlias(ConstantType(Constant(label.toString))))
881+
}
870882

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

0 commit comments

Comments
 (0)