Skip to content

Commit 1392f66

Browse files
committed
Brace reduction and remove dead code
1 parent 8a34dc8 commit 1392f66

File tree

7 files changed

+95
-854
lines changed

7 files changed

+95
-854
lines changed

compiler/src/dotty/tools/dotc/Compiler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class Compiler {
8484
new ExplicitOuter, // Add accessors to outer classes from nested ones.
8585
new ExplicitSelf, // Make references to non-trivial self types explicit as casts
8686
new ElimByName, // Expand by-name parameter references
87-
new StringInterpolatorOpt) :: // Optimizes raw and s string interpolators by rewriting them to string concatenations
87+
new StringInterpolatorOpt) :: // Optimizes raw and s and f string interpolators by rewriting them to string concatenations or formats
8888
List(new PruneErasedDefs, // Drop erased definitions from scopes and simplify erased expressions
8989
new UninitializedDefs, // Replaces `compiletime.uninitialized` by `_`
9090
new InlinePatterns, // Remove placeholders of inlined patterns

compiler/src/dotty/tools/dotc/transform/localopt/FormatChecker.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import scala.util.matching.Regex.Match
99

1010
import java.util.{Calendar, Date, Formattable}
1111

12-
import StringContextChecker.InterpolationReporter
13-
1412
/** Formatter string checker. */
1513
abstract class FormatChecker(using reporter: InterpolationReporter):
1614

compiler/src/dotty/tools/dotc/transform/localopt/FormatInterpolatorTransform.scala

Lines changed: 42 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -22,51 +22,7 @@ import scala.util.matching.Regex.Match
2222

2323
object FormatInterpolatorTransform:
2424
import tpd._
25-
import StringContextChecker.InterpolationReporter
2625

27-
/*
28-
/** This trait defines a tool to report errors/warnings that do not depend on Position. */
29-
trait InterpolationReporter:
30-
31-
/** Reports error/warning of size 1 linked with a part of the StringContext.
32-
*
33-
* @param message the message to report as error/warning
34-
* @param index the index of the part inside the list of parts of the StringContext
35-
* @param offset the index in the part String where the error is
36-
* @return an error/warning depending on the function
37-
*/
38-
def partError(message: String, index: Int, offset: Int): Unit
39-
def partWarning(message: String, index: Int, offset: Int): Unit
40-
41-
/** Reports error linked with an argument to format.
42-
*
43-
* @param message the message to report as error/warning
44-
* @param index the index of the argument inside the list of arguments of the format function
45-
* @return an error depending on the function
46-
*/
47-
def argError(message: String, index: Int): Unit
48-
49-
/** Reports error linked with the list of arguments or the StringContext.
50-
*
51-
* @param message the message to report in the error
52-
* @return an error
53-
*/
54-
def strCtxError(message: String): Unit
55-
def argsError(message: String): Unit
56-
57-
/** Claims whether an error or a warning has been reported
58-
*
59-
* @return true if an error/warning has been reported, false
60-
*/
61-
def hasReported: Boolean
62-
63-
/** Stores the old value of the reported and reset it to false */
64-
def resetReported(): Unit
65-
66-
/** Restores the value of the reported boolean that has been reset */
67-
def restoreReported(): Unit
68-
end InterpolationReporter
69-
*/
7026
class PartsReporter(fun: Tree, args0: Tree, parts: List[Tree], args: List[Tree])(using Context) extends InterpolationReporter:
7127
private var reported = false
7228
private var oldReported = false
@@ -193,3 +149,45 @@ object FormatInterpolatorTransform:
193149
(literally(checked.mkString), tpd.SeqLiteral(checker.actuals.toList, elemtpt))
194150
end checked
195151
end FormatInterpolatorTransform
152+
153+
/** This trait defines a tool to report errors/warnings that do not depend on Position. */
154+
trait InterpolationReporter:
155+
156+
/** Reports error/warning of size 1 linked with a part of the StringContext.
157+
*
158+
* @param message the message to report as error/warning
159+
* @param index the index of the part inside the list of parts of the StringContext
160+
* @param offset the index in the part String where the error is
161+
* @return an error/warning depending on the function
162+
*/
163+
def partError(message: String, index: Int, offset: Int): Unit
164+
def partWarning(message: String, index: Int, offset: Int): Unit
165+
166+
/** Reports error linked with an argument to format.
167+
*
168+
* @param message the message to report as error/warning
169+
* @param index the index of the argument inside the list of arguments of the format function
170+
* @return an error depending on the function
171+
*/
172+
def argError(message: String, index: Int): Unit
173+
174+
/** Reports error linked with the list of arguments or the StringContext.
175+
*
176+
* @param message the message to report in the error
177+
* @return an error
178+
*/
179+
def strCtxError(message: String): Unit
180+
def argsError(message: String): Unit
181+
182+
/** Claims whether an error or a warning has been reported
183+
*
184+
* @return true if an error/warning has been reported, false
185+
*/
186+
def hasReported: Boolean
187+
188+
/** Stores the old value of the reported and reset it to false */
189+
def resetReported(): Unit
190+
191+
/** Restores the value of the reported boolean that has been reset */
192+
def restoreReported(): Unit
193+
end InterpolationReporter

0 commit comments

Comments
 (0)