Skip to content

Commit fe9e53c

Browse files
authored
chore: remove all the warnings in the compiler codebase (scala#22975)
This PR changes the compiler such that all the warnings are not triggered anymore.
2 parents 88a741b + 5569c74 commit fe9e53c

File tree

2 files changed

+25
-26
lines changed

2 files changed

+25
-26
lines changed

.git-blame-ignore-revs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
46a26945a172429740ebdd1fc83517130670080b

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

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -412,10 +412,9 @@ object Types extends TypeUtils {
412412
catch case ex: Throwable => handleRecursive("unusableForInference", show, ex)
413413

414414
/** Does the type carry an annotation that is an instance of `cls`? */
415-
@tailrec final def hasAnnotation(cls: ClassSymbol)(using Context): Boolean = stripTypeVar match {
416-
case AnnotatedType(tp, annot) => (annot matches cls) || (tp hasAnnotation cls)
415+
@tailrec final def hasAnnotation(cls: ClassSymbol)(using Context): Boolean = stripTypeVar match
416+
case AnnotatedType(tp, annot) => annot.matches(cls) || tp.hasAnnotation(cls)
417417
case _ => false
418-
}
419418

420419
/** Returns the annotation that is an instance of `cls` carried by the type. */
421420
@tailrec final def getAnnotation(cls: ClassSymbol)(using Context): Option[Annotation] = stripTypeVar match {
@@ -584,8 +583,8 @@ object Types extends TypeUtils {
584583
case AndType(l, r) =>
585584
val lsym = l.classSymbol
586585
val rsym = r.classSymbol
587-
if (lsym isSubClass rsym) lsym
588-
else if (rsym isSubClass lsym) rsym
586+
if lsym.isSubClass(rsym) then lsym
587+
else if rsym.isSubClass(lsym) then rsym
589588
else NoSymbol
590589
case tp: OrType =>
591590
if tp.tp1.hasClassSymbol(defn.NothingClass) then
@@ -724,7 +723,7 @@ object Types extends TypeUtils {
724723
case tp: TypeProxy =>
725724
tp.superType.findDecl(name, excluded)
726725
case err: ErrorType =>
727-
newErrorSymbol(classSymbol orElse defn.RootClass, name, err.msg)
726+
newErrorSymbol(classSymbol.orElse(defn.RootClass), name, err.msg)
728727
case _ =>
729728
NoDenotation
730729
}
@@ -815,7 +814,7 @@ object Types extends TypeUtils {
815814
case tp: JavaArrayType =>
816815
defn.ObjectType.findMember(name, pre, required, excluded)
817816
case err: ErrorType =>
818-
newErrorSymbol(pre.classSymbol orElse defn.RootClass, name, err.msg)
817+
newErrorSymbol(pre.classSymbol.orElse(defn.RootClass), name, err.msg)
819818
case _ =>
820819
NoDenotation
821820
}
@@ -919,7 +918,7 @@ object Types extends TypeUtils {
919918
// member in Super instead of Sub.
920919
// As an example of this in the wild, see
921920
// loadClassWithPrivateInnerAndSubSelf in ShowClassTests
922-
go(tp.cls.typeRef) orElse d
921+
go(tp.cls.typeRef).orElse(d)
923922

924923
def goParam(tp: TypeParamRef) = {
925924
val next = tp.underlying
@@ -1157,7 +1156,7 @@ object Types extends TypeUtils {
11571156
false
11581157

11591158
def relaxed_<:<(that: Type)(using Context): Boolean =
1160-
(this <:< that) || (this isValueSubType that)
1159+
(this <:< that) || this.isValueSubType(that)
11611160

11621161
/** Is this type a legal type for member `sym1` that overrides another
11631162
* member `sym2` of type `that`? This is the same as `<:<`, except that
@@ -1208,10 +1207,10 @@ object Types extends TypeUtils {
12081207
* vice versa.
12091208
*/
12101209
def matchesLoosely(that: Type)(using Context): Boolean =
1211-
(this matches that) || {
1210+
this.matches(that) || {
12121211
val thisResult = this.widenExpr
12131212
val thatResult = that.widenExpr
1214-
(this eq thisResult) != (that eq thatResult) && (thisResult matchesLoosely thatResult)
1213+
(this eq thisResult) != (that eq thatResult) && thisResult.matchesLoosely(thatResult)
12151214
}
12161215

12171216
/** The basetype of this type with given class symbol, NoType if `base` is not a class. */
@@ -1869,7 +1868,7 @@ object Types extends TypeUtils {
18691868
* no symbol it tries `member` as an alternative.
18701869
*/
18711870
def typeParamNamed(name: TypeName)(using Context): Symbol =
1872-
classSymbol.unforcedDecls.lookup(name) orElse member(name).symbol
1871+
classSymbol.unforcedDecls.lookup(name).orElse(member(name).symbol)
18731872

18741873
/** If this is a prototype with some ignored component, reveal one more
18751874
* layer of it. Otherwise the type itself.
@@ -2008,9 +2007,9 @@ object Types extends TypeUtils {
20082007
def annotatedToRepeated(using Context): Type = this match {
20092008
case tp @ ExprType(tp1) =>
20102009
tp.derivedExprType(tp1.annotatedToRepeated)
2011-
case self @ AnnotatedType(tp, annot) if annot matches defn.RetainsByNameAnnot =>
2010+
case self @ AnnotatedType(tp, annot) if annot.matches(defn.RetainsByNameAnnot) =>
20122011
self.derivedAnnotatedType(tp.annotatedToRepeated, annot)
2013-
case AnnotatedType(tp, annot) if annot matches defn.RepeatedAnnot =>
2012+
case AnnotatedType(tp, annot) if annot.matches(defn.RepeatedAnnot) =>
20142013
val typeSym = tp.typeSymbol.asClass
20152014
assert(typeSym == defn.SeqClass || typeSym == defn.ArrayClass)
20162015
tp.translateParameterized(typeSym, defn.RepeatedParamClass)
@@ -2706,9 +2705,9 @@ object Types extends TypeUtils {
27062705
*/
27072706
final def controlled[T](op: => T)(using Context): T = try {
27082707
ctx.base.underlyingRecursions += 1
2709-
if (ctx.base.underlyingRecursions < Config.LogPendingUnderlyingThreshold)
2708+
if ctx.base.underlyingRecursions < Config.LogPendingUnderlyingThreshold then
27102709
op
2711-
else if (ctx.pendingUnderlying contains this)
2710+
else if ctx.pendingUnderlying.contains(this) then
27122711
throw CyclicReference(symbol)
27132712
else
27142713
try {
@@ -3465,8 +3464,8 @@ object Types extends TypeUtils {
34653464
val bcs1set = BaseClassSet(bcs1)
34663465
def recur(bcs2: List[ClassSymbol]): List[ClassSymbol] = bcs2 match {
34673466
case bc2 :: bcs2rest =>
3468-
if (bcs1set contains bc2)
3469-
if (bc2.is(Trait)) recur(bcs2rest)
3467+
if bcs1set.contains(bc2) then
3468+
if bc2.is(Trait) then recur(bcs2rest)
34703469
else bcs1 // common class, therefore rest is the same in both sequences
34713470
else bc2 :: recur(bcs2rest)
34723471
case nil => bcs1
@@ -3562,9 +3561,8 @@ object Types extends TypeUtils {
35623561
val bcs1set = BaseClassSet(bcs1)
35633562
def recur(bcs2: List[ClassSymbol]): List[ClassSymbol] = bcs2 match {
35643563
case bc2 :: bcs2rest =>
3565-
if (bcs1set contains bc2)
3566-
if (bc2.is(Trait)) bc2 :: recur(bcs2rest)
3567-
else bcs2
3564+
if bcs1set.contains(bc2) then
3565+
if bc2.is(Trait) then bc2 :: recur(bcs2rest) else bcs2
35683566
else recur(bcs2rest)
35693567
case nil =>
35703568
bcs2
@@ -5757,11 +5755,11 @@ object Types extends TypeUtils {
57575755
parent.hashIsStable
57585756

57595757
override def eql(that: Type): Boolean = that match
5760-
case that: AnnotatedType => (parent eq that.parent) && (annot eql that.annot)
5758+
case that: AnnotatedType => (parent eq that.parent) && annot.eql(that.annot)
57615759
case _ => false
57625760

57635761
override def iso(that: Any, bs: BinderPairs): Boolean = that match
5764-
case that: AnnotatedType => parent.equals(that.parent, bs) && (annot eql that.annot)
5762+
case that: AnnotatedType => parent.equals(that.parent, bs) && annot.eql(that.annot)
57655763
case _ => false
57665764
}
57675765

@@ -6354,7 +6352,7 @@ object Types extends TypeUtils {
63546352
tp.derivedClassInfo(prefix1, parents1, tp.decls, selfInfo1)
63556353
end DeepTypeMap
63566354

6357-
@sharable object IdentityTypeMap extends TypeMap()(NoContext) {
6355+
@sharable object IdentityTypeMap extends TypeMap()(using NoContext) {
63586356
def apply(tp: Type): Type = tp
63596357
}
63606358

@@ -6827,7 +6825,7 @@ object Types extends TypeUtils {
68276825
def maybeAdd(xs: List[NamedType], tp: NamedType): List[NamedType] = if p(tp) then tp :: xs else xs
68286826
val seen = util.HashSet[Type]()
68296827
def apply(xs: List[NamedType], tp: Type): List[NamedType] =
6830-
if seen contains tp then xs
6828+
if seen.contains(tp) then xs
68316829
else
68326830
seen += tp
68336831
tp match
@@ -7006,7 +7004,7 @@ object Types extends TypeUtils {
70067004

70077005
object fieldFilter extends NameFilter {
70087006
def apply(pre: Type, name: Name)(using Context): Boolean =
7009-
name.isTermName && (pre member name).hasAltWith(!_.symbol.is(Method))
7007+
name.isTermName && pre.member(name).hasAltWith(!_.symbol.is(Method))
70107008
def isStable = true
70117009
}
70127010

0 commit comments

Comments
 (0)