Skip to content

Commit 97ae9fe

Browse files
authored
Make TypeImplementing.directInterfaces private. (#3555)
1 parent 22d0c37 commit 97ae9fe

File tree

3 files changed

+15
-28
lines changed

3 files changed

+15
-28
lines changed

lib/src/element_type.dart

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,6 @@ abstract class DefinedElementType extends ElementType {
275275
return AliasedElementType(
276276
f as ParameterizedType, library, packageGraph, modelElement);
277277
}
278-
assert(f is ParameterizedType || f is TypeParameterType);
279-
assert(f is! FunctionType,
280-
'detected DefinedElementType for FunctionType: analyzer version too old?');
281278
if (f is TypeParameterType) {
282279
return TypeParameterElementType(f, library, packageGraph, modelElement);
283280
}

lib/src/generator/templates.runtime_renderers.dart

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15392,19 +15392,6 @@ class _Renderer_TypeImplementing extends RendererBase<TypeImplementing> {
1539215392
_propertyMapCache.putIfAbsent(
1539315393
CT_,
1539415394
() => {
15395-
'directInterfaces': Property(
15396-
getValue: (CT_ c) => c.directInterfaces,
15397-
renderVariable: (CT_ c, Property<CT_> self,
15398-
List<String> remainingNames) =>
15399-
self.renderSimpleVariable(
15400-
c, remainingNames, 'List<DefinedElementType>'),
15401-
renderIterable: (CT_ c, RendererBase<CT_> r,
15402-
List<MustachioNode> ast, StringSink sink) {
15403-
return c.directInterfaces.map((e) =>
15404-
_render_DefinedElementType(e, ast, r.template, sink,
15405-
parent: r));
15406-
},
15407-
),
1540815395
'hasModifiers': Property(
1540915396
getValue: (CT_ c) => c.hasModifiers,
1541015397
renderVariable: (CT_ c, Property<CT_> self,

lib/src/model/inheriting_container.dart

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ mixin MixedInTypes on InheritingContainer {
469469
/// Add the ability for an [InheritingContainer] to be implemented by other
470470
/// InheritingContainers and to reference what it itself implements.
471471
mixin TypeImplementing on InheritingContainer {
472-
late final List<DefinedElementType> directInterfaces = [
472+
late final List<DefinedElementType> _directInterfaces = [
473473
for (var interface in element.interfaces)
474474
modelBuilder.typeFrom(interface, library) as DefinedElementType
475475
];
@@ -486,7 +486,7 @@ mixin TypeImplementing on InheritingContainer {
486486
bool get hasPublicInterfaces => publicInterfaces.isNotEmpty;
487487

488488
/// Interfaces directly implemented by this container.
489-
List<DefinedElementType> get interfaces => directInterfaces;
489+
List<DefinedElementType> get interfaces => _directInterfaces;
490490

491491
/// Returns all the "immediate" public implementors of this
492492
/// [TypeImplementing]. For a [Mixin], this is actually the mixin
@@ -523,11 +523,14 @@ mixin TypeImplementing on InheritingContainer {
523523
/// private interfaces, and so unlike other public* methods, is not
524524
/// a strict subset of [interfaces].
525525
@override
526-
Iterable<DefinedElementType> get publicInterfaces sync* {
527-
for (var i in directInterfaces) {
526+
Iterable<DefinedElementType> get publicInterfaces {
527+
var interfaces = <DefinedElementType>[];
528+
for (var interface in _directInterfaces) {
529+
var interfaceElement = interface.modelElement;
530+
528531
/// Do not recurse if we can find an element here.
529-
if (i.modelElement.canonicalModelElement != null) {
530-
yield i;
532+
if (interfaceElement.canonicalModelElement != null) {
533+
interfaces.add(interface);
531534
continue;
532535
}
533536
// Public types used to be unconditionally exposed here. However,
@@ -540,21 +543,21 @@ mixin TypeImplementing on InheritingContainer {
540543
// the superchain and publicInterfaces of this interface to pretend
541544
// as though the hidden class didn't exist and this class was declared
542545
// directly referencing the canonical classes further up the chain.
543-
if (i.modelElement is InheritingContainer) {
544-
var hiddenContainer = i.modelElement as InheritingContainer;
545-
if (hiddenContainer.publicSuperChain.isNotEmpty) {
546-
yield hiddenContainer.publicSuperChain.first;
546+
if (interfaceElement is InheritingContainer) {
547+
if (interfaceElement.publicSuperChain.isNotEmpty) {
548+
interfaces.add(interfaceElement.publicSuperChain.first);
547549
}
548-
yield* hiddenContainer.publicInterfaces;
550+
interfaces.addAll(interfaceElement.publicInterfaces);
549551
} else {
550552
assert(
551553
false,
552554
'Can not handle intermediate non-public interfaces created by '
553555
'ModelElements that are not classes or mixins: $fullyQualifiedName '
554-
'contains an interface $i, defined by ${i.modelElement}');
556+
'contains an interface $interface, defined by $interfaceElement');
555557
continue;
556558
}
557559
}
560+
return interfaces;
558561
}
559562
}
560563

0 commit comments

Comments
 (0)