Skip to content

fix: don't show incorrect docs for inner methods #7096

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package scala.meta.internal.mtags

import java.util.Optional

import scala.annotation.tailrec
import scala.util.control.NonFatal

Expand Down Expand Up @@ -28,6 +30,7 @@ import dotty.tools.dotc.core.Types.Type
import dotty.tools.dotc.core.Types.TypeBounds
import dotty.tools.dotc.interactive.Interactive
import dotty.tools.dotc.interactive.InteractiveDriver
import dotty.tools.dotc.transform.SymUtils.isLocal
import dotty.tools.dotc.util.SourcePosition
import dotty.tools.dotc.util.Spans
import dotty.tools.dotc.util.Spans.Span
Expand Down Expand Up @@ -248,12 +251,14 @@ object MtagsEnrichments extends ScalametaCommonEnrichments:
symbol.maybeOwner.companion,
).filter(_ != NoSymbol) ++ symbol.allOverriddenSymbols
else symbol.allOverriddenSymbols

val documentation = search.documentation(
sym,
() => parentSymbols.map(toSemanticdbSymbol).toList.asJava,
contentType
)
val documentation =
if symbol.isLocal then Optional.empty
else
search.documentation(
sym,
() => parentSymbols.map(toSemanticdbSymbol).toList.asJava,
contentType
)
if documentation.isPresent then Some(documentation.get())
else None
end symbolDocumentation
Expand Down
14 changes: 14 additions & 0 deletions tests/cross/src/test/scala/tests/hover/HoverDocSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -527,4 +527,18 @@ class HoverDocSuite extends BaseHoverSuite {
|""".stripMargin
)
)

check(
"i7093",
"""|object O {
| /** Ooopsie daisy */
| val computeLogicOwners: Unit = {
| /** This is a comment */
| <<def logi@@cOwners = ???>>
| ???
| }
|}
|""".stripMargin,
"""def logicOwners: Nothing""".hover.stripMargin
)
}
Loading