Skip to content

Regression: Type inference in lambda chooses Nothing instead of dependant type #12247

Closed
@japgolly

Description

@japgolly

Compiler version

3.0.0-RC3

Minimized code

sealed abstract class CtorType
object CtorType {
  final class Props extends CtorType
  sealed trait Summoner { type CT <: CtorType }
  implicit def summonP: Summoner {type CT = Props} = ???
}

final case class Builder() {
  def build(using ctorType: CtorType.Summoner): Component[ctorType.CT] = ???
}

final class Component[CT <: CtorType]

object Test {

  def assertTypeOf[A](a: => A) = new TestDsl[A]
  class TestDsl[A] {
    def is[B](implicit ev: A =:= B): Unit = ()
  }

  type Expect = Component[CtorType.Props]

  assertTypeOf( Builder().build ).is[Expect] // error

  val x = Builder().build
  assertTypeOf(x).is[Expect] // ok
}

Output

[error] 23 |  assertTypeOf( Builder().build ).is[Expect] // error
[error]    |                                            ^
[error]    |                   Cannot prove that Component[Nothing] =:= Test.Expect.
[error] one error found

Expectation

Success. This compiles with Scala 2.x.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions