Skip to content

Instantly share code, notes, and snippets.

@rofrankel
Last active May 19, 2020 19:15
Show Gist options
  • Select an option

  • Save rofrankel/055d187a85ca14f2d3346ceb94956eb4 to your computer and use it in GitHub Desktop.

Select an option

Save rofrankel/055d187a85ca14f2d3346ceb94956eb4 to your computer and use it in GitHub Desktop.
class G {}
class Foo<T extends G, F extends Foo<T, F, B>, B extends Bar<T, F, B>> {}
class Bar<T extends G, F extends Foo<T, F, B>, B extends Bar<T, F, B>> {}
class SubFoo extends Foo<G, SubFoo, SubBar> {}
class SubBar extends Bar<G, SubFoo, SubBar> {}
String works<T extends G, F extends Foo<T, F, B>, B extends Bar<T, F, B>>(Foo<T, F, B> foo) => foo.runtimeType.toString();
String fails<T extends G, F extends Foo<T, F, B>, B extends Bar<T, F, B>>(F foo) => foo.runtimeType.toString();
void main() {
print(works(SubFoo()));
print(fails(SubFoo()));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment