- 
  Notifications
 You must be signed in to change notification settings 
- Fork 1.1k
Dotty should harder to unify subtypes of sealed traits #22478
 
 
 xiaoshihou514
 
 
 
 started this conversation in
 Feature Requests
 
 -
Consider the following:
sealed trait Expr case object IntLiteral extends Expr def foo[A <: Expr](expr: A): A = expr match { case IntLiteral => IntLiteral }
Ouput:
Found: Playground.IntLiteral.type
Required: A
where: A is a type in method renameExpr with bounds <: Playground.Expr
This should have compiled since Expr is sealed and every possible branch fulfilled the requirements (returned the same most specific type IntLiteral).
This means that I cannot pass a Foo & Bar into such a type-preserving function (A => A where A <: Foo) and expect the result to unify with Bar.
Thoughts?
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 0 comments
 
 Sign up for free
 to join this conversation on GitHub.
 Already have an account?
 Sign in to comment