Skip to content

Instantly share code, notes, and snippets.

@iapicca
Created December 5, 2023 13:04
Show Gist options
  • Save iapicca/2966ef8545140a396e7d7a4c86febbdb to your computer and use it in GitHub Desktop.
Save iapicca/2966ef8545140a396e7d7a4c86febbdb to your computer and use it in GitHub Desktop.
salvadorini's bug
import 'dart:math';
abstract class Foo {}
class Bar implements Foo {
const Bar();
}
class Baz implements Foo {
const Baz();
}
class Fizz extends Bar implements Baz {
const Fizz();
}
class RiverpodRocks extends Bar implements Baz {
const RiverpodRocks();
}
void main() {
final Baz baz =
Random().nextInt(2).isEven ? const Fizz() : const RiverpodRocks();
print(baz.runtimeType);
}
@iapicca
Copy link
Author

iapicca commented Dec 5, 2023

workaround

import 'dart:math';

abstract class Foo {}

class Bar implements Foo {
  const Bar();
}

class Baz implements Foo {
  const Baz();
}

class BarBaz extends Bar implements Baz {}

class Fizz  implements BarBaz {
  const Fizz();
}

class RiverpodRocks  implements BarBaz {
  const RiverpodRocks();
}

void main() {
  final Baz baz =  Random().nextInt(2).isEven ? const Fizz() : const RiverpodRocks();

  print(baz.runtimeType);
}

@rydmike
Copy link

rydmike commented Dec 5, 2023

Yes that works, because it ends up being this https://x.com/mraleph/status/1732020663672537357?s=20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment