Created
February 26, 2021 20:55
-
-
Save burakemir/83f7f89f5d855bae6708d409f8644904 to your computer and use it in GitHub Desktop.
What happens when you're missing variance
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
class Foo {} | |
class Bar extends Foo {} | |
void main() { | |
Map<String, Foo> m = {}; | |
Map<String, Bar> n = {}; | |
m = n; | |
m["a"] = Foo(); | |
// Uncaught Error: TypeError: Instance of 'Foo': type 'Foo' is not a subtype of type 'Bar' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment