Revert support for parsing simple nullable types

This reverts commit bc8c7cf7823a5b375b7dafdf088e06ee887824b9

Reason for revert: Breaks parsing less common conditionals (e.g. b ? c = true : g();)

Original change's description:
> Add support for parsing simple nullable types
>
> ... as part of adding NNBD as outlined in
> https://github.com/dart-lang/language/issues/110
>
> This only supports parsing simple nullable types
> such as int? and List<int>? while subsequent CLs
> will add support for parsing more complex types.

Change-Id: I49a21a85dca19241e3b23ed5c9fb6084e70f2000
Reviewed-on: https://dart-review.googlesource.com/c/87284
Reviewed-by: Dan Rubel <danrubel@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
diff --git a/pkg/front_end/lib/src/fasta/parser/type_info.dart b/pkg/front_end/lib/src/fasta/parser/type_info.dart
index 4dc7e66..5e9f636 100644
--- a/pkg/front_end/lib/src/fasta/parser/type_info.dart
+++ b/pkg/front_end/lib/src/fasta/parser/type_info.dart
@@ -12,7 +12,7 @@
 
 import 'type_info_impl.dart';
 
-import 'util.dart' show isOneOf, isOneOfOrEof, optional;
+import 'util.dart' show isOneOf, optional;
 
 /// [TypeInfo] provides information collected by [computeType]
 /// about a particular type reference.
@@ -199,19 +199,13 @@
       // We've seen identifier `<` identifier `>`
       next = typeParamOrArg.skip(next).next;
       if (!isGeneralizedFunctionType(next)) {
-        if (optional('?', next) && typeParamOrArg == simpleTypeArgument1) {
-          if (required || looksLikeName(next.next)) {
-            // identifier `<` identifier `>` `?` identifier
-            return simpleNullableTypeWith1Argument;
-          }
+        if (required || looksLikeName(next)) {
+          // identifier `<` identifier `>` identifier
+          return typeParamOrArg.typeInfo;
         } else {
-          if (required || looksLikeName(next)) {
-            // identifier `<` identifier `>` identifier
-            return typeParamOrArg.typeInfo;
-          }
+          // identifier `<` identifier `>` non-identifier
+          return noType;
         }
-        // identifier `<` identifier `>` non-identifier
-        return noType;
       }
     }
     // TODO(danrubel): Consider adding a const for
@@ -261,23 +255,7 @@
         .computeIdentifierGFT(required);
   }
 
-  if (optional('?', next)) {
-    if (required) {
-      // identifier `?`
-      return simpleNullableType;
-    } else {
-      next = next.next;
-      if (isGeneralizedFunctionType(next)) {
-        // identifier `?` Function `(`
-        return simpleNullableType;
-      } else if (looksLikeName(next) &&
-          isOneOfOrEof(
-              next.next, const [';', ',', '=', '>', '>=', '>>', '>>>'])) {
-        // identifier `?` identifier `=`
-        return simpleNullableType;
-      }
-    }
-  } else if (required || looksLikeName(next)) {
+  if (required || looksLikeName(next)) {
     // identifier identifier
     return simpleType;
   }
diff --git a/pkg/front_end/lib/src/fasta/parser/type_info_impl.dart b/pkg/front_end/lib/src/fasta/parser/type_info_impl.dart
index 2b87c5b..2a2b6ab 100644
--- a/pkg/front_end/lib/src/fasta/parser/type_info_impl.dart
+++ b/pkg/front_end/lib/src/fasta/parser/type_info_impl.dart
@@ -38,10 +38,6 @@
 /// when there is a single identifier as the type reference.
 const TypeInfo simpleType = const SimpleType();
 
-/// [SimpleNullableType] is a specialized [TypeInfo] returned by [computeType]
-/// when there is a single identifier followed by `?` as the type reference.
-const TypeInfo simpleNullableType = const SimpleNullableType();
-
 /// [PrefixedType] is a specialized [TypeInfo] returned by [computeType]
 /// when the type reference is of the form: identifier `.` identifier.
 const TypeInfo prefixedType = const PrefixedType();
@@ -64,12 +60,6 @@
 const TypeInfo simpleTypeWith1ArgumentGtGt =
     const SimpleTypeWith1Argument(simpleTypeArgument1GtGt);
 
-/// [SimpleNullableTypeWith1Argument] is a specialized [TypeInfo] returned by
-/// [computeType] when the type reference is of the form:
-/// identifier `<` identifier `>` `?`.
-const TypeInfo simpleNullableTypeWith1Argument =
-    const SimpleNullableTypeWith1Argument();
-
 /// [SimpleTypeArgument1] is a specialized [TypeParamOrArgInfo] returned by
 /// [computeTypeParamOrArg] when the type reference is of the form:
 /// `<` identifier `>`.
@@ -174,29 +164,6 @@
   }
 }
 
-/// See documentation on the [simpleNullableTypeWith1Argument] const.
-class SimpleNullableTypeWith1Argument extends SimpleTypeWith1Argument {
-  const SimpleNullableTypeWith1Argument() : super(simpleTypeArgument1);
-
-  @override
-  TypeInfo asNonNullableType() => simpleTypeWith1Argument;
-
-  @override
-  Token parseTypeRest(Token start, Token token, Parser parser) {
-    token = token.next;
-    assert(optional('?', token));
-    parser.listener.handleType(start, token);
-    return token;
-  }
-
-  @override
-  Token skipType(Token token) {
-    token = super.skipType(token).next;
-    assert(optional('?', token));
-    return token;
-  }
-}
-
 /// See documentation on the [simpleTypeWith1Argument] const.
 class SimpleTypeWith1Argument implements TypeInfo {
   final TypeParamOrArgInfo typeArg;
@@ -243,27 +210,6 @@
   }
 }
 
-/// See documentation on the [simpleNullableType] const.
-class SimpleNullableType extends SimpleType {
-  const SimpleNullableType();
-
-  @override
-  TypeInfo asNonNullableType() => simpleType;
-
-  @override
-  Token parseTypeRest(Token start, Parser parser) {
-    Token token = start.next;
-    assert(optional('?', token));
-    parser.listener.handleType(start, token);
-    return token;
-  }
-
-  @override
-  Token skipType(Token token) {
-    return token.next.next;
-  }
-}
-
 /// See documentation on the [simpleType] const.
 class SimpleType implements TypeInfo {
   const SimpleType();
diff --git a/pkg/front_end/test/fasta/parser/type_info_test.dart b/pkg/front_end/test/fasta/parser/type_info_test.dart
index 7b9b003..9a0400d 100644
--- a/pkg/front_end/test/fasta/parser/type_info_test.dart
+++ b/pkg/front_end/test/fasta/parser/type_info_test.dart
@@ -19,9 +19,7 @@
   defineReflectiveSuite(() {
     defineReflectiveTests(NoTypeInfoTest);
     defineReflectiveTests(PrefixedTypeInfoTest);
-    defineReflectiveTests(SimpleNullableTypeTest);
-    defineReflectiveTests(SimpleNullableTypeWith1ArgumentTest);
-    defineReflectiveTests(SimpleTypeTest);
+    defineReflectiveTests(SimpleTypeInfoTest);
     defineReflectiveTests(SimpleTypeWith1ArgumentTest);
     defineReflectiveTests(TypeInfoTest);
     defineReflectiveTests(VoidTypeInfoTest);
@@ -311,124 +309,7 @@
 }
 
 @reflectiveTest
-class SimpleNullableTypeTest {
-  void test_compute() {
-    expectInfo(simpleNullableType, 'C?', required: true);
-    expectInfo(simpleNullableType, 'C?;', required: true);
-    expectInfo(simpleNullableType, 'C?(', required: true);
-    expectInfo(simpleNullableType, 'C?<', required: true);
-    expectInfo(simpleNullableType, 'C?=', required: true);
-    expectInfo(simpleNullableType, 'C?*', required: true);
-    expectInfo(simpleNullableType, 'C? do', required: true);
-
-    expectInfo(simpleNullableType, 'C? foo');
-    expectInfo(simpleNullableType, 'C? get');
-    expectInfo(simpleNullableType, 'C? set');
-    expectInfo(simpleNullableType, 'C? operator');
-    expectInfo(simpleNullableType, 'C? this');
-    expectInfo(simpleNullableType, 'C? Function');
-
-    expectInfo(simpleNullableType, 'C? Function()', required: false);
-    expectInfo(simpleNullableType, 'C? Function<T>()', required: false);
-    expectInfo(simpleNullableType, 'C? Function(int)', required: false);
-    expectInfo(simpleNullableType, 'C? Function<T>(int)', required: false);
-    expectInfo(simpleNullableType, 'C? Function(int x)', required: false);
-    expectInfo(simpleNullableType, 'C? Function<T>(int x)', required: false);
-  }
-
-  void test_simpleNullableType() {
-    final Token start = scanString('before C? ;').tokens;
-    final Token expectedEnd = start.next.next;
-
-    expect(simpleNullableType.skipType(start), expectedEnd);
-    expect(simpleNullableType.couldBeExpression, isTrue);
-
-    TypeInfoListener listener;
-    assertResult(Token actualEnd) {
-      expect(actualEnd, expectedEnd);
-      expect(listener.calls, [
-        'handleIdentifier C typeReference',
-        'handleNoTypeArguments ?',
-        'handleType C ?',
-      ]);
-      expect(listener.errors, isNull);
-    }
-
-    listener = new TypeInfoListener();
-    assertResult(
-        simpleNullableType.ensureTypeNotVoid(start, new Parser(listener)));
-
-    listener = new TypeInfoListener();
-    assertResult(
-        simpleNullableType.ensureTypeOrVoid(start, new Parser(listener)));
-
-    listener = new TypeInfoListener();
-    assertResult(
-        simpleNullableType.parseTypeNotVoid(start, new Parser(listener)));
-
-    listener = new TypeInfoListener();
-    assertResult(simpleNullableType.parseType(start, new Parser(listener)));
-  }
-}
-
-@reflectiveTest
-class SimpleNullableTypeWith1ArgumentTest {
-  void test_compute() {
-    expectInfo(simpleNullableTypeWith1Argument, 'C<T>?', required: true);
-    expectInfo(simpleNullableTypeWith1Argument, 'C<T>?;', required: true);
-    expectInfo(simpleNullableTypeWith1Argument, 'C<T>?(', required: true);
-    expectInfo(simpleNullableTypeWith1Argument, 'C<T>? do', required: true);
-
-    expectInfo(simpleNullableTypeWith1Argument, 'C<T>? foo');
-    expectInfo(simpleNullableTypeWith1Argument, 'C<T>? get');
-    expectInfo(simpleNullableTypeWith1Argument, 'C<T>? set');
-    expectInfo(simpleNullableTypeWith1Argument, 'C<T>? operator');
-    expectInfo(simpleNullableTypeWith1Argument, 'C<T>? Function');
-  }
-
-  void test_gt_questionMark() {
-    final Token start = scanString('before C<T>? ;').tokens;
-    final Token expectedEnd = start.next.next.next.next.next;
-    expect(expectedEnd.lexeme, '?');
-
-    expect(simpleNullableTypeWith1Argument.skipType(start), expectedEnd);
-    expect(simpleNullableTypeWith1Argument.couldBeExpression, isFalse);
-
-    TypeInfoListener listener;
-    assertResult(Token actualEnd) {
-      expect(actualEnd, expectedEnd);
-      expect(listener.calls, [
-        'handleIdentifier C typeReference',
-        'beginTypeArguments <',
-        'handleIdentifier T typeReference',
-        'handleNoTypeArguments >',
-        'handleType T null',
-        'endTypeArguments 1 < >',
-        'handleType C ?',
-      ]);
-      expect(listener.errors, isNull);
-    }
-
-    listener = new TypeInfoListener();
-    assertResult(simpleNullableTypeWith1Argument.ensureTypeNotVoid(
-        start, new Parser(listener)));
-
-    listener = new TypeInfoListener();
-    assertResult(simpleNullableTypeWith1Argument.ensureTypeOrVoid(
-        start, new Parser(listener)));
-
-    listener = new TypeInfoListener();
-    assertResult(simpleNullableTypeWith1Argument.parseTypeNotVoid(
-        start, new Parser(listener)));
-
-    listener = new TypeInfoListener();
-    assertResult(
-        simpleNullableTypeWith1Argument.parseType(start, new Parser(listener)));
-  }
-}
-
-@reflectiveTest
-class SimpleTypeTest {
+class SimpleTypeInfoTest {
   void test_compute() {
     expectInfo(simpleType, 'C', required: true);
     expectInfo(simpleType, 'C;', required: true);
@@ -455,7 +336,7 @@
     expectInfo(simpleType, 'C Function<T>(int x)', required: false);
   }
 
-  void test_simpleType() {
+  void test_simpleTypeInfo() {
     final Token start = scanString('before C ;').tokens;
     final Token expectedEnd = start.next;
 
@@ -937,15 +818,10 @@
         expectedErrors: [
           error(codeExpectedType, 2, 1)
         ]);
-  }
 
-  void test_computeType_statements() {
     // Statements that should not have a type
     expectInfo(noType, 'C<T ; T>U;', required: false);
     expectInfo(noType, 'C<T && T>U;', required: false);
-
-    expectInfo(noType, 'C? D : E;', required: false);
-    expectInfo(noType, 'C? D.foo : E;', required: false);
   }
 
   void test_computeType_nested() {