Skip to content

Commit 8fa8c36

Browse files
committed
Make sure annotation's type is fully represented in semanticdb
1 parent c4bcba4 commit 8fa8c36

File tree

4 files changed

+28
-17
lines changed

4 files changed

+28
-17
lines changed

compiler/src/dotty/tools/dotc/semanticdb/Scala3.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ object Scala3:
9797
val signature = s.info.toSemanticSig(s)
9898
val symbolAnnotations = s.annotations.collect{
9999
case annot if annot.symbol != defn.BodyAnnot && annot.symbol != defn.ChildAnnot =>
100-
Annotation(annot.symbol.typeRef.toSemanticType(annot.symbol))
100+
Annotation(annot.tree.tpe.toSemanticType(annot.symbol))
101101
}
102102
SymbolInformation(
103103
symbol = sname,

tests/semanticdb/expect/Annotations.expect.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ class Annotations/*<-annot::Annotations#*/[@TypeParameterAnnotation/*->com::java
2222
class B/*<-annot::B#*/ @ConstructorAnnotation/*->com::javacp::annot::ConstructorAnnotation#*/()(x/*<-annot::B#x.*/: Int/*->scala::Int#*/) {
2323
@ConstructorAnnotation/*->com::javacp::annot::ConstructorAnnotation#*/
2424
def this/*<-annot::B#`<init>`(+1).*/() = this(42)
25+
26+
@throws/*->scala::throws#*/[Exception/*->scala::package.Exception#*/]
27+
def throwing/*<-annot::B#throwing().*/ = throw new Exception/*->scala::package.Exception#*/("")
2528
}
2629

2730
@ObjectAnnotation/*->com::javacp::annot::ObjectAnnotation#*/

tests/semanticdb/expect/Annotations.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ class Annotations[@TypeParameterAnnotation T](@ParameterAnnotation x: T) { self:
2222
class B @ConstructorAnnotation()(x: Int) {
2323
@ConstructorAnnotation
2424
def this() = this(42)
25+
26+
@throws[Exception]
27+
def throwing = throw new Exception("")
2528
}
2629

2730
@ObjectAnnotation

tests/semanticdb/metac.expect

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,8 @@ Schema => SemanticDB v4
222222
Uri => Annotations.scala
223223
Text => empty
224224
Language => Scala
225-
Symbols => 22 entries
226-
Occurrences => 48 entries
225+
Symbols => 23 entries
226+
Occurrences => 52 entries
227227

228228
Symbols:
229229
annot/Alias. => final object Alias extends Object { self: Alias.type => +2 decls }
@@ -236,10 +236,11 @@ annot/Annotations#`<init>`().(x) => @ParameterAnnotation param x: T
236236
annot/Annotations#field. => @FieldAnnotation val method field Int
237237
annot/Annotations#method(). => @MethodAnnotation method method => Int
238238
annot/Annotations#x. => @ParameterAnnotation private[this] val method x T
239-
annot/B# => class B extends Object { self: B => +3 decls }
239+
annot/B# => class B extends Object { self: B => +4 decls }
240240
annot/B#`<init>`(). => @ConstructorAnnotation primary ctor <init> (param x: Int): B
241241
annot/B#`<init>`().(x) => param x: Int
242242
annot/B#`<init>`(+1). => @ConstructorAnnotation ctor <init> (): B
243+
annot/B#throwing(). => @throws[Exception] method throwing => Nothing
243244
annot/B#x. => private[this] val method x Int
244245
annot/M. => @ObjectAnnotation final object M extends Object { self: M.type => +1 decls }
245246
annot/M.m(). => @MacroAnnotation macro m [typeparam TT ]: Int
@@ -285,19 +286,23 @@ Occurrences:
285286
[21:36..21:39): Int -> scala/Int#
286287
[22:3..22:24): ConstructorAnnotation -> com/javacp/annot/ConstructorAnnotation#
287288
[23:6..23:10): <- annot/B#`<init>`(+1).
288-
[26:1..26:17): ObjectAnnotation -> com/javacp/annot/ObjectAnnotation#
289-
[27:7..27:8): M <- annot/M.
290-
[28:3..28:18): MacroAnnotation -> com/javacp/annot/MacroAnnotation#
291-
[29:6..29:7): m <- annot/M.m().
292-
[29:8..29:10): TT <- annot/M.m().[TT]
293-
[29:13..29:16): Int -> scala/Int#
294-
[29:25..29:28): ??? -> scala/Predef.`???`().
295-
[32:1..32:16): TraitAnnotation -> com/javacp/annot/TraitAnnotation#
296-
[33:6..33:7): T <- annot/T#
297-
[35:7..35:12): Alias <- annot/Alias.
298-
[36:7..36:8): A <- annot/Alias.A#
299-
[36:11..36:26): ClassAnnotation -> com/javacp/annot/ClassAnnotation#
300-
[36:28..36:33): param -> scala/annotation/meta/param#
289+
[25:3..25:9): throws -> scala/throws#
290+
[25:10..25:19): Exception -> scala/package.Exception#
291+
[26:6..26:14): throwing <- annot/B#throwing().
292+
[26:27..26:36): Exception -> scala/package.Exception#
293+
[29:1..29:17): ObjectAnnotation -> com/javacp/annot/ObjectAnnotation#
294+
[30:7..30:8): M <- annot/M.
295+
[31:3..31:18): MacroAnnotation -> com/javacp/annot/MacroAnnotation#
296+
[32:6..32:7): m <- annot/M.m().
297+
[32:8..32:10): TT <- annot/M.m().[TT]
298+
[32:13..32:16): Int -> scala/Int#
299+
[32:25..32:28): ??? -> scala/Predef.`???`().
300+
[35:1..35:16): TraitAnnotation -> com/javacp/annot/TraitAnnotation#
301+
[36:6..36:7): T <- annot/T#
302+
[38:7..38:12): Alias <- annot/Alias.
303+
[39:7..39:8): A <- annot/Alias.A#
304+
[39:11..39:26): ClassAnnotation -> com/javacp/annot/ClassAnnotation#
305+
[39:28..39:33): param -> scala/annotation/meta/param#
301306

302307
expect/Anonymous.scala
303308
----------------------

0 commit comments

Comments
 (0)