Skip to content

The auto-approximated bound for match types leaks type captures #21256

Closed
@sjrd

Description

@sjrd

Compiler version

since 3.4.2, still present in main

Minimized code

object Test {
  type MTWithBind[X] = X match {
    case List[t] => t
  }
}

Output

With -Xprint:typer:

    type MTWithBind[X >: Nothing <: Any] =
      X match 
        {
          case List[t @ _] => t
        }
       <: t

Expectation

t should not appear in the inferred bound of the match type, since it is outside of its declaring scope.

Overall I'm getting increasingly uneasy about #19761. 🫤

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions