Skip to content

Change element type expectations for function aliases #2380

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/src/element_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ abstract class ElementType extends Privacy {
} else {
var element = ModelElement.fromElement(f.element, packageGraph);
assert(f is ParameterizedType || f is TypeParameterType);
// TODO(jcollins-g): Remove reference to f.element.enclosingElement after
// analyzer 0.41.
var isGenericTypeAlias =
f.element.enclosingElement is GenericTypeAliasElement;
f.element.enclosingElement is GenericTypeAliasElement ||
f.element is GenericTypeAliasElement;
if (f is FunctionType) {
assert(f is ParameterizedType);
if (isGenericTypeAlias) {
Expand Down
3 changes: 1 addition & 2 deletions lib/src/model/top_level_container.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,5 @@ abstract class TopLevelContainer implements Nameable {
Iterable<TopLevelVariable> get publicProperties =>
model_utils.filterNonPublic(properties);

Iterable<ModelFunctionTyped> get publicTypedefs =>
model_utils.filterNonPublic(typedefs);
Iterable<Typedef> get publicTypedefs => model_utils.filterNonPublic(typedefs);
}
8 changes: 4 additions & 4 deletions lib/src/model/typedef.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'package:dartdoc/src/render/typedef_renderer.dart';

class Typedef extends ModelElement
with TypeParameters, Categorization
implements EnclosedElement, ModelFunctionTyped {
implements EnclosedElement {
Typedef(FunctionTypeAliasElement element, Library library,
PackageGraph packageGraph)
: super(element, library, packageGraph, null);
Expand Down Expand Up @@ -44,17 +44,17 @@ class Typedef extends ModelElement
}

// Food for mustache.
@override
bool get isInherited => false;

@override
String get kind => 'typedef';

@override
String get linkedReturnType => modelType.createLinkedReturnTypeName();

@override
DefinedElementType get modelType => super.modelType;
// TODO(jcollins-g): change to FunctionTypeElementType after analyzer 0.41
// ignore: unnecessary_overrides
ElementType get modelType => super.modelType;

FunctionTypeAliasElement get _typedef =>
(element as FunctionTypeAliasElement);
Expand Down