Skip to content

Commit f039f7d

Browse files
ghostbuster91ckipp01
authored andcommitted
Fix string literals rendering
1 parent 0e47303 commit f039f7d

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

Diff for: compiler/src/dotty/tools/dotc/transform/patmat/Space.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,8 @@ object SpaceEngine {
790790

791791
def doShow(s: Space, flattenList: Boolean = false): String = s match {
792792
case Empty => "empty"
793-
case Typ(c: ConstantType, _) => "" + c.value.value
793+
case Typ(ConstantType(const : Constant), _) if const.tag == StringTag => "\"" + const.value + "\""
794+
case Typ(ConstantType(const : Constant), _) => "" + const.value
794795
case Typ(tp: TermRef, _) =>
795796
if (flattenList && tp <:< defn.NilType) ""
796797
else tp.symbol.showName

Diff for: compiler/test/dotty/tools/dotc/reporting/CodeActionTest.scala

+19
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)