Skip to content

Commit b9c35c0

Browse files
authored
Allow InvalidType as dynamic (#3418)
* Fix assert so it actually displays what we need * delete errant autoimport * Add an InvalidType exception
1 parent 702f3ff commit b9c35c0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/src/element_type.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,10 @@ class UndefinedElementType extends ElementType {
104104
String get name {
105105
if (type is VoidType) return 'void';
106106
if (type is DynamicType) return 'dynamic';
107-
assert(const {'Never'}.contains(typeElement!.name),
107+
// We can not simply throw here because not all SDK libraries resolve
108+
// all types.
109+
if (type is InvalidType) return 'dynamic';
110+
assert(const {'Never'}.contains(typeElement?.name),
108111
'Unrecognized type for UndefinedElementType: ${type.toString()}');
109112
return typeElement!.name!;
110113
}

0 commit comments

Comments
 (0)