Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
japgolly opened this issue Apr 28, 2021 · 0 comments · Fixed by #12294
Closed

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

japgolly opened this issue Apr 28, 2021 · 0 comments · Fixed by #12294
Milestone

Comments

@japgolly
Copy link
Contributor

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.

odersky added a commit to dotty-staging/dotty that referenced this issue Apr 30, 2021
When instantiating type variables before implicit search, refrain instantiating
them with bounds that are either Nothing or Any or that contain wildcard types.

Fixes scala#12247
michelou pushed a commit to michelou/scala3 that referenced this issue May 1, 2021
When instantiating type variables before implicit search, refrain instantiating
them with bounds that are either Nothing or Any or that contain wildcard types.

Fixes scala#12247
@Kordyjan Kordyjan added this to the 3.0.1 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants