Skip to content

Expand type member in type mismatches #17700

@kubukoz

Description

@kubukoz

scala-cli https://raw.githubusercontent.com/kubukoz/demos/scala3-dependent-error/main.scala

//> using scala "3.1.3"

trait Request {
  type Out
}

object demo {

  def foo(r: Request)(v: r.Out) = ()

  val get: Request { type Out = String } = ???
  val put: Request { type Out = Unit } = ???

  foo(get)(())
}

In the code above, the compilation error you get with Scala 3.1.3 is:

Found:    Unit
Required: demo.get.Out

Scala 2.13.8 gives you more information because it dealiases the Out type:

type mismatch;
 found   : Unit
 required: demo.get.Out
    (which expands to)  String

I think it's a very useful thing to have, so I hope it can be added back.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions