-
Notifications
You must be signed in to change notification settings - Fork 21
Failed type inference when path dependent types are used as type arguments #9469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Imported From: https://issues.scala-lang.org/browse/SI-9469?orig=1 |
@retronym said:
This might well be the same bug as #5294 |
@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
}
|
@retronym said (edited on Nov 9, 2015 12:07:39 AM UTC): |
@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.
The text was updated successfully, but these errors were encountered: