@@ -316,37 +316,42 @@ class MinifyNamer extends Namer
316
316
/// constructors declared along the inheritance chain.
317
317
class _ConstructorBodyNamingScope {
318
318
final int _startIndex;
319
- final List _constructors;
320
-
319
+ final List <ConstructorEntity > _constructors;
321
320
int get numberOfConstructors => _constructors.length;
322
321
323
- _ConstructorBodyNamingScope .rootScope (ClassElement cls)
322
+ _ConstructorBodyNamingScope .rootScope (
323
+ ClassEntity cls, ElementEnvironment environment)
324
324
: _startIndex = 0 ,
325
- _constructors = cls.constructors. toList (growable : false );
325
+ _constructors = _getConstructorList (cls, environment );
326
326
327
- _ConstructorBodyNamingScope .forClass (
328
- ClassElement cls, _ConstructorBodyNamingScope superScope )
327
+ _ConstructorBodyNamingScope .forClass (ClassEntity cls,
328
+ _ConstructorBodyNamingScope superScope, ElementEnvironment environment )
329
329
: _startIndex = superScope._startIndex + superScope.numberOfConstructors,
330
- _constructors = cls.constructors. toList (growable : false );
330
+ _constructors = _getConstructorList (cls, environment );
331
331
332
332
// Mixin Applications have constructors but we never generate code for them,
333
333
// so they do not count in the inheritance chain.
334
334
_ConstructorBodyNamingScope .forMixinApplication (
335
- ClassElement cls, _ConstructorBodyNamingScope superScope)
335
+ ClassEntity cls, _ConstructorBodyNamingScope superScope)
336
336
: _startIndex = superScope._startIndex + superScope.numberOfConstructors,
337
337
_constructors = const [];
338
338
339
- factory _ConstructorBodyNamingScope (ClassElement cls,
340
- Map <ClassElement , _ConstructorBodyNamingScope > registry) {
339
+ factory _ConstructorBodyNamingScope (
340
+ ClassEntity cls,
341
+ Map <ClassEntity , _ConstructorBodyNamingScope > registry,
342
+ ElementEnvironment environment) {
341
343
return registry.putIfAbsent (cls, () {
342
- if (cls.superclass == null ) {
343
- return new _ConstructorBodyNamingScope .rootScope (cls);
344
- } else if (cls.isMixinApplication) {
345
- return new _ConstructorBodyNamingScope .forMixinApplication (
346
- cls, new _ConstructorBodyNamingScope (cls.superclass, registry));
344
+ ClassEntity superclass = environment.getSuperClass (cls);
345
+ if (superclass == null ) {
346
+ return new _ConstructorBodyNamingScope .rootScope (cls, environment);
347
+ } else if (environment.isMixinApplication (cls)) {
348
+ return new _ConstructorBodyNamingScope .forMixinApplication (cls,
349
+ new _ConstructorBodyNamingScope (superclass, registry, environment));
347
350
} else {
348
351
return new _ConstructorBodyNamingScope .forClass (
349
- cls, new _ConstructorBodyNamingScope (cls.superclass, registry));
352
+ cls,
353
+ new _ConstructorBodyNamingScope (superclass, registry, environment),
354
+ environment);
350
355
}
351
356
});
352
357
}
@@ -356,16 +361,23 @@ class _ConstructorBodyNamingScope {
356
361
assert (position >= 0 , failedAt (body, "constructor body missing" ));
357
362
return "@constructorBody@${_startIndex + position }" ;
358
363
}
364
+
365
+ static List <ConstructorEntity > _getConstructorList (
366
+ ClassEntity cls, ElementEnvironment environment) {
367
+ var result = < ConstructorEntity > [];
368
+ environment.forEachConstructor (cls, result.add);
369
+ return result;
370
+ }
359
371
}
360
372
361
373
abstract class _MinifyConstructorBodyNamer implements Namer {
362
- Map <ClassElement , _ConstructorBodyNamingScope > _constructorBodyScopes =
363
- new Map <ClassElement , _ConstructorBodyNamingScope >();
374
+ Map <ClassEntity , _ConstructorBodyNamingScope > _constructorBodyScopes =
375
+ new Map <ClassEntity , _ConstructorBodyNamingScope >();
364
376
365
377
@override
366
378
jsAst.Name constructorBodyName (ConstructorBodyEntity method) {
367
379
_ConstructorBodyNamingScope scope = new _ConstructorBodyNamingScope (
368
- method.enclosingClass, _constructorBodyScopes);
380
+ method.enclosingClass, _constructorBodyScopes, elementEnvironment );
369
381
String key = scope.constructorBodyKeyFor (method);
370
382
return _disambiguateMemberByKey (
371
383
key, () => _proposeNameForConstructorBody (method));
0 commit comments