[#691] | project: compiler | priority: low | category: bug | |
---|---|---|---|---|
submitter | assigned to | status | date submitted | |
Sean | Martin | fixed | 2006-08-06 16:33:03.0 | |
subject | super selector broken in twisty mixin composition | |||
code |
trait Base { trait AssignArrow { type T <: Ti; trait Ti; } abstract class Arrow extends AssignArrow; val arrow : Arrow; } trait Ext0 extends Base { trait AssignArrow extends super.AssignArrow { type T <: Ti; trait Ti extends super.Ti; } } trait Ext1 extends Base { trait Arrow extends super.Arrow { type T <: Ti; trait Ti extends super.Ti; trait TiXX extends Ti; } val arrow : Arrow; } trait Composition extends Ext0 with Ext1 { object arrow0 extends Arrow with AssignArrow { type T = Ti /* with TiXX */; trait Ti extends super[Arrow].Ti with super[AssignArrow].Ti; } } |
|||
what happened | error overriding type T in trait Arrow with bounds >: scala.All <: arrow0.this.Ti; type T has incompatible type test2/src/test test.scala line 30 1154812245171 34629 |
|||
what expected | No type error. I think super[Arrow].Ti is resolving to Base#Arrow#Ti rather than Ext1#Arrow#Ti (the symbol provided to the presentation compiler backs this up). Note that if we uncomment the /* with TiXX */ the type error goes away because TiXX allows us to get at Ext1#Arrow#Ti. | |||
[back to overview] |
Martin edited on 2006-08-22 16:37:33.0 |
This was hard to figure out. The problem is that
Ext1.Arrow is a trait, whose superclass is Base.Arrow. Furthermore, the extends caluse of arrow0 starts with trait Ext1.Arrow, and is therefore implicitly augmented with a superclass. The augmented signature of arrow0 reads:
object arrow0 extends Base#Arrow with Ext1#Arrow with ...Hence, in object arrow0 the reference super[Arrow] really referred to Base#Arrow, because the spec said that the *first* parent class with the given name would be picked. To prevent mystifing behavior like this, I changed spec and compiler so that only a single parent class may have the given name, otherwise an ambiguity error results. |