-
Notifications
You must be signed in to change notification settings - Fork 22
Java Generic Signature for nested refinements imprecise #10543
Copy link
Copy link
Open
Labels
Milestone
Description
object Test {
def main(args: Array[String]) {
println(classOf[Foo[_]].getTypeParameters.apply(0).getBounds)
}
}
class C1 { def c1 = 0 }
trait T1 { def t1: Int }
trait T2 { def t2: Int }
class Foo[T <: (C1 with T1) with T2]// Note the parentheses
Prints: class C1, interface T2
Could we include T1 in the signature, too?
Discovered during porting of our implementation to dotty: scala/scala3#3234 (comment)
Fix is probably as simple as adding a recursive case to:
private def hiBounds(bounds: TypeBounds): List[Type] = bounds.hi.dealiasWiden match {
case RefinedType(parents, _) => parents map (_.dealiasWiden)
case tp => tp :: Nil
}
(Or using the existing flattening in RefinedType.normalize)
We need to be careful when changing this that we maintain the invariant that the erased type conforms to the generic type.
Reactions are currently unavailable