E185: Unimported and Imported
This error occurs when the same identifier is both imported and unimported (or unimported twice) on the same import line.
In Scala 3, you can selectively unimport members using as _ syntax. However, it doesn't make sense to both import and unimport the same identifier on the same line, as this represents contradictory intentions.
Example
object MyLib:
val value = 42
import MyLib.{value, value as _}
Error
-- [E185] Syntax Error: example.scala:4:21 -------------------------------------
4 |import MyLib.{value, value as _}
| ^^^^^
| value is unimported and imported on the same import line.
Solution
Choose either to import or unimport the identifier:
object MyLib:
val value = 42
// Either import it:
import MyLib.value
def example(): Int = value
Or unimport it if you want to exclude it from a wildcard import:
object MyLib:
val value = 42
val other = 100
// Unimport value, import everything else:
import MyLib.{value as _, *}
def example(): Int = other
In this article