diff --git a/mtags/src/main/scala-3/scala/meta/internal/pc/completions/OverrideCompletions.scala b/mtags/src/main/scala-3/scala/meta/internal/pc/completions/OverrideCompletions.scala index 7ae4c4fae76..fc8f3cf9847 100644 --- a/mtags/src/main/scala-3/scala/meta/internal/pc/completions/OverrideCompletions.scala +++ b/mtags/src/main/scala-3/scala/meta/internal/pc/completions/OverrideCompletions.scala @@ -275,7 +275,14 @@ object OverrideCompletions: else "" (indent, indent, lastIndent) end calcIndent - val abstractMembers = defn.tpe.abstractTermMembers.map(_.symbol) + val abstractMembers = + defn.tpe.abstractTermMembers.map(_.symbol).groupBy(_.owner).map { + case (owner, members) => (owner, members.sortWith{ (sym1, sym2) => + if(sym1.sourcePos.exists && sym2.sourcePos.exists) + sym1.sourcePos.start <= sym2.sourcePos.start + else !sym2.sourcePos.exists + }) + }.toSeq.sortBy(_._1.name.decoded).flatMap(_._2) val caseClassOwners = Set("Product", "Equals") val overridables = diff --git a/tests/cross/src/test/scala/tests/pc/AutoImplementAbstractMembersSuite.scala b/tests/cross/src/test/scala/tests/pc/AutoImplementAbstractMembersSuite.scala index 5f0688d04e8..cccf8796394 100644 --- a/tests/cross/src/test/scala/tests/pc/AutoImplementAbstractMembersSuite.scala +++ b/tests/cross/src/test/scala/tests/pc/AutoImplementAbstractMembersSuite.scala @@ -364,10 +364,10 @@ class AutoImplementAbstractMembersSuite extends BaseCodeActionSuite { |object Main { | class Baz extends Bar { | - | override def foo: Int = ??? - | | override def bar: Int = ??? | + | override def foo: Int = ??? + | | } |} |""".stripMargin @@ -1291,10 +1291,10 @@ class AutoImplementAbstractMembersSuite extends BaseCodeActionSuite { | |case class Concrete() extends Base: | - | override def bar(x: String): String = ??? - | | override def foo(x: Int): Int = ??? | + | override def bar(x: String): String = ??? + | | def aaa = "aaa" |end Concrete |""".stripMargin