Last active
January 26, 2023 15:52
-
-
Save osa1/a6b70f36d1041996c3ff7fa12c7589d8 to your computer and use it in GitHub Desktop.
Strange Dart 9 (2)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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