diff --git a/lib/src/relationship_generator.dart b/lib/src/relationship_generator.dart index 65efd6b3..d6c612c1 100644 --- a/lib/src/relationship_generator.dart +++ b/lib/src/relationship_generator.dart @@ -28,8 +28,12 @@ List? relationshipsFor( // Since mixins do not support inheritance, we only care about // methods that exist on classes if (node is MethodDeclaration && node.parent is ClassDeclaration) { - final parentNode = node.parent as ClassDeclaration; - final parentElement = parentNode.declaredElement as ClassElement; + final parentNode = node.parent as ClassDeclaration?; + final parentElement = parentNode?.declaredElement; + + // this shouldn't happen, but if the parent element happens to be + // null, just fail fast + if (parentElement == null) return null; // retrieve all of the methods and accessors of every parent type that // has the same name of [node]. These are the elements that this [node] diff --git a/pubspec.lock b/pubspec.lock index 240dd79e..58e9be38 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -437,10 +437,10 @@ packages: dependency: "direct dev" description: name: workiva_analysis_options - sha256: "428e75a330786b519c87409530c52a1f366731af2cf94fe6da85582889d583bc" + sha256: d7b1b88c2e4c5f795c56f40940583fa2de40510a23ef494a29db32699af52a3d url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.4.1" yaml: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 00fc5a88..2744f312 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -21,4 +21,4 @@ dev_dependencies: dart_dev: ^4.0.2 dependency_validator: ^3.2.3 glob: ^2.1.1 - workiva_analysis_options: ^1.0.0 \ No newline at end of file + workiva_analysis_options: ^1.4.1 \ No newline at end of file