Skip to content

Commit e1feb31

Browse files
ghostbuster91Kordyjan
authored andcommitted
Fix string literals rendering
[Cherry-picked f039f7d]
1 parent 8c681d7 commit e1feb31

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

compiler/src/dotty/tools/dotc/transform/patmat/Space.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,8 @@ object SpaceEngine {
786786

787787
def doShow(s: Space, flattenList: Boolean = false): String = s match {
788788
case Empty => "empty"
789-
case Typ(c: ConstantType, _) => "" + c.value.value
789+
case Typ(ConstantType(const : Constant), _) if const.tag == StringTag => "\"" + const.value + "\""
790+
case Typ(ConstantType(const : Constant), _) => "" + const.value
790791
case Typ(tp: TermRef, _) =>
791792
if (flattenList && tp <:< defn.NilType) ""
792793
else tp.symbol.showName

compiler/test/dotty/tools/dotc/reporting/CodeActionTest.scala

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,25 @@ class CodeActionTest extends DottyTest:
100100
afterPhase = "patternMatcher"
101101
)
102102

103+
@Test def insertMissingCasesForUnionIntType =
104+
checkCodeAction(
105+
code =
106+
"""object Test:
107+
| def foo(text: 1 | 2) = text match {
108+
| case 2 => ???
109+
| }
110+
|""".stripMargin,
111+
title = "Insert missing cases (1)",
112+
expected =
113+
"""object Test:
114+
| def foo(text: 1 | 2) = text match {
115+
| case 2 => ???
116+
| case 1 => ???
117+
| }
118+
|""".stripMargin,
119+
afterPhase = "patternMatcher"
120+
)
121+
103122
// Make sure we're not using the default reporter, which is the ConsoleReporter,
104123
// meaning they will get reported in the test run and that's it.
105124
private def newContext =

0 commit comments

Comments
 (0)