Skip to content

No warning about non-exhaustive pattern matching for constructor with type bound enclosing type member #23369

@Alex1005a

Description

@Alex1005a
Contributor

Compiler version

scala 3.7.1

Minimized code

class Module {
  type BarTy
  sealed trait Adt[A]
  case class Foo() extends Adt[String]
  case class Bar[A <: BarTy](x: BarTy) extends Adt[A]
}

object Basic extends Module {
  type BarTy = String
}

def test(a: Basic.Adt[String]) = {
    a match
        case Basic.Foo() =>
}

val result = test(Basic.Bar(""))
print(result)

Output

Exception in thread "main" scala.MatchError: Bar()

Expectation

Compiler warning: match may not be exhaustive.

Activity

added
area:reportingError reporting including formatting, implicit suggestions, etc
and removed
stat:needs triageEvery issue needs to have an "area" and "itype" label
on Jun 25, 2025
nox213

nox213 commented on Aug 7, 2025

@nox213
Contributor

It seems that during space calculation for Basic.Adt[String], BarTy is not being concretized to String, so Basic.Bar[String] is not included in the space. I’m trying to take a look and see if I can fix it.

Alex1005a

Alex1005a commented on Aug 7, 2025

@Alex1005a
ContributorAuthor

You can see that the type bounds checking happens in the addOneBound function. This check happens during refineUsingParent function.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @nox213@Gedochao@Alex1005a

      Issue actions

        No warning about non-exhaustive pattern matching for constructor with type bound enclosing type member · Issue #23369 · scala/scala3