Annotate TypeMatcher.having with useResult (#195)
The analyzer will surface a diagnostic for misuses like using
`..having()` and expecting it to mutate the instance.
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a60a68c..6db1541 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,7 @@
* Require Dart 2.17 or greater.
* Make `isCastError` no longer depend on the deprecated `CastError` type.
+* Annotate `TypeMatcher.having` with `useResult`.
## 0.12.12
diff --git a/lib/src/type_matcher.dart b/lib/src/type_matcher.dart
index 388adb5..500ce0c 100644
--- a/lib/src/type_matcher.dart
+++ b/lib/src/type_matcher.dart
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:meta/meta.dart';
+
import 'having_matcher.dart';
import 'interfaces.dart';
@@ -79,6 +81,7 @@
/// .having((e) => e.start, 'start', isNull)
/// .having((e) => e.end, 'end', isNull);
/// ```
+ @useResult
TypeMatcher<T> having(
Object? Function(T) feature, String description, dynamic matcher) =>
HavingMatcher(this, description, feature, matcher);