Skip to content

Problem with dependent implicit conversion #16208

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
odersky opened this issue Oct 19, 2022 · 3 comments · Fixed by #20177
Closed

Problem with dependent implicit conversion #16208

odersky opened this issue Oct 19, 2022 · 3 comments · Fixed by #20177
Labels
Milestone

Comments

@odersky
Copy link
Contributor

odersky commented Oct 19, 2022

Compiler version

3.2.2

Minimized example

class Ann(x: Any) extends annotation.Annotation
object Message:
  implicit def toNoExplanation(str: String): Message @Ann(str) = ???
class Message

object report:
  def error(x: Message): Unit = ???

def test =
  report.error("a") // works
  report.error("a".stripMargin) // error

Output

10 |  report.error("a".stripMargin)
   |               ^^^^^^^^^^^^^^^
   |               Found:    String
   |               Required: Message
   |

Expectation

Should compile. The problem needs the following elements:

  • the expected conversion needs to be a dependent method
  • the argument needs to involve another implicit conversion in some way (in this case, the wrapper to StringLike which contains stripMargin.
@odersky odersky added stat:needs triage Every issue needs to have an "area" and "itype" label itype:bug area:implicits related to implicits prio:low and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Oct 19, 2022
@odersky
Copy link
Contributor Author

odersky commented Oct 19, 2022

I marked this as low-priority since it affects old style conversions only. New style conversions cannot be dependent, period.

@odersky
Copy link
Contributor Author

odersky commented Oct 20, 2022

@smarter suggested that it's probably the fact that the argument is not a singleton that makes a difference, since in that case we have to skolemize.

@SethTisue
Copy link
Member

(Note that it does compile in Scala 2.13.10.)

EugeneFlesselle added a commit to dotty-staging/dotty that referenced this issue Apr 13, 2024
hamzaremmal added a commit that referenced this issue Apr 14, 2024
@Kordyjan Kordyjan added this to the 3.5.0 milestone May 10, 2024
WojciechMazur pushed a commit that referenced this issue Jul 5, 2024
Closes #19749
Closes #16208

[Cherry-picked 2afcf39]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants