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

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

Issue 2928613003: Fix corner cases of type inference with implicit references to `.call`. (Closed)
Patch Set: Created 3 years, 6 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) 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 library fasta.body_builder; 5 library fasta.body_builder;
6 6
7 import '../fasta_codes.dart' 7 import '../fasta_codes.dart'
8 show FastaMessage, codeExpectedButGot, codeExpectedFunctionBody; 8 show FastaMessage, codeExpectedButGot, codeExpectedFunctionBody;
9 9
10 import '../parser/parser.dart' show FormalParameterType, MemberKind, optional; 10 import '../parser/parser.dart' show FormalParameterType, MemberKind, optional;
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 push(finishSend(receiver, arguments, beginToken.charOffset)); 638 push(finishSend(receiver, arguments, beginToken.charOffset));
639 } 639 }
640 } 640 }
641 641
642 @override 642 @override
643 finishSend(Object receiver, Arguments arguments, int charOffset) { 643 finishSend(Object receiver, Arguments arguments, int charOffset) {
644 if (receiver is FastaAccessor) { 644 if (receiver is FastaAccessor) {
645 return receiver.doInvocation(charOffset, arguments); 645 return receiver.doInvocation(charOffset, arguments);
646 } else { 646 } else {
647 return buildMethodInvocation( 647 return buildMethodInvocation(
648 toValue(receiver), callName, arguments, charOffset); 648 toValue(receiver), callName, arguments, charOffset,
649 isImplicitCall: true);
649 } 650 }
650 } 651 }
651 652
652 @override 653 @override
653 void beginCascade(Token token) { 654 void beginCascade(Token token) {
654 debugEvent("beginCascade"); 655 debugEvent("beginCascade");
655 Expression expression = popForValue(); 656 Expression expression = popForValue();
656 if (expression is KernelCascadeExpression) { 657 if (expression is KernelCascadeExpression) {
657 push(expression); 658 push(expression);
658 push(new VariableAccessor(this, token, expression.variable)); 659 push(new VariableAccessor(this, token, expression.variable));
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 return throwNoSuchMethodError( 789 return throwNoSuchMethodError(
789 node.name.name, node.arguments, node.fileOffset, 790 node.name.name, node.arguments, node.fileOffset,
790 isSuper: true); 791 isSuper: true);
791 } 792 }
792 Expression receiver = new KernelDirectPropertyGet( 793 Expression receiver = new KernelDirectPropertyGet(
793 new ThisExpression()..fileOffset = node.fileOffset, target); 794 new ThisExpression()..fileOffset = node.fileOffset, target);
794 // TODO(ahe): Use [DirectPropertyGet] when possible, that is, remove the 795 // TODO(ahe): Use [DirectPropertyGet] when possible, that is, remove the
795 // next line: 796 // next line:
796 receiver = new KernelSuperPropertyGet(node.name, target); 797 receiver = new KernelSuperPropertyGet(node.name, target);
797 return buildMethodInvocation( 798 return buildMethodInvocation(
798 receiver, callName, node.arguments, node.fileOffset); 799 receiver, callName, node.arguments, node.fileOffset,
800 isImplicitCall: true);
799 } 801 }
800 802
801 bool areArgumentsCompatible(FunctionNode function, Arguments arguments) { 803 bool areArgumentsCompatible(FunctionNode function, Arguments arguments) {
802 // TODO(ahe): Implement this. 804 // TODO(ahe): Implement this.
803 return true; 805 return true;
804 } 806 }
805 807
806 @override 808 @override
807 Expression throwNoSuchMethodError( 809 Expression throwNoSuchMethodError(
808 String name, Arguments arguments, int charOffset, 810 String name, Arguments arguments, int charOffset,
(...skipping 2031 matching lines...) Expand 10 before | Expand all | Expand 10 after
2840 } 2842 }
2841 return expression; 2843 return expression;
2842 } 2844 }
2843 2845
2844 @override 2846 @override
2845 bool isIdentical(Member member) => member == coreTypes.identicalProcedure; 2847 bool isIdentical(Member member) => member == coreTypes.identicalProcedure;
2846 2848
2847 @override 2849 @override
2848 Expression buildMethodInvocation( 2850 Expression buildMethodInvocation(
2849 Expression receiver, Name name, Arguments arguments, int offset, 2851 Expression receiver, Name name, Arguments arguments, int offset,
2850 {bool isConstantExpression: false, bool isNullAware: false}) { 2852 {bool isConstantExpression: false,
2853 bool isNullAware: false,
2854 bool isImplicitCall: false}) {
2851 if (constantExpressionRequired && !isConstantExpression) { 2855 if (constantExpressionRequired && !isConstantExpression) {
2852 return buildCompileTimeError("Not a constant expression.", offset); 2856 return buildCompileTimeError("Not a constant expression.", offset);
2853 } 2857 }
2854 if (isNullAware) { 2858 if (isNullAware) {
2855 VariableDeclaration variable = new VariableDeclaration.forValue(receiver); 2859 VariableDeclaration variable = new VariableDeclaration.forValue(receiver);
2856 return makeLet( 2860 return makeLet(
2857 variable, 2861 variable,
2858 new ConditionalExpression( 2862 new ConditionalExpression(
2859 buildIsNull(new VariableGet(variable)), 2863 buildIsNull(new VariableGet(variable)),
2860 new NullLiteral(), 2864 new NullLiteral(),
2861 new MethodInvocation(new VariableGet(variable), name, arguments) 2865 new MethodInvocation(new VariableGet(variable), name, arguments)
2862 ..fileOffset = offset, 2866 ..fileOffset = offset,
2863 const DynamicType())); 2867 const DynamicType()));
2864 } else { 2868 } else {
2865 return new KernelMethodInvocation(receiver, name, arguments) 2869 return new KernelMethodInvocation(receiver, name, arguments,
2870 isImplicitCall: isImplicitCall)
2866 ..fileOffset = offset; 2871 ..fileOffset = offset;
2867 } 2872 }
2868 } 2873 }
2869 2874
2870 @override 2875 @override
2871 void addCompileTimeErrorFromMessage(FastaMessage message) { 2876 void addCompileTimeErrorFromMessage(FastaMessage message) {
2872 library.addCompileTimeError(message.charOffset, message.message, 2877 library.addCompileTimeError(message.charOffset, message.message,
2873 fileUri: message.uri); 2878 fileUri: message.uri);
2874 } 2879 }
2875 2880
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
3325 if (starToken == null) { 3330 if (starToken == null) {
3326 return AsyncMarker.Async; 3331 return AsyncMarker.Async;
3327 } else { 3332 } else {
3328 assert(identical(starToken.stringValue, "*")); 3333 assert(identical(starToken.stringValue, "*"));
3329 return AsyncMarker.AsyncStar; 3334 return AsyncMarker.AsyncStar;
3330 } 3335 }
3331 } else { 3336 } else {
3332 return internalError("Unknown async modifier: $asyncToken"); 3337 return internalError("Unknown async modifier: $asyncToken");
3333 } 3338 }
3334 } 3339 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698