Skip to content

Commit 3d2a85b

Browse files
authored
Prepare for adding InvalidType, make 'TypeChecker.isAssignableFromType()' null safe. (#666)
1 parent 3d1f86b commit 3d2a85b

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

source_gen/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.3.2
2+
3+
* Make `TypeChecker.isAssignableFromType()` null safe.
4+
15
## 1.3.1
26

37
* Always use a Uri in `part of` directives (previously a name would be used if

source_gen/lib/src/type_checker.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,10 @@ abstract class TypeChecker {
167167
(element is InterfaceElement && element.allSupertypes.any(isExactlyType));
168168

169169
/// Returns `true` if [staticType] can be assigned to this type.
170-
bool isAssignableFromType(DartType staticType) =>
171-
isAssignableFrom(staticType.element!);
170+
bool isAssignableFromType(DartType staticType) {
171+
final element = staticType.element;
172+
return element != null && isAssignableFrom(element);
173+
}
172174

173175
/// Returns `true` if representing the exact same class as [element].
174176
bool isExactly(Element element);

source_gen/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: source_gen
2-
version: 1.3.1
2+
version: 1.3.2
33
description: >-
44
Source code generation builders and utilities for the Dart build system
55
repository: https://github.com/dart-lang/source_gen/tree/master/source_gen

0 commit comments

Comments
 (0)