Skip to content

Commit

Permalink
Apply review changes
Browse files Browse the repository at this point in the history
[Cherry-picked e3c984e]
  • Loading branch information
schuetzcarl authored and WojciechMazur committed Jun 20, 2024
1 parent 2f81430 commit 7b1b898
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions compiler/src/dotty/tools/dotc/transform/CheckShadowing.scala
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,15 @@ class CheckShadowing extends MiniPhase:
!owner.isConstructor && !owner.is(Synthetic) && !owner.is(Exported)

private def reportShadowing(res: ShadowingData.ShadowResult)(using Context): Unit =
res.warnings.sortBy(w => (w.pos.line, w.pos.startPos.column))(using Ordering[(Int, Int)]).foreach { s =>
s match
case PrivateShadowWarning(pos, shadow, shadowed) =>
report.warning(s"${shadow.showLocated} shadows field ${shadowed.name} inherited from ${shadowed.owner}", pos)
case TypeParamShadowWarning(pos, shadow, parent, shadowed) =>
if shadowed.exists then
report.warning(s"Type parameter ${shadow.name} for $parent shadows the type defined by ${shadowed.showLocated}", pos)
else
report.warning(s"Type parameter ${shadow.name} for $parent shadows an explicitly renamed type : ${shadow.name}", pos)
}
res.warnings.sortBy(w => (w.pos.line, w.pos.startPos.column))(using Ordering[(Int, Int)]).foreach {
case PrivateShadowWarning(pos, shadow, shadowed) =>
report.warning(s"${shadow.showLocated} shadows field ${shadowed.name} inherited from ${shadowed.owner}", pos)
case TypeParamShadowWarning(pos, shadow, parent, shadowed) =>
if shadowed.exists then
report.warning(s"Type parameter ${shadow.name} for $parent shadows the type defined by ${shadowed.showLocated}", pos)
else
report.warning(s"Type parameter ${shadow.name} for $parent shadows an explicitly renamed type : ${shadow.name}", pos)
}

private def nestedTypeTraverser(parent: Symbol) = new TreeTraverser:
import tpd._
Expand Down Expand Up @@ -311,4 +310,5 @@ object CheckShadowing:
/** A container for the results of the shadow elements analysis */
case class ShadowResult(warnings: List[ShadowWarning])

end CheckShadowing
end CheckShadowing

0 comments on commit 7b1b898

Please sign in to comment.