[parser] Follow-up on feedback posted after land of record commit

Follow-up to https://dart-review.googlesource.com/c/sdk/+/262605

Change-Id: I5178f7118af30eaa280dde746ddbf579fff5df40
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/263127
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
This commit is contained in:
Jens Johansen 2022-10-14 10:57:39 +00:00 committed by Commit Queue
parent c4ea2d95cd
commit 7aeda010bf
4 changed files with 14 additions and 14 deletions

View file

@ -600,7 +600,7 @@ class Parser {
_isIdentifierOrQuestionIdentifier(endParen.next!)) {
// Looks like a typedef with a record.
TypeInfo typeInfo = computeType(keyword, /* required = */ false);
if (typeInfo is ComplexTypeInfo && typeInfo.recordType) {
if (typeInfo is ComplexTypeInfo && typeInfo.isRecordType) {
typedefWithRecord = true;
}
}
@ -1423,7 +1423,7 @@ class Parser {
/// ( ',' recordTypeNamedField )* ','? '}'
/// recordTypeNamedField ::= metadata type identifier
Token parseRecordType(
final Token start, Token token, bool questionMarkPartOfType) {
final Token start, Token token, bool isQuestionMarkPartOfType) {
token = token.next!;
assert(optional('(', token));
@ -1503,7 +1503,7 @@ class Parser {
// Only consume the `?` if it is part of the type.
Token? questionMark = token.next!;
if (optional('?', questionMark) && questionMarkPartOfType) {
if (optional('?', questionMark) && isQuestionMarkPartOfType) {
token = questionMark;
} else {
questionMark = null;

View file

@ -405,7 +405,7 @@ TypeParamOrArgInfo computeTypeParamOrArg(Token token,
if (isPossibleRecordType(next)) {
TypeInfo type = computeType(beginGroup, /* required = */ false);
if (type is ComplexTypeInfo &&
(type.recordType || type.gftReturnTypeHasRecordType) &&
(type.isRecordType || type.gftReturnTypeHasRecordType) &&
!type.recovered) {
// Looks like a record type.
recordType = true;

View file

@ -510,7 +510,7 @@ class ComplexTypeInfo implements TypeInfo {
bool? gftHasReturnType;
/// If the type is a record type.
bool recordType = false;
bool isRecordType = false;
/// If this is a generalized function type with a record type included in the
/// return type. E.g. `(int, int) Function(bool) Function(int)`.
@ -532,7 +532,7 @@ class ComplexTypeInfo implements TypeInfo {
this.end,
this.typeVariableStarters,
this.gftHasReturnType,
this.recordType,
this.isRecordType,
this.gftReturnTypeHasRecordType,
this.recovered);
@ -546,7 +546,7 @@ class ComplexTypeInfo implements TypeInfo {
beforeQuestionMark,
typeVariableStarters,
gftHasReturnType,
recordType,
isRecordType,
gftReturnTypeHasRecordType,
recovered);
}
@ -599,12 +599,12 @@ class ComplexTypeInfo implements TypeInfo {
// Push the non-existing return type first. The loop below will
// generate the full type.
noType.parseType(token, parser);
} else if (recordType) {
} else if (isRecordType) {
token = parser.parseRecordType(start, token,
/* questionMarkPartOfType = */ beforeQuestionMark != null);
/* isQuestionMarkPartOfType = */ beforeQuestionMark != null);
} else if (gftReturnTypeHasRecordType) {
token = parser.parseRecordType(
start, token, /* questionMarkPartOfType = */ true);
start, token, /* isQuestionMarkPartOfType = */ true);
} else {
Token typeRefOrPrefix = token.next!;
if (optional('void', typeRefOrPrefix)) {
@ -794,7 +794,7 @@ class ComplexTypeInfo implements TypeInfo {
token = token.next!;
}
recordType = true;
isRecordType = true;
assert(end != null);
return this;

View file

@ -439,11 +439,11 @@ class TestParser extends Parser {
@override
Token parseRecordType(
final Token start, Token token, bool questionMarkPartOfType) {
final Token start, Token token, bool isQuestionMarkPartOfType) {
doPrint(
'parseRecordType(' '$start, ' '$token, ' '$questionMarkPartOfType)');
'parseRecordType(' '$start, ' '$token, ' '$isQuestionMarkPartOfType)');
indent++;
var result = super.parseRecordType(start, token, questionMarkPartOfType);
var result = super.parseRecordType(start, token, isQuestionMarkPartOfType);
indent--;
return result;
}