Skip to content

Allow sending a generic object with a function type parameter between isolates #44431

Closed
@dnfield

Description

@dnfield

See #37294

This code fails, now with a meaningful error message:

import 'dart:isolate';

void fun() {
 print('hi from fun');
}

Future<void> main() async {
  final x = <void Function()>[fun];
  await Isolate.spawn(isolate, x);
}

void isolate(List<void Function()> foo) async {
  print('Tick: $foo');
  foo.first();
}

But this code works:

import 'dart:isolate';

void fun() {
  print('hi from fun');
}

Future<void> main() async {
  final x = <dynamic>[fun];
  await Isolate.spawn(isolate, x);
}

void isolate(List<dynamic> foo) async {
  print('Tick: $foo');
  (foo.first as void Function())();
}

It'd be nice to let the typed version work too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.library-isolate

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions