Skip to content
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

Make TypeImplementing.directInterfaces private. #3555

Merged
merged 1 commit into from
Oct 26, 2023
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
3 changes: 0 additions & 3 deletions lib/src/element_type.dart
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,6 @@ abstract class DefinedElementType extends ElementType {
return AliasedElementType(
f as ParameterizedType, library, packageGraph, modelElement);
}
assert(f is ParameterizedType || f is TypeParameterType);
assert(f is! FunctionType,
'detected DefinedElementType for FunctionType: analyzer version too old?');
if (f is TypeParameterType) {
return TypeParameterElementType(f, library, packageGraph, modelElement);
}
Expand Down
13 changes: 0 additions & 13 deletions lib/src/generator/templates.runtime_renderers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15372,19 +15372,6 @@ class _Renderer_TypeImplementing extends RendererBase<TypeImplementing> {
_propertyMapCache.putIfAbsent(
CT_,
() => {
'directInterfaces': Property(
getValue: (CT_ c) => c.directInterfaces,
renderVariable: (CT_ c, Property<CT_> self,
List<String> remainingNames) =>
self.renderSimpleVariable(
c, remainingNames, 'List<DefinedElementType>'),
renderIterable: (CT_ c, RendererBase<CT_> r,
List<MustachioNode> ast, StringSink sink) {
return c.directInterfaces.map((e) =>
_render_DefinedElementType(e, ast, r.template, sink,
parent: r));
},
),
'hasModifiers': Property(
getValue: (CT_ c) => c.hasModifiers,
renderVariable: (CT_ c, Property<CT_> self,
Expand Down
27 changes: 15 additions & 12 deletions lib/src/model/inheriting_container.dart
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ mixin MixedInTypes on InheritingContainer {
/// Add the ability for an [InheritingContainer] to be implemented by other
/// InheritingContainers and to reference what it itself implements.
mixin TypeImplementing on InheritingContainer {
late final List<DefinedElementType> directInterfaces = [
late final List<DefinedElementType> _directInterfaces = [
for (var interface in element.interfaces)
modelBuilder.typeFrom(interface, library) as DefinedElementType
];
Expand All @@ -486,7 +486,7 @@ mixin TypeImplementing on InheritingContainer {
bool get hasPublicInterfaces => publicInterfaces.isNotEmpty;

/// Interfaces directly implemented by this container.
List<DefinedElementType> get interfaces => directInterfaces;
List<DefinedElementType> get interfaces => _directInterfaces;

/// Returns all the "immediate" public implementors of this
/// [TypeImplementing]. For a [Mixin], this is actually the mixin
Expand Down Expand Up @@ -523,11 +523,14 @@ mixin TypeImplementing on InheritingContainer {
/// private interfaces, and so unlike other public* methods, is not
/// a strict subset of [interfaces].
@override
Iterable<DefinedElementType> get publicInterfaces sync* {
for (var i in directInterfaces) {
Iterable<DefinedElementType> get publicInterfaces {
var interfaces = <DefinedElementType>[];
for (var interface in _directInterfaces) {
var interfaceElement = interface.modelElement;

/// Do not recurse if we can find an element here.
if (i.modelElement.canonicalModelElement != null) {
yield i;
if (interfaceElement.canonicalModelElement != null) {
interfaces.add(interface);
continue;
}
// Public types used to be unconditionally exposed here. However,
Expand All @@ -540,21 +543,21 @@ mixin TypeImplementing on InheritingContainer {
// the superchain and publicInterfaces of this interface to pretend
// as though the hidden class didn't exist and this class was declared
// directly referencing the canonical classes further up the chain.
if (i.modelElement is InheritingContainer) {
var hiddenContainer = i.modelElement as InheritingContainer;
if (hiddenContainer.publicSuperChain.isNotEmpty) {
yield hiddenContainer.publicSuperChain.first;
if (interfaceElement is InheritingContainer) {
if (interfaceElement.publicSuperChain.isNotEmpty) {
interfaces.add(interfaceElement.publicSuperChain.first);
}
yield* hiddenContainer.publicInterfaces;
interfaces.addAll(interfaceElement.publicInterfaces);
} else {
assert(
false,
'Can not handle intermediate non-public interfaces created by '
'ModelElements that are not classes or mixins: $fullyQualifiedName '
'contains an interface $i, defined by ${i.modelElement}');
'contains an interface $interface, defined by $interfaceElement');
continue;
}
}
return interfaces;
}
}

Expand Down