From 6e8ceeeb39bc7334487ecf32e0860b7b338dab95 Mon Sep 17 00:00:00 2001 From: Jacob MacDonald Date: Wed, 11 Sep 2024 14:18:31 -0700 Subject: [PATCH] Revert "Revive to the object's `variableElement` if available (dart-lang/source_gen#713)" (dart-lang/source_gen#719) This reverts commit 893353eff894d796f88fb6ee40561437a862fa4a. --- source_gen/source_gen/source_gen/CHANGELOG.md | 1 - .../source_gen/lib/src/constants/revive.dart | 15 --------------- .../source_gen/test/constants_test.dart | 11 ----------- 3 files changed, 27 deletions(-) diff --git a/source_gen/source_gen/source_gen/CHANGELOG.md b/source_gen/source_gen/source_gen/CHANGELOG.md index f3436dac4..f79caa5cf 100644 --- a/source_gen/source_gen/source_gen/CHANGELOG.md +++ b/source_gen/source_gen/source_gen/CHANGELOG.md @@ -8,7 +8,6 @@ - Document deduplication behavior for the output of `GeneratorForAnnotation.generateForAnnotatedElement`. - Support all the glob quotes. -- Revive to the object's `variableElement` if available - Require `analyzer: ^6.9.0` - Require Dart 3.5.0 diff --git a/source_gen/source_gen/source_gen/lib/src/constants/revive.dart b/source_gen/source_gen/source_gen/lib/src/constants/revive.dart index 47eb66170..ddfaded2e 100644 --- a/source_gen/source_gen/source_gen/lib/src/constants/revive.dart +++ b/source_gen/source_gen/source_gen/lib/src/constants/revive.dart @@ -23,21 +23,6 @@ import '../utils.dart'; /// Dart source code (such as referencing private constructors). It is up to the /// build tool(s) using this library to surface error messages to the user. Revivable reviveInstance(DartObject object, [LibraryElement? origin]) { - final variableElement = object.variable; - if (variableElement != null && - variableElement.isConst && - variableElement.isPublic) { - final url = Uri.parse(urlOfElement(variableElement)).removeFragment(); - if (variableElement.enclosingElement - case final TypeDefiningElement enclosingElement?) { - return Revivable._( - source: url, - accessor: '${enclosingElement.name}.${variableElement.name}', - ); - } - return Revivable._(source: url, accessor: variableElement.name); - } - final objectType = object.type; Element? element = objectType!.alias?.element; if (element == null) { diff --git a/source_gen/source_gen/source_gen/test/constants_test.dart b/source_gen/source_gen/source_gen/test/constants_test.dart index 0335efe94..fe97e07c4 100644 --- a/source_gen/source_gen/source_gen/test/constants_test.dart +++ b/source_gen/source_gen/source_gen/test/constants_test.dart @@ -227,7 +227,6 @@ void main() { @_privateField @Wrapper(_privateFunction) @ProcessStartMode.normal - @ExtensionTypeWithStaticField.staticField class Example {} class Int64Like implements Int64LikeBase{ @@ -297,10 +296,6 @@ void main() { } void _privateFunction() {} - - extension type const ExtensionTypeWithStaticField._(int _) { - static const staticField = ExtensionTypeWithStaticField._(1); - } ''', (resolver) async => (await resolver.findLibraryByName('test_lib'))!, ); @@ -398,11 +393,5 @@ void main() { expect(staticFieldWithPrivateImpl.isPrivate, isFalse); expect(staticFieldWithPrivateImpl.source.fragment, isEmpty); }); - - test('should decode static fields on extension types', () { - final fieldOnly = constants[14].revive(); - expect(fieldOnly.source.fragment, isEmpty); - expect(fieldOnly.accessor, 'ExtensionTypeWithStaticField.staticField'); - }); }); }