@@ -8,6 +8,9 @@ import scala.meta.pc.PcSymbolInformation
8
8
import dotty .tools .pc .base .BasePCSuite
9
9
import scala .language .unsafeNulls
10
10
import org .junit .Test
11
+ import scala .meta .internal .metals .CompilerOffsetParams
12
+ import java .nio .file .Paths
13
+ import scala .annotation .nowarn
11
14
12
15
class InfoSuite extends BasePCSuite {
13
16
@@ -53,4 +56,48 @@ class InfoSuite extends BasePCSuite {
53
56
|scala/collection/IterableOnceOps#flatMap().
54
57
|""" .stripMargin
55
58
)
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
+
56
103
}
0 commit comments