Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upFailed type inference when path dependent types are used as type arguments #9469
Comments
This comment has been minimized.
This comment has been minimized.
Imported From: https://issues.scala-lang.org/browse/SI-9469?orig=1 |
This comment has been minimized.
This comment has been minimized.
@retronym said:
This might well be the same bug as #5294 |
This comment has been minimized.
This comment has been minimized.
@retronym said: object Test {
trait SubtypeOf[+T] {
type Type <: T
}
class Owned[+P <: Owner with Singleton](val next: Option[P#R])
class Owner {
type This <: Owner with Singleton
val R = SubtypeOf[Owned[This]]
type R = R.Type
def next(o: Owned[this.type]): Owned[This] = o.next.get
}
object Owner extends Owner {
type This = this.type
}
def SubtypeOf[T]: SubtypeOf[T] = new SubtypeOf[T] { type Type = T }
def compiles(o: Owned[Owner.type]): Owned[Owner.type] = o.next.get
def fails(o: Owned[Owner.type]): Owned[Owner.type] = o.next.get.next.get
def fix(o: Owned[Owner.type]): Owned[Owner.type] = (o.next.get: Owned[Owner.type]).next.get
}
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@retronym said (edited on Nov 9, 2015 12:07:39 AM UTC): |
This comment has been minimized.
This comment has been minimized.
@paulp said: |
I don't know if this is the right place to report it, but this code demonstrates an issue when path dependent types are used as type parameters for generic types:
This is not as academic as it might look, the code is derived from an attempt to create 'type boxes' grouping declarations of related types. So Owned is in fact a couple of dozen classes forming a component tree, where properties of those classes can be of types declared by passed Owner. This way one can duplicate a component hierarchy to add minor changes by simply overriding a type definition in Owner. SubtypeOf is a workaround to allow 'overridable covariant type declarations', so that adding a new component hierarchy would require only overriding changed types, instead of defining all types from scratch.