mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 23:19:47 +00:00
Rework typesWithImplicitTypeArguments as an expando.
An expando is a better conceptual fit, since we are using typesWithImplicitTypeArguments as a substitute for adding a new property to every DartType object. Using an expando rather than an identity set also has the advantage of interacting better with the garbage collector, since the expando only has weak references to its keys. Change-Id: I39f538bd40b5ef264d637dbc8fafc11194ae27fa Reviewed-on: https://dart-review.googlesource.com/48321 Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Commit-Queue: Paul Berry <paulberry@google.com>
This commit is contained in:
parent
b0f3cd9022
commit
761980b44a
|
@ -24,6 +24,15 @@ import 'package:analyzer/src/summary/format.dart';
|
|||
import 'package:analyzer/src/summary/idl.dart';
|
||||
import 'package:analyzer/src/summary/summary_sdk.dart';
|
||||
|
||||
/**
|
||||
* Expando for marking types with implicit type arguments, which are the same as
|
||||
* type parameter bounds (in strong mode), or `dynamic` (in spec mode).
|
||||
*
|
||||
* If a type is associated with a non-null value in this expando, then it has
|
||||
* implicit type arguments.
|
||||
*/
|
||||
final _typesWithImplicitTypeArguments = new Expando();
|
||||
|
||||
/// An instance of [LibraryResynthesizer] is responsible for resynthesizing the
|
||||
/// elements in a single library from that library's summary.
|
||||
abstract class LibraryResynthesizer {
|
||||
|
@ -970,13 +979,6 @@ class _LibraryResynthesizer extends LibraryResynthesizerMixin {
|
|||
final Map<String, CompilationUnitElementImpl> resynthesizedUnits =
|
||||
<String, CompilationUnitElementImpl>{};
|
||||
|
||||
/**
|
||||
* Types with implicit type arguments, which are the same as type parameter
|
||||
* bounds (in strong mode), or `dynamic` (in spec mode).
|
||||
*/
|
||||
final Set<DartType> typesWithImplicitTypeArguments =
|
||||
new Set<DartType>.identity();
|
||||
|
||||
_LibraryResynthesizer(this.summaryResynthesizer, this.linkedLibrary,
|
||||
this.unlinkedUnits, this.librarySource) {
|
||||
libraryUri = librarySource.uri.toString();
|
||||
|
@ -1356,7 +1358,7 @@ class _ReferenceInfo extends ReferenceInfo {
|
|||
// Mark the type as having implicit type arguments, so that we don't
|
||||
// attempt to request them during constant expression resynthesizing.
|
||||
if (typeArguments == null) {
|
||||
libraryResynthesizer.typesWithImplicitTypeArguments.add(type);
|
||||
_typesWithImplicitTypeArguments[type] = true;
|
||||
}
|
||||
// Done.
|
||||
return type;
|
||||
|
@ -1872,7 +1874,7 @@ class _UnitResynthesizer extends UnitResynthesizer {
|
|||
|
||||
@override
|
||||
bool doesTypeHaveImplicitArguments(ParameterizedType type) =>
|
||||
libraryResynthesizer.typesWithImplicitTypeArguments.contains(type);
|
||||
_typesWithImplicitTypeArguments[type] != null;
|
||||
|
||||
@override
|
||||
ConstructorElement getConstructorForInfo(
|
||||
|
|
Loading…
Reference in a new issue