diff --git a/lib/src/element_type.dart b/lib/src/element_type.dart index 0779604e35..02a4f4a6a7 100644 --- a/lib/src/element_type.dart +++ b/lib/src/element_type.dart @@ -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); } diff --git a/lib/src/generator/templates.runtime_renderers.dart b/lib/src/generator/templates.runtime_renderers.dart index 38897d33a8..8de939ab5a 100644 --- a/lib/src/generator/templates.runtime_renderers.dart +++ b/lib/src/generator/templates.runtime_renderers.dart @@ -15372,19 +15372,6 @@ class _Renderer_TypeImplementing extends RendererBase { _propertyMapCache.putIfAbsent( CT_, () => { - 'directInterfaces': Property( - getValue: (CT_ c) => c.directInterfaces, - renderVariable: (CT_ c, Property self, - List remainingNames) => - self.renderSimpleVariable( - c, remainingNames, 'List'), - renderIterable: (CT_ c, RendererBase r, - List 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 self, diff --git a/lib/src/model/inheriting_container.dart b/lib/src/model/inheriting_container.dart index 10c6607062..5300dee6c1 100644 --- a/lib/src/model/inheriting_container.dart +++ b/lib/src/model/inheriting_container.dart @@ -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 directInterfaces = [ + late final List _directInterfaces = [ for (var interface in element.interfaces) modelBuilder.typeFrom(interface, library) as DefinedElementType ]; @@ -486,7 +486,7 @@ mixin TypeImplementing on InheritingContainer { bool get hasPublicInterfaces => publicInterfaces.isNotEmpty; /// Interfaces directly implemented by this container. - List get interfaces => directInterfaces; + List get interfaces => _directInterfaces; /// Returns all the "immediate" public implementors of this /// [TypeImplementing]. For a [Mixin], this is actually the mixin @@ -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 get publicInterfaces sync* { - for (var i in directInterfaces) { + Iterable get publicInterfaces { + var interfaces = []; + 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, @@ -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; } }