Skip to content

Commit

Permalink
Version 3.7.0-135.0.dev
Browse files Browse the repository at this point in the history
Merge d75c493 into dev
  • Loading branch information
Dart CI committed Nov 12, 2024
2 parents ce043b2 + d75c493 commit f93aa0c
Show file tree
Hide file tree
Showing 59 changed files with 1,218 additions and 51 deletions.
5 changes: 4 additions & 1 deletion pkg/_fe_analyzer_shared/lib/src/parser/parser_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7282,10 +7282,12 @@ class Parser {

Token parseSendOrFunctionLiteral(Token token, IdentifierContext context,
ConstantPatternContext constantPatternContext) {
if (!mayParseFunctionExpressions) {
if (!mayParseFunctionExpressions || context.isContinuation) {
// "Inside" a continuation we can't have a function literal.
return parseSend(token, context, constantPatternContext);
}
TypeInfo typeInfo = computeType(token, /* required = */ false);

Token beforeName = typeInfo.skipType(token);
Token name = beforeName.next!;
if (name.isIdentifier) {
Expand All @@ -7298,6 +7300,7 @@ class Parser {
}
}
}

return parseSend(token, context, constantPatternContext);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11120,6 +11120,60 @@ suggestions
''');
}

Future<void> test_partial_code_before_nested_function() async {
// Issue https://github.com/dart-lang/sdk/issues/49477.
allowedIdentifiers = {'bar', 'baz'};
await computeSuggestions('''
class Foo {
Bar get bar => Bar();
}
class Bar {
String get baz => "baz";
}
void main(List<String> args) async {
final f = Foo();
f.bar.^
void writeMessage(String message) {}
}
''');
assertResponse(r'''
suggestions
baz
kind: getter
''');
}


Future<void> test_partial_code_before_nested_function_2() async {
// Variant of issue https://github.com/dart-lang/sdk/issues/49477,
// requested in https://dart-review.googlesource.com/c/sdk/+/393340.
allowedIdentifiers = {'bar', 'baz'};
await computeSuggestions('''
class Foo {
Bar get bar => Bar();
}
class Bar {
String get baz => "baz";
}
void main(List<String> args) async {
final f = Foo();
f.bar.^
int getNumber() { return 42; }
}
''');
assertResponse(r'''
suggestions
baz
kind: getter
''');
}

Future<void> test_single_2() async {
allowedIdentifiers = {'B'};
await computeSuggestions('''
Expand Down
12 changes: 9 additions & 3 deletions pkg/front_end/lib/src/kernel/body_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3285,11 +3285,15 @@ class BodyBuilder extends StackListenerImpl
return new ThisPropertyAccessGenerator(this, nameToken, n,
thisVariable: inConstructorInitializer ? null : thisVariable);
} else if (declaration.isExtensionInstanceMember) {
// TODO(johnniwinther): Better check for constantContext like below/above?
if (constantContext != ConstantContext.none && thisVariable == null) {
return new IncompleteErrorGenerator(
this, nameToken, fasta.messageNotAConstantExpression);
}
ExtensionBuilder extensionBuilder =
declaration.parent as ExtensionBuilder;
MemberBuilder? setterBuilder =
_getCorrespondingSetterBuilder(scope, declaration, name, nameOffset);
// TODO(johnniwinther): Check for constantContext like below?
if (declaration.isField) {
declaration = null;
}
Expand Down Expand Up @@ -5826,9 +5830,11 @@ class BodyBuilder extends StackListenerImpl
Name name = new Name(operator);
if (receiver is Generator) {
push(receiver.buildUnaryOperation(token, name));
} else if (receiver is Expression) {
push(forest.createUnary(fileOffset, name, receiver));
} else {
assert(receiver is Expression);
push(forest.createUnary(fileOffset, name, receiver as Expression));
Expression value = toValue(receiver);
push(forest.createUnary(fileOffset, name, value));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/front_end/lib/src/source/builder_factory.dart
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ abstract class BuilderFactory {
void beginExtensionDeclaration(String? name, int charOffset,
List<NominalParameterBuilder>? typeParameters);

void beginExtensionBody(TypeBuilder? extensionThisType);
void beginExtensionBody(TypeBuilder extensionThisType);

void endExtensionDeclaration(String? name);

Expand Down
11 changes: 7 additions & 4 deletions pkg/front_end/lib/src/source/outline_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1110,11 +1110,14 @@ class OutlineBuilder extends StackListenerImpl {
assert(checkState(token, [
unionOfKinds([ValueKinds.ParserRecovery, ValueKinds.TypeBuilder])
]));

Object? extensionThisType = peek();
// TODO(johnniwinther): Supply an invalid type as the extension on type.
_builderFactory.beginExtensionBody(
extensionThisType is TypeBuilder ? extensionThisType : null);
_builderFactory.beginExtensionBody(extensionThisType is TypeBuilder
? extensionThisType
: new InvalidTypeBuilderImpl(
uri,
extensionThisType is ParserRecovery
? extensionThisType.charOffset
: TreeNode.noOffset));
break;
case DeclarationKind.ExtensionType:
declarationContext = DeclarationContext.ExtensionTypeBody;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ parseUnit(Future)
listener: handleSend(Future, .)
parsePrimary(., expressionContinuation, ConstantPatternContext.none)
parseSendOrFunctionLiteral(., expressionContinuation, ConstantPatternContext.none)
looksLikeFunctionBody(;)
parseSend(., expressionContinuation, ConstantPatternContext.none)
isNextIdentifier(.)
ensureIdentifier(., expressionContinuation)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import 'dart:io';

void main(List<String> args) async {
final proc = await Process.start('', []);
proc.stdout. // we're typing here!

void writeMessage(String message) {}
}
119 changes: 119 additions & 0 deletions pkg/front_end/parser_testcases/error_recovery/issue_49477.dart.expect
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
Problems reported:

parser/error_recovery/issue_49477:7:3: Expected an identifier, but got 'void'.
void writeMessage(String message) {}
^^^^

parser/error_recovery/issue_49477:5:14: Expected ';' after this.
proc.stdout. // we're typing here!
^

beginCompilationUnit(import)
beginMetadataStar(import)
endMetadataStar(0)
beginUncategorizedTopLevelDeclaration(import)
beginImport(import)
beginLiteralString('dart:io')
endLiteralString(0, ;)
beginConditionalUris(;)
endConditionalUris(0)
handleImportPrefix(null, null)
beginCombinators(;)
endCombinators(0)
endImport(import, null, ;)
endTopLevelDeclaration(;)
beginMetadataStar(void)
endMetadataStar(0)
beginTopLevelMember(void)
beginTopLevelMethod(;, null, null)
handleVoidKeyword(void)
handleIdentifier(main, topLevelFunctionDeclaration)
handleNoTypeVariables(()
beginFormalParameters((, MemberKind.TopLevelMethod)
beginMetadataStar(List)
endMetadataStar(0)
beginFormalParameter(List, MemberKind.TopLevelMethod, null, null, null)
handleIdentifier(List, typeReference)
beginTypeArguments(<)
handleIdentifier(String, typeReference)
handleNoTypeArguments(>)
handleType(String, null)
endTypeArguments(1, <, >)
handleType(List, null)
handleIdentifier(args, formalParameterDeclaration)
handleFormalParameterWithoutValue())
endFormalParameter(null, null, null, args, null, null, FormalParameterKind.requiredPositional, MemberKind.TopLevelMethod)
endFormalParameters(1, (, ), MemberKind.TopLevelMethod)
handleAsyncModifier(async, null)
beginBlockFunctionBody({)
beginMetadataStar(final)
endMetadataStar(0)
handleNoType(final)
beginVariablesDeclaration(proc, null, final)
handleIdentifier(proc, localVariableDeclaration)
beginInitializedIdentifier(proc)
beginVariableInitializer(=)
beginAwaitExpression(await)
handleIdentifier(Process, expression)
handleNoTypeArguments(.)
handleNoArguments(.)
handleSend(Process, .)
handleIdentifier(start, expressionContinuation)
handleNoTypeArguments(()
beginArguments(()
beginLiteralString('')
endLiteralString(0, ,)
handleNoTypeArguments([])
handleLiteralList(0, [, null, ])
endArguments(2, (, ))
handleSend(start, ;)
handleEndingBinaryExpression(., ))
endAwaitExpression(await, ))
endVariableInitializer(=)
endInitializedIdentifier(proc)
endVariablesDeclaration(1, ;)
handleIdentifier(proc, expression)
handleNoTypeArguments(.)
handleNoArguments(.)
handleSend(proc, .)
handleIdentifier(stdout, expressionContinuation)
handleNoTypeArguments(.)
handleNoArguments(.)
handleSend(stdout, .)
handleEndingBinaryExpression(., stdout)
handleRecoverableError(Message[ExpectedIdentifier, Expected an identifier, but got 'void'., Try inserting an identifier before 'void'., {lexeme: void}], void, void)
handleIdentifier(, expressionContinuation)
handleNoTypeArguments(void)
handleNoArguments(void)
handleSend(, void)
handleEndingBinaryExpression(., )
handleRecoverableError(Message[ExpectedAfterButGot, Expected ';' after this., null, {string: ;}], ., .)
handleExpressionStatement(proc, ;)
beginMetadataStar(void)
endMetadataStar(0)
handleNoTypeVariables(()
beginLocalFunctionDeclaration(void)
handleVoidKeyword(void)
beginFunctionName(writeMessage)
handleIdentifier(writeMessage, localFunctionDeclaration)
endFunctionName(void, ()
beginFormalParameters((, MemberKind.Local)
beginMetadataStar(String)
endMetadataStar(0)
beginFormalParameter(String, MemberKind.Local, null, null, null)
handleIdentifier(String, typeReference)
handleNoTypeArguments(message)
handleType(String, null)
handleIdentifier(message, formalParameterDeclaration)
handleFormalParameterWithoutValue())
endFormalParameter(null, null, null, message, null, null, FormalParameterKind.requiredPositional, MemberKind.Local)
endFormalParameters(1, (, ), MemberKind.Local)
handleNoInitializers()
handleAsyncModifier(null, null)
beginBlockFunctionBody({)
endBlockFunctionBody(0, {, })
endLocalFunctionDeclaration(})
endBlockFunctionBody(3, {, })
endTopLevelMethod(void, null, })
endTopLevelDeclaration(})
endCompilationUnit(2, )
Loading

0 comments on commit f93aa0c

Please sign in to comment.