Skip to content

Null checks are incorrectly optimized out for Flutter Border lerp function #43366

Closed
@ferhatb

Description

@ferhatb

Original customer issue: flutter/flutter#63740

Code that reproduces problem:
https://gist.github.com/rydmike/2e8e6a4cc9126dbe6f95e81e674f6d6b

The following BoxBorder.lerp/Border.lerp function is compiled from:

static Border? lerp(Border? a, Border? b, double t) {
    assert(t != null);
    if (a == null && b == null)
      return null;
    if (a == null)
      return b!.scale(t);
    if (b == null)
      return a.scale(1.0 - t);
    return Border(
      top: BorderSide.lerp(a.top, b.top, t),
      right: BorderSide.lerp(a.right, b.right, t),
      bottom: BorderSide.lerp(a.bottom, b.bottom, t),
      left: BorderSide.lerp(a.left, b.left, t),
    );
  }

// The caller
 static BoxBorder? lerp(BoxBorder? a, BoxBorder? b, double t) {
    assert(t != null);
    if ((a is Border?) && (b is Border?))
      return Border.lerp(a, b, t);
.......

to:

Border_lerp: function(a, b, t) {
  ///!!!!! NO null checks
      return new F.Border(Y.BorderSide_lerp(a.top, b.top, t), Y.BorderSide_lerp(a.right, b.right, t), Y.BorderSide_lerp(a.bottom, b.bottom, t), Y.BorderSide_lerp(a.left, b.left, t));
    },


BoxBorder_lerp: function(a, b, t) {
      var t0, t2,
        t1 = type$.nullable_Border;
      if (t1._is(a) && t1._is(b))
        return F.Border_lerp(a, b, t);
      t1 = type$.nullable_BorderDirectional;

Metadata

Metadata

Assignees

Labels

NNBDIssues related to NNBD ReleaseP1A high priority bug; for example, a single project is unusable or has many test failuresarea-web-jsIssues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.customer-fluttermerge-to-betatype-bugIncorrect behavior (everything from a crash to more subtle misbehavior)web-dart2js

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions