Skip to content

Commit 1677c33

Browse files
authored
Merge pull request #483 from scala/backport-lts-3.3-23462
Backport "Exclude named parameters inlay hints for java defined" to 3.3 LTS
2 parents b85547d + bc0e95e commit 1677c33

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

presentation-compiler/src/main/dotty/tools/pc/PcInlayHintsProvider.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ object Parameters:
434434
def unapply(tree: Tree)(using params: InlayHintsParams, ctx: Context): Option[(Boolean, List[(Name, SourcePosition, Boolean)])] =
435435
def shouldSkipFun(fun: Tree)(using Context): Boolean =
436436
fun match
437-
case sel: Select => isForComprehensionMethod(sel) || sel.symbol.name == nme.unapply
437+
case sel: Select => isForComprehensionMethod(sel) || sel.symbol.name == nme.unapply || sel.symbol.is(Flags.JavaDefined)
438438
case _ => false
439439

440440
def isInfixFun(fun: Tree, args: List[Tree])(using Context): Boolean =

presentation-compiler/test/dotty/tools/pc/tests/inlayHints/InlayHintsSuite.scala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,4 +1227,20 @@ class InlayHintsSuite extends BaseInlayHintsSuite {
12271227
|}
12281228
|""".stripMargin
12291229
)
1230+
1231+
@Test def `java-method-call` =
1232+
check(
1233+
"""|object Main {
1234+
| val str = "hello"
1235+
| val sub = str.substring(1, 3)
1236+
| val replaced = str.replace('l', 'x')
1237+
|}
1238+
|""".stripMargin,
1239+
"""|object Main {
1240+
| val str/*: String<<java/lang/String#>>*/ = "hello"
1241+
| val sub/*: String<<java/lang/String#>>*/ = str.substring(1, 3)
1242+
| val replaced/*: String<<java/lang/String#>>*/ = str.replace('l', 'x')
1243+
|}
1244+
|""".stripMargin
1245+
)
12301246
}

0 commit comments

Comments
 (0)