This file contains 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 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
// Private members are not part of a class's interface, but implementing | |
// classes need to implement them. | |
// | |
// ... except when the class being implemented is in a separate library. See | |
// the second part: https://gist.github.com/osa1/a6b70f36d1041996c3ff7fa12c7589d8 | |
class A { | |
int _a = 1; | |
int _b = 2; |
This file contains 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
class A { | |
@override | |
Type get runtimeType => int; | |
} | |
class B<T> {} | |
void main() { | |
print(A().runtimeType); // int | |
print(B<A>().runtimeType); // B<A> |
This file contains 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
// Almost by definition, if I'm able to pass X where Y is expected, then X is a | |
// subtype of Y. | |
// | |
// In Dart, this mostly holds, but `dynamic` is an exception. I can pass | |
// `dynamic` everywhere, but it's not really a subtype of anything. | |
void f(int a) {} | |
class C<A> {} |
This file contains 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
module Lexer | |
( Token(..) | |
, TokenPos | |
, tokenize | |
) where | |
import Text.ParserCombinators.Parsec hiding (token, tokens) | |
import Control.Applicative ((<*), (*>), (<$>), (<*>)) | |
data Token = Ide String |
This file contains 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
class C { | |
dynamic get a { | |
print('C.a getter called'); | |
return (x) => print('C.a return value called'); | |
} | |
} | |
void main() { | |
var x = C(); |
This file contains 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
class A { | |
void f() { | |
print('A.f called'); | |
} | |
} | |
class B implements A { | |
void f({int test}); // optional non-nullable with no default value, also not a valid override | |
// `f` above is not valid without a `noSuchMethod` |
This file contains 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
class A { | |
void f() {} | |
} | |
extension B on A { | |
void g() {} | |
} | |
void main() { | |
final a = A(); |
This file contains 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
class A { | |
void f() { | |
print('A.f called'); | |
} | |
} | |
class B extends A { | |
@override | |
void f(); | |
} |
This file contains 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
void voidFun() => 123; | |
class A<T> { | |
T x; | |
A (this.x); | |
Object? getX() => x; | |
} |