Skip to content

Commit fe4378d

Browse files
committed
Fix for parsing generic function types with Fasta.
[email protected] BUG= Review-Url: https://codereview.chromium.org/2732213003 .
1 parent 271ea5a commit fe4378d

File tree

5 files changed

+18
-84
lines changed

5 files changed

+18
-84
lines changed

pkg/analyzer/lib/dart/ast/ast_factory.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ abstract class AstFactory {
626626
TypeAnnotation returnType,
627627
Token functionKeyword,
628628
TypeParameterList typeParameters,
629-
FormalParameterList _parameters);
629+
FormalParameterList parameters);
630630

631631
/**
632632
* Returns a newly created generic type alias. Either or both of the

pkg/analyzer/lib/src/dart/ast/ast_factory.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,9 +548,9 @@ class AstFactoryImpl extends AstFactory {
548548
TypeAnnotation returnType,
549549
Token functionKeyword,
550550
TypeParameterList typeParameters,
551-
FormalParameterList _parameters) =>
551+
FormalParameterList parameters) =>
552552
new GenericFunctionTypeImpl(
553-
returnType, functionKeyword, typeParameters, _parameters);
553+
returnType, functionKeyword, typeParameters, parameters);
554554

555555
@override
556556
GenericTypeAlias genericTypeAlias(

pkg/analyzer/test/generated/parser_fasta_test.dart

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,6 @@ class ClassMemberParserTest_Fasta extends FastaParserTestCase
106106
super.test_parseClassMember_method_returnType_functionType();
107107
}
108108

109-
@override
110-
@failingTest
111-
void test_parseClassMember_operator_functionType() {
112-
// TODO(paulberry): InputError: ErrorKind.ExpectedFunctionBody {actual: operator}
113-
super.test_parseClassMember_operator_functionType();
114-
}
115-
116109
@override
117110
@failingTest
118111
void test_parseClassMember_redirectingFactory_const() {
@@ -1339,78 +1332,4 @@ class TopLevelParserTest_Fasta extends FastaParserTestCase
13391332
// Fasta.
13401333
super.test_parsePartOfDirective_uri();
13411334
}
1342-
1343-
@override
1344-
@failingTest
1345-
void test_parseTypeAlias_genericFunction_noParameters() {
1346-
super.test_parseTypeAlias_genericFunction_noParameters();
1347-
}
1348-
1349-
@override
1350-
@failingTest
1351-
void test_parseTypeAlias_genericFunction_noReturnType() {
1352-
super.test_parseTypeAlias_genericFunction_noReturnType();
1353-
}
1354-
1355-
@override
1356-
@failingTest
1357-
void test_parseTypeAlias_genericFunction_parameterizedReturnType() {
1358-
super.test_parseTypeAlias_genericFunction_parameterizedReturnType();
1359-
}
1360-
1361-
@override
1362-
@failingTest
1363-
void test_parseTypeAlias_genericFunction_parameters() {
1364-
super.test_parseTypeAlias_genericFunction_parameters();
1365-
}
1366-
1367-
@override
1368-
@failingTest
1369-
void test_parseTypeAlias_genericFunction_typeParameters() {
1370-
super.test_parseTypeAlias_genericFunction_typeParameters();
1371-
}
1372-
1373-
@override
1374-
@failingTest
1375-
void test_parseTypeAlias_genericFunction_typeParameters_noParameters() {
1376-
super.test_parseTypeAlias_genericFunction_typeParameters_noParameters();
1377-
}
1378-
1379-
@override
1380-
@failingTest
1381-
void test_parseTypeAlias_genericFunction_typeParameters_noReturnType() {
1382-
super.test_parseTypeAlias_genericFunction_typeParameters_noReturnType();
1383-
}
1384-
1385-
@override
1386-
@failingTest
1387-
void
1388-
test_parseTypeAlias_genericFunction_typeParameters_parameterizedReturnType() {
1389-
super
1390-
.test_parseTypeAlias_genericFunction_typeParameters_parameterizedReturnType();
1391-
}
1392-
1393-
@override
1394-
@failingTest
1395-
void test_parseTypeAlias_genericFunction_typeParameters_parameters() {
1396-
super.test_parseTypeAlias_genericFunction_typeParameters_parameters();
1397-
}
1398-
1399-
@override
1400-
@failingTest
1401-
void test_parseTypeAlias_genericFunction_typeParameters_typeParameters() {
1402-
super.test_parseTypeAlias_genericFunction_typeParameters_typeParameters();
1403-
}
1404-
1405-
@override
1406-
@failingTest
1407-
void test_parseTypeAlias_genericFunction_typeParameters_voidReturnType() {
1408-
super.test_parseTypeAlias_genericFunction_typeParameters_voidReturnType();
1409-
}
1410-
1411-
@override
1412-
@failingTest
1413-
void test_parseTypeAlias_genericFunction_voidReturnType() {
1414-
super.test_parseTypeAlias_genericFunction_voidReturnType();
1415-
}
14161335
}

pkg/front_end/lib/src/fasta/analyzer/ast_builder.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,15 @@ class AstBuilder extends ScopeListener {
598598
push(new _ParameterDefaultValue(equals, value));
599599
}
600600

601+
void handleFunctionType(Token functionToken, Token semicolon) {
602+
debugEvent("FunctionType");
603+
FormalParameterList parameters = pop();
604+
TypeParameterList typeParameters = pop();
605+
TypeAnnotation returnType = pop();
606+
push(ast.genericFunctionType(returnType, toAnalyzerToken(functionToken),
607+
typeParameters, parameters));
608+
}
609+
601610
void handleFormalParameterWithoutValue(Token token) {
602611
debugEvent("FormalParameterWithoutValue");
603612
push(NullValue.ParameterDefaultValue);

pkg/front_end/lib/src/fasta/parser/listener.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,12 @@ class Listener {
680680
logEvent("NoName");
681681
}
682682

683+
/// Handle the end of a generic function type declaration.
684+
///
685+
/// Substructures:
686+
/// - Return type
687+
/// - Type variables
688+
/// - Formal parameters
683689
void handleFunctionType(Token functionToken, Token endToken) {
684690
logEvent("FunctionType");
685691
}

0 commit comments

Comments
 (0)