Skip to content

Extension type expression evaluation error when from closure parameter Β #56911

@FMorschel

Description

@FMorschel

Repro below (I could not find a way to remove more code than this).

import 'dart:typed_data';

void main() {
  var b = B(0);
  var list = [b];
  b.value2;
  list.forEach((b) {
    print(b.value2);
  });
}

extension type A._(Uint8List i) {
  A(int i) : this._(Uint8List.fromList([i]));

  int get value => i.elementAt(0);
}

extension type B._(A i) implements A {
  B(int i) : this._(A(i));

  bool get value2 => i.value == 0;
}

Steps:

  1. In the above code, place a breakpoint on line 6 (b.value2) and line 8 (inside the closure)
  2. Debug and add to watch b.value2
  3. On the first break, you'll see true as the result (as expected).
  4. On the second break, this is the output for expression evaluation:
Unhandled exception:
NoSuchMethodError: Class 'int' has no instance method 'elementAt'.
Receiver: 274334218320
Tried calling: elementAt(0)
#0      Object.noSuchMethod (dart:core-patch/object_patch.dart:38:5)
#1      A.value (package:bug/bug.dart:15:22)
#2      B.value2 (package:bug/bug.dart:21:24)
#3      Eval ()
#4      main.<anonymous closure> (package:bug/bug.dart:8:13)
#5      List.forEach (dart:core-patch/growable_array.dart:417:8)
#6      main (package:bug/bug.dart:7:8)
#7      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:297:19)
#8      _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)

CC @DanTup

Metadata

Metadata

Assignees

Labels

P2A bug or feature request we're likely to work oncfe-expression-compilationIssues related to expression compilation in the CFElegacy-area-front-endLegacy: Use area-dart-model instead.triagedIssue has been triaged by sub teamtype-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