Skip to content

Fix nested pkg member 2 #905

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

Merged
merged 4 commits into from
Nov 9, 2015
Merged

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Nov 2, 2015

One more fix to compile stdlib. Review by @smarter.

Compiling scala.math.BigDecimal and scala.math.BigInteger shows a problem.
The conversion `int2bigInt` is not applicable to a Byte because `Byte -> Int`
requires another implicit conversion.

We fix that by using a new method relaxed_<:< for implicit compatibility checks,
which always admits numeric widenings.

This leads to another problem. Now the conversions

    implicit def byteToInt(x: Byte): Int
    implicit def byteToShort(x: Byte): Short

are ambiguous when we try to convert from Byte to Int.
We fix that by adding a "tie-break" to implicit search
where if several methods match a numeric value result type
and all have numeric value types as result types, we
pick the numerically largest type that matches.
Dotty delivers an ambiguity error. The comment in the test argues why
this is OK.
and explain why it's different now.
The previous rules picked the once outer removed member rather than
the innermost one, of both members exist.

Seen in the wild in scala.sys.ShutdownHookThread. No separate test here,
because we'll include large parts of stdlib anyway as a build test.
@odersky
Copy link
Contributor Author

odersky commented Nov 2, 2015

/rebuild

@smarter
Copy link
Member

smarter commented Nov 5, 2015

LGTM (but this should be rebased to not be on top of #902)

odersky added a commit that referenced this pull request Nov 9, 2015
@odersky odersky merged commit 3d5a2e2 into scala:master Nov 9, 2015
@allanrenucci allanrenucci deleted the fix-nested-pkg-member-2 branch December 14, 2017 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants