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

Fix #1457: Three incompatbilities with scalac #1465

Merged
merged 4 commits into from
Sep 16, 2016

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Aug 23, 2016

Two of these are unavoidable. I moved the tests to diabled/not-representable
and added in each case a comment to the main scala file detailing why there
is a deviation.

The last one (import-rewrite) is fixed.

review by @olafurpg

Two of these are unavoidable. I moved the tests to diabled/not-representable
and added in each case a comment to the main scala file detailing why there
is a deviation.

The last one (import-rewrite) is fixed.
@olafurpg
Copy link
Contributor

olafurpg commented Aug 24, 2016

LGTM. Would be interesting to know how much code in the wild will be affected by these differences.

@odersky
Copy link
Contributor Author

odersky commented Aug 25, 2016

@olafurpg Yes, let's talk about how to bridge the gap here. I believe the rewriting tool and/or the scala compiler could at least give warnings for cases like these which are not representable. We might also be able to handle the "naming-resolution" problem specially in scala2mode.

Scala2 does not conform to spec Section 2, where it says:

Bindings of different kinds have a precedence defined on them:

 1. Definitions and declarations that are local, inherited, or made available by a package clause and also defined in the same compilation unit as the reference, have highest precedence.
 2. Explicit imports have next highest precedence.
 3. Wildcard imports have next highest precedence.
 4. Definitions made available by a package clause, but not also defined in the same compilation unit as the reference, have lowest precedence.

In fact Scala 2, merges (1) and (4) into highest precedence.

This commit simulates the Scala2 behavior under -language:Scala2, but gives a migration
warning. For the naming-resolution test case we get:

    dotc *.scala -language:Scala2 -migration
    callsite.scala:9: migration warning: Name resolution will change.
     currently selected                     : naming.resolution.Files
     in the future, without -language:Scala2: java.nio.file.Files'

    where  Files   is a type in package object package which is an alias of java.util.stream.Stream[java.nio.file.Path]
           Files'  is a class in package file

      def gimmeFiles: Files = Files.list(Paths.get("."))
                      ^
    one warning found
@odersky
Copy link
Contributor Author

odersky commented Aug 26, 2016

The naming resolution case is now supported under -language:Scala2, and gives a migration warning.

There's still nothing we can do about the hkt case.

Three goals:

 1. Fix crasher in compileStdLib by saving and restoring
    foundUnderScala2 analogous to iportedFromRoot.
 2. Make behavior the same as scalac under Scala2 mode -
    ListBuffer behaved differently before.
 3. Make findRef faster by making it tail-recursive
    as long as nothing was found.
@odersky odersky merged commit c420b4c into scala:master Sep 16, 2016
@allanrenucci allanrenucci deleted the fix-#1457 branch December 14, 2017 16:59
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