OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 /// This file declares a "shadow hierarchy" of concrete classes which extend | 5 /// This file declares a "shadow hierarchy" of concrete classes which extend |
6 /// the kernel class hierarchy, adding methods and fields needed by the | 6 /// the kernel class hierarchy, adding methods and fields needed by the |
7 /// BodyBuilder. | 7 /// BodyBuilder. |
8 /// | 8 /// |
9 /// Instances of these classes may be created using the factory methods in | 9 /// Instances of these classes may be created using the factory methods in |
10 /// `ast_factory.dart`. | 10 /// `ast_factory.dart`. |
(...skipping 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1153 DartType _inferExpression( | 1153 DartType _inferExpression( |
1154 KernelTypeInferrer inferrer, DartType typeContext, bool typeNeeded) { | 1154 KernelTypeInferrer inferrer, DartType typeContext, bool typeNeeded) { |
1155 typeNeeded = | 1155 typeNeeded = |
1156 inferrer.listener.propertyGetEnter(this, typeContext) || typeNeeded; | 1156 inferrer.listener.propertyGetEnter(this, typeContext) || typeNeeded; |
1157 // First infer the receiver so we can look up the getter that was invoked. | 1157 // First infer the receiver so we can look up the getter that was invoked. |
1158 var receiverType = inferrer.inferExpression(receiver, null, true); | 1158 var receiverType = inferrer.inferExpression(receiver, null, true); |
1159 Member interfaceMember; | 1159 Member interfaceMember; |
1160 if (receiverType is InterfaceType) { | 1160 if (receiverType is InterfaceType) { |
1161 interfaceMember = inferrer.classHierarchy | 1161 interfaceMember = inferrer.classHierarchy |
1162 .getInterfaceMember(receiverType.classNode, name); | 1162 .getInterfaceMember(receiverType.classNode, name); |
| 1163 if (inferrer.isTopLevel && |
| 1164 ((interfaceMember is Procedure && |
| 1165 interfaceMember.kind == ProcedureKind.Getter) || |
| 1166 interfaceMember is Field)) { |
| 1167 // References to fields and getters can't be relied upon for top level |
| 1168 // inference. |
| 1169 inferrer.recordNotImmediatelyEvident(fileOffset); |
| 1170 } |
1163 // Our non-strong golden files currently don't include interface targets, | 1171 // Our non-strong golden files currently don't include interface targets, |
1164 // so we can't store the interface target without causing tests to fail. | 1172 // so we can't store the interface target without causing tests to fail. |
1165 // TODO(paulberry): fix this. | 1173 // TODO(paulberry): fix this. |
1166 if (inferrer.strongMode) { | 1174 if (inferrer.strongMode) { |
1167 inferrer.instrumentation?.record(Uri.parse(inferrer.uri), fileOffset, | 1175 inferrer.instrumentation?.record(Uri.parse(inferrer.uri), fileOffset, |
1168 'target', new InstrumentationValueForMember(interfaceMember)); | 1176 'target', new InstrumentationValueForMember(interfaceMember)); |
1169 interfaceTarget = interfaceMember; | 1177 interfaceTarget = interfaceMember; |
1170 } | 1178 } |
1171 } | 1179 } |
1172 var inferredType = | 1180 var inferredType = |
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1917 } | 1925 } |
1918 | 1926 |
1919 transformChildren(v) { | 1927 transformChildren(v) { |
1920 return internalError("Internal error: Unsupported operation."); | 1928 return internalError("Internal error: Unsupported operation."); |
1921 } | 1929 } |
1922 | 1930 |
1923 visitChildren(v) { | 1931 visitChildren(v) { |
1924 return internalError("Internal error: Unsupported operation."); | 1932 return internalError("Internal error: Unsupported operation."); |
1925 } | 1933 } |
1926 } | 1934 } |
OLD | NEW |