diff --git a/presentation-compiler/src/main/dotty/tools/pc/completions/Completions.scala b/presentation-compiler/src/main/dotty/tools/pc/completions/Completions.scala index db578e32663f..a657df224ab6 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/completions/Completions.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/completions/Completions.scala @@ -65,6 +65,10 @@ class Completions( */ case (fun) :: (appl: GenericApply) :: _ if appl.fun == fun => false + /* In case of `T@@[]` we should not add snippets. + */ + case tpe :: (appl: AppliedTypeTree) :: _ if appl.tpt == tpe => + false case _ :: (withcursor @ Select(fun, name)) :: (appl: GenericApply) :: _ if appl.fun == withcursor && name.decoded == Cursor.value => false diff --git a/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionSnippetSuite.scala b/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionSnippetSuite.scala index 5769304919ca..2c91f71d8d19 100644 --- a/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionSnippetSuite.scala +++ b/presentation-compiler/test/dotty/tools/pc/tests/completion/CompletionSnippetSuite.scala @@ -451,3 +451,34 @@ class CompletionSnippetSuite extends BaseCompletionSuite: """.stripMargin, filter = _.contains("bar: Int") ) + + @Test def `brackets-already-present` = + check( + """|package a + |case class AAA[T]() + |object O { + | val l: AA@@[Int] = ??? + |} + |""".stripMargin, + """|AAA a + |ArrowAssoc scala.Predef + |""".stripMargin, + ) + + @Test def `brackets-already-present-edit` = + checkEdit( + """|package a + |case class AAA[T]() + |object O { + | val l: AA@@[Int] = ??? + |} + |""".stripMargin, + """|package a + |case class AAA[T]() + |object O { + | val l: AAA[Int] = ??? + |} + |""".stripMargin, + assertSingleItem = false, + ) +