Created
July 25, 2022 17:40
-
-
Save ailabs-software/a1be34092b1ddf04bb4b980a69ade05c to your computer and use it in GitHub Desktop.
More of more specific generic type parameter assigned to variable, causing loss of type checking.
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 Foo<T> | |
{ | |
late T value; | |
} | |
void main() { | |
Foo<Object?> foo1 = new Foo<String>(); | |
Foo<Object?> foo2 = new Foo<int>(); | |
foo1.value = "bar"; | |
foo2.value = "bar"; // Will fail because foo2 is Foo<int> | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment