Skip to content
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

Bizarre inference of upper bound for different boxed Java primitive numbers #3749

Open
scabug opened this issue Aug 11, 2010 · 3 comments
Open

Comments

@scabug
Copy link

scabug commented Aug 11, 2010

This seems needlessly baroque, not that I have any concrete suggestions for how it might be improved.

scala> List(java.lang.Double.valueOf(1), java.lang.Long.valueOf(2))
res16: List[java.lang.Number with java.lang.Comparable[_ >: java.lang.Long with java.lang.Double <: java.lang.Number with java.lang.Comparable[_ >: java.lang.Long with java.lang.Double <: java.lang.Number]]] = List(1.0, 2)
@scabug
Copy link
Author

scabug commented Aug 11, 2010

Imported From: https://issues.scala-lang.org/browse/SI-3749?orig=1
Reporter: @acruise

@scabug
Copy link
Author

scabug commented Aug 16, 2010

@lrytz said:
Note that

scala> List(1.0, 2l)
res1: List[Double] = List(1.0, 2.0)

@scabug
Copy link
Author

scabug commented Aug 17, 2010

@adriaanm said:
We plan to address this issue in future versions of Scala by introducing union types, so that the approximation of the least upper bound you see here could be denoted directly (and precisely) as java.lang.Double or java.lang.Long.

The current Scala compiler must approximate this type by expanding it, and truncating when it's gone two levels deep (to avoid even longer types -- in principle, the expansion is infinite).

First, we need to work out the nitty gritty details of the theory, though.

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

3 participants