Skip to content

Commit

Permalink
fix: correctly print litteral types in the refined printer
Browse files Browse the repository at this point in the history
  • Loading branch information
hamzaremmal committed Jan 12, 2025
1 parent 0ecc057 commit 937bc4c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
case tree: TypeTree =>
typeText(toText(tree.typeOpt))
~ Str("(inf)").provided(tree.isInferred && printDebug)
case SingletonTypeTree(ref: Literal) => toTextLocal(ref)
case SingletonTypeTree(ref) =>
toTextLocal(ref) ~ "." ~ keywordStr("type")
case RefinedTypeTree(tpt, refines) =>
Expand Down
15 changes: 15 additions & 0 deletions tests/printing/i22349.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[[syntax trees at end of typer]] // tests/printing/i22349.scala
package <empty> {
final lazy module val i22349$package: i22349$package = new i22349$package()
final module class i22349$package() extends Object() {
this: i22349$package.type =>
val x: Int = 0
val _$1: x.type = x
inline val _$2: true = true
inline val _$3: "abc" = "abc"
inline val _$4: 'c' = 'c'
inline val _$5: 1.2f = 1.2f
inline val _$6: 1.2d = 1.2d
}
}

7 changes: 7 additions & 0 deletions tests/printing/i22349.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
val x = 0
val _: x.type = x
inline val _: true = true // boolean literal
inline val _: "abc" = "abc" // string literal
inline val _: 'c' = 'c' // character literal
inline val _: 1.2f = 1.2f // floating point literal
inline val _: 1.2d = 1.2d // double number literal

0 comments on commit 937bc4c

Please sign in to comment.