From 9f9613f9e39fb177b011b457bc13cc8269e1cdfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20Zieli=C5=84ski?= Date: Wed, 2 Jul 2025 11:59:50 +0200 Subject: [PATCH] exclude java defined methods --- .../dotty/tools/pc/PcInlayHintsProvider.scala | 2 +- .../pc/tests/inlayHints/InlayHintsSuite.scala | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/presentation-compiler/src/main/dotty/tools/pc/PcInlayHintsProvider.scala b/presentation-compiler/src/main/dotty/tools/pc/PcInlayHintsProvider.scala index 0251f06e75ea..b22b3ae8b7f4 100644 --- a/presentation-compiler/src/main/dotty/tools/pc/PcInlayHintsProvider.scala +++ b/presentation-compiler/src/main/dotty/tools/pc/PcInlayHintsProvider.scala @@ -434,7 +434,7 @@ object Parameters: def unapply(tree: Tree)(using params: InlayHintsParams, ctx: Context): Option[(Boolean, List[(Name, SourcePosition, Boolean)])] = def shouldSkipFun(fun: Tree)(using Context): Boolean = fun match - case sel: Select => isForComprehensionMethod(sel) || sel.symbol.name == nme.unapply + case sel: Select => isForComprehensionMethod(sel) || sel.symbol.name == nme.unapply || sel.symbol.is(Flags.JavaDefined) case _ => false def isInfixFun(fun: Tree, args: List[Tree])(using Context): Boolean = diff --git a/presentation-compiler/test/dotty/tools/pc/tests/inlayHints/InlayHintsSuite.scala b/presentation-compiler/test/dotty/tools/pc/tests/inlayHints/InlayHintsSuite.scala index 845a2582c54b..bb79c19f5823 100644 --- a/presentation-compiler/test/dotty/tools/pc/tests/inlayHints/InlayHintsSuite.scala +++ b/presentation-compiler/test/dotty/tools/pc/tests/inlayHints/InlayHintsSuite.scala @@ -1261,4 +1261,20 @@ class InlayHintsSuite extends BaseInlayHintsSuite { |} |""".stripMargin ) + + @Test def `java-method-call` = + check( + """|object Main { + | val str = "hello" + | val sub = str.substring(1, 3) + | val replaced = str.replace('l', 'x') + |} + |""".stripMargin, + """|object Main { + | val str/*: String<>*/ = "hello" + | val sub/*: String<>*/ = str.substring(1, 3) + | val replaced/*: String<>*/ = str.replace('l', 'x') + |} + |""".stripMargin + ) }