Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'ConstTopLevelVariableElementImpl' is not a subtype of type 'FieldElement' #28

Closed
mzakizadeh opened this issue Aug 26, 2020 · 5 comments
Labels
bug Something isn't working dependency Tickets related to dcdg as a dependency

Comments

@mzakizadeh
Copy link

mzakizadeh commented Aug 26, 2020

Is this project unmaintained? I do believe that this software won't work with new dart versions...

Unhandled exception:
_ElementMismatchException: Element mismatch in C:\dev\flutter\tourhq\lib\core\models\enrollment_state.dart at C:\dev\flutter\tourhq\lib\core\models\enrollment_state.dart
Caused by type 'ConstTopLevelVariableElementImpl' is not a subtype of type 'FieldElement'
#0      DeclarationResolver.visitFieldDeclaration (package:analyzer/src/generated/declaration_resolver.dart:189:18)
#1      FieldDeclarationImpl.accept (package:analyzer/src/dart/ast/ast.dart:4010:49)
#2      NodeListImpl.accept (package:analyzer/src/dart/ast/ast.dart:7687:20)
#3      ExtensionDeclarationImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:3934:14)
#4      RecursiveAstVisitor.visitExtensionDeclaration (package:analyzer/dart/ast/visitor.dart:847:10)
#5      ExtensionDeclarationImpl.accept (package:analyzer/src/dart/ast/ast.dart:3927:49)
#6      NodeListImpl.accept (package:analyzer/src/dart/ast/ast.dart:7687:20)
#7      CompilationUnitImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:2167:21)
#8      RecursiveAstVisitor.visitCompilationUnit (package:analyzer/dart/ast/visitor.dart:727:10)
#9      CompilationUnitImpl.accept (package:analyzer/src/dart/ast/ast.dart:2146:49)
#10     DeclarationResolver.resolve (package:analyzer/src/generated/declaration_resolver.dart:46:12)
#11     LibraryAnalyzer._resolveFile (package:analyzer/src/dart/analysis/library_analyzer.dart:675:31)
#12     LibraryAnalyzer.analyzeSync.<anonymous closure> (package:analyzer/src/dart/analysis/library_analyzer.dart:158:7)
#13     _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:377:8)
#14     LibraryAnalyzer.analyzeSync (package:analyzer/src/dart/analysis/library_analyzer.dart:157:11)
#15     LibraryAnalyzer.analyze.<anonymous closure> (package:analyzer/src/dart/analysis/library_analyzer.dart:111:14)
#16     _PerformanceTagImpl.makeCurrentWhile (package:analyzer/src/generated/utilities_general.dart:258:15)
#17     LibraryAnalyzer.analyze (package:analyzer/src/dart/analysis/library_analyzer.dart:110:43)
#18     AnalysisDriver._computeAnalysisResult.<anonymous closure> (package:analyzer/src/dart/analysis/driver.dart:1451:63)
#19     PerformanceLog.run (package:analyzer/src/dart/analysis/performance_logger.dart:34:15)
#20     AnalysisDriver._computeAnalysisResult (package:analyzer/src/dart/analysis/driver.dart:1428:20)
#21     AnalysisDriver.performWork (package:analyzer/src/dart/analysis/driver.dart:1100:33)
<asynchronous suspension>
#22     AnalysisDriverScheduler._run (package:analyzer/src/dart/analysis/driver.dart:2188:24)
<asynchronous suspension>
#23     AnalysisDriverScheduler.start (package:analyzer/src/dart/analysis/driver.dart:2118:5)
#24     ContextBuilderImpl.createContext (package:analyzer/src/dart/analysis/context_builder.dart:77:17)
#25     new AnalysisContextCollectionImpl (package:analyzer/src/dart/analysis/analysis_context_collection.dart:46:36)
#26     findClassElements (package:dcdg/src/find_class_elements.dart:26:29)
#27     main (file:///C:/Users/Zaki/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/dcdg-2.0.1/bin/dcdg.dart:28:25)
#28     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:299:32)
#29     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)


#0      DeclarationResolver.resolve (package:analyzer/src/generated/declaration_resolver.dart:49:7)
#1      LibraryAnalyzer._resolveFile (package:analyzer/src/dart/analysis/library_analyzer.dart:675:31)
#2      LibraryAnalyzer.analyzeSync.<anonymous closure> (package:analyzer/src/dart/analysis/library_analyzer.dart:158:7)
#3      _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:377:8)
#4      LibraryAnalyzer.analyzeSync (package:analyzer/src/dart/analysis/library_analyzer.dart:157:11)
#5      LibraryAnalyzer.analyze.<anonymous closure> (package:analyzer/src/dart/analysis/library_analyzer.dart:111:14)
#6      _PerformanceTagImpl.makeCurrentWhile (package:analyzer/src/generated/utilities_general.dart:258:15)
#7      LibraryAnalyzer.analyze (package:analyzer/src/dart/analysis/library_analyzer.dart:110:43)
#8      AnalysisDriver._computeAnalysisResult.<anonymous closure> (package:analyzer/src/dart/analysis/driver.dart:1451:63)
#9      PerformanceLog.run (package:analyzer/src/dart/analysis/performance_logger.dart:34:15)
#10     AnalysisDriver._computeAnalysisResult (package:analyzer/src/dart/analysis/driver.dart:1428:20)
#11     AnalysisDriver.performWork (package:analyzer/src/dart/analysis/driver.dart:1100:33)
<asynchronous suspension>
#12     AnalysisDriverScheduler._run (package:analyzer/src/dart/analysis/driver.dart:2188:24)
<asynchronous suspension>
#13     AnalysisDriverScheduler.start (package:analyzer/src/dart/analysis/driver.dart:2118:5)
#14     ContextBuilderImpl.createContext (package:analyzer/src/dart/analysis/context_builder.dart:77:17)
#15     new AnalysisContextCollectionImpl (package:analyzer/src/dart/analysis/analysis_context_collection.dart:46:36)
#16     findClassElements (package:dcdg/src/find_class_elements.dart:26:29)
#17     main (file:///C:/Users/Zaki/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/dcdg-2.0.1/bin/dcdg.dart:28:25)
#18     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:299:32)
#19     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)

#0      AnalysisDriver._computeAnalysisResult.<anonymous closure> (package:analyzer/src/dart/analysis/driver.dart:1487:9)
#1      PerformanceLog.run (package:analyzer/src/dart/analysis/performance_logger.dart:34:15)
#2      AnalysisDriver._computeAnalysisResult (package:analyzer/src/dart/analysis/driver.dart:1428:20)
#3      AnalysisDriver.performWork (package:analyzer/src/dart/analysis/driver.dart:1100:33)
<asynchronous suspension>
#4      AnalysisDriverScheduler._run (package:analyzer/src/dart/analysis/driver.dart:2188:24)
<asynchronous suspension>
#5      AnalysisDriverScheduler.start (package:analyzer/src/dart/analysis/driver.dart:2118:5)
#6      ContextBuilderImpl.createContext (package:analyzer/src/dart/analysis/context_builder.dart:77:17)
#7      new AnalysisContextCollectionImpl (package:analyzer/src/dart/analysis/analysis_context_collection.dart:46:36)
#8      findClassElements (package:dcdg/src/find_class_elements.dart:26:29)
#9      main (file:///C:/Users/Zaki/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/dcdg-2.0.1/bin/dcdg.dart:28:25)
#10     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:299:32)
#11     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)
Unhandled exception:
_ElementMismatchException: Element mismatch in C:\dev\flutter\tourhq\lib\core\models\enrollment_state.dart at C:\dev\flutter\tourhq\lib\core\models\enrollment_state.dart
Caused by type 'ConstTopLevelVariableElementImpl' is not a subtype of type 'FieldElement'
#0      DeclarationResolver.visitFieldDeclaration (package:analyzer/src/generated/declaration_resolver.dart:189:18)
#1      FieldDeclarationImpl.accept (package:analyzer/src/dart/ast/ast.dart:4010:49)
#2      NodeListImpl.accept (package:analyzer/src/dart/ast/ast.dart:7687:20)
#3      ExtensionDeclarationImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:3934:14)
#4      RecursiveAstVisitor.visitExtensionDeclaration (package:analyzer/dart/ast/visitor.dart:847:10)
#5      ExtensionDeclarationImpl.accept (package:analyzer/src/dart/ast/ast.dart:3927:49)
#6      NodeListImpl.accept (package:analyzer/src/dart/ast/ast.dart:7687:20)
#7      CompilationUnitImpl.visitChildren (package:analyzer/src/dart/ast/ast.dart:2167:21)
#8      RecursiveAstVisitor.visitCompilationUnit (package:analyzer/dart/ast/visitor.dart:727:10)
#9      CompilationUnitImpl.accept (package:analyzer/src/dart/ast/ast.dart:2146:49)
#10     DeclarationResolver.resolve (package:analyzer/src/generated/declaration_resolver.dart:46:12)
#11     LibraryAnalyzer._resolveFile (package:analyzer/src/dart/analysis/library_analyzer.dart:675:31)
#12     LibraryAnalyzer.analyzeSync.<anonymous closure> (package:analyzer/src/dart/analysis/library_analyzer.dart:158:7)
#13     _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:377:8)
#14     LibraryAnalyzer.analyzeSync (package:analyzer/src/dart/analysis/library_analyzer.dart:157:11)
#15     LibraryAnalyzer.analyze.<anonymous closure> (package:analyzer/src/dart/analysis/library_analyzer.dart:111:14)
#16     _PerformanceTagImpl.makeCurrentWhile (package:analyzer/src/generated/utilities_general.dart:258:15)
#17     LibraryAnalyzer.analyze (package:analyzer/src/dart/analysis/library_analyzer.dart:110:43)
#18     AnalysisDriver._computeAnalysisResult.<anonymous closure> (package:analyzer/src/dart/analysis/driver.dart:1451:63)
#19     PerformanceLog.run (package:analyzer/src/dart/analysis/performance_logger.dart:34:15)
#20     AnalysisDriver._computeAnalysisResult (package:analyzer/src/dart/analysis/driver.dart:1428:20)
#21     AnalysisDriver.performWork (package:analyzer/src/dart/analysis/driver.dart:1100:33)
<asynchronous suspension>
#22     AnalysisDriverScheduler._run (package:analyzer/src/dart/analysis/driver.dart:2188:24)
<asynchronous suspension>
#23     AnalysisDriverScheduler.start (package:analyzer/src/dart/analysis/driver.dart:2118:5)
#24     ContextBuilderImpl.createContext (package:analyzer/src/dart/analysis/context_builder.dart:77:17)
#25     new AnalysisContextCollectionImpl (package:analyzer/src/dart/analysis/analysis_context_collection.dart:46:36)
#26     findClassElements (package:dcdg/src/find_class_elements.dart:26:29)
#27     main (file:///C:/Users/Zaki/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/dcdg-2.0.1/bin/dcdg.dart:28:25)
#28     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:299:32)
#29     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)


#0      DeclarationResolver.resolve (package:analyzer/src/generated/declaration_resolver.dart:49:7)
#1      LibraryAnalyzer._resolveFile (package:analyzer/src/dart/analysis/library_analyzer.dart:675:31)
#2      LibraryAnalyzer.analyzeSync.<anonymous closure> (package:analyzer/src/dart/analysis/library_analyzer.dart:158:7)
#3      _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:377:8)
#4      LibraryAnalyzer.analyzeSync (package:analyzer/src/dart/analysis/library_analyzer.dart:157:11)
#5      LibraryAnalyzer.analyze.<anonymous closure> (package:analyzer/src/dart/analysis/library_analyzer.dart:111:14)
#6      _PerformanceTagImpl.makeCurrentWhile (package:analyzer/src/generated/utilities_general.dart:258:15)
#7      LibraryAnalyzer.analyze (package:analyzer/src/dart/analysis/library_analyzer.dart:110:43)
#8      AnalysisDriver._computeAnalysisResult.<anonymous closure> (package:analyzer/src/dart/analysis/driver.dart:1451:63)
#9      PerformanceLog.run (package:analyzer/src/dart/analysis/performance_logger.dart:34:15)
#10     AnalysisDriver._computeAnalysisResult (package:analyzer/src/dart/analysis/driver.dart:1428:20)
#11     AnalysisDriver.performWork (package:analyzer/src/dart/analysis/driver.dart:1100:33)
<asynchronous suspension>
#12     AnalysisDriverScheduler._run (package:analyzer/src/dart/analysis/driver.dart:2188:24)
<asynchronous suspension>
#13     AnalysisDriverScheduler.start (package:analyzer/src/dart/analysis/driver.dart:2118:5)
#14     ContextBuilderImpl.createContext (package:analyzer/src/dart/analysis/context_builder.dart:77:17)
#15     new AnalysisContextCollectionImpl (package:analyzer/src/dart/analysis/analysis_context_collection.dart:46:36)
#16     findClassElements (package:dcdg/src/find_class_elements.dart:26:29)
#17     main (file:///C:/Users/Zaki/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/dcdg-2.0.1/bin/dcdg.dart:28:25)
#18     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:299:32)
#19     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)

#0      AnalysisDriver._computeAnalysisResult.<anonymous closure> (package:analyzer/src/dart/analysis/driver.dart:1487:9)
#1      PerformanceLog.run (package:analyzer/src/dart/analysis/performance_logger.dart:34:15)
#2      AnalysisDriver._computeAnalysisResult (package:analyzer/src/dart/analysis/driver.dart:1428:20)
#3      AnalysisDriver.performWork (package:analyzer/src/dart/analysis/driver.dart:1100:33)
<asynchronous suspension>
#4      AnalysisDriverScheduler._run (package:analyzer/src/dart/analysis/driver.dart:2188:24)
<asynchronous suspension>
#5      AnalysisDriverScheduler.start (package:analyzer/src/dart/analysis/driver.dart:2118:5)
#6      ContextBuilderImpl.createContext (package:analyzer/src/dart/analysis/context_builder.dart:77:17)
#7      new AnalysisContextCollectionImpl (package:analyzer/src/dart/analysis/analysis_context_collection.dart:46:36)
#8      findClassElements (package:dcdg/src/find_class_elements.dart:26:29)
#9      main (file:///C:/Users/Zaki/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/dcdg-2.0.1/bin/dcdg.dart:28:25)
#10     _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:299:32)
#11     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)
@glesica
Copy link
Owner

glesica commented Aug 26, 2020

It's maintained, but only very lightly, as I have time. I'll take a look. The analyzer API probably changed, that's usually what breaks things.

@glesica
Copy link
Owner

glesica commented Aug 27, 2020

It looks like analyzer 0.4.0 breaks things, but it isn't compatible with the test package so I don't think I can update at this time. However, I'm going to do a dependency override and try to fix the issues I'm seeing so I can push out a fix once the test package is updated.

@glesica glesica added bug Something isn't working dependency Tickets related to dcdg as a dependency labels Aug 27, 2020
@glesica
Copy link
Owner

glesica commented Aug 27, 2020

For reference, here's the stack trace I get when I run DCDG with an override to analyzer 0.4.0...

Unable to spawn isolate: lib/src/diagram_visitor.dart:112:37: Error: The getter 'type' isn't defined for the class 'ClassElement'.
 - 'ClassElement' is from 'package:analyzer/dart/element/element.dart' ('../../../.pub-cache/hosted/pub.dartlang.org/analyzer-0.40.0/lib/dart/element/element.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'type'.
    InterfaceType current = element.type;
                                    ^^^^
lib/src/diagram_visitor.dart:216:40: Error: The getter 'isObject' isn't defined for the class 'InterfaceType'.
 - 'InterfaceType' is from 'package:analyzer/dart/element/type.dart' ('../../../.pub-cache/hosted/pub.dartlang.org/analyzer-0.40.0/lib/dart/element/type.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'isObject'.
      final superIsObject = superType?.isObject == true;
                                       ^^^^^^^^
lib/src/diagram_visitor.dart:225:23: Error: The getter 'isObject' isn't defined for the class 'InterfaceType'.
 - 'InterfaceType' is from 'package:analyzer/dart/element/type.dart' ('../../../.pub-cache/hosted/pub.dartlang.org/analyzer-0.40.0/lib/dart/element/type.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'isObject'.
        if (mixinType.isObject) {
                      ^^^^^^^^
lib/src/diagram_visitor.dart:237:27: Error: The getter 'isObject' isn't defined for the class 'InterfaceType'.
 - 'InterfaceType' is from 'package:analyzer/dart/element/type.dart' ('../../../.pub-cache/hosted/pub.dartlang.org/analyzer-0.40.0/lib/dart/element/type.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'isObject'.
        if (interfaceType.isObject) {
                          ^^^^^^^^
lib/src/diagram_visitor.dart:274:16: Error: The getter 'isObject' isn't defined for the class 'DartType'.
 - 'DartType' is from 'package:analyzer/dart/element/type.dart' ('../../../.pub-cache/hosted/pub.dartlang.org/analyzer-0.40.0/lib/dart/element/type.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'isObject'.
          type.isObject ||
               ^^^^^^^^
lib/src/diagram_visitor.dart:275:16: Error: The getter 'isUndefined' isn't defined for the class 'DartType'.
 - 'DartType' is from 'package:analyzer/dart/element/type.dart' ('../../../.pub-cache/hosted/pub.dartlang.org/analyzer-0.40.0/lib/dart/element/type.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'isUndefined'.
          type.isUndefined ||
               ^^^^^^^^^^^
lib/src/builders/type_name.dart:15:20: Error: The getter 'type' isn't defined for the class 'TypeDefiningElement'.
 - 'TypeDefiningElement' is from 'package:analyzer/dart/element/element.dart' ('../../../.pub-cache/hosted/pub.dartlang.org/analyzer-0.40.0/lib/dart/element/element.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'type'.
    return element.type.displayName;

@glesica
Copy link
Owner

glesica commented Aug 29, 2020

I've got the exceptions resolved, but the output has changed a bit because of differences in the newer analyzer API so I'm going to fiddle with it to make sure we don't lose any information.

@glesica
Copy link
Owner

glesica commented Mar 16, 2021

I've updated to the latest analyzer, so the bug described above should no longer exist.

@glesica glesica closed this as completed Mar 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dependency Tickets related to dcdg as a dependency
Projects
None yet
Development

No branches or pull requests

2 participants