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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * This library is capable of producing linked summaries from unlinked 6 * This library is capable of producing linked summaries from unlinked
7 * ones (or prelinked ones). It functions by building a miniature 7 * ones (or prelinked ones). It functions by building a miniature
8 * element model to represent the contents of the summaries, and then 8 * element model to represent the contents of the summaries, and then
9 * scanning the element model to gather linked information and adding 9 * scanning the element model to gather linked information and adding
10 * it to the summary data structures. 10 * it to the summary data structures.
(...skipping 1773 matching lines...) Expand 10 before | Expand all | Expand 10 after
1784 case UnlinkedConstOperation.assignToRef: 1784 case UnlinkedConstOperation.assignToRef:
1785 _doAssignToRef(); 1785 _doAssignToRef();
1786 break; 1786 break;
1787 case UnlinkedConstOperation.assignToProperty: 1787 case UnlinkedConstOperation.assignToProperty:
1788 _doAssignToProperty(); 1788 _doAssignToProperty();
1789 break; 1789 break;
1790 case UnlinkedConstOperation.assignToIndex: 1790 case UnlinkedConstOperation.assignToIndex:
1791 _doAssignToIndex(); 1791 _doAssignToIndex();
1792 break; 1792 break;
1793 case UnlinkedConstOperation.extractIndex: 1793 case UnlinkedConstOperation.extractIndex:
1794 stack.length -= 2; 1794 _doExtractIndex();
1795 // TODO(paulberry): implement.
1796 stack.add(DynamicTypeImpl.instance);
1797 break; 1795 break;
1798 case UnlinkedConstOperation.invokeMethodRef: 1796 case UnlinkedConstOperation.invokeMethodRef:
1799 _doInvokeMethodRef(); 1797 _doInvokeMethodRef();
1800 break; 1798 break;
1801 case UnlinkedConstOperation.invokeMethod: 1799 case UnlinkedConstOperation.invokeMethod:
1802 _doInvokeMethod(); 1800 _doInvokeMethod();
1803 break; 1801 break;
1804 case UnlinkedConstOperation.cascadeSectionBegin: 1802 case UnlinkedConstOperation.cascadeSectionBegin:
1805 stack.add(stack.last); 1803 stack.add(stack.last);
1806 break; 1804 break;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1917 1915
1918 void _doConditional() { 1916 void _doConditional() {
1919 DartType elseType = stack.removeLast(); 1917 DartType elseType = stack.removeLast();
1920 DartType thenType = stack.removeLast(); 1918 DartType thenType = stack.removeLast();
1921 stack.removeLast(); 1919 stack.removeLast();
1922 DartType type = _leastUpperBound(thenType, elseType); 1920 DartType type = _leastUpperBound(thenType, elseType);
1923 type = _dynamicIfNull(type); 1921 type = _dynamicIfNull(type);
1924 stack.add(type); 1922 stack.add(type);
1925 } 1923 }
1926 1924
1925 void _doExtractIndex() {
1926 stack.removeLast(); // index
1927 DartType target = stack.removeLast();
1928 stack.add(() {
1929 if (target is InterfaceType) {
1930 MethodElement method = target.lookUpMethod('[]', library);
1931 if (method != null) {
1932 return method.returnType;
1933 }
1934 }
1935 return DynamicTypeImpl.instance;
1936 }());
1937 }
1938
1927 void _doExtractProperty() { 1939 void _doExtractProperty() {
1928 DartType target = stack.removeLast(); 1940 DartType target = stack.removeLast();
1929 String propertyName = _getNextString(); 1941 String propertyName = _getNextString();
1930 stack.add(() { 1942 stack.add(() {
1931 if (target is InterfaceType) { 1943 if (target is InterfaceType) {
1932 PropertyAccessorElement getter = 1944 PropertyAccessorElement getter =
1933 target.lookUpGetter(propertyName, library); 1945 target.lookUpGetter(propertyName, library);
1934 if (getter != null) { 1946 if (getter != null) {
1935 return getter.returnType; 1947 return getter.returnType;
1936 } 1948 }
(...skipping 2008 matching lines...) Expand 10 before | Expand all | Expand 10 after
3945 List<int> implicitFunctionTypeIndices) => 3957 List<int> implicitFunctionTypeIndices) =>
3946 DynamicTypeImpl.instance; 3958 DynamicTypeImpl.instance;
3947 3959
3948 ReferenceableElementForLink getContainedName(String name) { 3960 ReferenceableElementForLink getContainedName(String name) {
3949 return new NonstaticMemberElementForLink(_constNode); 3961 return new NonstaticMemberElementForLink(_constNode);
3950 } 3962 }
3951 3963
3952 @override 3964 @override
3953 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 3965 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
3954 } 3966 }
OLDNEW
« 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