Skip to content

Problem with dependent implicit conversion #16208

Closed
@odersky

Description

@odersky

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions