Skip to content

Commit 9be03a5

Browse files
authored
Merge branch 'main' into i24120-move-MatchReducer
2 parents f0ae39d + cad0d2a commit 9be03a5

File tree

82 files changed

+386
-349
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+386
-349
lines changed

compiler/src/dotty/tools/dotc/config/ScalaSettings.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,12 +290,16 @@ private sealed trait WarningSettings:
290290
)
291291

292292
object WshadowHas:
293-
def allOr(s: String)(using Context) =
294-
Wshadow.value.pipe(us => us.contains("all") || us.contains(s))
293+
// Is any choice set for -Wshadow?
294+
def any(using Context): Boolean = Wall.value || Wshadow.value.nonEmpty
295+
296+
def allOr(s: String)(using Context): Boolean =
297+
Wall.value || Wshadow.value.pipe(us => us.contains("all") || us.contains(s))
295298
def privateShadow(using Context) =
296299
allOr("private-shadow")
297300
def typeParameterShadow(using Context) =
298301
allOr("type-parameter-shadow")
302+
end WshadowHas
299303

300304
val WsafeInit: Setting[Boolean] = BooleanSetting(WarningSetting, "Wsafe-init", "Ensure safe initialization of objects.")
301305

compiler/src/dotty/tools/dotc/printing/PlainPrinter.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ class PlainPrinter(_ctx: Context) extends Printer {
705705
def toText(denot: Denotation): Text = toText(denot.symbol) ~ "/D"
706706

707707
def toText(const: Constant): Text = const.tag match {
708-
case StringTag => stringText(Chars.escapedString(const.value.toString, quoted = true))
708+
case StringTag => literalText(Chars.escapedString(const.value.toString, quoted = true))
709709
case ClazzTag => "classOf[" ~ toText(const.typeValue) ~ "]"
710710
case CharTag => literalText(Chars.escapedChar(const.charValue))
711711
case LongTag => literalText(const.longValue.toString + "L")
@@ -841,10 +841,9 @@ class PlainPrinter(_ctx: Context) extends Printer {
841841

842842
protected def keywordStr(text: String): String = coloredStr(text, SyntaxHighlighting.KeywordColor)
843843
protected def keywordText(text: String): Text = coloredStr(text, SyntaxHighlighting.KeywordColor)
844-
protected def valDefText(text: Text): Text = coloredText(text, SyntaxHighlighting.ValDefColor)
844+
protected def valDefText(text: Text): Text = coloredText(text, SyntaxHighlighting.DefinitionColor)
845845
protected def typeText(text: Text): Text = coloredText(text, SyntaxHighlighting.TypeColor)
846846
protected def literalText(text: Text): Text = coloredText(text, SyntaxHighlighting.LiteralColor)
847-
protected def stringText(text: Text): Text = coloredText(text, SyntaxHighlighting.StringColor)
848847

849848
protected def coloredStr(text: String, color: String): String =
850849
if (ctx.useColors) color + text + SyntaxHighlighting.NoColor else text

compiler/src/dotty/tools/dotc/printing/RefinedPrinter.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
598598
case tree @ Inlined(call, bindings, body) =>
599599
val bodyText = if bindings.isEmpty then toText(body) else blockText(bindings :+ body)
600600
if homogenizedView || !ctx.settings.XprintInline.value then bodyText
601-
else if tree.inlinedFromOuterScope then stringText("{{") ~ stringText("/* inlined from outside */") ~ bodyText ~ stringText("}}")
601+
else if tree.inlinedFromOuterScope then literalText("{{") ~ literalText("/* inlined from outside */") ~ bodyText ~ literalText("}}")
602602
else keywordText("{{") ~ keywordText("/* inlined from ") ~ toText(call) ~ keywordText(" */") ~ bodyText ~ keywordText("}}")
603603
case tpt: untpd.DerivedTypeTree =>
604604
"<derived typetree watching " ~ tpt.watched.showSummary() ~ ">"

compiler/src/dotty/tools/dotc/printing/SyntaxHighlighting.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,9 @@ object SyntaxHighlighting {
2626
val NoColor: String = Console.RESET
2727
val CommentColor: String = Console.BLUE
2828
val KeywordColor: String = Console.YELLOW
29-
val ValDefColor: String = Console.CYAN
29+
val DefinitionColor: String = Console.CYAN
3030
val LiteralColor: String = Console.GREEN
31-
val StringColor: String = Console.GREEN
32-
val TypeColor: String = Console.MAGENTA
33-
val AnnotationColor: String = Console.MAGENTA
31+
val TypeColor: String = Console.GREEN
3432

3533
def highlight(in: String)(using Context): String = {
3634
def freshCtx = ctx.fresh.setReporter(Reporter.NoReporter)
@@ -101,7 +99,7 @@ object SyntaxHighlighting {
10199

102100
def highlightAnnotations(tree: MemberDef): Unit =
103101
for (annotation <- tree.rawMods.annotations)
104-
highlightPosition(annotation.span, AnnotationColor)
102+
highlightPosition(annotation.span, TypeColor)
105103

106104
def highlight(trees: List[Tree])(using Context): Unit =
107105
trees.foreach(traverse)
@@ -112,14 +110,16 @@ object SyntaxHighlighting {
112110
()
113111
case tree: ValOrDefDef =>
114112
highlightAnnotations(tree)
115-
highlightPosition(tree.nameSpan, ValDefColor)
116-
highlightPosition(tree.endSpan, ValDefColor)
113+
highlightPosition(tree.nameSpan, DefinitionColor)
114+
highlightPosition(tree.endSpan, DefinitionColor)
117115
case tree: MemberDef /* ModuleDef | TypeDef */ =>
118116
highlightAnnotations(tree)
119-
highlightPosition(tree.nameSpan, TypeColor)
120-
highlightPosition(tree.endSpan, TypeColor)
117+
highlightPosition(tree.nameSpan, DefinitionColor)
118+
highlightPosition(tree.endSpan, DefinitionColor)
121119
case tree: Ident if tree.isType =>
122120
highlightPosition(tree.span, TypeColor)
121+
case tree: Select if tree.isType =>
122+
highlightPosition(tree.nameSpan, TypeColor)
123123
case _: TypeTree =>
124124
highlightPosition(tree.span, TypeColor)
125125
case _ =>

compiler/src/dotty/tools/dotc/transform/CheckShadowing.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ class CheckShadowing extends MiniPhase:
4848

4949
override def description: String = CheckShadowing.description
5050

51-
override def isEnabled(using Context): Boolean = ctx.settings.Wshadow.value.nonEmpty
51+
override def isEnabled(using Context): Boolean = ctx.settings.WshadowHas.any
5252

5353
override def isRunnable(using Context): Boolean =
54-
super.isRunnable && ctx.settings.Wshadow.value.nonEmpty && !ctx.isJava
54+
super.isRunnable && ctx.settings.WshadowHas.any && !ctx.isJava
5555

5656
override def prepareForUnit(tree: tpd.Tree)(using Context): Context =
5757
val data = ShadowingData()

0 commit comments

Comments
 (0)