anchor.diff:              "'${elementToMock.displayName}' for the following reasons:\n"
               '$joinedMessages');
         }
  -      return typeToMock as analyzer.InterfaceType;
  -    } else if (elementToMock is FunctionTypeAliasElement) {
  +      return typeToMock;
  +    }
  +
  +    var aliasElement = typeToMock.aliasElement;
  +    if (aliasElement != null) {
         throw InvalidMockitoAnnotationException('Mockito cannot mock a typedef: '
  -          '${elementToMock.displayName}');
  -    } else if (elementToMock is GenericFunctionTypeElement &&
  -        elementToMock.enclosingElement is FunctionTypeAliasElement) {
  -      throw InvalidMockitoAnnotationException('Mockito cannot mock a typedef: '
  -          '${elementToMock.enclosingElement.displayName}');
  +          '${aliasElement.displayName}');
       } else {
         throw InvalidMockitoAnnotationException(
  -          'Mockito cannot mock a non-class: ${elementToMock.displayName}');
  +          'Mockito cannot mock a non-class: $typeToMock');
       }
     }
   
  
positive.code:           ..types.addAll(type.typeArguments.map(_typeReference));
        });
      } else if (type is analyzer.FunctionType) {
        var element = type.element;
        if (element == null) {
          // [type] represents a FunctionTypedFormalParameter.
          return FunctionType((b) {
  
negative.code:         });
        }
        return TypeReference((b) {
          b
            ..symbol = element.name
            ..url = _typeImport(element)
            ..isNullable = forceNullable || typeSystem.isNullable(type);
          for (var typeArgument in type.aliasArguments) {
            b.types.add(_typeReference(typeArgument));
          }
        });
  