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

Unified Diff: pkg/analyzer/lib/src/summary/link.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 | « no previous file | pkg/analyzer/test/src/summary/resynthesize_ast_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/summary/link.dart
diff --git a/pkg/analyzer/lib/src/summary/link.dart b/pkg/analyzer/lib/src/summary/link.dart
index 1b3f15fa5287835fb07461b801505ccd823d5cdb..8d7d33ed206c6a37fd2f83e9f27f0cd8ac2f4bae 100644
--- a/pkg/analyzer/lib/src/summary/link.dart
+++ b/pkg/analyzer/lib/src/summary/link.dart
@@ -1791,9 +1791,7 @@ class ExprTypeComputer {
_doAssignToIndex();
break;
case UnlinkedConstOperation.extractIndex:
- stack.length -= 2;
- // TODO(paulberry): implement.
- stack.add(DynamicTypeImpl.instance);
+ _doExtractIndex();
break;
case UnlinkedConstOperation.invokeMethodRef:
_doInvokeMethodRef();
@@ -1924,6 +1922,20 @@ class ExprTypeComputer {
stack.add(type);
}
+ void _doExtractIndex() {
+ stack.removeLast(); // index
+ DartType target = stack.removeLast();
+ stack.add(() {
+ if (target is InterfaceType) {
+ MethodElement method = target.lookUpMethod('[]', library);
+ if (method != null) {
+ return method.returnType;
+ }
+ }
+ return DynamicTypeImpl.instance;
+ }());
+ }
+
void _doExtractProperty() {
DartType target = stack.removeLast();
String propertyName = _getNextString();
« no previous file with comments | « no previous file | pkg/analyzer/test/src/summary/resynthesize_ast_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698