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

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

Issue 2899693003: Fix crash with generalized function types in type tests. (Closed)
Patch Set: Created 3 years, 7 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/front_end/testcases/function_type_is_check.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 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 1459 matching lines...) Expand 10 before | Expand all | Expand 10 after
1470 pop(); 1470 pop();
1471 warning("Type variables can only be used in instance methods.", 1471 warning("Type variables can only be used in instance methods.",
1472 beginToken.charOffset); 1472 beginToken.charOffset);
1473 push(const DynamicType()); 1473 push(const DynamicType());
1474 } 1474 }
1475 } 1475 }
1476 } 1476 }
1477 1477
1478 @override 1478 @override
1479 void handleFunctionType(Token functionToken, Token endToken) { 1479 void handleFunctionType(Token functionToken, Token endToken) {
1480 debugEvent("FunctionType");
1480 FormalParameters formals = pop(); 1481 FormalParameters formals = pop();
1481 ignore(Unhandled.TypeVariables); 1482 ignore(Unhandled.TypeVariables);
1482 DartType returnType = pop(); 1483 DartType returnType = pop();
1483 push(formals.toFunctionType(returnType)); 1484 push(formals.toFunctionType(returnType));
1484 } 1485 }
1485 1486
1486 @override 1487 @override
1487 void handleVoidKeyword(Token token) { 1488 void handleVoidKeyword(Token token) {
1488 debugEvent("VoidKeyword"); 1489 debugEvent("VoidKeyword");
1489 push(const VoidType()); 1490 push(const VoidType());
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1583 type: type, 1584 type: type,
1584 initializer: name.initializer, 1585 initializer: name.initializer,
1585 isFinal: isFinal, 1586 isFinal: isFinal,
1586 isConst: isConst); 1587 isConst: isConst);
1587 } else { 1588 } else {
1588 addCompileTimeError(offsetForToken(name.token), 1589 addCompileTimeError(offsetForToken(name.token),
1589 "'${name.name}' isn't a field in this class."); 1590 "'${name.name}' isn't a field in this class.");
1590 } 1591 }
1591 } 1592 }
1592 variable ??= astFactory.variableDeclaration( 1593 variable ??= astFactory.variableDeclaration(
1593 name.name, name.token, functionNestingLevel, 1594 name?.name, name?.token, functionNestingLevel,
1594 type: type, 1595 type: type,
1595 initializer: name.initializer, 1596 initializer: name?.initializer,
1596 isFinal: isFinal, 1597 isFinal: isFinal,
1597 isConst: isConst); 1598 isConst: isConst);
1598 push(variable); 1599 push(variable);
1599 } 1600 }
1600 1601
1601 @override 1602 @override
1602 void endOptionalFormalParameters( 1603 void endOptionalFormalParameters(
1603 int count, Token beginToken, Token endToken) { 1604 int count, Token beginToken, Token endToken) {
1604 debugEvent("OptionalFormalParameters"); 1605 debugEvent("OptionalFormalParameters");
1605 FormalParameterType kind = optional("{", beginToken) 1606 FormalParameterType kind = optional("{", beginToken)
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1650 OptionalFormals optional; 1651 OptionalFormals optional;
1651 if (count > 0 && peek() is OptionalFormals) { 1652 if (count > 0 && peek() is OptionalFormals) {
1652 optional = pop(); 1653 optional = pop();
1653 count--; 1654 count--;
1654 } 1655 }
1655 FormalParameters formals = new FormalParameters( 1656 FormalParameters formals = new FormalParameters(
1656 popList(count) ?? <VariableDeclaration>[], 1657 popList(count) ?? <VariableDeclaration>[],
1657 optional, 1658 optional,
1658 beginToken.charOffset); 1659 beginToken.charOffset);
1659 push(formals); 1660 push(formals);
1660 if (inCatchClause || functionNestingLevel != 0) { 1661 if ((inCatchClause || functionNestingLevel != 0) &&
1662 kind != MemberKind.GeneralizedFunctionType) {
1661 enterLocalScope(formals.computeFormalParameterScope( 1663 enterLocalScope(formals.computeFormalParameterScope(
1662 scope, member ?? classBuilder ?? library)); 1664 scope, member ?? classBuilder ?? library));
1663 } 1665 }
1664 } 1666 }
1665 1667
1666 @override 1668 @override
1667 void beginCatchClause(Token token) { 1669 void beginCatchClause(Token token) {
1668 debugEvent("beginCatchClause"); 1670 debugEvent("beginCatchClause");
1669 inCatchClause = true; 1671 inCatchClause = true;
1670 } 1672 }
(...skipping 1493 matching lines...) Expand 10 before | Expand all | Expand 10 after
3164 if (starToken == null) { 3166 if (starToken == null) {
3165 return AsyncMarker.Async; 3167 return AsyncMarker.Async;
3166 } else { 3168 } else {
3167 assert(identical(starToken.stringValue, "*")); 3169 assert(identical(starToken.stringValue, "*"));
3168 return AsyncMarker.AsyncStar; 3170 return AsyncMarker.AsyncStar;
3169 } 3171 }
3170 } else { 3172 } else {
3171 return internalError("Unknown async modifier: $asyncToken"); 3173 return internalError("Unknown async modifier: $asyncToken");
3172 } 3174 }
3173 } 3175 }
OLDNEW
« no previous file with comments | « no previous file | pkg/front_end/testcases/function_type_is_check.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698