@@ -889,35 +889,12 @@ trait Implicits { self: Typer =>
889889 * Scope = <scope> // if scope ne NoType
890890 * }
891891 */
892- private def mirrorCore (parentClass : ClassSymbol , monoType : Type , mirroredType : Type , label : Name , extras : List [( Name , Type )]) (implicit ctx : Context ) = {
893- val m = parentClass.typeRef
892+ private def mirrorCore (parentClass : ClassSymbol , monoType : Type , mirroredType : Type , label : Name , formal : Type )(implicit ctx : Context ) =
893+ formal & parentClass.typeRef
894894 .refinedWith(tpnme.MirroredMonoType , TypeAlias (monoType))
895895 .refinedWith(tpnme.MirroredType , TypeAlias (mirroredType))
896896 .refinedWith(tpnme.MirroredLabel , TypeAlias (ConstantType (Constant (label.toString))))
897897
898- extras.foldLeft(m) { case (m, (tpnme, tpe)) => m.refinedWith(tpnme, tpe) }
899- }
900-
901- private def extraRefinements (formal : Type )(implicit ctx : Context ): List [(Name , Type )] = {
902- def isMirrorMember (nme : Name ): Boolean =
903- nme == tpnme.MirroredType ||
904- nme == tpnme.MirroredMonoType ||
905- nme == tpnme.MirroredLabel ||
906- nme == tpnme.MirroredElemTypes ||
907- nme == tpnme.MirroredElemLabels
908-
909- @ tailrec
910- def loop (tp : Type , acc : List [(Name , Type )]): List [(Name , Type )] = tp match {
911- case RefinedType (parent, nme, rhs) if ! isMirrorMember(nme) =>
912- loop(parent, (nme, rhs) :: acc)
913- case RefinedType (parent, nme, rhs) =>
914- loop(parent, acc)
915- case other =>
916- acc
917- }
918- loop(formal, Nil )
919- }
920-
921898 /** A path referencing the companion of class type `clsType` */
922899 private def companionPath (clsType : Type , span : Span )(implicit ctx : Context ) = {
923900 val ref = pathFor(clsType.companionRef)
@@ -940,12 +917,12 @@ trait Implicits { self: Typer =>
940917 val module = mirroredType.termSymbol
941918 val modulePath = pathFor(mirroredType).withSpan(span)
942919 if (module.info.classSymbol.is(Scala2x )) {
943- val mirrorType = mirrorCore(defn.Mirror_SingletonProxyClass , mirroredType, mirroredType, module.name, extraRefinements( formal) )
920+ val mirrorType = mirrorCore(defn.Mirror_SingletonProxyClass , mirroredType, mirroredType, module.name, formal)
944921 val mirrorRef = New (defn.Mirror_SingletonProxyClass .typeRef, modulePath :: Nil )
945922 mirrorRef.cast(mirrorType)
946923 }
947924 else {
948- val mirrorType = mirrorCore(defn.Mirror_SingletonClass , mirroredType, mirroredType, module.name, extraRefinements( formal) )
925+ val mirrorType = mirrorCore(defn.Mirror_SingletonClass , mirroredType, mirroredType, module.name, formal)
949926 modulePath.cast(mirrorType)
950927 }
951928 }
@@ -967,7 +944,7 @@ trait Implicits { self: Typer =>
967944 (mirroredType, elems)
968945 }
969946 val mirrorType =
970- mirrorCore(defn.Mirror_ProductClass , monoType, mirroredType, cls.name, extraRefinements( formal) )
947+ mirrorCore(defn.Mirror_ProductClass , monoType, mirroredType, cls.name, formal)
971948 .refinedWith(tpnme.MirroredElemTypes , TypeAlias (elemsType))
972949 .refinedWith(tpnme.MirroredElemLabels , TypeAlias (TypeOps .nestedPairs(elemLabels)))
973950 val mirrorRef =
@@ -1048,7 +1025,7 @@ trait Implicits { self: Typer =>
10481025 }
10491026
10501027 val mirrorType =
1051- mirrorCore(defn.Mirror_SumClass , monoType, mirroredType, cls.name, extraRefinements( formal) )
1028+ mirrorCore(defn.Mirror_SumClass , monoType, mirroredType, cls.name, formal)
10521029 .refinedWith(tpnme.MirroredElemTypes , TypeAlias (elemsType))
10531030 .refinedWith(tpnme.MirroredElemLabels , TypeAlias (TypeOps .nestedPairs(elemLabels)))
10541031 val mirrorRef =
0 commit comments