diff options
author | Martin Odersky <odersky@gmail.com> | 2015-02-12 11:24:15 +0100 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2015-03-18 11:09:42 +0100 |
commit | 3f5d15defa7481da1b9d1f20e91569a340c71e8e (patch) | |
tree | 8a6051f6064069dfb91257412e29504e24f9fc87 /src/dotty/tools/dotc/ast/Desugar.scala | |
parent | 8cf176ae6c33015336b654a819e307110a505a76 (diff) | |
download | dotty-3f5d15defa7481da1b9d1f20e91569a340c71e8e.tar.gz dotty-3f5d15defa7481da1b9d1f20e91569a340c71e8e.tar.bz2 dotty-3f5d15defa7481da1b9d1f20e91569a340c71e8e.zip |
Fix desugaring of refined types with "&"-parent.
need to generate more than one parent class.
Diffstat (limited to 'src/dotty/tools/dotc/ast/Desugar.scala')
-rw-r--r-- | src/dotty/tools/dotc/ast/Desugar.scala | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/dotty/tools/dotc/ast/Desugar.scala b/src/dotty/tools/dotc/ast/Desugar.scala index 7cdedb19a..cd198818a 100644 --- a/src/dotty/tools/dotc/ast/Desugar.scala +++ b/src/dotty/tools/dotc/ast/Desugar.scala @@ -864,18 +864,19 @@ object desugar { * @param parentType The type of `parent` */ def refinedTypeToClass(parent: tpd.Tree, refinements: List[Tree])(implicit ctx: Context): TypeDef = { - def stripToCore(tp: Type): Type = tp match { - case tp: RefinedType if tp.argInfos.nonEmpty => tp // parameterized class type - case tp: TypeRef if tp.symbol.isClass => tp // monomorphic class type + def stripToCore(tp: Type): List[Type] = tp match { + case tp: RefinedType if tp.argInfos.nonEmpty => tp :: Nil // parameterized class type + case tp: TypeRef if tp.symbol.isClass => tp :: Nil // monomorphic class type case tp: TypeProxy => stripToCore(tp.underlying) - case _ => defn.AnyType + case AndType(tp1, tp2) => stripToCore(tp1) ::: stripToCore(tp2) + case _ => defn.AnyType :: Nil } - val parentCore = stripToCore(parent.tpe) + val parentCores = stripToCore(parent.tpe) val untpdParent = TypedSplice(parent) - val (classParent, self) = - if (parent.tpe eq parentCore) (untpdParent, EmptyValDef) - else (TypeTree(parentCore), ValDef(nme.WILDCARD, untpdParent, EmptyTree)) - val impl = Template(emptyConstructor, classParent :: Nil, self, refinements) + val (classParents, self) = + if (parentCores.length == 1 && (parent.tpe eq parentCores.head)) (untpdParent :: Nil, EmptyValDef) + else (parentCores map TypeTree, ValDef(nme.WILDCARD, untpdParent, EmptyTree)) + val impl = Template(emptyConstructor, classParents, self, refinements) TypeDef(tpnme.REFINE_CLASS, impl).withFlags(Trait) } |