Skip to content

Commit ed8ac3c

Browse files
authored
Do not crash when documenting an export with '//' (#2254)
1 parent 95214ad commit ed8ac3c

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

lib/src/model/class.dart

+10
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,16 @@ class Class extends Container
303303
return __inheritedElements = <ExecutableElement>[];
304304
}
305305

306+
if (definingLibrary == null) {
307+
// [definingLibrary] may be null if [element] has been imported or
308+
// exported with a non-normalized URI, like "src//a.dart".
309+
// TODO(srawlins): It would be nice to allow references from such
310+
// libraries, but for now, PackageGraph.allLibraries is a Map with
311+
// LibraryElement keys, which include [Element.location] in their
312+
// `==` calculation; I think we should not key off of Elements.
313+
return __inheritedElements = <ExecutableElement>[];
314+
}
315+
306316
var inheritance = definingLibrary.inheritanceManager;
307317
var cmap = inheritance.getInheritedConcreteMap2(element);
308318
var imap = inheritance.getInheritedMap2(element);

lib/src/model/library.dart

+3
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,9 @@ class Library extends ModelElement with Categorization, TopLevelContainer {
568568
if (_modelElementsNameMap == null) {
569569
_modelElementsNameMap = <String, Set<ModelElement>>{};
570570
allModelElements.forEach((ModelElement modelElement) {
571+
// [definingLibrary] may be null if [element] has been imported or
572+
// exported with a non-normalized URI, like "src//a.dart".
573+
if (modelElement.definingLibrary == null) return;
571574
_modelElementsNameMap.putIfAbsent(
572575
modelElement.fullyQualifiedNameWithoutLibrary, () => {});
573576
_modelElementsNameMap[modelElement.fullyQualifiedNameWithoutLibrary]

lib/src/model/model_element.dart

+2-1
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,8 @@ abstract class ModelElement extends Canonicalization
661661
// just shortcut them out.
662662
if (!utils.hasPublicName(element)) {
663663
_canonicalLibrary = null;
664-
} else if (!packageGraph.localPublicLibraries.contains(definingLibrary)) {
664+
} else if (definingLibrary != null &&
665+
!packageGraph.localPublicLibraries.contains(definingLibrary)) {
665666
var candidateLibraries = definingLibrary.exportedInLibraries
666667
?.where((l) =>
667668
l.isPublic &&

0 commit comments

Comments
 (0)