Skip to content

Two variance checking holes: constructors and default getters #8737

Description

@scabug

The variance validator does not check constructors or default methods. The test case here shows that both of these decisions are unsound (and I suspect the decision not to check case class apply/unapply methods also falls into this category).

The VarianceChecker class in dotty PR #147 detects both variance violations.

As far as default getters are concerned we need to be careful with default getters for case class copy methods. These are allowed to violate variance because of the particular way copy works. The Dotty PR achieves this by
annotating the default getters of copy methods with @uncheckedVariance.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixed in Scala 3This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)should not compile

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions