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

Side by Side Diff: pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart

Issue 2954403002: Add type inference for super method invocations. (Closed)
Patch Set: Created 3 years, 5 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
OLDNEW
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 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 } 503 }
504 } 504 }
505 505
506 /// Shadow object for [DirectMethodInvocation]. 506 /// Shadow object for [DirectMethodInvocation].
507 class KernelDirectMethodInvocation extends DirectMethodInvocation 507 class KernelDirectMethodInvocation extends DirectMethodInvocation
508 implements KernelExpression { 508 implements KernelExpression {
509 KernelDirectMethodInvocation( 509 KernelDirectMethodInvocation(
510 Expression receiver, Procedure target, Arguments arguments) 510 Expression receiver, Procedure target, Arguments arguments)
511 : super(receiver, target, arguments); 511 : super(receiver, target, arguments);
512 512
513 KernelDirectMethodInvocation.byReference(
514 Expression receiver, Reference targetReference, Arguments arguments)
515 : super.byReference(receiver, targetReference, arguments);
516
517 @override 513 @override
518 void _collectDependencies(KernelDependencyCollector collector) { 514 void _collectDependencies(KernelDependencyCollector collector) {
519 // TODO(paulberry): Determine the right thing to do here. 515 // DirectMethodInvocation can only occur as a result of a use of `super`,
520 throw 'TODO(paulberry)'; 516 // and `super` can't appear inside a field initializer. So this code should
517 // never be reached.
518 internalError(
519 'Unexpected call to _collectDependencies for DirectMethodInvocation');
521 } 520 }
522 521
523 @override 522 @override
524 DartType _inferExpression( 523 DartType _inferExpression(
525 KernelTypeInferrer inferrer, DartType typeContext, bool typeNeeded) { 524 KernelTypeInferrer inferrer, DartType typeContext, bool typeNeeded) {
526 // TODO(scheglov): implement. 525 inferrer.instrumentation?.record(Uri.parse(inferrer.uri), fileOffset,
527 return typeNeeded ? const DynamicType() : null; 526 'target', new InstrumentationValueForMember(target));
527 return inferrer.inferMethodInvocation(
528 this, receiver, fileOffset, false, typeContext, typeNeeded,
529 interfaceMember: target, methodName: target.name, arguments: arguments);
528 } 530 }
529 } 531 }
530 532
531 /// Shadow object for [DirectPropertyGet]. 533 /// Shadow object for [DirectPropertyGet].
532 class KernelDirectPropertyGet extends DirectPropertyGet 534 class KernelDirectPropertyGet extends DirectPropertyGet
533 implements KernelExpression { 535 implements KernelExpression {
534 KernelDirectPropertyGet(Expression receiver, Member target) 536 KernelDirectPropertyGet(Expression receiver, Member target)
535 : super(receiver, target); 537 : super(receiver, target);
536 538
537 KernelDirectPropertyGet.byReference( 539 KernelDirectPropertyGet.byReference(
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after
1259 // receiver. 1261 // receiver.
1260 collector.collectDependencies(receiver); 1262 collector.collectDependencies(receiver);
1261 if (isOverloadableArithmeticOperator(name.name)) { 1263 if (isOverloadableArithmeticOperator(name.name)) {
1262 collector.collectDependencies(arguments.positional[0]); 1264 collector.collectDependencies(arguments.positional[0]);
1263 } 1265 }
1264 } 1266 }
1265 1267
1266 @override 1268 @override
1267 DartType _inferExpression( 1269 DartType _inferExpression(
1268 KernelTypeInferrer inferrer, DartType typeContext, bool typeNeeded) { 1270 KernelTypeInferrer inferrer, DartType typeContext, bool typeNeeded) {
1269 return inferrer.inferMethodInvocation(this, receiver, fileOffset, this, 1271 return inferrer.inferMethodInvocation(
1270 _isImplicitCall, typeContext, typeNeeded); 1272 this, receiver, fileOffset, _isImplicitCall, typeContext, typeNeeded,
1273 desugaredInvocation: this);
1271 } 1274 }
1272 } 1275 }
1273 1276
1274 /// Shadow object for [Not]. 1277 /// Shadow object for [Not].
1275 class KernelNot extends Not implements KernelExpression { 1278 class KernelNot extends Not implements KernelExpression {
1276 KernelNot(Expression operand) : super(operand); 1279 KernelNot(Expression operand) : super(operand);
1277 1280
1278 @override 1281 @override
1279 void _collectDependencies(KernelDependencyCollector collector) { 1282 void _collectDependencies(KernelDependencyCollector collector) {
1280 collector.collectDependencies(operand); 1283 collector.collectDependencies(operand);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1314 collector.recordNotImmediatelyEvident(fileOffset); 1317 collector.recordNotImmediatelyEvident(fileOffset);
1315 } 1318 }
1316 1319
1317 @override 1320 @override
1318 DartType _inferExpression( 1321 DartType _inferExpression(
1319 KernelTypeInferrer inferrer, DartType typeContext, bool typeNeeded) { 1322 KernelTypeInferrer inferrer, DartType typeContext, bool typeNeeded) {
1320 var inferredType = inferrer.inferMethodInvocation( 1323 var inferredType = inferrer.inferMethodInvocation(
1321 this, 1324 this,
1322 variable.initializer, 1325 variable.initializer,
1323 fileOffset, 1326 fileOffset,
1324 _desugaredInvocation,
1325 false, 1327 false,
1326 typeContext, 1328 typeContext,
1327 typeNeeded || inferrer.strongMode, 1329 typeNeeded || inferrer.strongMode,
1328 receiverVariable: variable); 1330 receiverVariable: variable,
1331 desugaredInvocation: _desugaredInvocation);
1329 if (inferrer.strongMode) { 1332 if (inferrer.strongMode) {
1330 body.staticType = inferredType; 1333 body.staticType = inferredType;
1331 } 1334 }
1332 return inferredType; 1335 return inferredType;
1333 } 1336 }
1334 } 1337 }
1335 1338
1336 /// Concrete shadow object representing a null-aware read from a property. 1339 /// Concrete shadow object representing a null-aware read from a property.
1337 /// 1340 ///
1338 /// A null-aware property get of the form `a?.b` is represented as the kernel 1341 /// A null-aware property get of the form `a?.b` is represented as the kernel
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
1780 @override 1783 @override
1781 void _collectDependencies(KernelDependencyCollector collector) { 1784 void _collectDependencies(KernelDependencyCollector collector) {
1782 // Super expressions should never occur in top level type inference. 1785 // Super expressions should never occur in top level type inference.
1783 // TODO(paulberry): but could they occur due to invalid code? 1786 // TODO(paulberry): but could they occur due to invalid code?
1784 assert(false); 1787 assert(false);
1785 } 1788 }
1786 1789
1787 @override 1790 @override
1788 DartType _inferExpression( 1791 DartType _inferExpression(
1789 KernelTypeInferrer inferrer, DartType typeContext, bool typeNeeded) { 1792 KernelTypeInferrer inferrer, DartType typeContext, bool typeNeeded) {
1790 // TODO(scheglov): implement. 1793 inferrer.instrumentation?.record(Uri.parse(inferrer.uri), fileOffset,
1791 return typeNeeded ? const DynamicType() : null; 1794 'target', new InstrumentationValueForMember(interfaceTarget));
1795 return inferrer.inferMethodInvocation(this, new KernelThisExpression(),
1796 fileOffset, false, typeContext, typeNeeded,
1797 interfaceMember: interfaceTarget,
1798 methodName: name,
1799 arguments: arguments);
1792 } 1800 }
1793 } 1801 }
1794 1802
1795 /// Shadow object for [SuperPropertyGet]. 1803 /// Shadow object for [SuperPropertyGet].
1796 class KernelSuperPropertyGet extends SuperPropertyGet 1804 class KernelSuperPropertyGet extends SuperPropertyGet
1797 implements KernelExpression { 1805 implements KernelExpression {
1798 KernelSuperPropertyGet(Name name, [Member interfaceTarget]) 1806 KernelSuperPropertyGet(Name name, [Member interfaceTarget])
1799 : super(name, interfaceTarget); 1807 : super(name, interfaceTarget);
1800 1808
1801 KernelSuperPropertyGet.byReference( 1809 KernelSuperPropertyGet.byReference(
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
2304 } 2312 }
2305 2313
2306 transformChildren(v) { 2314 transformChildren(v) {
2307 return internalError("Internal error: Unsupported operation."); 2315 return internalError("Internal error: Unsupported operation.");
2308 } 2316 }
2309 2317
2310 visitChildren(v) { 2318 visitChildren(v) {
2311 return internalError("Internal error: Unsupported operation."); 2319 return internalError("Internal error: Unsupported operation.");
2312 } 2320 }
2313 } 2321 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698