From 996cd594a64295e2089f3aa230d00f0578b200fa Mon Sep 17 00:00:00 2001 From: Jake Macdonald Date: Wed, 11 Sep 2024 19:24:14 +0000 Subject: [PATCH] Revert "Revive to the object's `variableElement` if available (#713)" This reverts commit ac1837fdd1ba6eed236082c88537fdb8c619b1f4. --- 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/CHANGELOG.md b/source_gen/CHANGELOG.md index f3436dac..f79caa5c 100644 --- a/source_gen/CHANGELOG.md +++ b/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/lib/src/constants/revive.dart b/source_gen/lib/src/constants/revive.dart index 47eb6617..ddfaded2 100644 --- a/source_gen/lib/src/constants/revive.dart +++ b/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/test/constants_test.dart b/source_gen/test/constants_test.dart index 0335efe9..fe97e07c 100644 --- a/source_gen/test/constants_test.dart +++ b/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'); - }); }); }