This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Abstract type member mixin possible?

2 replies
Sciss
Joined: 2008-12-17,
User offline. Last seen 28 weeks 5 days ago.

Hi,

any chance to get this working with any experimental scalac switch or compiler plugin?

trait Sys[ S <: Sys[ S ]] {
type Entity
}

def test[ S <: Sys[ S ]] = new AnyRef with S#Entity { override def toString = "hallo" }

thanks, -sciss-

Joshua.Suereth
Joined: 2008-09-02,
User offline. Last seen 32 weeks 5 days ago.
Re: Abstract type member mixin possible?

Nevermind....  you. Need a known type to instatiate that.   You could use implicits to look up a factory.

On Nov 25, 2011 11:44 AM, "Sciss" <contact [at] sciss [dot] de> wrote:
Hi,

any chance to get this working with any experimental scalac switch or compiler plugin?

   trait Sys[ S <: Sys[ S ]] {
      type Entity
   }

   def test[ S <: Sys[ S ]] = new AnyRef with S#Entity { override def toString = "hallo" }

thanks, -sciss-
Joshua.Suereth
Joined: 2008-09-02,
User offline. Last seen 32 weeks 5 days ago.
Re: Abstract type member mixin possible?

Try S with Sys[S] for the method argument type.

On Nov 25, 2011 11:44 AM, "Sciss" <contact [at] sciss [dot] de> wrote:
Hi,

any chance to get this working with any experimental scalac switch or compiler plugin?

   trait Sys[ S <: Sys[ S ]] {
      type Entity
   }

   def test[ S <: Sys[ S ]] = new AnyRef with S#Entity { override def toString = "hallo" }

thanks, -sciss-

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland