Created
July 7, 2021 20:55
-
-
Save eseidelGoogle/49c27f86409b51b03a2a7b157be3b206 to your computer and use it in GitHub Desktop.
Why do generic methods get treated like dynamic, but functions dont?
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 Test<T> { | |
Future<T?> method() { | |
return Future.value(null); | |
} | |
} | |
Future<T?> function<T>() { | |
return Future.value(null); | |
} | |
void main() async { | |
Test test = Test<bool>(); | |
bool foo = await test.method(); // Analyzer thinks this returns Future<dynamic> | |
bool bar = await function<bool>(); // Analyzer knows this returns Future<bool?> | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment