[#349] | project: compiler | priority: medium | category: feature | |
---|---|---|---|---|
submitter | assigned to | status | date submitted | |
Burak | Martin | won't fix | 2004-07-08 14:44:09.0 | |
subject | inheritance of virtual types | |||
code |
trait A { type foo <: Foo; abstract class Foo; } trait B extends A { type foo = Foo; case class Bar(i:Int) extends Foo; } class AFun( a:A ) { val myA = a; val x = new scala.collection.mutable.HashSet[myA.foo]; } class BFun( b:B ) extends AFun( b ) { val myB = b; x += myB.Bar( 2 ); } |
|||
what happened | /tmp> scalac foo.scala foo.scala:24: type mismatch; found : BFun.this.myB.Bar required: BFun.this.myA.foo x += myB.Bar( 2 ); ^ one error found |
|||
what expected | given myB.Bar <: myB.Foo which is actually foo, silent run | |||
[back to overview] |
Burak edited on 2004-07-08 19:12:05.0 |
this is not a bug. With Matthias help, I realized that this was the correct thing to do:
abstract class AFun { val my:A; val x = new scala.collection.mutable.HashSet[my.foo]; } abstract class BFun extends AFun { val my:B; x += my.Bar( 2 ); }works like a charm now. |
Burak edited on 2004-07-08 19:12:46.0 |