Skip to content
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

dart2js not setting default function field #36222

hterkelsen opened this Issue Mar 14, 2019 · 3 comments


None yet
5 participants
Copy link

hterkelsen commented Mar 14, 2019

I have the following program:

typedef int BinaryFunc(int x, int y);

class A {
  const A({ = A.defaultFoo});

  static int defaultFoo(int x, int y) {
    return x + y;

  final BinaryFunc foo;

class B<T> {
  T get item => _item;
  T _item;

class C extends B<A> {
  bar() {
    print(, 2));

class Box {
  final B<Object> b;
  Box(B<Object> b) : this.b = b;

  update(Object o) {
    b._item = o;

main() {
  var c = C();
  var box1 = Box(c);

  var b = B<int>();
  var box2 = Box(b);


This code works fine in older versions of dart2js (works on Dartpad), but fails on the most current version of dart2js (Dart-to-JavaScript compiler (dart2js) version: 2.2.1-edge.5e1397fc4e7dd8e32a79252a7e780d120c939392).

dart2js emits this code for the class A:

  T.A.prototype = {
    foo$2: function(arg0, arg1) {
      return$2(arg0, arg1);

but it never sets so when is run, it crashes with:

TypeError: Cannot read property 'call$2' of undefined
         throw e;
TypeError: Cannot read property 'call$2' of undefined
   at$2 (out.js:1464:23)
   at main (out.js:1221:33)
   at action (/usr/local/google/home/het/Projects/dart/sdk/sdk/lib/_internal/js_runtime/lib/preambles/d8.js:275:31)
   at eventLoop (/usr/local/google/home/het/Projects/dart/sdk/sdk/lib/_internal/js_runtime/lib/preambles/d8.js:258:9)
   at self.dartMainRunner (/usr/local/google/home/het/Projects/dart/sdk/sdk/lib/_internal/js_runtime/lib/preambles/d8.js:276:5)
   at out.js:1534:7
   at out.js:1520:7
   at dartProgram (out.js:1531:5)
   at out.js:1538:3

@kevmoo kevmoo added the p1-high label Mar 14, 2019

@kevmoo kevmoo added this to the Dart2.2.1 milestone Mar 14, 2019

@vsmenon vsmenon modified the milestones: Dart2.2.1, Dart2.3 Mar 14, 2019


This comment has been minimized.

Copy link

vsmenon commented Mar 14, 2019

@kevmoo - I've been folding 2.2.1 issues to 2.3.


This comment has been minimized.

Copy link

sigmundch commented Mar 14, 2019

@johnniwinther - I bisected this and found that this started failing with 1720704

@johnniwinther johnniwinther self-assigned this Mar 15, 2019


This comment has been minimized.

Copy link

johnniwinther commented Mar 15, 2019

@dart-bot dart-bot closed this in eb6f1b6 Mar 15, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.