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 1391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1402 if (read != null) { | 1402 if (read != null) { |
1403 inferrer.findPropertyGetMember(receiverType, read, silent: true); | 1403 inferrer.findPropertyGetMember(receiverType, read, silent: true); |
1404 } | 1404 } |
1405 Member writeMember; | 1405 Member writeMember; |
1406 if (write != null) { | 1406 if (write != null) { |
1407 writeMember = inferrer.findPropertySetMember(receiverType, write); | 1407 writeMember = inferrer.findPropertySetMember(receiverType, write); |
1408 if (inferrer.isTopLevel && | 1408 if (inferrer.isTopLevel && |
1409 ((writeMember is Procedure && | 1409 ((writeMember is Procedure && |
1410 writeMember.kind == ProcedureKind.Setter) || | 1410 writeMember.kind == ProcedureKind.Setter) || |
1411 writeMember is Field)) { | 1411 writeMember is Field)) { |
1412 // References to fields and setters can't be relied upon for top level | 1412 if (TypeInferenceEngineImpl.fullTopLevelInference) { |
1413 // inference. | 1413 if (writeMember is KernelField && writeMember._fieldNode != null) { |
1414 inferrer.recordNotImmediatelyEvident(fileOffset); | 1414 inferrer.engine |
| 1415 .inferFieldFused(writeMember._fieldNode, inferrer.fieldNode); |
| 1416 } |
| 1417 } else { |
| 1418 // References to fields and setters can't be relied upon for top level |
| 1419 // inference. |
| 1420 inferrer.recordNotImmediatelyEvident(fileOffset); |
| 1421 } |
1415 } | 1422 } |
1416 } | 1423 } |
1417 // To replicate analyzer behavior, we base type inference on the write | 1424 // To replicate analyzer behavior, we base type inference on the write |
1418 // member. TODO(paulberry): would it be better to use the read member when | 1425 // member. TODO(paulberry): would it be better to use the read member when |
1419 // doing compound assignment? | 1426 // doing compound assignment? |
1420 var writeContext = writeMember?.setterType; | 1427 var writeContext = writeMember?.setterType; |
1421 var inferredType = _inferRhs(inferrer, writeContext); | 1428 var inferredType = _inferRhs(inferrer, writeContext); |
1422 inferrer.listener.propertyAssignExit(desugared, inferredType); | 1429 inferrer.listener.propertyAssignExit(desugared, inferredType); |
1423 return inferredType; | 1430 return inferredType; |
1424 } | 1431 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1458 typeNeeded = | 1465 typeNeeded = |
1459 inferrer.listener.propertyGetEnter(this, typeContext) || typeNeeded; | 1466 inferrer.listener.propertyGetEnter(this, typeContext) || typeNeeded; |
1460 // First infer the receiver so we can look up the getter that was invoked. | 1467 // First infer the receiver so we can look up the getter that was invoked. |
1461 var receiverType = inferrer.inferExpression(receiver, null, true); | 1468 var receiverType = inferrer.inferExpression(receiver, null, true); |
1462 Member interfaceMember = | 1469 Member interfaceMember = |
1463 inferrer.findInterfaceMember(receiverType, name, fileOffset); | 1470 inferrer.findInterfaceMember(receiverType, name, fileOffset); |
1464 if (inferrer.isTopLevel && | 1471 if (inferrer.isTopLevel && |
1465 ((interfaceMember is Procedure && | 1472 ((interfaceMember is Procedure && |
1466 interfaceMember.kind == ProcedureKind.Getter) || | 1473 interfaceMember.kind == ProcedureKind.Getter) || |
1467 interfaceMember is Field)) { | 1474 interfaceMember is Field)) { |
1468 // References to fields and getters can't be relied upon for top level | 1475 if (TypeInferenceEngineImpl.fullTopLevelInference) { |
1469 // inference. | 1476 if (interfaceMember is KernelField && |
1470 inferrer.recordNotImmediatelyEvident(fileOffset); | 1477 interfaceMember._fieldNode != null) { |
| 1478 inferrer.engine |
| 1479 .inferFieldFused(interfaceMember._fieldNode, inferrer.fieldNode); |
| 1480 } |
| 1481 } else { |
| 1482 // References to fields and getters can't be relied upon for top level |
| 1483 // inference. |
| 1484 inferrer.recordNotImmediatelyEvident(fileOffset); |
| 1485 } |
1471 } | 1486 } |
1472 interfaceTarget = interfaceMember; | 1487 interfaceTarget = interfaceMember; |
1473 var inferredType = | 1488 var inferredType = |
1474 inferrer.getCalleeType(interfaceMember, receiverType, name); | 1489 inferrer.getCalleeType(interfaceMember, receiverType, name); |
1475 // TODO(paulberry): Infer tear-off type arguments if appropriate. | 1490 // TODO(paulberry): Infer tear-off type arguments if appropriate. |
1476 inferrer.listener.propertyGetExit(this, inferredType); | 1491 inferrer.listener.propertyGetExit(this, inferredType); |
1477 return typeNeeded ? inferredType : null; | 1492 return typeNeeded ? inferredType : null; |
1478 } | 1493 } |
1479 } | 1494 } |
1480 | 1495 |
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2273 } | 2288 } |
2274 | 2289 |
2275 transformChildren(v) { | 2290 transformChildren(v) { |
2276 return internalError("Internal error: Unsupported operation."); | 2291 return internalError("Internal error: Unsupported operation."); |
2277 } | 2292 } |
2278 | 2293 |
2279 visitChildren(v) { | 2294 visitChildren(v) { |
2280 return internalError("Internal error: Unsupported operation."); | 2295 return internalError("Internal error: Unsupported operation."); |
2281 } | 2296 } |
2282 } | 2297 } |
OLD | NEW |