Mixing in traits with name-clashing inner classes

156 views
Skip to first unread message

Jon Pretty

unread,
Oct 18, 2015, 6:22:31 AM10/18/15
to dotty-internals
Hello,

If I have traits with inner classes of the same name, i.e.

   trait A { trait Inner }
   trait B { trait Inner }

I'm not able to create an `object C extends A with B`, due to the name clash with the inner traits.

Is there a workaround for this? (And should there be?)

I wonder whether the constraint could be used or abused to define traits which simply cannot be mixed in to certain others, albeit only by virtue of having inner classes with names that clash. In Scala, this wasn't a problem because the inner types were shadowed in linearization order, but each existed independently.

Jon

martin odersky

unread,
Oct 18, 2015, 6:33:50 AM10/18/15
to Jon Pretty, dotty-internals
Hi Jon,

Yes, that's intentionally forbidden. Your only workaround is to rename
one of the Inner classes.
Yes, you could do that. "used or abused" is a nice term for it.

- Martin

>
> Jon
>
> --
> You received this message because you are subscribed to the Google Groups
> "dotty-internals" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to dotty-interna...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Martin Odersky
EPFL
Reply all
Reply to author
Forward
0 new messages