Skip to content

Commit 585f0aa

Browse files
authored
Allow annotations returning the dynamic type (#1840)
* Add dynamic annotation to test package * Allow dynamic constants as annotations * Rebuild test package docs * dartfmt * build-pub-package cares about dev dependencies
1 parent ad10e49 commit 585f0aa

File tree

250 files changed

+2927
-5
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

250 files changed

+2927
-5
lines changed

lib/src/model.dart

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3105,9 +3105,8 @@ abstract class ModelElement extends Canonicalization
31053105

31063106
ClassElement annotationClassElement;
31073107
if (annotationElement is ExecutableElement) {
3108-
annotationElement = (annotationElement as ExecutableElement)
3109-
.returnType
3110-
.element as ClassElement;
3108+
annotationElement =
3109+
(annotationElement as ExecutableElement).returnType.element;
31113110
}
31123111
if (annotationElement is ClassElement) {
31133112
annotationClassElement = annotationElement;
@@ -3117,7 +3116,9 @@ abstract class ModelElement extends Canonicalization
31173116
// annotationElement can be null if the element can't be resolved.
31183117
Class annotationClass = packageGraph
31193118
.findCanonicalModelElementFor(annotationClassElement) as Class;
3120-
if (annotationClass == null && annotationElement != null) {
3119+
if (annotationClass == null &&
3120+
annotationElement != null &&
3121+
annotationClassElement != null) {
31213122
annotationClass =
31223123
new ModelElement.fromElement(annotationClassElement, packageGraph)
31233124
as Class;
@@ -5037,12 +5038,14 @@ class PackageGraph {
50375038
packages.where((p) => p.documentedWhere != DocumentLocation.missing);
50385039

50395040
Map<LibraryElement, Set<Library>> _libraryElementReexportedBy = new Map();
5041+
50405042
/// Prevent cycles from breaking our stack.
50415043
Set<Tuple2<Library, LibraryElement>> _reexportsTagged = new Set();
50425044
void _tagReexportsFor(
50435045
final Library topLevelLibrary, final LibraryElement libraryElement,
50445046
[ExportElement lastExportedElement]) {
5045-
Tuple2<Library, LibraryElement> key = new Tuple2(topLevelLibrary, libraryElement);
5047+
Tuple2<Library, LibraryElement> key =
5048+
new Tuple2(topLevelLibrary, libraryElement);
50465049
if (_reexportsTagged.contains(key)) {
50475050
return;
50485051
}

testing/test_package/lib/fake.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,13 @@ const String bulletDoced = 'Foo bar baz';
112112
@pragma('Hello world')
113113
class HasPragma {}
114114

115+
const dynamic aDynamicAnnotation = 4;
116+
117+
@aDynamicAnnotation
118+
119+
/// This class has a dynamic annotation.
120+
class HasDynamicAnnotation {}
121+
115122
/// This is a class with a table.
116123
///
117124
/// It has multiple sentences before the table. Because testing is a good

testing/test_package_docs/fake/ABaseClass-class.html

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

testing/test_package_docs/fake/AClassUsingASuperMixin-class.html

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

testing/test_package_docs/fake/AClassUsingNewStyleMixin-class.html

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

testing/test_package_docs/fake/AClassWithFancyProperties-class.html

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

testing/test_package_docs/fake/AMixinCallingSuper-class.html

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

testing/test_package_docs/fake/ATypeTakingClass-class.html

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

testing/test_package_docs/fake/ATypeTakingClassMixedIn-class.html

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

testing/test_package_docs/fake/Annotation-class.html

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)