metals icon indicating copy to clipboard operation
metals copied to clipboard

inlining not working due to false-positive variable shadowing

Open scarf005 opened this issue 1 month ago • 0 comments

Describe the bug

def findXSum(nums: Array[Int], k: Int, x: Int) =
    val <<pq>> = scala.collection.mutable.PriorityQueue.empty[Int](using Ordering.by(x => -x))
    pq.iterator

unable to inline pq at cursor with:

Following variables are shadowed: findXSum.pq.$anonfun.x.

Expected behavior

pq is inlined without issue because inlinding doesn't affect behavior of x:

def findXSum(nums: Array[Int], k: Int, x: Int) =
    scala.collection.mutable.PriorityQueue.empty[Int](using Ordering.by(x => -x)).iterator

Operating system

Linux

Editor/Extension

VS Code

Version of Metals

1.6.3+23-7730a35a-SNAPSHOT

Scala version/s

3.7.3

Extra context or search terms

reports.zip

scarf005 avatar Nov 04 '25 12:11 scarf005