diff options
author | Martin Odersky <odersky@gmail.com> | 2017-02-02 16:38:27 +1100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2017-02-08 22:20:26 +1100 |
commit | 0f396544ced68ca2548b204527e2325c3fc65135 (patch) | |
tree | b88c6f374a1f510d5ffdc41996a216c489844daa /compiler/src | |
parent | 97b0a084f4490a0e5cc3c7a02d18647e7fa89330 (diff) | |
download | dotty-0f396544ced68ca2548b204527e2325c3fc65135.tar.gz dotty-0f396544ced68ca2548b204527e2325c3fc65135.tar.bz2 dotty-0f396544ced68ca2548b204527e2325c3fc65135.zip |
Refine AnonClass generation
The leading class should be the superclass of the first trait
(which is not always Object).
We could think of a more refined condition, (i.e. taking the least
common superclass of all extended traits), but I think it's not worth
it, as one can always spell out the right superclass manually.
Diffstat (limited to 'compiler/src')
-rw-r--r-- | compiler/src/dotty/tools/dotc/ast/tpd.scala | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/src/dotty/tools/dotc/ast/tpd.scala b/compiler/src/dotty/tools/dotc/ast/tpd.scala index 565ec5ce2..ed268fda7 100644 --- a/compiler/src/dotty/tools/dotc/ast/tpd.scala +++ b/compiler/src/dotty/tools/dotc/ast/tpd.scala @@ -260,7 +260,7 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo { def AnonClass(parents: List[Type], fns: List[TermSymbol], methNames: List[TermName])(implicit ctx: Context): Block = { val owner = fns.head.owner val parents1 = - if (parents.head.classSymbol.is(Trait)) defn.ObjectType :: parents + if (parents.head.classSymbol.is(Trait)) parents.head.parents.head :: parents else parents val cls = ctx.newNormalizedClassSymbol(owner, tpnme.ANON_FUN, Synthetic, parents1, coord = fns.map(_.pos).reduceLeft(_ union _)) |