Skip to content

Incorrect type inside tuple returned from match #15972

Open
@Arthurm1

Description

@Arthurm1

I'm not sure if I'm asking for too much here, but using a match to refine the type of Option to Some doesn't work inside a Tuple

Compiler version

3.2.0-RC1 (using Scastie)

happens in Scala 2.13.8 as well

Minimized code

// `Option` correctly converted to `Some`
val somes = Set.empty[Option[String]]
val some: Set[Some[String]] = somes.collect { case foo @ Some(_) => foo }

// `Option` inside `Tuple` not converted to `Some`
val tupledSomes = Set.empty[(String, Option[String])]
val whyNotSome: Set[(String, Some[String])] = tupledSomes.collect {   case foo @ (_, Some(_)) => foo }

Output

The following error is returned for the last line of code...

type mismatch;
 found   : (String, Option[String])
 required: (String, Some[String])

Expectation

I'd hope the second collect would convert the Option to Some in the same way the first collect does

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