Skip to content

Bounds on generic methods should be treated invariantly in subtyping #29014

Closed
@leafpetersen

Description

@leafpetersen

Currently, the analyzer treats generic method bounds contra-variantly for sub-typing purposes. For example, the following is allowed:

class A {
  void foo<T extends num>() {}
}

class B extends A {
  void foo<T extends Object>() {}
}

Per language team decision, this should be changed to require that bounds be equal.

Metadata

Metadata

Labels

P2A bug or feature request we're likely to work onlegacy-area-analyzerUse area-devexp instead.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions