@@ -8,6 +8,9 @@ import scala.meta.pc.PcSymbolInformation
88import dotty .tools .pc .base .BasePCSuite
99import scala .language .unsafeNulls
1010import org .junit .Test
11+ import scala .meta .internal .metals .CompilerOffsetParams
12+ import java .nio .file .Paths
13+ import scala .annotation .nowarn
1114
1215class InfoSuite extends BasePCSuite {
1316
@@ -53,4 +56,48 @@ class InfoSuite extends BasePCSuite {
5356 |scala/collection/IterableOnceOps#flatMap().
5457 |""" .stripMargin
5558 )
59+
60+ @ Test def i7251 =
61+ withSource(
62+ """ |package a
63+ |sealed trait TA:
64+ | type SomeType
65+ |trait TB extends TA:
66+ | type SomeType = Int
67+ |""" .stripMargin
68+ )
69+ val info = presentationCompiler.info(" a/TA#SomeType#" ).get()
70+ assertNoDiff(info.get().symbol(), " a/TA#SomeType#" )
71+
72+ @ Test def memberDefsAnnotations =
73+ def assertMemberDefsAnnotations (symbol : String , expected : String ) =
74+ val info = presentationCompiler.info(symbol).get()
75+ assertNoDiff(info.get().memberDefsAnnotations().asScala.mkString(" \n " ), expected, Some (symbol))
76+ withSource(
77+ """ |package a
78+ |import scala.annotation.nowarn
79+ |sealed trait TA:
80+ | @nowarn
81+ | def aaa = 1
82+ |
83+ |object O:
84+ | @nowarn
85+ | def aaa = 1
86+ |
87+ |class D:
88+ | @nowarn
89+ | def bbb = 1
90+ |""" .stripMargin
91+ )
92+ assertMemberDefsAnnotations(" a/TA#" , " scala.annotation.nowarn" )
93+ assertMemberDefsAnnotations(" a/O." , " scala.annotation.nowarn" )
94+ assertMemberDefsAnnotations(" a/D#" , " scala.annotation.nowarn" )
95+ assertMemberDefsAnnotations(" a/D#bbb()." , " " )
96+
97+ // hacky way to add a source file to the presentation compiler sources
98+ private def withSource (code : String ) =
99+ val filename = " Hover.scala"
100+ val pcParams = CompilerOffsetParams (Paths .get(filename).toUri(), code, 0 )
101+ presentationCompiler.hover(pcParams).get()
102+
56103}
0 commit comments