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

Issue resolving "ambiguous" import statements #1117

Closed
nrinaudo opened this issue Dec 6, 2019 · 7 comments
Closed

Issue resolving "ambiguous" import statements #1117

nrinaudo opened this issue Dec 6, 2019 · 7 comments
Labels
bug A defect or misbehaviour. task / compile under investigation Any PR or ticket that requires investigation before further labelling or finding it actionable.

Comments

@nrinaudo
Copy link

nrinaudo commented Dec 6, 2019

Steps to reproduce

Compile the following code:

import a.b
import c.d

Such that a.b.c exists.

Observed behaviour

Scalac will understand these imports as:

import _root_.a.b
import _root_.c.d

But bloop will understand:

import _root_.a.b
import _root_.a.b.c.d

Suggested fix

I'm not actually sure which behaviour is correct, but I think it should be desirable for all compilers to agree on the semantics of the language.

If I replace my code with:

import a.b
import _root_.c.d

Then scalac and bloop will behave the same.

@olafurpg
Copy link
Contributor

olafurpg commented Dec 6, 2019

Thank you for reporting! Bloop uses the normal Scala compiler so there should be no differences in how import statements are resolved. Can you provide a repo to reproduce the issue?

@nrinaudo
Copy link
Author

nrinaudo commented Dec 6, 2019

Absolutely: nrinaudo/kantan.codecs#176

If you were to run, say, test:compile in SBT, everything should work fine.

If, on the other hand, you were to get the bloop integration working (I've done it with both vscode / metals and sbt bloopInstall) and run bloop compile shapeless-test, you'll get compile errors.

@jvican
Copy link
Contributor

jvican commented Dec 10, 2019

Thanks for reporting @nrinaudo and for the great reproduction. I'll have a look at this and figure out what's going on. 👍

@jvican jvican added bug A defect or misbehaviour. task / compile under investigation Any PR or ticket that requires investigation before further labelling or finding it actionable. labels Dec 10, 2019
@nrinaudo
Copy link
Author

Let me know if I can do anything to help.

One possible avenue is - I think the behaviour for this kind of import changed between 2.12 and 2.13. I'm never sure which is which, but one version gives priority to explicit imports, the other to object "naturally" in the scope...

@jvican
Copy link
Contributor

jvican commented Dec 10, 2019

I've tried to reproduce but I was not successful. I'm using the latest bloop master, but that shouldn't be important if we want to reproduce this as there hasn't been any important change in the way compilation works between the version you're using and the one I'm using.

➜ kantan.codecs git:(readability) ✗ bloop compile kantan-codecs-test Compiling core (40 Scala sources) Compiling coreJS (36 Scala sources) Compiled core (4799ms) Compiling enumeratum (4 Scala sources) Compiling java8 (6 Scala sources) Compiling cats (2 Scala sources) Compiling laws (23 Scala sources) Compiling core-test (41 Scala sources) Compiling shapeless (2 Scala sources) Compiling refined (2 Scala sources) Compiling scalaz (2 Scala sources) Compiling libra (2 Scala sources) Compiled refined (507ms) Compiling refined-test (2 Scala sources) Compiled libra (633ms) Compiling libra-test (1 Scala source) Compiled shapeless (741ms) Compiling shapeless-test (2 Scala sources) Compiled enumeratum (810ms) Compiling enumeratum-test (9 Scala sources) Compiled cats (1002ms) Compiled scalaz (992ms) Compiling scalaz-test (5 Scala sources) Compiling cats-test (3 Scala sources) Compiled java8 (2311ms) Compiling java8-test (15 Scala sources) Compiled coreJS (8161ms) Compiling enumeratumJS (4 Scala sources) Compiling catsJS (2 Scala sources) Compiling refinedJS (2 Scala sources) Compiling scalazJS (2 Scala sources) Compiling lawsJS (21 Scala sources) Compiling coreJS-test (25 Scala sources) Compiling shapelessJS (2 Scala sources) Compiled refinedJS (635ms) Compiling refinedJS-test (1 Scala source) Compiled enumeratumJS (1135ms) Compiling enumeratumJS-test (7 Scala sources) Compiled shapelessJS (1086ms) Compiled libra-test (3812ms) Compiling shapelessJS-test (1 Scala source) Compiled scalazJS (1373ms) Compiling scalazJS-test (5 Scala sources) Compiled catsJS (1642ms) Compiling catsJS-test (3 Scala sources) Compiled refined-test (4813ms) Compiled cats-test (6085ms) Compiled scalaz-test (6622ms) Compiled refinedJS-test (3720ms) Compiled laws (9794ms) Compiling scalaz-laws (4 Scala sources) Compiling laws-test (1 Scala source) Compiling refined-laws (2 Scala sources) Compiling cats-laws (3 Scala sources) Compiling java8-laws (2 Scala sources) Compiling shapeless-laws (3 Scala sources) Compiling libra-laws (2 Scala sources) Compiling enumeratum-laws (3 Scala sources) Compiled catsJS-test (5932ms) Compiled scalazJS-test (6190ms) Compiled libra-laws (1922ms) Compiled refined-laws (2047ms) Compiled java8-laws (9495ms) Compiled shapeless-laws (9512ms) Compiled enumeratum-test (18738ms) Compiled cats-laws (9617ms) Compiled scalaz-laws (10395ms) Compiled laws-test (10783ms) Compiled enumeratum-laws (10339ms) [W] [E4] java8/core/target/scala-2.13/src_managed/test/kantan/codecs/strings/java8/TimeEncoderCompanionDoctest.scala:7:31 [W] type Matchers in package scalatest is deprecated (since 3.1.0): The org.scalatest.Matchers trait has been moved and renamed. Please use org.scalatest.matchers.should.Matchers instead. This can be rewritten automatically with autofix: https://github.com/scalatest/autofix/tree/master/3.1.x [W] L7: with _root_.org.scalatest.Matchers [W] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [W] [E3] java8/core/target/scala-2.13/src_managed/test/kantan/codecs/strings/java8/TimeDecoderCompanionDoctest.scala:7:31 [W] type Matchers in package scalatest is deprecated (since 3.1.0): The org.scalatest.Matchers trait has been moved and renamed. Please use org.scalatest.matchers.should.Matchers instead. This can be rewritten automatically with autofix: https://github.com/scalatest/autofix/tree/master/3.1.x [W] L7: with _root_.org.scalatest.Matchers [W] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [W] [E2] java8/core/target/scala-2.13/src_managed/test/kantan/codecs/strings/java8/TimeCodecCompanionDoctest.scala:7:31 [W] type Matchers in package scalatest is deprecated (since 3.1.0): The org.scalatest.Matchers trait has been moved and renamed. Please use org.scalatest.matchers.should.Matchers instead. This can be rewritten automatically with autofix: https://github.com/scalatest/autofix/tree/master/3.1.x [W] L7: with _root_.org.scalatest.Matchers [W] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [W] [E1] java8/core/target/scala-2.13/src_managed/test/kantan/codecs/strings/java8/FormatDoctest.scala:7:31 [W] type Matchers in package scalatest is deprecated (since 3.1.0): The org.scalatest.Matchers trait has been moved and renamed. Please use org.scalatest.matchers.should.Matchers instead. This can be rewritten automatically with autofix: https://github.com/scalatest/autofix/tree/master/3.1.x [W] L7: with _root_.org.scalatest.Matchers [W] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [W] java8/core/target/scala-2.13/src_managed/test/kantan/codecs/strings/java8/TimeEncoderCompanionDoctest.scala: L7 [E4] [W] java8/core/target/scala-2.13/src_managed/test/kantan/codecs/strings/java8/TimeCodecCompanionDoctest.scala: L7 [E2] [W] java8/core/target/scala-2.13/src_managed/test/kantan/codecs/strings/java8/FormatDoctest.scala: L7 [E1] [W] java8/core/target/scala-2.13/src_managed/test/kantan/codecs/strings/java8/TimeDecoderCompanionDoctest.scala: L7 [E3] Compiled java8-test (19410ms) Compiled enumeratumJS-test (17370ms) Compiled lawsJS (18523ms) Compiling cats-lawsJS (3 Scala sources) Compiling enumeratum-lawsJS (3 Scala sources) Compiling refined-lawsJS (2 Scala sources) Compiling shapeless-lawsJS (3 Scala sources) Compiling lawsJS-test (1 Scala source) Compiling scalaz-lawsJS (4 Scala sources) Compiled shapeless-lawsJS (1574ms) Compiled refined-lawsJS (1796ms) Compiled cats-lawsJS (1888ms) Compiled enumeratum-lawsJS (2417ms) Compiled scalaz-lawsJS (2536ms) Compiled lawsJS-test (2649ms) Compiled shapeless-test (27559ms) Compiled coreJS-test (25241ms) Compiled shapelessJS-test (24180ms) [W] [E4] core/jvm/target/scala-2.13/src_managed/test/kantan/codecs/strings/codecsDoctest.scala:7:31 [W] type Matchers in package scalatest is deprecated (since 3.1.0): The org.scalatest.Matchers trait has been moved and renamed. Please use org.scalatest.matchers.should.Matchers instead. This can be rewritten automatically with autofix: https://github.com/scalatest/autofix/tree/master/3.1.x [W] L7: with _root_.org.scalatest.Matchers [W] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [W] [E3] core/jvm/target/scala-2.13/src_managed/test/kantan/codecs/strings/StringDecoderDoctest.scala:7:31 [W] type Matchers in package scalatest is deprecated (since 3.1.0): The org.scalatest.Matchers trait has been moved and renamed. Please use org.scalatest.matchers.should.Matchers instead. This can be rewritten automatically with autofix: https://github.com/scalatest/autofix/tree/master/3.1.x [W] L7: with _root_.org.scalatest.Matchers [W] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [W] [E2] core/jvm/target/scala-2.13/src_managed/test/kantan/codecs/strings/PlatformSpecificInstancesDoctest.scala:7:31 [W] type Matchers in package scalatest is deprecated (since 3.1.0): The org.scalatest.Matchers trait has been moved and renamed. Please use org.scalatest.matchers.should.Matchers instead. This can be rewritten automatically with autofix: https://github.com/scalatest/autofix/tree/master/3.1.x [W] L7: with _root_.org.scalatest.Matchers [W] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [W] [E1] core/jvm/target/scala-2.13/src_managed/test/kantan/codecs/resource/ResourceResultDoctest.scala:7:31 [W] type Matchers in package scalatest is deprecated (since 3.1.0): The org.scalatest.Matchers trait has been moved and renamed. Please use org.scalatest.matchers.should.Matchers instead. This can be rewritten automatically with autofix: https://github.com/scalatest/autofix/tree/master/3.1.x [W] L7: with _root_.org.scalatest.Matchers [W] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [W] core/jvm/target/scala-2.13/src_managed/test/kantan/codecs/strings/StringDecoderDoctest.scala: L7 [E3] [W] core/jvm/target/scala-2.13/src_managed/test/kantan/codecs/resource/ResourceResultDoctest.scala: L7 [E1] [W] core/jvm/target/scala-2.13/src_managed/test/kantan/codecs/strings/codecsDoctest.scala: L7 [E4] [W] core/jvm/target/scala-2.13/src_managed/test/kantan/codecs/strings/PlatformSpecificInstancesDoctest.scala: L7 [E2] Compiled core-test (29308ms)

@nrinaudo
Copy link
Author

I... wat.

Sorry. My mistake. After manually killing the bloop daemon, trashing all target, .bloop and .metals directories, and reinitialising everything, it seems to work fine now.

I'm honestly not sure what happened there. Sorry for having wasted your time :/

@jvican
Copy link
Contributor

jvican commented Dec 10, 2019

No worries, thanks a lot for all of the time you put in creating this ticket and following up. It's a pleasure to always read this kind of tickets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A defect or misbehaviour. task / compile under investigation Any PR or ticket that requires investigation before further labelling or finding it actionable.
Projects
None yet
Development

No branches or pull requests

3 participants