Skip to content

Type pattern not widening scrutinee type #20992

Closed
@EugeneFlesselle

Description

@EugeneFlesselle

Compiler version

3.5.1-RC1-bin-SNAPSHOT-nonbootstrapped-git-cd8c5ed

Minimized code

Minimized from i7294.scala with @hamzaremmal

object Test:

  trait Foo:
    val x: Any

  ??? match
    case f: Foo =>
      (f: Foo).x // ok
      f.x // error

Output

-- [E007] Type Mismatch Error: tests/playground/example.scala:11:6 -------------
11 |      f.x // error
   |      ^
   |Found:    (f : Nothing)
   |Required: ?{ x: ? }
   |Note that implicit conversions were not tried because the result of an implicit conversion
   |must be more specific than ?{ x: <?> }

Expectation

no error

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions