Skip to content

Match expression aliases types without considering type bounds #6758

Closed
@fhackett

Description

@fhackett

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions