Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(187)

Side by Side Diff: pkg/analyzer/lib/src/dart/element/element.dart

Issue 2655243007: Fix for invalid 'extends/implements/with SomeEnum'. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer.src.dart.element.element; 5 library analyzer.src.dart.element.element;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import 'dart:math' show min; 8 import 'dart:math' show min;
9 9
10 import 'package:analyzer/dart/ast/ast.dart'; 10 import 'package:analyzer/dart/ast/ast.dart';
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 } 723 }
724 return false; 724 return false;
725 } 725 }
726 726
727 @override 727 @override
728 List<InterfaceType> get interfaces { 728 List<InterfaceType> get interfaces {
729 if (_unlinkedClass != null && _interfaces == null) { 729 if (_unlinkedClass != null && _interfaces == null) {
730 ResynthesizerContext context = enclosingUnit.resynthesizerContext; 730 ResynthesizerContext context = enclosingUnit.resynthesizerContext;
731 _interfaces = _unlinkedClass.interfaces 731 _interfaces = _unlinkedClass.interfaces
732 .map((EntityRef t) => context.resolveTypeRef(t, this)) 732 .map((EntityRef t) => context.resolveTypeRef(t, this))
733 .where((DartType type) => type is InterfaceType) 733 .where(_isClassInterfaceType)
734 .toList(growable: false); 734 .toList(growable: false);
735 } 735 }
736 return _interfaces ?? const <InterfaceType>[]; 736 return _interfaces ?? const <InterfaceType>[];
737 } 737 }
738 738
739 void set interfaces(List<InterfaceType> interfaces) { 739 void set interfaces(List<InterfaceType> interfaces) {
740 _assertNotResynthesized(_unlinkedClass); 740 _assertNotResynthesized(_unlinkedClass);
741 _interfaces = interfaces; 741 _interfaces = interfaces;
742 } 742 }
743 743
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 _assertNotResynthesized(_unlinkedClass); 830 _assertNotResynthesized(_unlinkedClass);
831 setModifier(Modifier.MIXIN_APPLICATION, isMixinApplication); 831 setModifier(Modifier.MIXIN_APPLICATION, isMixinApplication);
832 } 832 }
833 833
834 @override 834 @override
835 List<InterfaceType> get mixins { 835 List<InterfaceType> get mixins {
836 if (_unlinkedClass != null && _mixins == null) { 836 if (_unlinkedClass != null && _mixins == null) {
837 ResynthesizerContext context = enclosingUnit.resynthesizerContext; 837 ResynthesizerContext context = enclosingUnit.resynthesizerContext;
838 _mixins = _unlinkedClass.mixins 838 _mixins = _unlinkedClass.mixins
839 .map((EntityRef t) => context.resolveTypeRef(t, this)) 839 .map((EntityRef t) => context.resolveTypeRef(t, this))
840 .where((DartType type) => type is InterfaceType) 840 .where(_isClassInterfaceType)
841 .toList(growable: false); 841 .toList(growable: false);
842 } 842 }
843 return _mixins ?? const <InterfaceType>[]; 843 return _mixins ?? const <InterfaceType>[];
844 } 844 }
845 845
846 void set mixins(List<InterfaceType> mixins) { 846 void set mixins(List<InterfaceType> mixins) {
847 _assertNotResynthesized(_unlinkedClass); 847 _assertNotResynthesized(_unlinkedClass);
848 _mixins = mixins; 848 _mixins = mixins;
849 } 849 }
850 850
(...skipping 13 matching lines...) Expand all
864 } 864 }
865 return offset; 865 return offset;
866 } 866 }
867 867
868 @override 868 @override
869 InterfaceType get supertype { 869 InterfaceType get supertype {
870 if (_unlinkedClass != null && _supertype == null) { 870 if (_unlinkedClass != null && _supertype == null) {
871 if (_unlinkedClass.supertype != null) { 871 if (_unlinkedClass.supertype != null) {
872 DartType type = enclosingUnit.resynthesizerContext 872 DartType type = enclosingUnit.resynthesizerContext
873 .resolveTypeRef(_unlinkedClass.supertype, this); 873 .resolveTypeRef(_unlinkedClass.supertype, this);
874 if (type is InterfaceType) { 874 if (_isClassInterfaceType(type)) {
875 _supertype = type; 875 _supertype = type;
876 } else { 876 } else {
877 _supertype = context.typeProvider.objectType; 877 _supertype = context.typeProvider.objectType;
878 } 878 }
879 } else if (_unlinkedClass.hasNoSupertype) { 879 } else if (_unlinkedClass.hasNoSupertype) {
880 return null; 880 return null;
881 } else { 881 } else {
882 _supertype = context.typeProvider.objectType; 882 _supertype = context.typeProvider.objectType;
883 } 883 }
884 } 884 }
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
1268 } 1268 }
1269 } 1269 }
1270 supertypes = element.mixins; 1270 supertypes = element.mixins;
1271 for (int i = 0; i < supertypes.length; i++) { 1271 for (int i = 0; i < supertypes.length; i++) {
1272 if (_safeIsOrInheritsProxy(supertypes[i].element, visited)) { 1272 if (_safeIsOrInheritsProxy(supertypes[i].element, visited)) {
1273 return true; 1273 return true;
1274 } 1274 }
1275 } 1275 }
1276 return false; 1276 return false;
1277 } 1277 }
1278
1279 /**
1280 * Return `true` if the given [type] is a class [InterfaceType].
1281 */
1282 static bool _isClassInterfaceType(DartType type) {
1283 return type is InterfaceType && !type.element.isEnum;
Brian Wilkerson 2017/01/28 17:18:39 Personally, I'd rather have a method like this be
1284 }
1278 } 1285 }
1279 1286
1280 /** 1287 /**
1281 * A concrete implementation of a [CompilationUnitElement]. 1288 * A concrete implementation of a [CompilationUnitElement].
1282 */ 1289 */
1283 class CompilationUnitElementImpl extends UriReferencedElementImpl 1290 class CompilationUnitElementImpl extends UriReferencedElementImpl
1284 implements CompilationUnitElement { 1291 implements CompilationUnitElement {
1285 /** 1292 /**
1286 * The context in which this unit is resynthesized, or `null` if the 1293 * The context in which this unit is resynthesized, or `null` if the
1287 * element is not resynthesized a summary. 1294 * element is not resynthesized a summary.
(...skipping 7330 matching lines...) Expand 10 before | Expand all | Expand 10 after
8618 8625
8619 @override 8626 @override
8620 void visitElement(Element element) { 8627 void visitElement(Element element) {
8621 int offset = element.nameOffset; 8628 int offset = element.nameOffset;
8622 if (offset != -1) { 8629 if (offset != -1) {
8623 map[offset] = element; 8630 map[offset] = element;
8624 } 8631 }
8625 super.visitElement(element); 8632 super.visitElement(element);
8626 } 8633 }
8627 } 8634 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698