Skip to content

Type inference too imprecise when approximating union of abstract types #998

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

Closed
smarter opened this issue Dec 11, 2015 · 0 comments
Closed

Comments

@smarter
Copy link
Member

smarter commented Dec 11, 2015

In this example, elem is inferred to be of type Any instead of type X as in Scala 2:

object Test {
  def foo[A <: X, B <: X, X](left: A, right: B): Unit = {
    val elem = if (false) left else right
  }
}

The issue is in TypeOps#approximateUnion, we approximate a union of types using the intersection of the base classes of the types, but that's not correct when the types are bounded by abstract types.

odersky added a commit to dotty-staging/dotty that referenced this issue Jan 19, 2016
Needed a fix in approximateUnion.
DarkDimius pushed a commit to dotty-linker/dotty that referenced this issue May 9, 2016
Needed a fix in approximateUnion.
OlivierBlanvillain pushed a commit to OlivierBlanvillain/dotty that referenced this issue Dec 8, 2016
OlivierBlanvillain pushed a commit to OlivierBlanvillain/dotty that referenced this issue Dec 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants