@@ -376,9 +376,6 @@ class ComplexTypeInfo implements TypeInfo {
376
376
/// Type arguments were seen during analysis.
377
377
final TypeParamOrArgInfo typeArguments;
378
378
379
- /// The token before the trailing question mark or `null` if none.
380
- Token beforeQuestionMark;
381
-
382
379
/// The last token in the type reference.
383
380
Token end;
384
381
@@ -393,18 +390,12 @@ class ComplexTypeInfo implements TypeInfo {
393
390
ComplexTypeInfo (Token beforeStart, this .typeArguments)
394
391
: this .start = beforeStart.next;
395
392
396
- ComplexTypeInfo ._nonNullable (this .start, this .typeArguments, this .end,
397
- this .typeVariableStarters, this .gftHasReturnType);
398
-
399
393
@override
400
394
bool get couldBeExpression => false ;
401
395
402
396
@override
403
397
TypeInfo asNonNullableType () {
404
- return beforeQuestionMark == null
405
- ? this
406
- : new ComplexTypeInfo ._nonNullable (start, typeArguments,
407
- beforeQuestionMark, typeVariableStarters, gftHasReturnType);
398
+ return this ;
408
399
}
409
400
410
401
@override
@@ -461,15 +452,7 @@ class ComplexTypeInfo implements TypeInfo {
461
452
}
462
453
}
463
454
token = typeArguments.parseArguments (token, parser);
464
- Token questionMark = token.next;
465
- if (optional ('?' , questionMark) &&
466
- (typeVariableEndGroups.isNotEmpty || beforeQuestionMark != null )) {
467
- // Only consume the `?` if it is part of the complex type
468
- token = questionMark;
469
- } else {
470
- questionMark = null ;
471
- }
472
- parser.listener.handleType (typeRefOrPrefix, questionMark);
455
+ parser.listener.handleType (typeRefOrPrefix, null );
473
456
}
474
457
}
475
458
@@ -509,11 +492,10 @@ class ComplexTypeInfo implements TypeInfo {
509
492
510
493
/// Given `Function` non-identifier, compute the type
511
494
/// and return the receiver or one of the [TypeInfo] constants.
512
- TypeInfo computeNoTypeGFT (Token beforeStart, bool required ) {
495
+ TypeInfo computeNoTypeGFT (bool required ) {
513
496
assert (optional ('Function' , start));
514
- assert (beforeStart.next == start);
515
497
516
- computeRest (beforeStart , required );
498
+ computeRest (start , required );
517
499
if (gftHasReturnType == null ) {
518
500
return required ? simpleType : noType;
519
501
}
@@ -527,7 +509,7 @@ class ComplexTypeInfo implements TypeInfo {
527
509
assert (optional ('void' , start));
528
510
assert (optional ('Function' , start.next));
529
511
530
- computeRest (start, required );
512
+ computeRest (start.next , required );
531
513
if (gftHasReturnType == null ) {
532
514
return voidType;
533
515
}
@@ -541,36 +523,21 @@ class ComplexTypeInfo implements TypeInfo {
541
523
assert (isValidTypeReference (start));
542
524
assert (optional ('Function' , start.next));
543
525
544
- computeRest (start, required );
526
+ computeRest (start.next , required );
545
527
if (gftHasReturnType == null ) {
546
528
return simpleType;
547
529
}
548
530
assert (end != null );
549
531
return this ;
550
532
}
551
533
552
- /// Given identifier `?` `Function` non-identifier, compute the type
553
- /// and return the receiver or one of the [TypeInfo] constants.
554
- TypeInfo computeIdentifierQuestionGFT (bool required ) {
555
- assert (isValidTypeReference (start));
556
- assert (optional ('?' , start.next));
557
- assert (optional ('Function' , start.next.next));
558
-
559
- computeRest (start, required );
560
- if (gftHasReturnType == null ) {
561
- return simpleNullableType;
562
- }
563
- assert (end != null );
564
- return this ;
565
- }
566
-
567
534
/// Given a builtin, return the receiver so that parseType will report
568
535
/// an error for the builtin used as a type.
569
536
TypeInfo computeBuiltinOrVarAsType (bool required ) {
570
537
assert (start.type.isBuiltIn || optional ('var' , start));
571
538
572
539
end = typeArguments.skip (start);
573
- computeRest (end, required );
540
+ computeRest (end.next , required );
574
541
assert (end != null );
575
542
return this ;
576
543
}
@@ -583,7 +550,7 @@ class ComplexTypeInfo implements TypeInfo {
583
550
assert (typeArguments != noTypeParamOrArg);
584
551
585
552
end = typeArguments.skip (start);
586
- computeRest (end, required );
553
+ computeRest (end.next , required );
587
554
588
555
if (! required && ! looksLikeName (end.next) && gftHasReturnType == null ) {
589
556
return noType;
@@ -607,7 +574,7 @@ class ComplexTypeInfo implements TypeInfo {
607
574
}
608
575
609
576
end = typeArguments.skip (token);
610
- computeRest (end, required );
577
+ computeRest (end.next , required );
611
578
if (! required && ! looksLikeName (end.next) && gftHasReturnType == null ) {
612
579
return noType;
613
580
}
@@ -616,11 +583,6 @@ class ComplexTypeInfo implements TypeInfo {
616
583
}
617
584
618
585
void computeRest (Token token, bool required ) {
619
- if (optional ('?' , token.next)) {
620
- beforeQuestionMark = token;
621
- end = token = token.next;
622
- }
623
- token = token.next;
624
586
while (optional ('Function' , token)) {
625
587
Token typeVariableStart = token;
626
588
// TODO(danrubel): Consider caching TypeParamOrArgInfo
@@ -641,14 +603,9 @@ class ComplexTypeInfo implements TypeInfo {
641
603
assert (optional (')' , token));
642
604
gftHasReturnType ?? = typeVariableStart != start;
643
605
typeVariableStarters = typeVariableStarters.prepend (typeVariableStart);
644
- beforeQuestionMark = null ;
645
606
end = token;
646
607
token = token.next;
647
608
}
648
- if (optional ('?' , token)) {
649
- beforeQuestionMark = end;
650
- end = token;
651
- }
652
609
}
653
610
}
654
611
0 commit comments