[scala] Strangeness with self types & wildcards in 2.8

View: New views
1 Messages — Rating Filter:   Alert me  

[scala] Strangeness with self types & wildcards in 2.8

by bearfeeder :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Howdy,

I've got a construct:

trait Frog[T] {
  def hello: T 
  def size: Int                                                                                                                                                          
}

trait OnlyWithFrogs {
  self: Frog[_] =>

    def sizeStr = size.toString
}

The OnlyWithFrogs trait must be mixed into a Frog (no, it's not okay to make it derive from Frog).  The above code worked with 2.7.5, but fails in 2.8 with:
: error: illegal cyclic reference involving type _$1
[WARNING]   self: Frog[_] =>

So, I tried to make my own wildcard:

  self: Frog[(Q forSome {type Q})] =>

This compiles, but when I try to create a concrete instance:

object Ribbit extends Frog[String] with OnlyWithFrogs {
  def hello = "Hi"
  def size = 44
}

The results in the following compile-time error:

[WARNING]  error: illegal inheritance;
[WARNING]  self-type net.liftweb.mapper.Ribbit.type does not conform to net.liftweb.mapper.OnlyWithFrogs's selftype net.liftweb.mapper.OnlyWithFrogs with net.liftweb.mapper.Frog[Q forSome { type Q }]
[WARNING] object Ribbit extends Frog[String] with OnlyWithFrogs {

Is this a bug in 2.8 worthy of a ticket or is there another way to deal with the wildcard/self-type issue?

Thanks,

David

--
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Surf the harmonics