diff --git a/pkg/analyzer/lib/src/generated/element.dart b/pkg/analyzer/lib/src/generated/element.dart index b527762ab81..46b6d035979 100644 --- a/pkg/analyzer/lib/src/generated/element.dart +++ b/pkg/analyzer/lib/src/generated/element.dart @@ -177,6 +177,12 @@ abstract class ClassElement implements Element { */ bool get isEnum; + /** + * Return `true` if this class is a mixin application. A class is a mixin + * application if it was declared using the syntax "class A = B with C;". + */ + bool get isMixinApplication; + /** * Return `true` if this class [isProxy], or if it inherits the proxy * annotation from a supertype. @@ -659,6 +665,9 @@ class ClassElementImpl extends ElementImpl implements ClassElement { @override bool get isEnum => hasModifier(Modifier.ENUM); + @override + bool get isMixinApplication => hasModifier(Modifier.MIXIN_APPLICATION); + @override bool get isOrInheritsProxy => _safeIsOrInheritsProxy(this, new HashSet()); @@ -695,6 +704,13 @@ class ClassElementImpl extends ElementImpl implements ClassElement { this._methods = methods; } + /** + * Set whether this class is a mixin application. + */ + void set mixinApplication(bool isMixinApplication) { + setModifier(Modifier.MIXIN_APPLICATION, isMixinApplication); + } + bool get mixinErrorsReported => hasModifier(Modifier.MIXIN_ERRORS_REPORTED); /** @@ -7921,42 +7937,48 @@ class Modifier extends Enum { */ static const Modifier MIXIN = const Modifier('MIXIN', 10); + /** + * Indicates that a class is a mixin application. + */ + static const Modifier MIXIN_APPLICATION = + const Modifier('MIXIN_APPLICATION', 11); + /** * Indicates that an error has reported explaining why this class is an * invalid mixin application. */ static const Modifier MIXIN_ERRORS_REPORTED = - const Modifier('MIXIN_ERRORS_REPORTED', 11); + const Modifier('MIXIN_ERRORS_REPORTED', 12); /** * Indicates that the value of a parameter or local variable might be mutated * within the context. */ static const Modifier POTENTIALLY_MUTATED_IN_CONTEXT = - const Modifier('POTENTIALLY_MUTATED_IN_CONTEXT', 12); + const Modifier('POTENTIALLY_MUTATED_IN_CONTEXT', 13); /** * Indicates that the value of a parameter or local variable might be mutated * within the scope. */ static const Modifier POTENTIALLY_MUTATED_IN_SCOPE = - const Modifier('POTENTIALLY_MUTATED_IN_SCOPE', 13); + const Modifier('POTENTIALLY_MUTATED_IN_SCOPE', 14); /** * Indicates that a class contains an explicit reference to 'super'. */ static const Modifier REFERENCES_SUPER = - const Modifier('REFERENCES_SUPER', 14); + const Modifier('REFERENCES_SUPER', 15); /** * Indicates that the pseudo-modifier 'set' was applied to the element. */ - static const Modifier SETTER = const Modifier('SETTER', 15); + static const Modifier SETTER = const Modifier('SETTER', 16); /** * Indicates that the modifier 'static' was applied to the element. */ - static const Modifier STATIC = const Modifier('STATIC', 16); + static const Modifier STATIC = const Modifier('STATIC', 17); /** * Indicates that the element does not appear in the source code but was @@ -7964,13 +7986,13 @@ class Modifier extends Enum { * constructors, an implicit zero-argument constructor will be created and it * will be marked as being synthetic. */ - static const Modifier SYNTHETIC = const Modifier('SYNTHETIC', 17); + static const Modifier SYNTHETIC = const Modifier('SYNTHETIC', 18); /** * Indicates that a class was defined using an alias. * TODO(brianwilkerson) This should be renamed to 'ALIAS'. */ - static const Modifier TYPEDEF = const Modifier('TYPEDEF', 18); + static const Modifier TYPEDEF = const Modifier('TYPEDEF', 19); static const List values = const [ ABSTRACT, @@ -7984,6 +8006,7 @@ class Modifier extends Enum { GETTER, HAS_EXT_URI, MIXIN, + MIXIN_APPLICATION, MIXIN_ERRORS_REPORTED, POTENTIALLY_MUTATED_IN_CONTEXT, POTENTIALLY_MUTATED_IN_SCOPE, diff --git a/pkg/analyzer/lib/src/generated/element_handle.dart b/pkg/analyzer/lib/src/generated/element_handle.dart index 07c7f3abed8..856483ba9e6 100644 --- a/pkg/analyzer/lib/src/generated/element_handle.dart +++ b/pkg/analyzer/lib/src/generated/element_handle.dart @@ -60,6 +60,9 @@ class ClassElementHandle extends ElementHandle implements ClassElement { @override bool get isEnum => actualElement.isEnum; + @override + bool get isMixinApplication => actualElement.isMixinApplication; + @override bool get isOrInheritsProxy => actualElement.isOrInheritsProxy; diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart index b26caee40f2..29817fdfc44 100644 --- a/pkg/analyzer/lib/src/generated/resolver.dart +++ b/pkg/analyzer/lib/src/generated/resolver.dart @@ -2487,6 +2487,7 @@ class ElementBuilder extends RecursiveAstVisitor { SimpleIdentifier className = node.name; ClassElementImpl element = new ClassElementImpl.forNode(className); element.abstract = node.abstractKeyword != null; + element.mixinApplication = true; element.typedef = true; List typeParameters = holder.typeParameters; element.typeParameters = typeParameters; diff --git a/pkg/analyzer/test/generated/all_the_rest_test.dart b/pkg/analyzer/test/generated/all_the_rest_test.dart index abae2267291..e16bff6bcae 100644 --- a/pkg/analyzer/test/generated/all_the_rest_test.dart +++ b/pkg/analyzer/test/generated/all_the_rest_test.dart @@ -4963,6 +4963,7 @@ class ElementBuilderTest extends EngineTestCase { List typeParameters = type.typeParameters; expect(typeParameters, hasLength(0)); expect(type.isAbstract, isTrue); + expect(type.isMixinApplication, isFalse); expect(type.isSynthetic, isFalse); } @@ -4981,6 +4982,7 @@ class ElementBuilderTest extends EngineTestCase { List typeParameters = type.typeParameters; expect(typeParameters, hasLength(0)); expect(type.isAbstract, isFalse); + expect(type.isMixinApplication, isFalse); expect(type.isSynthetic, isFalse); } @@ -5005,6 +5007,7 @@ class ElementBuilderTest extends EngineTestCase { expect(typeParameters[0].name, firstVariableName); expect(typeParameters[1].name, secondVariableName); expect(type.isAbstract, isFalse); + expect(type.isMixinApplication, isFalse); expect(type.isSynthetic, isFalse); } @@ -5031,6 +5034,7 @@ class ElementBuilderTest extends EngineTestCase { expect(type, isNotNull); expect(type.name, className); expect(type.isAbstract, isFalse); + expect(type.isMixinApplication, isFalse); expect(type.isSynthetic, isFalse); List typeParameters = type.typeParameters; expect(typeParameters, hasLength(1)); @@ -5072,6 +5076,7 @@ class ElementBuilderTest extends EngineTestCase { expect(alias.element, same(type)); expect(type.name, equals('C')); expect(type.isAbstract, isFalse); + expect(type.isMixinApplication, isTrue); expect(type.isSynthetic, isFalse); expect(type.typeParameters, isEmpty); expect(type.fields, isEmpty); @@ -5099,6 +5104,7 @@ class ElementBuilderTest extends EngineTestCase { expect(types, hasLength(1)); ClassElement type = types[0]; expect(type.isAbstract, isTrue); + expect(type.isMixinApplication, isTrue); } void test_visitClassTypeAlias_typeParams() {