Skip to content

Commit

Permalink
Prepare for adding InvalidType, make 'TypeChecker.isAssignableFromTyp…
Browse files Browse the repository at this point in the history
…e()' null safe. (#666)
  • Loading branch information
scheglov committed May 10, 2023
1 parent 3d1f86b commit 3d2a85b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions source_gen/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.3.2

* Make `TypeChecker.isAssignableFromType()` null safe.

## 1.3.1

* Always use a Uri in `part of` directives (previously a name would be used if
Expand Down
6 changes: 4 additions & 2 deletions source_gen/lib/src/type_checker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,10 @@ abstract class TypeChecker {
(element is InterfaceElement && element.allSupertypes.any(isExactlyType));

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

/// Returns `true` if representing the exact same class as [element].
bool isExactly(Element element);
Expand Down
2 changes: 1 addition & 1 deletion source_gen/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: source_gen
version: 1.3.1
version: 1.3.2
description: >-
Source code generation builders and utilities for the Dart build system
repository: https://github.com/dart-lang/source_gen/tree/master/source_gen
Expand Down

0 comments on commit 3d2a85b

Please sign in to comment.