Skip to content

Commit

Permalink
Merge branch 'master' into nicer-analysis-failures
Browse files Browse the repository at this point in the history
  • Loading branch information
matanlurey authored Jul 6, 2017
2 parents 779215b + 0593ca3 commit 10ba7c2
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/src/type_checker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@ abstract class TypeChecker {
.map(_checkedConstantValue)
.where((a) => a?.type != null && isExactlyType(a.type));

/// Returns annotating constants on [element] assignable to this type.
Iterable<DartObject> annotationsOf(Element element) => element.metadata
.map((a) => a.computeConstantValue())
.where((a) => isAssignableFromType(a.type));

/// Returns annotating constants on [element] of exactly this type.
Iterable<DartObject> annotationsOfExact(Element element) => element.metadata
.map((a) => a.computeConstantValue())
.where((a) => isExactlyType(a.type));

/// Returns `true` if the type of [element] can be assigned to this type.
bool isAssignableFrom(Element element) =>
isExactly(element) || _getAllSupertypes(element).any(isExactlyType);
Expand Down

0 comments on commit 10ba7c2

Please sign in to comment.