Skip to content

Instantly share code, notes, and snippets.

@osa1
Last active January 26, 2023 15:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save osa1/a6b70f36d1041996c3ff7fa12c7589d8 to your computer and use it in GitHub Desktop.
Save osa1/a6b70f36d1041996c3ff7fa12c7589d8 to your computer and use it in GitHub Desktop.
Strange Dart 9 (2)
import 'my_library.dart';
// Same class B in Strange Dart 9.1, but this time it's accepted.
class B implements A {}
void main() {
wat(B()); // _a getters and setters redirect to noSuchMethod
}
// Same definition in Strange Dart 9.1.
class A {
int _a = 1;
int _b = 2;
@override
String toString() => '$_a $_b';
}
void wat(A a) {
print(a._a); // subtypes need to have getter _a
a._a = 123; // subtypes need to have setter _a
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment