Skip to content

Commit 50f9b55

Browse files
Backport "fix: don't add suffix if brackets already present" to LTS (#22080)
Backports #21259 to the 3.3.5. PR submitted by the release tooling. [skip ci]
2 parents 0b24d81 + a975681 commit 50f9b55

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

presentation-compiler/src/main/dotty/tools/pc/completions/Completions.scala

+4
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ class Completions(
6565
*/
6666
case (fun) :: (appl: GenericApply) :: _ if appl.fun == fun =>
6767
false
68+
/* In case of `T@@[]` we should not add snippets.
69+
*/
70+
case tpe :: (appl: AppliedTypeTree) :: _ if appl.tpt == tpe =>
71+
false
6872
case _ :: (withcursor @ Select(fun, name)) :: (appl: GenericApply) :: _
6973
if appl.fun == withcursor && name.decoded == Cursor.value =>
7074
false

presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionSnippetSuite.scala

+31
Original file line numberDiff line numberDiff line change
@@ -451,3 +451,34 @@ class CompletionSnippetSuite extends BaseCompletionSuite:
451451
""".stripMargin,
452452
filter = _.contains("bar: Int")
453453
)
454+
455+
@Test def `brackets-already-present` =
456+
check(
457+
"""|package a
458+
|case class AAA[T]()
459+
|object O {
460+
| val l: AA@@[Int] = ???
461+
|}
462+
|""".stripMargin,
463+
"""|AAA a
464+
|ArrowAssoc scala.Predef
465+
|""".stripMargin,
466+
)
467+
468+
@Test def `brackets-already-present-edit` =
469+
checkEdit(
470+
"""|package a
471+
|case class AAA[T]()
472+
|object O {
473+
| val l: AA@@[Int] = ???
474+
|}
475+
|""".stripMargin,
476+
"""|package a
477+
|case class AAA[T]()
478+
|object O {
479+
| val l: AAA[Int] = ???
480+
|}
481+
|""".stripMargin,
482+
assertSingleItem = false,
483+
)
484+

0 commit comments

Comments
 (0)