Mixin declarations don't have supertype, fix isMoreSpecificThan().

R=brianwilkerson@google.com, paulberry@google.com

Bug: https://github.com/dart-lang/sdk/issues/34563
Change-Id: I0edcc887694e895856cb262865b8ec61976bafad
Reviewed-on: https://dart-review.googlesource.com/76281
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
diff --git a/pkg/analyzer/lib/src/dart/element/type.dart b/pkg/analyzer/lib/src/dart/element/type.dart
index b1303b0..71c1338 100644
--- a/pkg/analyzer/lib/src/dart/element/type.dart
+++ b/pkg/analyzer/lib/src/dart/element/type.dart
@@ -1508,9 +1508,11 @@
     //
     List<DartType> jArgs = j.typeArguments;
     List<DartType> jVars = jElement.type.typeArguments;
-    supertype = supertype.substitute2(jArgs, jVars);
-    if (supertype == i) {
-      return true;
+    if (supertype != null) {
+      supertype = supertype.substitute2(jArgs, jVars);
+      if (supertype == i) {
+        return true;
+      }
     }
     //
     // I is listed in the on clause of J.
diff --git a/pkg/analyzer/test/src/dart/resolution/mixin_test.dart b/pkg/analyzer/test/src/dart/resolution/mixin_test.dart
index d1e8e1f..2c27d0d 100644
--- a/pkg/analyzer/test/src/dart/resolution/mixin_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/mixin_test.dart
@@ -1419,70 +1419,6 @@
     assertTypeName(bRef, findElement.class_('B'), 'B');
   }
 
-  test_inconsistentInheritanceGetterAndMethod_implements_getter_method() async {
-    addTestFile(r'''
-abstract class A {
-  int get x;
-}
-abstract class B {
-  int x();
-}
-mixin M implements A, B {}
-''');
-    await resolveTestFile();
-    assertTestErrors([
-      CompileTimeErrorCode.INCONSISTENT_INHERITANCE_GETTER_AND_METHOD,
-    ]);
-  }
-
-  test_inconsistentInheritanceGetterAndMethod_implements_method_getter() async {
-    addTestFile(r'''
-abstract class A {
-  int x();
-}
-abstract class B {
-  int get x;
-}
-mixin M implements A, B {}
-''');
-    await resolveTestFile();
-    assertTestErrors([
-      CompileTimeErrorCode.INCONSISTENT_INHERITANCE_GETTER_AND_METHOD,
-    ]);
-  }
-
-  test_inconsistentInheritanceGetterAndMethod_on_getter_method() async {
-    addTestFile(r'''
-abstract class A {
-  int get x;
-}
-abstract class B {
-  int x();
-}
-mixin M implements A, B {}
-''');
-    await resolveTestFile();
-    assertTestErrors([
-      CompileTimeErrorCode.INCONSISTENT_INHERITANCE_GETTER_AND_METHOD,
-    ]);
-  }
-
-  test_inconsistentInheritanceGetterAndMethod_on_method_getter() async {
-    addTestFile(r'''
-abstract class A {
-  int x();
-}
-abstract class B {
-  int get x;
-}
-mixin M implements A, B {}
-''');
-    await resolveTestFile();
-    assertTestErrors([
-      CompileTimeErrorCode.INCONSISTENT_INHERITANCE_GETTER_AND_METHOD,
-    ]);
-  }
-
   test_inconsistentInheritance_implements_parameterType() async {
     addTestFile(r'''
 abstract class A {
@@ -1579,6 +1515,82 @@
     ]);
   }
 
+  test_inconsistentInheritanceGetterAndMethod_implements_getter_method() async {
+    addTestFile(r'''
+abstract class A {
+  int get x;
+}
+abstract class B {
+  int x();
+}
+mixin M implements A, B {}
+''');
+    await resolveTestFile();
+    assertTestErrors([
+      CompileTimeErrorCode.INCONSISTENT_INHERITANCE_GETTER_AND_METHOD,
+    ]);
+  }
+
+  test_inconsistentInheritanceGetterAndMethod_implements_method_getter() async {
+    addTestFile(r'''
+abstract class A {
+  int x();
+}
+abstract class B {
+  int get x;
+}
+mixin M implements A, B {}
+''');
+    await resolveTestFile();
+    assertTestErrors([
+      CompileTimeErrorCode.INCONSISTENT_INHERITANCE_GETTER_AND_METHOD,
+    ]);
+  }
+
+  test_inconsistentInheritanceGetterAndMethod_on_getter_method() async {
+    addTestFile(r'''
+abstract class A {
+  int get x;
+}
+abstract class B {
+  int x();
+}
+mixin M implements A, B {}
+''');
+    await resolveTestFile();
+    assertTestErrors([
+      CompileTimeErrorCode.INCONSISTENT_INHERITANCE_GETTER_AND_METHOD,
+    ]);
+  }
+
+  test_inconsistentInheritanceGetterAndMethod_on_method_getter() async {
+    addTestFile(r'''
+abstract class A {
+  int x();
+}
+abstract class B {
+  int get x;
+}
+mixin M implements A, B {}
+''');
+    await resolveTestFile();
+    assertTestErrors([
+      CompileTimeErrorCode.INCONSISTENT_INHERITANCE_GETTER_AND_METHOD,
+    ]);
+  }
+
+  test_isMoreSpecificThan() async {
+    addTestFile(r'''
+mixin M {}
+''');
+    await resolveTestFile();
+    assertNoTestErrors();
+
+    var element = findElement.mixin('M');
+    var type = element.type;
+    expect(type.isMoreSpecificThan(intType), isFalse);
+  }
+
   test_metadata() async {
     addTestFile(r'''
 const a = 0;