Skip to content
This repository was archived by the owner on Jul 16, 2023. It is now read-only.

Commit ad3b9fe

Browse files
committed
fix: fix regression in avoid-unnecessary-type-assertions
1 parent 2599200 commit ad3b9fe

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 4.18.3
4+
5+
* fix: fix regression in is! checks for [`avoid-unnecessary-type-assertions`](https://dartcodemetrics.dev/docs/rules/common/avoid-unnecessary-type-assertions).
6+
37
## 4.18.2
48

59
* fix: use empty analysis options exclude to properly resolve units and speed up commands analysis.

lib/src/analyzers/lint_analyzer/rules/rules_list/avoid_unnecessary_type_assertions/visitor.dart

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class _Visitor extends RecursiveAstVisitor<void> {
4545

4646
if (node.notOperator != null) {
4747
if (objectType != null &&
48+
objectType is! TypeParameterType &&
4849
!objectType.isDynamic &&
4950
!objectType.isDartCoreObject &&
5051
_isUselessTypeCheck(castedType, objectType, true)) {

test/resources/unnecessary_nullable_analyzer/suppressed_file.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// ignore_for_file: unnecessary-nullable
1+
// ignore_for_file: unnecessary-nullable, avoid-unused-parameters, no-empty-block
22

33
class IgnoredClassWithMethods {
44
void someMethod(String? value) {}

test/src/analyzers/lint_analyzer/rules/rules_list/avoid_unnecessary_type_assertions/examples/example_with_not_is.dart

+5
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,8 @@ void checkSameOrInheritor() {
2626
final Object b;
2727
final check = b is! int;
2828
}
29+
30+
void check<T>() {
31+
final T b;
32+
final check = b is! int;
33+
}

0 commit comments

Comments
 (0)