Skip to content

Commit

Permalink
Merge pull request #928 from Workiva/fix-num-key-warning
Browse files Browse the repository at this point in the history
FED-2854 Fix num keys incorrectly linting as not unique
  • Loading branch information
rmconsole3-wf authored Jun 24, 2024
2 parents ec6d0b2 + 48b7b4b commit c08e8f6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 5 additions & 1 deletion tools/analyzer_plugin/lib/src/diagnostic/bad_key.dart
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,11 @@ class BadKeyDiagnostic extends ComponentUsageDiagnosticContributor {
getTypeContextString() =>
type == topLevelKeyType ? '' : ' (from ${topLevelKeyType.getDisplayString(withNullability: false)})';

if (type.isDartCoreInt || type.isDartCoreDouble || type.isDartCoreString || type.isDartCoreSymbol) {
if (type.isDartCoreNum ||
type.isDartCoreInt ||
type.isDartCoreDouble ||
type.isDartCoreString ||
type.isDartCoreSymbol) {
// Ignore core types that have good `Object.toString` implementations values.
} else if (type.isDartCoreObject || type.isDynamic) {
collector.addError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,13 @@ class BadKeyDiagnosticTest_NoErrors extends BadKeyDiagnosticTest {

Future<void> test_noErrors() async {
final source = newSourceWithPrefix(/*language=dart*/ r'''
test() => [
test(num aNum, int anInt, double aDouble) => [
(Dom.div()..key = 'a string')(),
(Dom.div()..key = AnEnum.foo)(),
(Dom.div()..key = 122)(),
(Dom.div()..key = aNum)(),
(Dom.div()..key = anInt)(),
(Dom.div()..key = aDouble)(),
(Dom.div()..key = modelVar.id)(),
(Dom.div()..key = modelVarWithCustomToString)(),
(Dom.div()..key = deriveKeyFrom(modelVar))(),
Expand Down

0 comments on commit c08e8f6

Please sign in to comment.