Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Unified Diff: pkg/analyzer/test/src/task/strong/inferred_type_test.dart

Issue 2016873002: Implement AST-based type inference involving expression-type closures. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/summary/link.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/src/task/strong/inferred_type_test.dart
diff --git a/pkg/analyzer/test/src/task/strong/inferred_type_test.dart b/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
index 45e0ada2bb86505783aa9b49f400845c1c2493d0..7eec4c6a0af9fdef355ee9e5e5274aaf802144fc 100644
--- a/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
+++ b/pkg/analyzer/test/src/task/strong/inferred_type_test.dart
@@ -2631,6 +2631,42 @@ var x = (f().n *= null);
expect(x.type.toString(), 'num');
}
+ void test_inferredType_viaClosure_multipleLevelsOfNesting() {
+ var mainUnit = checkFile('''
+class C {
+ static final f = (bool b) => (int i) => /*info:INFERRED_TYPE_LITERAL*/{i: b};
+}
+''');
+ var f = mainUnit.getType('C').fields[0];
+ expect(f.type.toString(), '(bool) → (int) → Map<int, bool>');
+ }
+
+ void test_inferredType_viaClosure_typeDependsOnArgs() {
+ var mainUnit = checkFile('''
+class C {
+ static final f = (bool b) => b;
+}
+''');
+ var f = mainUnit.getType('C').fields[0];
+ expect(f.type.toString(), '(bool) → bool');
+ }
+
+ void test_inferredType_viaClosure_typeIndependentOfArgs_field() {
+ var mainUnit = checkFile('''
+class C {
+ static final f = (bool b) => 1;
+}
+''');
+ var f = mainUnit.getType('C').fields[0];
+ expect(f.type.toString(), '(bool) → int');
+ }
+
+ void test_inferredType_viaClosure_typeIndependentOfArgs_topLevel() {
+ var mainUnit = checkFile('final f = (bool b) => 1;');
+ var f = mainUnit.topLevelVariables[0];
+ expect(f.type.toString(), '(bool) → int');
+ }
+
void test_inferStaticsTransitively() {
addFile(
'''
« no previous file with comments | « pkg/analyzer/lib/src/summary/link.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698