[dart2js] Fix function_type GVN bug

Fixes #30476

Change-Id: Ie1e536c197b137ccddeeaa45d337f1bd16a2ff78
Reviewed-on: https://dart-review.googlesource.com/68848
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
diff --git a/pkg/compiler/lib/src/elements/types.dart b/pkg/compiler/lib/src/elements/types.dart
index 231c558..9248fe1 100644
--- a/pkg/compiler/lib/src/elements/types.dart
+++ b/pkg/compiler/lib/src/elements/types.dart
@@ -707,8 +707,8 @@
   }
 
   bool _equalsInternal(FunctionType other, _Assumptions assumptions) {
+    if (typeVariables.length != other.typeVariables.length) return false;
     if (typeVariables.isNotEmpty) {
-      if (typeVariables.length != other.typeVariables.length) return false;
       assumptions ??= new _Assumptions();
       for (int index = 0; index < typeVariables.length; index++) {
         assumptions.assume(typeVariables[index], other.typeVariables[index]);
diff --git a/tests/language_2/language_2_dart2js.status b/tests/language_2/language_2_dart2js.status
index 98f6320..44bff76 100644
--- a/tests/language_2/language_2_dart2js.status
+++ b/tests/language_2/language_2_dart2js.status
@@ -116,33 +116,11 @@
 field_type_check2_test/01: MissingRuntimeError
 regress_23996_test: RuntimeError # Jsshell does not provide non-zero timers, Issue 7728
 
-[ $compiler == dart2js && $runtime != none ]
-function_type/function_type0_test: RuntimeError # Issue 30476
-function_type/function_type1_test: RuntimeError # Issue 30476
-function_type/function_type2_test: RuntimeError # Issue 30476
-function_type/function_type3_test: RuntimeError # Issue 30476
-function_type/function_type58_test: RuntimeError # Issue 30476
-function_type/function_type96_test: RuntimeError # Issue 30476
-function_type/function_type97_test: RuntimeError # Issue 30476
-function_type/function_type98_test: RuntimeError # Issue 30476
-function_type/function_type99_test: RuntimeError # Issue 30476
-
 [ $compiler == dart2js && $runtime != none && $checked ]
 assert_with_message_test: RuntimeError
 syncstar_covariant_type_test: RuntimeError # dart2js misplaces check in Iterator, not Iterable.
 syncstar_dcall_type_test: RuntimeError # dart2js misplaces check in Iterator, not Iterable.
 
-[ $compiler == dart2js && $runtime != none && $host_checked ]
-function_type/function_type0_test: RuntimeError # Issue 30476
-function_type/function_type1_test: RuntimeError # Issue 30476
-function_type/function_type2_test: RuntimeError # Issue 30476
-function_type/function_type3_test: RuntimeError # Issue 30476
-function_type/function_type58_test: Crash # Failed assertion: line 2259 pos 18: 'other.gvnEquals(instruction) && instruction.gvnEquals(other)': is not true.
-function_type/function_type96_test: Crash # Failed assertion: line 2259 pos 18: 'other.gvnEquals(instruction) && instruction.gvnEquals(other)': is not true.
-function_type/function_type97_test: Crash # Failed assertion: line 2259 pos 18: 'other.gvnEquals(instruction) && instruction.gvnEquals(other)': is not true.
-function_type/function_type98_test: Crash # Failed assertion: line 2259 pos 18: 'other.gvnEquals(instruction) && instruction.gvnEquals(other)': is not true.
-function_type/function_type99_test: Crash # Failed assertion: line 2259 pos 18: 'other.gvnEquals(instruction) && instruction.gvnEquals(other)': is not true.
-
 [ $compiler == dart2js && $runtime == safari ]
 field_override_optimization_test: RuntimeError
 field_type_check2_test/01: MissingRuntimeError