Skip to content

NNBD: Dart does not throw compile error when declare incorrectly super bounded to non-null Object variable. #42429

@iarkh

Description

@iarkh

Dart VM version: 2.9.0-16.0.dev (dev) (Tue Jun 16 10:35:10 2020 +0200) on "windows_x64"

Here is a source code example:

class A<T extends A<T>> {}

main() {
  A<Object?> a1;
  A<Object>  a2;

  A<A<Object?>> a3;
  A<A<Object>>  a4;
}

Dart passes with this with nnbd enabled.

Object is not a top type with null-safety enabled, so actually dart should throw a compile error for a2 and a4 here.

See also Issue #42415.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NNBDIssues related to NNBD Releaselegacy-area-front-endLegacy: Use area-dart-model instead.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions