dartdoc icon indicating copy to clipboard operation
dartdoc copied to clipboard

dartdoc failed: type 'PropertyAccessImpl' is not a subtype of type 'IdentifierImpl' in type cast

Open lunacd opened this issue 3 years ago • 18 comments

Result of running dart doc .:

Documenting omnilore_scheduler...                                                                                                                               |
dartdoc 4.1.0 (.../omnilore_scheduler/dartdev) failed: type 'PropertyAccessImpl' is not a subtype of type 'IdentifierImpl' in type cast
#0      CommentReferenceImpl.identifier (package:analyzer/src/dart/ast/ast.dart:1911:48)
#1      new _ModelCommentReferenceImpl (package:dartdoc/src/comment_references/model_comment_reference.dart:101:29)
#2      new ModelCommentReference (package:dartdoc/src/comment_references/model_comment_reference.dart:24:7)
#3      ModelNode._commentRefsFor (package:dartdoc/src/model/model_node.dart:30:11)
#4      new ModelNode (package:dartdoc/src/model/model_node.dart:22:23)
#5      PackageGraph.populateModelNodeFor.<anonymous closure> (package:dartdoc/src/model/package_graph.dart:174:15)
#6      _LinkedHashMapMixin.putIfAbsent (dart:collection-patch/compact_hash.dart:453:23)
#7      PackageGraph.populateModelNodeFor (package:dartdoc/src/model/package_graph.dart:172:17)
#8      new Library.fromLibraryResult.<anonymous closure> (package:dartdoc/src/model/library.dart:82:26)
#9      _HashableChildLibraryElementVisitor.visitElement (package:dartdoc/src/model/library.dart:34:21)
#10     GeneralizingElementVisitor.visitExecutableElement (package:analyzer/dart/element/visitor.dart:101:59)
#11     GeneralizingElementVisitor.visitMethodElement (package:analyzer/dart/element/visitor.dart:151:7)
#12     MethodElementImpl.accept (package:analyzer/src/dart/element/element.dart:4323:54)
#13     ElementImpl.safelyVisitChildren (package:analyzer/src/dart/element/element.dart:2587:13)
#14     ClassElementImpl.visitChildren (package:analyzer/src/dart/element/element.dart:804:5)
#15     GeneralizingElementVisitor.visitElement (package:analyzer/dart/element/visitor.dart:97:13)
#16     _HashableChildLibraryElementVisitor.visitElement (package:dartdoc/src/model/library.dart:35:11)
#17     GeneralizingElementVisitor.visitClassElement (package:analyzer/dart/element/visitor.dart:86:49)
#18     AbstractClassElementImpl.accept (package:analyzer/src/dart/element/element.dart:126:54)
#19     ElementImpl.safelyVisitChildren (package:analyzer/src/dart/element/element.dart:2587:13)
#20     CompilationUnitElementImpl.visitChildren (package:analyzer/src/dart/element/element.dart:1228:5)
#21     GeneralizingElementVisitor.visitElement (package:analyzer/dart/element/visitor.dart:97:13)
#22     _HashableChildLibraryElementVisitor.visitElement (package:dartdoc/src/model/library.dart:35:11)
#23     GeneralizingElementVisitor.visitCompilationUnitElement (package:analyzer/dart/element/visitor.dart:90:7)
#24     CompilationUnitElementImpl.accept (package:analyzer/src/dart/element/element.dart:1190:15)
#25     ElementImpl.safelyVisitChildren (package:analyzer/src/dart/element/element.dart:2587:13)
#26     LibraryElementImpl.visitChildren (package:analyzer/src/dart/element/element.dart:4169:5)
#27     GeneralizingElementVisitor.visitElement (package:analyzer/dart/element/visitor.dart:97:13)
#28     _HashableChildLibraryElementVisitor.visitElement (package:dartdoc/src/model/library.dart:35:11)
#29     new Library.fromLibraryResult (package:dartdoc/src/model/library.dart:83:10)
#30     PackageGraph.addLibraryToGraph (package:dartdoc/src/model/package_graph.dart:72:23)
#31     PubPackageBuilder._parseLibraries (package:dartdoc/src/model/package_builder.dart:225:23)
<asynchronous suspension>
#32     PubPackageBuilder.getLibraries (package:dartdoc/src/model/package_builder.dart:404:5)
<asynchronous suspension>
#33     PubPackageBuilder.buildPackageGraph (package:dartdoc/src/model/package_builder.dart:75:5)
<asynchronous suspension>
#34     Dartdoc.generateDocsBase (package:dartdoc/dartdoc.dart:185:24)
<asynchronous suspension>
#35     Dartdoc.generateDocs (package:dartdoc/dartdoc.dart:233:24)
<asynchronous suspension>
#36     Dartdoc.executeGuarded.<anonymous closure> (package:dartdoc/dartdoc.dart:493:9)
<asynchronous suspension>

Not sure if this is a bug or if I did something wrong.

lunacd avatar Feb 04 '22 01:02 lunacd

I'm seeing this too on the bleeding edge SDK (commit b41922f9253a59ed693d238f2d1332684b5873a6) when running dartdoc on dart_style.

munificent avatar Feb 04 '22 18:02 munificent

I'm a dart rookie but this seems related? https://github.com/dart-lang/dartdoc/commit/b3927dd89d6ff9c78dc88ab2901e63b6a3bf29b7

If the fix is already in, should releasing a new path version fix the issue?

lunacd avatar Feb 04 '22 18:02 lunacd

I am also having this issue.

joranmulderij avatar Feb 05 '22 09:02 joranmulderij

Same issue for me. The base dartdoc package does not have this issue

ivoleitao avatar Feb 05 '22 15:02 ivoleitao

Link to my package github actions output. This started to happen with the latest update.

ivoleitao avatar Feb 05 '22 15:02 ivoleitao

Same problem here

Dart version: 2.16.0

RicardoRB avatar Feb 07 '22 20:02 RicardoRB

I am getting error as well!

Flutter 2.10.0 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 5f105a6ca7 (6 days ago) • 2022-02-01 14:15:42 -0800
Engine • revision 776efd2034
Tools • Dart 2.16.0 • DevTools 2.9.2

dw2kim avatar Feb 07 '22 21:02 dw2kim

Fixed in https://github.com/dart-lang/dartdoc/commit/b3927dd89d6ff9c78dc88ab2901e63b6a3bf29b7. Might be able to cherry-pick into a 2.16 minor release.

srawlins avatar Feb 08 '22 18:02 srawlins

~~I'm not sure if dart sdk 2.16.1 is supposed to fix this issue but I'm facing the same thing on 2.16.1.~~

I see. It's not supposed to fix it. Hope it get cherry-picked into 2.16.2 or something.

lunacd avatar Feb 10 '22 18:02 lunacd

No I didn't make that cherry-pick.

srawlins avatar Feb 10 '22 20:02 srawlins

It looks like the only workaround is to downgrade to dart 2.15, correct?

Is there a suggested workaround for those using flutter? Downgrading to flutter 2.8.1 and then generating docs works, but it is not a great solution to have to keep switching versions. I supposed I could install dart 2.15 separately from flutter, but that also doesn't seem like a great solution.

Does this impact ability to generate documentation after publishing to pub, or is this issue only local?

Jordan-Nelson avatar Feb 16 '22 21:02 Jordan-Nelson

Sorry, I meant to post the other workaround. Instead of running dart doc, you can use the dartdoc package:

Run pub global activate dartdoc to install the latest version of dartdoc compatible with your SDK. Then run pub run dartdoc (I think).

srawlins avatar Feb 16 '22 22:02 srawlins

Sorry, I meant to post the other workaround. Instead of running dart doc, you can use the dartdoc package:

Run pub global activate dartdoc to install the latest version of dartdoc compatible with your SDK. Then run pub run dartdoc (I think).

I hit the same issue when I do that. Instead of pub run dartdoc I just ran dartdoc. Let me know if that isn't what you meant. pub run dartdoc gives me "Could not find package "dartdoc". Did you forget to add a dependency?"

Jordan-Nelson avatar Feb 16 '22 23:02 Jordan-Nelson

Sorry, I think pub global run dartdoc is the right command after activating it globally.

srawlins avatar Feb 16 '22 23:02 srawlins

Sorry, I think pub global run dartdoc is the right command after activating it globally.

That works. Thank you.

Jordan-Nelson avatar Feb 17 '22 15:02 Jordan-Nelson

for flutter users:

flutter pub global activate dartdoc
flutter pub global run dartdoc .

doradsoft avatar Feb 17 '22 18:02 doradsoft

I'm hitting this issue as well

$ dart --version
Dart SDK version: 2.16.2 (stable) (Unknown timestamp) on "linux_x64"

mkorbel1 avatar Apr 05 '22 18:04 mkorbel1

try to add the package in your pubspec.yaml file if you faced any packages incompatible with dependency constraints, it will be (maybe) flutter-test comment it, in flutter version: 2.10.4 dart version: 2.16.2,

run:

flutter pub global activate dartdoc

make sure that the version of the plugin is 5.0.1, not 4.0.0, the error was thrown to me because of the incompatible dependency , and activated the 4.0.0 version not 5.0.1 version

then run:

flutter pub global run dartdoc .

I hope this solves your issue Happy coding mates

Mo0Khaled avatar Apr 09 '22 00:04 Mo0Khaled