Skip to content

Commit 937bc4c

Browse files
committed
fix: correctly print litteral types in the refined printer
1 parent 0ecc057 commit 937bc4c

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

Diff for: compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala

+1
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
572572
case tree: TypeTree =>
573573
typeText(toText(tree.typeOpt))
574574
~ Str("(inf)").provided(tree.isInferred && printDebug)
575+
case SingletonTypeTree(ref: Literal) => toTextLocal(ref)
575576
case SingletonTypeTree(ref) =>
576577
toTextLocal(ref) ~ "." ~ keywordStr("type")
577578
case RefinedTypeTree(tpt, refines) =>

Diff for: tests/printing/i22349.check

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[[syntax trees at end of typer]] // tests/printing/i22349.scala
2+
package <empty> {
3+
final lazy module val i22349$package: i22349$package = new i22349$package()
4+
final module class i22349$package() extends Object() {
5+
this: i22349$package.type =>
6+
val x: Int = 0
7+
val _$1: x.type = x
8+
inline val _$2: true = true
9+
inline val _$3: "abc" = "abc"
10+
inline val _$4: 'c' = 'c'
11+
inline val _$5: 1.2f = 1.2f
12+
inline val _$6: 1.2d = 1.2d
13+
}
14+
}
15+

Diff for: tests/printing/i22349.scala

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
val x = 0
2+
val _: x.type = x
3+
inline val _: true = true // boolean literal
4+
inline val _: "abc" = "abc" // string literal
5+
inline val _: 'c' = 'c' // character literal
6+
inline val _: 1.2f = 1.2f // floating point literal
7+
inline val _: 1.2d = 1.2d // double number literal

0 commit comments

Comments
 (0)