mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 00:09:49 +00:00
[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:
parent
c4ea2d95cd
commit
7aeda010bf
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue