Skip to content

Problem with dependent implicit conversion #16208

@odersky

Description

@odersky
Contributor

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.

Activity

added
stat:needs triageEvery issue needs to have an "area" and "itype" label
and removed
stat:needs triageEvery issue needs to have an "area" and "itype" label
on Oct 19, 2022
odersky

odersky commented on Oct 19, 2022

@odersky
ContributorAuthor

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

odersky

odersky commented on Oct 20, 2022

@odersky
ContributorAuthor

@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

SethTisue commented on Oct 21, 2022

@SethTisue
Member

(Note that it does compile in Scala 2.13.10.)

added a commit that references this issue on Apr 13, 2024
f1e3714
added a commit that references this issue on Apr 14, 2024
2afcf39
added a commit that references this issue on Apr 14, 2024
54d67e0
added this to the 3.5.0 milestone on May 10, 2024
added a commit that references this issue on Jul 5, 2024
b8786aa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      Participants

      @SethTisue@odersky@Kordyjan

      Issue actions

        Problem with dependent implicit conversion · Issue #16208 · scala/scala3