Skip to content

Commit 07752e8

Browse files
authored
Merge pull request #355 from scala/backport-lts-3.3-22975
Backport "chore: remove all the warnings in the compiler codebase" to 3.3 LTS
2 parents 48aa0a3 + 326326f commit 07752e8

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
@@ -392,10 +392,9 @@ object Types extends TypeUtils {
392392
case _ => false
393393

394394
/** Does the type carry an annotation that is an instance of `cls`? */
395-
@tailrec final def hasAnnotation(cls: ClassSymbol)(using Context): Boolean = stripTypeVar match {
396-
case AnnotatedType(tp, annot) => (annot matches cls) || (tp hasAnnotation cls)
395+
@tailrec final def hasAnnotation(cls: ClassSymbol)(using Context): Boolean = stripTypeVar match
396+
case AnnotatedType(tp, annot) => annot.matches(cls) || tp.hasAnnotation(cls)
397397
case _ => false
398-
}
399398

400399
/** Does this type have a supertype with an annotation satisfying given predicate `p`? */
401400
def derivesAnnotWith(p: Annotation => Boolean)(using Context): Boolean = this match {
@@ -556,8 +555,8 @@ object Types extends TypeUtils {
556555
case AndType(l, r) =>
557556
val lsym = l.classSymbol
558557
val rsym = r.classSymbol
559-
if (lsym isSubClass rsym) lsym
560-
else if (rsym isSubClass lsym) rsym
558+
if lsym.isSubClass(rsym) then lsym
559+
else if rsym.isSubClass(lsym) then rsym
561560
else NoSymbol
562561
case tp: OrType =>
563562
if tp.tp1.hasClassSymbol(defn.NothingClass) then
@@ -696,7 +695,7 @@ object Types extends TypeUtils {
696695
case tp: TypeProxy =>
697696
tp.superType.findDecl(name, excluded)
698697
case err: ErrorType =>
699-
newErrorSymbol(classSymbol orElse defn.RootClass, name, err.msg)
698+
newErrorSymbol(classSymbol.orElse(defn.RootClass), name, err.msg)
700699
case _ =>
701700
NoDenotation
702701
}
@@ -777,7 +776,7 @@ object Types extends TypeUtils {
777776
case tp: JavaArrayType =>
778777
defn.ObjectType.findMember(name, pre, required, excluded)
779778
case err: ErrorType =>
780-
newErrorSymbol(pre.classSymbol orElse defn.RootClass, name, err.msg)
779+
newErrorSymbol(pre.classSymbol.orElse(defn.RootClass), name, err.msg)
781780
case _ =>
782781
NoDenotation
783782
}
@@ -872,7 +871,7 @@ object Types extends TypeUtils {
872871
// member in Super instead of Sub.
873872
// As an example of this in the wild, see
874873
// loadClassWithPrivateInnerAndSubSelf in ShowClassTests
875-
go(tp.cls.typeRef) orElse d
874+
go(tp.cls.typeRef).orElse(d)
876875

877876
def goParam(tp: TypeParamRef) = {
878877
val next = tp.underlying
@@ -1110,7 +1109,7 @@ object Types extends TypeUtils {
11101109
false
11111110

11121111
def relaxed_<:<(that: Type)(using Context): Boolean =
1113-
(this <:< that) || (this isValueSubType that)
1112+
(this <:< that) || this.isValueSubType(that)
11141113

11151114
/** Is this type a legal type for member `sym1` that overrides another
11161115
* member `sym2` of type `that`? This is the same as `<:<`, except that
@@ -1164,10 +1163,10 @@ object Types extends TypeUtils {
11641163
* vice versa.
11651164
*/
11661165
def matchesLoosely(that: Type)(using Context): Boolean =
1167-
(this matches that) || {
1166+
this.matches(that) || {
11681167
val thisResult = this.widenExpr
11691168
val thatResult = that.widenExpr
1170-
(this eq thisResult) != (that eq thatResult) && (thisResult matchesLoosely thatResult)
1169+
(this eq thisResult) != (that eq thatResult) && thisResult.matchesLoosely(thatResult)
11711170
}
11721171

11731172
/** The basetype of this type with given class symbol, NoType if `base` is not a class. */
@@ -1798,7 +1797,7 @@ object Types extends TypeUtils {
17981797
* no symbol it tries `member` as an alternative.
17991798
*/
18001799
def typeParamNamed(name: TypeName)(using Context): Symbol =
1801-
classSymbol.unforcedDecls.lookup(name) orElse member(name).symbol
1800+
classSymbol.unforcedDecls.lookup(name).orElse(member(name).symbol)
18021801

18031802
/** If this is a prototype with some ignored component, reveal one more
18041803
* layer of it. Otherwise the type itself.
@@ -1931,9 +1930,9 @@ object Types extends TypeUtils {
19311930
def annotatedToRepeated(using Context): Type = this match {
19321931
case tp @ ExprType(tp1) =>
19331932
tp.derivedExprType(tp1.annotatedToRepeated)
1934-
case self @ AnnotatedType(tp, annot) if annot matches defn.RetainsByNameAnnot =>
1933+
case self @ AnnotatedType(tp, annot) if annot.matches(defn.RetainsByNameAnnot) =>
19351934
self.derivedAnnotatedType(tp.annotatedToRepeated, annot)
1936-
case AnnotatedType(tp, annot) if annot matches defn.RepeatedAnnot =>
1935+
case AnnotatedType(tp, annot) if annot.matches(defn.RepeatedAnnot) =>
19371936
val typeSym = tp.typeSymbol.asClass
19381937
assert(typeSym == defn.SeqClass || typeSym == defn.ArrayClass)
19391938
tp.translateParameterized(typeSym, defn.RepeatedParamClass)
@@ -2633,9 +2632,9 @@ object Types extends TypeUtils {
26332632
*/
26342633
final def controlled[T](op: => T)(using Context): T = try {
26352634
ctx.base.underlyingRecursions += 1
2636-
if (ctx.base.underlyingRecursions < Config.LogPendingUnderlyingThreshold)
2635+
if ctx.base.underlyingRecursions < Config.LogPendingUnderlyingThreshold then
26372636
op
2638-
else if (ctx.pendingUnderlying contains this)
2637+
else if ctx.pendingUnderlying.contains(this) then
26392638
throw CyclicReference(symbol)
26402639
else
26412640
try {
@@ -3375,8 +3374,8 @@ object Types extends TypeUtils {
33753374
val bcs1set = BaseClassSet(bcs1)
33763375
def recur(bcs2: List[ClassSymbol]): List[ClassSymbol] = bcs2 match {
33773376
case bc2 :: bcs2rest =>
3378-
if (bcs1set contains bc2)
3379-
if (bc2.is(Trait)) recur(bcs2rest)
3377+
if bcs1set.contains(bc2) then
3378+
if bc2.is(Trait) then recur(bcs2rest)
33803379
else bcs1 // common class, therefore rest is the same in both sequences
33813380
else bc2 :: recur(bcs2rest)
33823381
case nil => bcs1
@@ -3472,9 +3471,8 @@ object Types extends TypeUtils {
34723471
val bcs1set = BaseClassSet(bcs1)
34733472
def recur(bcs2: List[ClassSymbol]): List[ClassSymbol] = bcs2 match {
34743473
case bc2 :: bcs2rest =>
3475-
if (bcs1set contains bc2)
3476-
if (bc2.is(Trait)) bc2 :: recur(bcs2rest)
3477-
else bcs2
3474+
if bcs1set.contains(bc2) then
3475+
if bc2.is(Trait) then bc2 :: recur(bcs2rest) else bcs2
34783476
else recur(bcs2rest)
34793477
case nil =>
34803478
bcs2
@@ -5415,11 +5413,11 @@ object Types extends TypeUtils {
54155413
parent.hashIsStable
54165414

54175415
override def eql(that: Type): Boolean = that match
5418-
case that: AnnotatedType => (parent eq that.parent) && (annot eql that.annot)
5416+
case that: AnnotatedType => (parent eq that.parent) && annot.eql(that.annot)
54195417
case _ => false
54205418

54215419
override def iso(that: Any, bs: BinderPairs): Boolean = that match
5422-
case that: AnnotatedType => parent.equals(that.parent, bs) && (annot eql that.annot)
5420+
case that: AnnotatedType => parent.equals(that.parent, bs) && annot.eql(that.annot)
54235421
case _ => false
54245422
}
54255423

@@ -5986,7 +5984,7 @@ object Types extends TypeUtils {
59865984
}
59875985
}
59885986

5989-
@sharable object IdentityTypeMap extends TypeMap()(NoContext) {
5987+
@sharable object IdentityTypeMap extends TypeMap()(using NoContext) {
59905988
def apply(tp: Type): Type = tp
59915989
}
59925990

@@ -6457,7 +6455,7 @@ object Types extends TypeUtils {
64576455
def maybeAdd(xs: List[NamedType], tp: NamedType): List[NamedType] = if p(tp) then tp :: xs else xs
64586456
val seen = util.HashSet[Type]()
64596457
def apply(xs: List[NamedType], tp: Type): List[NamedType] =
6460-
if seen contains tp then xs
6458+
if seen.contains(tp) then xs
64616459
else
64626460
seen += tp
64636461
tp match
@@ -6636,7 +6634,7 @@ object Types extends TypeUtils {
66366634

66376635
object fieldFilter extends NameFilter {
66386636
def apply(pre: Type, name: Name)(using Context): Boolean =
6639-
name.isTermName && (pre member name).hasAltWith(!_.symbol.is(Method))
6637+
name.isTermName && pre.member(name).hasAltWith(!_.symbol.is(Method))
66406638
def isStable = true
66416639
}
66426640

0 commit comments

Comments
 (0)