Skip to content

derived with explicit term parameter creates confusing error at derives-site #15987

Closed
@Sporarum

Description

@Sporarum

Compiler version

scalacOptions ++= Seq(
  "-deprecation",
  "-encoding", "UTF-8",
  "-feature",
  "-unchecked"
)

scalaVersion := "3.2.0-RC1"
libraryDependencies += "org.scastie" %% "runtime-scala" % "1.0.0-SNAPSHOT"

addSbtPlugin("org.scastie" % "sbt-scastie" % "1.0.0-SNAPSHOT")

(3.2.0-RC1 is the latest version available on scastie)

Minimized code

trait Show[A]:
  extension(a: A) def show: String

object Show:
  def derived[A, B](x: B): Show[A] = ???

case object obj derives Show

https://scastie.scala-lang.org/Bw7NrMnbQdyKaakA8D5VQQ

Output

Found:    Playground.Show[A]
Required: String

where:    A is a type variable

Expectation

Something like:

derived instance Show[Person] failed to generate:
method `derived` from object Show takes explicit term parameters

Or:

Show cannot be used after `derives` as its companion object does not contain a method `derived` with signature:
  def derived[A, ...](using ...)...(using ...): Show[A]
Found:
  def derived[A, B](x: B): Show[A]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions