Skip to content

Commit

Permalink
fix: correctly auto import when there is a renamed symbol with the sa…
Browse files Browse the repository at this point in the history
…me name in scope
  • Loading branch information
kasiaMarek committed Jun 10, 2024
1 parent 284e7cc commit a4c7e4a
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ sealed trait IndexedContext:
Result.InScope
// when all the conflicting symbols came from an old version of the file
case Some(symbols) if symbols.nonEmpty && symbols.forall(_.isStale) => Result.Missing
case Some(_) => Result.Conflict
case None => Result.Missing
case Some(symbols) if symbols.exists(rename(_).isEmpty) => Result.Conflict
case _ => Result.Missing
end lookupSym

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1952,3 +1952,34 @@ class CompletionSuite extends BaseCompletionSuite:
"""TestEnum test
|""".stripMargin,
)

@Test def `i6477-1` =
checkEdit(
"""|package a
|import a.b.SomeClass as SC
|
|package b {
| class SomeClass
|}
|package c {
| class SomeClass
|}
|
|val bar: SC = ???
|val foo: SomeClass@@
|""".stripMargin,
"""|package a
|import a.b.SomeClass as SC
|import a.c.SomeClass
|
|package b {
| class SomeClass
|}
|package c {
| class SomeClass
|}
|
|val bar: SC = ???
|val foo: SomeClass
|""".stripMargin,
)
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,37 @@ class AutoImportsSuite extends BaseAutoImportsSuite:
|""".stripMargin,
)

@Test def `i6477` =
checkEdit(
"""|package a
|import a.b.SomeClass as SC
|
|package b {
| class SomeClass
|}
|package c {
| class SomeClass
|}
|
|val bar: SC = ???
|val foo: <<SomeClass>> = ???
|""".stripMargin,
"""|package a
|import a.b.SomeClass as SC
|import a.c.SomeClass
|
|package b {
| class SomeClass
|}
|package c {
| class SomeClass
|}
|
|val bar: SC = ???
|val foo: SomeClass = ???
|""".stripMargin
)

private def ammoniteWrapper(code: String): String =
// Vaguely looks like a scala file that Ammonite generates
// from a sc file.
Expand Down

0 comments on commit a4c7e4a

Please sign in to comment.