Skip to content

Unbound wildcard type when matching with @unchecked #13168

@noresttherein

Description

@noresttherein

Reproduction steps

Scala version: 2.13.16

	type ArrayLike[+X] >: Array[_ <: X] <: AnyRef
	(new Array[String](0) :ArrayLike[_] @unchecked) match {
		case _ :Array[AnyRef] => println("yes")
		case _                         => println("no")
	}

Problem

unbound wildcard type
	(new Array[String](0) :ArrayLike[_] @unchecked) match {

Compiles correctly without @unchecked.

Why would I want it? In more complex cases, generic type T[X] cannot be matched against T[Something] because of an error 'match pattern does not conform to matches subject' (or similar). Hence uptyping to an existential type. Presence of annotation @unchecked in this case was mandated by #13167

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions