Skip to content

Commit 18a2335

Browse files
committed
Make fixesForRemovingConstructor take the module name as the key
1 parent 95fbe8d commit 18a2335

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

tests/NoUnused/CustomTypeConstructors.elm

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ type alias ModuleContext =
206206
, constructorsToIgnore : List (Set ( ModuleNameAsString, ConstructorName ))
207207
, wasUsedInLocationThatNeedsItself : Set ( ModuleNameAsString, ConstructorName )
208208
, wasUsedInComparisons : Set ( ModuleNameAsString, ConstructorName )
209-
, fixesForRemovingConstructor : Dict ConstructorName (Dict ModuleNameAsString (List Fix))
209+
, fixesForRemovingConstructor : Dict ( ModuleNameAsString, ConstructorName ) (Dict ModuleNameAsString (List Fix))
210210
, ignoredComparisonRanges : List Range
211211
}
212212

@@ -322,12 +322,7 @@ fromModuleToProject =
322322
untouched
323323
)
324324
moduleContext.wasUsedInComparisons
325-
, fixesForRemovingConstructor =
326-
mapDictKeys
327-
(\constructorName ->
328-
( moduleNameAsString, constructorName )
329-
)
330-
moduleContext.fixesForRemovingConstructor
325+
, fixesForRemovingConstructor = moduleContext.fixesForRemovingConstructor
331326
}
332327
)
333328
|> Rule.withModuleKey
@@ -669,12 +664,12 @@ expressionVisitor node moduleContext =
669664
else
670665
"True"
671666

672-
fixes : Dict ConstructorName (Dict ModuleNameAsString (List Fix))
667+
fixes : Dict ( ModuleNameAsString, ConstructorName ) (Dict ModuleNameAsString (List Fix))
673668
fixes =
674669
Set.foldl
675-
(\( moduleName, constructor ) dict ->
670+
(\(( moduleName, _ ) as key) dict ->
676671
Dict.update
677-
constructor
672+
key
678673
(\existingValues ->
679674
updateToAdd
680675
moduleName
@@ -718,15 +713,15 @@ expressionVisitor node moduleContext =
718713
else
719714
"always " ++ replacementBoolean
720715

721-
fixes : Dict ConstructorName (Dict ModuleNameAsString (List Fix))
716+
fixes : Dict ( ModuleNameAsString, ConstructorName ) (Dict ModuleNameAsString (List Fix))
722717
fixes =
723718
Set.foldl
724-
(\( _, constructor ) dict ->
719+
(\(( moduleName, _ ) as key) dict ->
725720
Dict.update
726-
constructor
721+
key
727722
(\existingValues ->
728723
updateToAdd
729-
moduleContext.currentModuleName
724+
moduleName
730725
(Fix.replaceRangeBy (Node.range node) replacement)
731726
(Maybe.withDefault Dict.empty existingValues)
732727
|> Just
@@ -774,10 +769,10 @@ caseBranchEnterVisitor caseExpression ( casePattern, body ) moduleContext =
774769
constructors =
775770
constructorsInPattern moduleContext.lookupTable [ casePattern ] Set.empty
776771

777-
fixes : Dict ConstructorName (Dict ModuleNameAsString (List Fix))
772+
fixes : Dict ( ModuleNameAsString, ConstructorName ) (Dict ModuleNameAsString (List Fix))
778773
fixes =
779774
Set.foldl
780-
(\( moduleName, constructorName ) acc ->
775+
(\(( moduleName, _ ) as key) acc ->
781776
let
782777
fix : Fix
783778
fix =
@@ -787,10 +782,10 @@ caseBranchEnterVisitor caseExpression ( casePattern, body ) moduleContext =
787782
}
788783
in
789784
Dict.update
790-
constructorName
785+
key
791786
(\existingValues ->
792787
updateToAdd
793-
moduleContext.currentModuleName
788+
moduleName
794789
fix
795790
(Maybe.withDefault Dict.empty existingValues)
796791
|> Just

0 commit comments

Comments
 (0)