Skip to content
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

Correctly prettify names in coverage info #18542

Merged
merged 1 commit into from
Feb 7, 2024
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
6 changes: 3 additions & 3 deletions compiler/src/dotty/tools/dotc/coverage/Location.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ object Location:

val ownerDenot = ctx.owner.denot
val enclosingClass = ownerDenot.enclosingClass
val packageName = ownerDenot.enclosingPackageClass.fullName.toSimpleName.toString
val className = enclosingClass.name.toSimpleName.toString
val methodName = ownerDenot.enclosingMethod.name.toSimpleName.toString
val packageName = ownerDenot.enclosingPackageClass.fullName.toSimpleName.show
val className = enclosingClass.name.toSimpleName.show
val methodName = ownerDenot.enclosingMethod.name.toSimpleName.show

val classType: String =
if enclosingClass.is(Trait) then "Trait"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class InstrumentCoverage extends MacroTransform with IdentityDenotTransformer:
// the internal line number is 0-base https://github.com/lampepfl/dotty/blob/18ada516a85532524a39a962b2ddecb243c65376/compiler/src/dotty/tools/dotc/util/SourceFile.scala#L173-L176
line = pos.line + 1,
desc = sourceFile.content.slice(pos.start, pos.end).mkString,
symbolName = tree.symbol.name.toSimpleName.toString,
symbolName = tree.symbol.name.toSimpleName.show,
treeName = tree.getClass.getSimpleName.nn,
branch
)
Expand Down
16 changes: 8 additions & 8 deletions tests/coverage/pos/Constructor.scoverage.check
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ def g
9
Constructor.scala
covtest
O$
O
Object
covtest.O$
covtest.O
g
203
208
Expand All @@ -191,9 +191,9 @@ def g
10
Constructor.scala
covtest
O$
O
Object
covtest.O$
covtest.O
y
223
228
Expand All @@ -208,9 +208,9 @@ def y
11
Constructor.scala
covtest
O$
O
Object
covtest.O$
covtest.O
<init>
235
239
Expand All @@ -225,9 +225,9 @@ g(y)
12
Constructor.scala
covtest
O$
O
Object
covtest.O$
covtest.O
<init>
237
238
Expand Down
56 changes: 28 additions & 28 deletions tests/coverage/pos/Enum.scoverage.check
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ def surfaceWeight
3
Enum.scala
covtest
EnumTypes$
EnumTypes
Object
covtest.EnumTypes$
covtest.EnumTypes
test
1043
1077
Expand All @@ -89,9 +89,9 @@ println("Example 1: \\n"+emptyList)
4
Enum.scala
covtest
EnumTypes$
EnumTypes
Object
covtest.EnumTypes$
covtest.EnumTypes
test
1051
1076
Expand All @@ -106,9 +106,9 @@ false
5
Enum.scala
covtest
EnumTypes$
EnumTypes
Object
covtest.EnumTypes$
covtest.EnumTypes
test
1082
1103
Expand All @@ -123,9 +123,9 @@ println(s"${list}\\n")
6
Enum.scala
covtest
EnumTypes$
EnumTypes
Object
covtest.EnumTypes$
covtest.EnumTypes
test
1090
1102
Expand All @@ -140,9 +140,9 @@ s"${list}\\n"
7
Enum.scala
covtest
EnumTypes$
EnumTypes
Object
covtest.EnumTypes$
covtest.EnumTypes
calculateEarthWeightOnPlanets
1195
1222
Expand All @@ -157,9 +157,9 @@ Planet.Earth.surfaceGravity
8
Enum.scala
covtest
EnumTypes$
EnumTypes
Object
covtest.EnumTypes$
covtest.EnumTypes
calculateEarthWeightOnPlanets
1229
1320
Expand All @@ -174,9 +174,9 @@ for p <- Planet.values do\n println(s"Your weight on $p is ${p.surfaceWei
9
Enum.scala
covtest
EnumTypes$
EnumTypes
Object
covtest.EnumTypes$
covtest.EnumTypes
calculateEarthWeightOnPlanets
1238
1251
Expand All @@ -191,9 +191,9 @@ Planet.values
10
Enum.scala
covtest
EnumTypes$
EnumTypes
Object
covtest.EnumTypes$
covtest.EnumTypes
$anonfun
1263
1320
Expand All @@ -208,9 +208,9 @@ println(s"Your weight on $p is ${p.surfaceWeight(mass)}")
11
Enum.scala
covtest
EnumTypes$
EnumTypes
Object
covtest.EnumTypes$
covtest.EnumTypes
$anonfun
1271
1319
Expand All @@ -225,9 +225,9 @@ s"Your weight on $p is ${p.surfaceWeight(mass)}"
12
Enum.scala
covtest
EnumTypes$
EnumTypes
Object
covtest.EnumTypes$
covtest.EnumTypes
$anonfun
1296
1317
Expand All @@ -242,9 +242,9 @@ p.surfaceWeight(mass)
13
Enum.scala
covtest
EnumTypes$
EnumTypes
Object
covtest.EnumTypes$
covtest.EnumTypes
calculateEarthWeightOnPlanets
1109
1142
Expand All @@ -259,9 +259,9 @@ def calculateEarthWeightOnPlanets
14
Enum.scala
covtest
EnumTypes$
EnumTypes
Object
covtest.EnumTypes$
covtest.EnumTypes
test
1326
1347
Expand All @@ -276,9 +276,9 @@ println("Example 2:")
15
Enum.scala
covtest
EnumTypes$
EnumTypes
Object
covtest.EnumTypes$
covtest.EnumTypes
test
1352
1385
Expand All @@ -293,9 +293,9 @@ calculateEarthWeightOnPlanets(80)
16
Enum.scala
covtest
EnumTypes$
EnumTypes
Object
covtest.EnumTypes$
covtest.EnumTypes
test
901
909
Expand Down
Loading
Loading