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

Unified Diff: pkg/analyzer/test/src/summary/resynthesize_ast_test.dart

Issue 1878223002: Infer type of extract index expressions. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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/summary/resynthesize_ast_test.dart
diff --git a/pkg/analyzer/test/src/summary/resynthesize_ast_test.dart b/pkg/analyzer/test/src/summary/resynthesize_ast_test.dart
index 408db12bcc9ce3c0e8dd32cd8cadd6737ff1a059..5e2bcd6adc92ffcb88ac8fff3ee9a06ca722bbae 100644
--- a/pkg/analyzer/test/src/summary/resynthesize_ast_test.dart
+++ b/pkg/analyzer/test/src/summary/resynthesize_ast_test.dart
@@ -209,6 +209,33 @@ class AstInferredTypeTest extends AbstractResynthesizeTest
super.test_genericMethods_inferJSBuiltin();
}
+ void test_infer_extractIndex_custom() {
+ var unit = checkFile('''
+class A {
+ String operator [](_) => null;
+}
+var a = new A();
+var b = a[0];
+ ''');
+ expect(unit.topLevelVariables[1].type.toString(), 'String');
+ }
+
+ void test_infer_extractIndex_fromList() {
+ var unit = checkFile('''
+var a = <int>[1, 2, 3];
+var b = a[0];
+ ''');
+ expect(unit.topLevelVariables[1].type.toString(), 'int');
+ }
+
+ void test_infer_extractIndex_fromMap() {
+ var unit = checkFile('''
+var a = <int, double>{};
+var b = a[0];
+ ''');
+ expect(unit.topLevelVariables[1].type.toString(), 'double');
+ }
+
void test_infer_extractProperty_getter() {
checkFile(r'''
var a = 1.isEven;
« 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