Skip to content

Commit

Permalink
Merged branch idea243.release into idea243.x
Browse files Browse the repository at this point in the history
  • Loading branch information
builduser committed Jan 13, 2025
2 parents 076430e + 1067e62 commit f5b9a83
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ object AddOnlyStrategy {
anchor match {
case p: ScParameter =>
val parameter = p.getParent match {
case Parent(Parent(Parent(_: ScBlockExpr))) => p
case Parent(Parent(Parent(block: ScBlockExpr))) if !block.isEnclosedByColon => p
// ensure that the parameter is wrapped in parentheses before we add the type annotation.
case clause: ScParameterClause if clause.parameters.length == 1 =>
clause.replace(createClauseForFunctionExprFromText(p.getText.parenthesize(), clause))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,17 @@ final class ToggleTypeAnnotationIntentionTest_Scala3 extends ToggleTypeAnnotatio
|}
|""".stripMargin
)

def testAddTypeToFewerBracesParameter(): Unit = doTest(
s"""
|class Example:
| Seq(1, 2, 3).foreach: x$caretTag =>
| println(x)
|""".stripMargin,
s"""
|class Example:
| Seq(1, 2, 3).foreach: (x: Int)$caretTag =>
| println(x)
|""".stripMargin,
)
}

0 comments on commit f5b9a83

Please sign in to comment.