File tree 2 files changed +41
-16
lines changed
src/main/dotty/tools/pc/completions
test/dotty/tools/pc/tests/completion
2 files changed +41
-16
lines changed Original file line number Diff line number Diff line change @@ -97,25 +97,26 @@ object CaseKeywordCompletion:
97
97
selectorSym
98
98
)
99
99
then
100
- val label =
101
- if patternOnly.isEmpty then s " case ${parents.selector.show} => "
102
- else parents.selector.show
103
- List (
104
- CompletionValue .CaseKeyword (
105
- selectorSym,
106
- label,
107
- Some (
108
- if patternOnly.isEmpty then
100
+ if patternOnly.isEmpty then
101
+ val selectorTpe = parents.selector.show
102
+ val tpeLabel =
103
+ if ! selectorTpe.contains(" x$1" ) then selectorTpe
104
+ else selector.symbol.info.show
105
+ val label = s " case ${tpeLabel} => "
106
+ List (
107
+ CompletionValue .CaseKeyword (
108
+ selectorSym,
109
+ label,
110
+ Some (
109
111
if config.isCompletionSnippetsEnabled() then " case ($0) =>"
110
112
else " case () =>"
111
- else if config.isCompletionSnippetsEnabled() then " ($0)"
112
- else " ()"
113
- ),
114
- Nil ,
115
- range = Some (completionPos.toEditRange),
116
- command = config.parameterHintsCommand().asScala
113
+ ),
114
+ Nil ,
115
+ range = Some (completionPos.toEditRange),
116
+ command = config.parameterHintsCommand().asScala,
117
+ )
117
118
)
118
- )
119
+ else Nil
119
120
else
120
121
val result = ListBuffer .empty[SymbolImport ]
121
122
val isVisited = mutable.Set .empty[Symbol ]
Original file line number Diff line number Diff line change @@ -698,3 +698,27 @@ class CompletionCaseSuite extends BaseCompletionSuite:
698
698
|case Dog => test.O.Animal
699
699
|""" .stripMargin,
700
700
)
701
+ @ Test def `for-comp` =
702
+ check(
703
+ """ |object A {
704
+ | val a = for {
705
+ | foo <- List("a", "b", "c")
706
+ | abc = println("Print!")
707
+ | } yield bar@@
708
+ |
709
+ |}
710
+ |""" .stripMargin,
711
+ " " ,
712
+ )
713
+
714
+ @ Test def `lambda-case-tuple` =
715
+ check(
716
+ """ |object A {
717
+ | val a = List((1,2)).foreach {
718
+ | case (a,b) => println(a)
719
+ | case@@
720
+ | }
721
+ |}
722
+ |""" .stripMargin,
723
+ " case (Int, Int) => scala" ,
724
+ )
You can’t perform that action at this time.
0 commit comments