Skip to content

[dart2js/Dart 2.0] Fix behavior of type errors on partial instantiation in dart2js #34295

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sjindel-google opened this issue Aug 29, 2018 · 1 comment
Assignees
Labels
area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) web-dart2js

Comments

@sjindel-google
Copy link
Contributor

sjindel-google commented Aug 29, 2018

It was decided in #31953 that the partial instantiation operator needs to check the bounds of type arguments at the point of partial instantiation, rather than waiting until the resulting closure is called. The VM is currently being updated with the correct behavior, but dart2js also has the incorrect behavior. For example, the following test should pass:

// Copyright (c) 2018, the Dart project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
//
// This test checks that necessary type argument bounds checks are performed
// eagerly during partial instantiation, rather than being delayed until the
// partially instantiated closure is invoked.

import "package:expect/expect.dart";

class C<T> {
  void foo<S extends T>(S x) {}
}

void main() {
  C<Object> c = C<int>();
  void Function(String) fn;
  Expect.throwsTypeError(() {
    fn = c.foo;
  });
}

I've suggested P1 priority for this issue because fixing the semantics here is a breaking change.

@sjindel-google sjindel-google added P1 A high priority bug; for example, a single project is unusable or has many test failures web-dart2js type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Aug 29, 2018
@sjindel-google sjindel-google removed the P1 A high priority bug; for example, a single project is unusable or has many test failures label Aug 31, 2018
@vsmenon vsmenon added the area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. label Jul 20, 2019
@joshualitt
Copy link
Contributor

Closing because this seems to be passing in dart2js on TOT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) web-dart2js
Projects
None yet
Development

No branches or pull requests

4 participants