Skip to content

Commit e5fe5e5

Browse files
committed
Introduce MirroredTypeConstructor
1 parent 6cdf08f commit e5fe5e5

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._
@@ -817,12 +818,23 @@ trait Implicits { self: Typer =>
817818

818819
/** The mirror type
819820
*
820-
* <parent> { MirroredMonoType = <monoType; MirroredLabel = <label> }
821+
* <parent> {
822+
* MirroredMonoType = <monoType>
823+
* MirroredTypeConstrictor = <tycon>
824+
* MirroredLabel = <label> }
821825
*/
822-
private def mirrorCore(parent: Type, monoType: Type, label: Name)(implicit ctx: Context) =
826+
private def mirrorCore(parent: Type, monoType: Type, label: Name)(implicit ctx: Context) = {
827+
val mirroredType = monoType match {
828+
case monoType @ AppliedType(tycon, targs) if targs.forall(_.isInstanceOf[TypeBounds]) =>
829+
EtaExpansion(tycon)
830+
case _ =>
831+
monoType
832+
}
823833
parent
824834
.refinedWith(tpnme.MirroredMonoType, TypeAlias(monoType))
835+
.refinedWith(tpnme.MirroredTypeConstructor, TypeAlias(mirroredType))
825836
.refinedWith(tpnme.MirroredLabel, TypeAlias(ConstantType(Constant(label.toString))))
837+
}
826838

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

0 commit comments

Comments
 (0)