Skip to content

Fix #17667 account for import order #17951

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

Conversation

PaulCoral
Copy link
Contributor

@PaulCoral PaulCoral commented Jun 9, 2023

Fix #17667

  • Imports in the same scope, but after the usage are reported.
  • Add test suit i17667
  • Fix test i15503a

An example to illustrate this :
This compiles:

import scala.util.Try
val trying = Try(1)

This does NOT compile

val trying = Try(1) // Not found: Try
import scala.util.Try

- Import in the same scope, but after the usage are reported.
- Add test suit i17667
- Fix test i15503a
import collection.mutable.Set // ok
import collection.mutable.Set // error
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@szymon-rd
I was just wondering about this one, it seems like this import is not required. It can be removed and still get the correct result : https://scastie.scala-lang.org/9pyvzVWyTAyBsOPduePhqg
Am I missing something ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, you are correct. Some of these tests lay out the expected false negatives. If this is not a false negative, then great.

Copy link
Contributor

@szymon-rd szymon-rd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! I just left one comment, and could you fix the failing test?

@@ -349,7 +348,7 @@ object CheckUnused:
*
* See the `isAccessibleAsIdent` extension method below in the file
*/
private val usedInScope = MutStack(MutSet[(Symbol,Boolean, Option[Name], Boolean)]())
private val usedInScope = MutStack(MutSet[(Symbol,Boolean, Option[Name], Boolean, Option[SrcPos])]())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you make it a case class instead? This tuple got very long and hard to understand.

@szymon-rd
Copy link
Contributor

@PaulCoral Can I finish this PR? Or are you planning to come back to it?

@PaulCoral
Copy link
Contributor Author

@szymon-rd Yes, sure! Sorry for this, I was stuck with this last test, which seems to be related to "derives" (again...). I don't think I will have time soon for this, so you can go for it.

@som-snytt
Copy link
Contributor

I think this stale PR can be retired. Tracking imports by source position does not seem like a natural approach.

@Gedochao
Copy link
Contributor

Closing due to inactivity.
Feel free to open another attempt.

@Gedochao Gedochao closed this Nov 22, 2024
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.

-Wunused:import gets confused on import both locally and globally in file
4 participants