diff --git a/mtags/src/main/scala-3/scala/meta/internal/pc/completions/MatchCaseCompletions.scala b/mtags/src/main/scala-3/scala/meta/internal/pc/completions/MatchCaseCompletions.scala index 0d701c94cc2..e256a137618 100644 --- a/mtags/src/main/scala-3/scala/meta/internal/pc/completions/MatchCaseCompletions.scala +++ b/mtags/src/main/scala-3/scala/meta/internal/pc/completions/MatchCaseCompletions.scala @@ -39,7 +39,6 @@ object CaseKeywordCompletion: * @param selector `selector` of `selector match { cases }` or `EmptyTree` when * not in a match expression (for example `List(1).foreach { case@@ }`. * @param completionPos the position of the completion - * @param typedtree typed tree of the file, used for generating auto imports * @param indexedContext * @param config * @param parent the parent tree node of the pattern match, for example `Apply(_, _)` when in @@ -88,7 +87,7 @@ object CaseKeywordCompletion: new Parents(NoType, definitions) case sel => new Parents(sel.tpe, definitions) - val selectorSym = parents.selector.typeSymbol + val selectorSym = parents.selector.metalsDealias.typeSymbol // Special handle case when selector is a tuple or `FunctionN`. if definitions.isTupleClass(selectorSym) || definitions.isFunctionClass( @@ -240,8 +239,8 @@ object CaseKeywordCompletion: clientSupportsSnippets, ) val tpe = selector.tpe.widen.bounds.hi match - case tr @ TypeRef(_, _) => tr.underlying - case t => t + case tr @ TypeRef(_, _) => tr.underlying.metalsDealias + case t => t.metalsDealias val sortedSubclasses = val subclasses = diff --git a/tests/cross/src/test/scala/tests/pc/CompletionMatchSuite.scala b/tests/cross/src/test/scala/tests/pc/CompletionMatchSuite.scala index 256a67c920b..3ff6f65ac1b 100644 --- a/tests/cross/src/test/scala/tests/pc/CompletionMatchSuite.scala +++ b/tests/cross/src/test/scala/tests/pc/CompletionMatchSuite.scala @@ -734,4 +734,52 @@ class CompletionMatchSuite extends BaseCompletionSuite { filter = _.contains("exhaustive"), ) + checkEdit( + "type-alias".tag(IgnoreScala2), + s"""|object O { + | type Id[A] = A + | + | enum Animal: + | case Cat, Dog + | + | val animal: Id[Animal] = ??? + | + | animal ma@@ + |} + |""".stripMargin, + s"""object O { + | type Id[A] = A + | + | enum Animal: + | case Cat, Dog + | + | val animal: Id[Animal] = ??? + | + | animal match + |\tcase Animal.Cat => $$0 + |\tcase Animal.Dog => + | + |} + |""".stripMargin, + filter = _.contains("exhaustive"), + ) + + check( + "type-alias2".tag(IgnoreScala2), + s"""|object O { + | type Id[A] = A + | + | enum Animal: + | case Cat, Dog + | + | val animal: Id[Animal] = ??? + | + | animal match { + | \tcase Animal.C@@ + | } + |} + |""".stripMargin, + "Cat: Animal", + ) + }