Skip to content

type test patterns evade deprecation warnings #12493

@adriaanm-da

Description

@adriaanm-da

I'd expect two deprecation warnings (I tried on latest 2.13.x), but get none:

object Test {
    class C

    @deprecated
    type DeprecatedAlias = C
    
    @deprecated
    class DeprecatedClass

    (??? : Any) match { 
        case _ : DeprecatedAlias =>   // should emit warning
        case _ : DeprecatedClass =>   // should emit warning
    }
}

I suspect the inPattern condition in https://github.com/scala/scala/blob/5697b87cf9aafd979533a92a92331874396b8584/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala#L1778-L1779 needs to be pushed into theRefCheckTypeMap and the skipping needs to a bit more fine-grained: deprecation warnings should be emitted (since pattern matching expansion happens after refchecks, I guess the emitted code evade further checking), but bounds may still need to be ignored.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions