Skip to content

Commit ea01d77

Browse files
committed
Avoid matches against NoSymbol
1 parent 77454f8 commit ea01d77

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

compiler/src/dotty/tools/backend/jvm/BCodeBodyBuilder.scala

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,10 +1213,11 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
12131213
def genLoadModule(tree: Tree): BType = {
12141214
val module = (
12151215
if (!tree.symbol.is(PackageClass)) tree.symbol
1216-
else tree.symbol.info.member(nme.PACKAGE).symbol match {
1217-
case NoSymbol => abort(s"SI-5604: Cannot use package as value: $tree")
1218-
case s => abort(s"SI-5604: found package class where package object expected: $tree")
1219-
}
1216+
else
1217+
val s = tree.symbol.info.member(nme.PACKAGE).symbol
1218+
if s.exists
1219+
then abort(s"SI-5604: found package class where package object expected: $tree")
1220+
else abort(s"SI-5604: Cannot use package as value: $tree")
12201221
)
12211222
lineNumber(tree)
12221223
genLoadModule(module)

compiler/src/dotty/tools/dotc/core/Comments.scala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -428,9 +428,8 @@ object Comments {
428428
* @param vble The variable for which a definition is searched
429429
* @param site The class for which doc comments are generated
430430
*/
431-
def lookupVariable(vble: String, site: Symbol)(using Context): Option[String] = site match {
432-
case NoSymbol => None
433-
case _ =>
431+
def lookupVariable(vble: String, site: Symbol)(using Context): Option[String] =
432+
if site.exists then
434433
val searchList =
435434
if (site.flags.is(Flags.Module)) site :: site.info.baseClasses
436435
else site.info.baseClasses
@@ -439,7 +438,7 @@ object Comments {
439438
case Some(str) if str startsWith "$" => lookupVariable(str.tail, site)
440439
case res => res orElse lookupVariable(vble, site.owner)
441440
}
442-
}
441+
else None
443442

444443
/** The position of the raw doc comment of symbol `sym`, or NoPosition if missing
445444
* If a symbol does not have a doc comment but some overridden version of it does,

compiler/src/dotty/tools/dotc/core/GadtConstraint.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,9 @@ sealed trait GadtConstraint (
249249
// ---- Private ----------------------------------------------------------
250250

251251
private def externalize(tp: Type, theMap: TypeMap | Null = null)(using Context): Type = tp match
252-
case param: TypeParamRef => reverseMapping(param) match
253-
case sym: Symbol => sym.typeRef
254-
case null => param
252+
case param: TypeParamRef =>
253+
val sym = reverseMapping(param)
254+
if sym != null then sym.typeRef else param
255255
case tp: TypeAlias => tp.derivedAlias(externalize(tp.alias, theMap))
256256
case tp => (if theMap == null then ExternalizeMap() else theMap).mapOver(tp)
257257

compiler/src/dotty/tools/dotc/reporting/messages.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -712,9 +712,9 @@ extends SyntaxMsg(WrongNumberOfTypeArgsID) {
712712
.mkString("[", ", ", "]")
713713
val actualArgString = actual.map(_.show).mkString("[", ", ", "]")
714714
val prettyName =
715-
try fntpe.termSymbol match
716-
case NoSymbol => fntpe.show
717-
case symbol => symbol.showFullName
715+
try
716+
val symbol = fntpe.termSymbol
717+
if symbol.exists then symbol.showFullName else fntpe.show
718718
catch case NonFatal(ex) => fntpe.show
719719
i"""|$msgPrefix type arguments for $prettyName$expectedArgString
720720
|expected: $expectedArgString

0 commit comments

Comments
 (0)