Support Structural Refinements
bishabosha opened this issue · comments
Jamie Thompson commented
[2 days]
class Structural1[M <: { val output: Int } ] {
import reflect.Selectable.reflectiveSelectable
def get(m: M): Int = m.output
}
class Structural2[M <: { def output: Int } ] {
import reflect.Selectable.reflectiveSelectable
def get(m: M): Int = m.output
}
class Structural3[M <: { def encode(t: Int): String } ] {
import reflect.Selectable.reflectiveSelectable
def encodeWith(m: M, t: Int): String = m.encode(t)
}
class StructuralSelectable[M <: Selectable { def encode(t: Int): String } ] {
def encodeWith(m: M, t: Int): String = m.encode(t)
}
class StructuralFlip1 {
import reflect.Selectable.reflectiveSelectable
def get[M <: { val output: Int } ](m: M): Int = m.output
}
class StructuralFlip2 {
import reflect.Selectable.reflectiveSelectable
def get[M <: { def output: Int } ](m: M): Int = m.output
}
class StructuralFlip3 {
import reflect.Selectable.reflectiveSelectable
def encodeWith[M <: { def encode(t: Int): String } ](m: M, t: Int): String = m.encode(t)
}
class StructuralSelectableFlip {
def encodeWith[M <: Selectable { def encode(t: Int): String } ](m: M, t: Int): String = m.encode(t)
}
Structural refinement callsites and bounds on scala.Selectable
are treated specially in Dotty, so there is an open question to how to support them if approved.