diff --git a/presentation-compiler/src/main/dotty/tools/pc/IndexedContext.scala b/presentation-compiler/src/main/dotty/tools/pc/IndexedContext.scala index 6b74e3aa2ec1..7c2c34cf5ebb 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/IndexedContext.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/IndexedContext.scala @@ -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 /** diff --git a/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionSuite.scala b/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionSuite.scala index 03c4fa2bc5bc..f660baa6af6d 100644 --- a/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionSuite.scala +++ b/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionSuite.scala @@ -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, + ) diff --git a/presentation-compiler/test/dotty/tools/pc/tests/edit/AutoImportsSuite.scala b/presentation-compiler/test/dotty/tools/pc/tests/edit/AutoImportsSuite.scala index a862df975d0b..ce5ae4a1cca4 100644 --- a/presentation-compiler/test/dotty/tools/pc/tests/edit/AutoImportsSuite.scala +++ b/presentation-compiler/test/dotty/tools/pc/tests/edit/AutoImportsSuite.scala @@ -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: <> = ??? + |""".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.