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

Allow using clauses to introduce Scala-2 conversions #13662

Merged
merged 1 commit into from Oct 4, 2021

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Oct 3, 2021

Notably, (using A <:< B) should introduce an implicit conversion.
Previously that did not work since we tried to elaborate the context
parameter as a scala.Conversion.

Notably, `(using A <:< B)` should introduce an implicit conversion.
Previously that did not work since we tried to elaborate the context
parameter as a `scala.Conversion`.
Copy link
Member

@dwijnand dwijnand left a comment

Choose a reason for hiding this comment

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

Unless I'm blind, this makes (using map: Map[String, Int]) a problem again. I think we should "just" special-case <:< (and thus its subclass =:=): I know it's a special-casing, but I see it as a retroactive definition of them as subclasses of Conversion. Perhaps it can even be special-cased that way: stick Conversion as <:<'s base class or interfaces?

@odersky
Copy link
Contributor Author

odersky commented Oct 4, 2021

@dwijnand

Unless I'm blind, this makes (using map: Map[String, Int]) a problem again.

No, we do require that the implicit candidate returns a Conversion for that test, which Map does not do. There are actually two code points that are relevant here. One is in filterMatching where we do indeed special case <:<. The problem was that <:< can still only be used when passed as an implicit. And that's what is fixed by this PR.

Copy link
Member

@dwijnand dwijnand left a comment

Choose a reason for hiding this comment

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

Ah, right. Thanks! Do we have or want to add a test to safe guard against that Map puzzler?

@odersky
Copy link
Contributor Author

odersky commented Oct 4, 2021 via email

@odersky odersky merged commit d4ba729 into scala:master Oct 4, 2021
@odersky odersky deleted the fix-12955 branch October 4, 2021 10:38
@Kordyjan Kordyjan added this to the 3.1.1 milestone Aug 2, 2023
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.

Scala 3 does not perform implicit conversion using <:<
4 participants