| Index: pkg/compiler/lib/src/patch_parser.dart
|
| diff --git a/pkg/compiler/lib/src/patch_parser.dart b/pkg/compiler/lib/src/patch_parser.dart
|
| index f0ba4fc0272a34ddae1718154dc487390591050d..a572d742902b67cb4b35cb3dee1cb45839101aaa 100644
|
| --- a/pkg/compiler/lib/src/patch_parser.dart
|
| +++ b/pkg/compiler/lib/src/patch_parser.dart
|
| @@ -227,15 +227,10 @@ class PatchMemberListener extends MemberListener {
|
| void addMember(Element patch) {
|
| addMetadata(patch);
|
|
|
| - PatchVersion patchVersion = getPatchVersion(compiler, patch);
|
| - if (patchVersion != null) {
|
| - if (patchVersion.isActive(compiler.patchVersion)) {
|
| - Element origin = enclosingClass.origin.localLookup(patch.name);
|
| - patchElement(compiler, reporter, origin, patch);
|
| - enclosingClass.addMember(patch, reporter);
|
| - } else {
|
| - // Skip this element.
|
| - }
|
| + if (_isMarkedAsPatch(compiler, patch)) {
|
| + Element origin = enclosingClass.origin.localLookup(patch.name);
|
| + patchElement(compiler, reporter, origin, patch);
|
| + enclosingClass.addMember(patch, reporter);
|
| } else {
|
| if (Name.isPublicName(patch.name)) {
|
| reporter.reportErrorMessage(patch, MessageKind.INJECTED_PUBLIC_MEMBER);
|
| @@ -261,17 +256,12 @@ class PatchElementListener extends ElementListener implements Listener {
|
| void pushElement(Element patch) {
|
| popMetadata(patch);
|
|
|
| - PatchVersion patchVersion = getPatchVersion(compiler, patch);
|
| - if (patchVersion != null) {
|
| - if (patchVersion.isActive(compiler.patchVersion)) {
|
| - LibraryElement originLibrary = compilationUnitElement.library;
|
| - assert(originLibrary.isPatched);
|
| - Element origin = originLibrary.localLookup(patch.name);
|
| - patchElement(compiler, reporter, origin, patch);
|
| - compilationUnitElement.addMember(patch, reporter);
|
| - } else {
|
| - // Skip this element.
|
| - }
|
| + if (_isMarkedAsPatch(compiler, patch)) {
|
| + LibraryElement originLibrary = compilationUnitElement.library;
|
| + assert(originLibrary.isPatched);
|
| + Element origin = originLibrary.localLookup(patch.name);
|
| + patchElement(compiler, reporter, origin, patch);
|
| + compilationUnitElement.addMember(patch, reporter);
|
| } else {
|
| if (Name.isPublicName(patch.name)) {
|
| reporter.reportErrorMessage(patch, MessageKind.INJECTED_PUBLIC_MEMBER);
|
| @@ -381,28 +371,17 @@ abstract class EagerAnnotationHandler<T> {
|
| }
|
|
|
| /// Annotation handler for pre-resolution detection of `@patch` annotations.
|
| -class PatchAnnotationHandler extends EagerAnnotationHandler<PatchVersion> {
|
| +class PatchAnnotationHandler extends EagerAnnotationHandler<bool> {
|
| const PatchAnnotationHandler();
|
|
|
| - PatchVersion getPatchVersion(MetadataAnnotationX annotation) {
|
| - if (annotation.beginToken != null) {
|
| - if (annotation.beginToken.next.lexeme == 'patch') {
|
| - return const PatchVersion(null);
|
| - } else if (annotation.beginToken.next.lexeme == 'patch_full') {
|
| - return const PatchVersion('full');
|
| - } else if (annotation.beginToken.next.lexeme == 'patch_lazy') {
|
| - return const PatchVersion('lazy');
|
| - } else if (annotation.beginToken.next.lexeme == 'patch_startup') {
|
| - return const PatchVersion('startup');
|
| - }
|
| - }
|
| - return null;
|
| - }
|
| -
|
| @override
|
| - PatchVersion apply(
|
| + bool apply(
|
| Compiler compiler, Element element, MetadataAnnotation annotation) {
|
| - return getPatchVersion(annotation);
|
| + MetadataAnnotationX meta = annotation;
|
| + if (meta.beginToken?.next?.lexeme == 'patch') {
|
| + return true;
|
| + }
|
| + return null;
|
| }
|
|
|
| @override
|
| @@ -520,17 +499,8 @@ void patchFunction(DiagnosticReporter reporter, BaseFunctionElementX origin,
|
| origin.applyPatch(patch);
|
| }
|
|
|
| -PatchVersion getPatchVersion(Compiler compiler, Element element) {
|
| +bool _isMarkedAsPatch(Compiler compiler, Element element) {
|
| return EagerAnnotationHandler.checkAnnotation(
|
| - compiler, element, const PatchAnnotationHandler());
|
| -}
|
| -
|
| -class PatchVersion {
|
| - final String tag;
|
| -
|
| - const PatchVersion(this.tag);
|
| -
|
| - bool isActive(String patchTag) => tag == null || tag == patchTag;
|
| -
|
| - String toString() => 'PatchVersion($tag)';
|
| + compiler, element, const PatchAnnotationHandler()) ==
|
| + true;
|
| }
|
|
|