Skip to content

Match expression aliases types without considering type bounds #6758

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
fhackett opened this issue Jun 26, 2019 · 2 comments
Closed

Match expression aliases types without considering type bounds #6758

fhackett opened this issue Jun 26, 2019 · 2 comments

Comments

@fhackett
Copy link
Contributor

minimized code

class X[A,B]

abstract class A[T]

class B[F <: X[_,_]] extends A[F]

def fn1[T](a : A[T]) = a match {
  case aa : B[f] => fn2(aa)
}

def fn2[F <: X[_,_]](b : B[F]) = ???

This blows up on the call to fn2 saying that type parameter T does not conform to upper bound X[_,_]. While this is true, we just matched a to aa which is of type B[f], where f should by construction have the correct bounds. Somehow Dotty is considering f === T, ignoring changes in bounds due to the match.

expectation

This code compiles without the error described above.

Note: this might be related to #6697, since that looks similar but on the type level

@liufengyun
Copy link
Contributor

@AleksanderBG It seems related to GADT. Feel free to reassign if it's not related.

@DmytroMitin
Copy link

Not reproducible in 3.2.2 https://scastie.scala-lang.org/DmytroMitin/eECHNH2IRdCKRUNPU4x0Vg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants