Skip to content

Analyzer crashes accessing the superConstructorParameter of a SuperFormalParameterElement #49225

@srawlins

Description

@srawlins

I haven't been able to make a minimal reproduction of this. :/ The only one I have takes more than 10 minutes, running dartdoc over flutter.

  1. get dartdoc
  2. bump analyzer dep to ^4.1.0, or use dependency_overrides to use main branch at HEAD (which also lets you do print debugging)
  3. run DARTDOC_BOT=flutter ./tool/ci.sh

You get a crash like

flutter-docs: dartdoc 5.1.3-dev (/Users/srawlins/code/dart-dartdoc/.dart_tool/pub/bin/dartdoc/dartdoc.dart-2.18.0-170.0.dev.snapshot) failed: Bad state: Members must be created from a declaration, but is "{Key key}" (SuperFormalParameterMember) (parent: PopupMenuEntry<T> PopupMenuEntry({Key? key})).
flutter-docs: #0      new Member (package:analyzer/src/dart/element/member.dart:463:7)
flutter-docs: #1      new ParameterMember._ (package:analyzer/src/dart/element/member.dart)
flutter-docs: #2      new ParameterMember (package:analyzer/src/dart/element/member.dart:824:28)
flutter-docs: #3      SuperFormalParameterMember.superConstructorParameter (package:analyzer/src/dart/element/member.dart:1088:12)
flutter-docs: #4      Constructor.referenceChildren.<anonymous closure>.dereferenceParameter (package:dartdoc/src/model/constructor.dart:107:47)
flutter-docs: #5      Constructor.referenceChildren.<anonymous closure>.dereferenceParameter (package:dartdoc/src/model/constructor.dart:107:16)
flutter-docs: #6      Constructor.referenceChildren.<anonymous closure>.<anonymous closure> (package:dartdoc/src/model/constructor.dart:114:26)
...

I've tried to minimally reproduce the PopupMenuEntry hierarchy:

class Key {}

class Widget {
  const Widget({Key? key});
}

class StatefulWidget extends Widget {
  const StatefulWidget({super.key});
}

abstract class PopupMenuEntry<T> extends StatefulWidget {
  const PopupMenuEntry({super.key});
}

class PopupMenuDivider extends PopupMenuEntry<Never> {
  final int height;
  const PopupMenuDivider({super.key, this.height = 0});
}

class PopupMenuItem<T> extends PopupMenuEntry<T> {
  const PopupMenuItem({super.key});
}

class CheckedPopupMenuItem<T> extends PopupMenuItem<T> {
  const CheckedPopupMenuItem({super.key});
}

but resolving this does not throw an error, and I can't seem to get the error by calling superConstructorParameter on a SuperFormalParameterElement, like dartdoc does. I've tried using the resolution test finders like so:

var entryKeySP = findElement
    .unnamedConstructor('PopupMenuEntry')
    .superFormalParameter('key');
entryKeySP.superConstructorParameter;

CC @scheglov for tips

Metadata

Metadata

Assignees

Labels

P2A bug or feature request we're likely to work onanalyzer-apiIssues that impact the public API of the analyzer packagecrashProcess exits with SIGSEGV, SIGABRT, etc. An unhandled exception is not a crash.legacy-area-analyzerUse area-devexp instead.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions