IntelliJ warns me about something which looks correct to me.
I have a local variable declaration (left) inside a pattern match which has the same name as another variable
which is declared below the partial function in a different scope.
IntelliJ warns me that if I want the value of the variable left I can use the backquote syntax.
BUT I DON’T want that value. Is there a syntax I should use to say it should be a new variable declaration? I see that If I replace left with left:LS (i.e., include a redundant type declaration) the warning goes away.
def mergeSort(unsorted:LS):LS = {
bisect(unsorted) match {
case (Nil,Nil) => Nil
case (Nil,right) => right
case (left,Nil) => left // InteliJ warns about the (suspicious) variable left
case (left,right) => merge2Lists(mergeSort(left),mergeSort(right))
}
val len = unsorted.length / 2
val left = unsorted.drop(len)
unsorted match {
case Nil => Nil
case h::Nil => unsorted
case _ => merge2Lists(mergeSort(left),mergeSort(unsorted.dropRight(left.length)))
}
}