@@ -864,18 +864,19 @@ object desugar {
864
864
* @param parentType The type of `parent`
865
865
*/
866
866
def refinedTypeToClass (parent : tpd.Tree , refinements : List [Tree ])(implicit ctx : Context ): TypeDef = {
867
- def stripToCore (tp : Type ): Type = tp match {
868
- case tp : RefinedType if tp.argInfos.nonEmpty => tp // parameterized class type
869
- case tp : TypeRef if tp.symbol.isClass => tp // monomorphic class type
867
+ def stripToCore (tp : Type ): List [ Type ] = tp match {
868
+ case tp : RefinedType if tp.argInfos.nonEmpty => tp :: Nil // parameterized class type
869
+ case tp : TypeRef if tp.symbol.isClass => tp :: Nil // monomorphic class type
870
870
case tp : TypeProxy => stripToCore(tp.underlying)
871
- case _ => defn.AnyType
871
+ case AndType (tp1, tp2) => stripToCore(tp1) ::: stripToCore(tp2)
872
+ case _ => defn.AnyType :: Nil
872
873
}
873
- val parentCore = stripToCore(parent.tpe)
874
+ val parentCores = stripToCore(parent.tpe)
874
875
val untpdParent = TypedSplice (parent)
875
- val (classParent , self) =
876
- if (parent.tpe eq parentCore) (untpdParent, EmptyValDef )
877
- else (TypeTree (parentCore) , ValDef (nme.WILDCARD , untpdParent, EmptyTree ))
878
- val impl = Template (emptyConstructor, classParent :: Nil , self, refinements)
876
+ val (classParents , self) =
877
+ if (parentCores.length == 1 && ( parent.tpe eq parentCores.head)) (untpdParent :: Nil , EmptyValDef )
878
+ else (parentCores map TypeTree , ValDef (nme.WILDCARD , untpdParent, EmptyTree ))
879
+ val impl = Template (emptyConstructor, classParents , self, refinements)
879
880
TypeDef (tpnme.REFINE_CLASS , impl).withFlags(Trait )
880
881
}
881
882
0 commit comments