diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs new file mode 100644 index 000000000000..118a334b383a --- /dev/null +++ b/.git-blame-ignore-revs @@ -0,0 +1 @@ +46a26945a172429740ebdd1fc83517130670080b diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index df7700c73a17..901d73eabe01 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -412,10 +412,9 @@ object Types extends TypeUtils { catch case ex: Throwable => handleRecursive("unusableForInference", show, ex) /** Does the type carry an annotation that is an instance of `cls`? */ - @tailrec final def hasAnnotation(cls: ClassSymbol)(using Context): Boolean = stripTypeVar match { - case AnnotatedType(tp, annot) => (annot matches cls) || (tp hasAnnotation cls) + @tailrec final def hasAnnotation(cls: ClassSymbol)(using Context): Boolean = stripTypeVar match + case AnnotatedType(tp, annot) => annot.matches(cls) || tp.hasAnnotation(cls) case _ => false - } /** Returns the annotation that is an instance of `cls` carried by the type. */ @tailrec final def getAnnotation(cls: ClassSymbol)(using Context): Option[Annotation] = stripTypeVar match { @@ -584,8 +583,8 @@ object Types extends TypeUtils { case AndType(l, r) => val lsym = l.classSymbol val rsym = r.classSymbol - if (lsym isSubClass rsym) lsym - else if (rsym isSubClass lsym) rsym + if lsym.isSubClass(rsym) then lsym + else if rsym.isSubClass(lsym) then rsym else NoSymbol case tp: OrType => if tp.tp1.hasClassSymbol(defn.NothingClass) then @@ -724,7 +723,7 @@ object Types extends TypeUtils { case tp: TypeProxy => tp.superType.findDecl(name, excluded) case err: ErrorType => - newErrorSymbol(classSymbol orElse defn.RootClass, name, err.msg) + newErrorSymbol(classSymbol.orElse(defn.RootClass), name, err.msg) case _ => NoDenotation } @@ -815,7 +814,7 @@ object Types extends TypeUtils { case tp: JavaArrayType => defn.ObjectType.findMember(name, pre, required, excluded) case err: ErrorType => - newErrorSymbol(pre.classSymbol orElse defn.RootClass, name, err.msg) + newErrorSymbol(pre.classSymbol.orElse(defn.RootClass), name, err.msg) case _ => NoDenotation } @@ -919,7 +918,7 @@ object Types extends TypeUtils { // member in Super instead of Sub. // As an example of this in the wild, see // loadClassWithPrivateInnerAndSubSelf in ShowClassTests - go(tp.cls.typeRef) orElse d + go(tp.cls.typeRef).orElse(d) def goParam(tp: TypeParamRef) = { val next = tp.underlying @@ -1157,7 +1156,7 @@ object Types extends TypeUtils { false def relaxed_<:<(that: Type)(using Context): Boolean = - (this <:< that) || (this isValueSubType that) + (this <:< that) || this.isValueSubType(that) /** Is this type a legal type for member `sym1` that overrides another * member `sym2` of type `that`? This is the same as `<:<`, except that @@ -1208,10 +1207,10 @@ object Types extends TypeUtils { * vice versa. */ def matchesLoosely(that: Type)(using Context): Boolean = - (this matches that) || { + this.matches(that) || { val thisResult = this.widenExpr val thatResult = that.widenExpr - (this eq thisResult) != (that eq thatResult) && (thisResult matchesLoosely thatResult) + (this eq thisResult) != (that eq thatResult) && thisResult.matchesLoosely(thatResult) } /** The basetype of this type with given class symbol, NoType if `base` is not a class. */ @@ -1869,7 +1868,7 @@ object Types extends TypeUtils { * no symbol it tries `member` as an alternative. */ def typeParamNamed(name: TypeName)(using Context): Symbol = - classSymbol.unforcedDecls.lookup(name) orElse member(name).symbol + classSymbol.unforcedDecls.lookup(name).orElse(member(name).symbol) /** If this is a prototype with some ignored component, reveal one more * layer of it. Otherwise the type itself. @@ -2008,9 +2007,9 @@ object Types extends TypeUtils { def annotatedToRepeated(using Context): Type = this match { case tp @ ExprType(tp1) => tp.derivedExprType(tp1.annotatedToRepeated) - case self @ AnnotatedType(tp, annot) if annot matches defn.RetainsByNameAnnot => + case self @ AnnotatedType(tp, annot) if annot.matches(defn.RetainsByNameAnnot) => self.derivedAnnotatedType(tp.annotatedToRepeated, annot) - case AnnotatedType(tp, annot) if annot matches defn.RepeatedAnnot => + case AnnotatedType(tp, annot) if annot.matches(defn.RepeatedAnnot) => val typeSym = tp.typeSymbol.asClass assert(typeSym == defn.SeqClass || typeSym == defn.ArrayClass) tp.translateParameterized(typeSym, defn.RepeatedParamClass) @@ -2706,9 +2705,9 @@ object Types extends TypeUtils { */ final def controlled[T](op: => T)(using Context): T = try { ctx.base.underlyingRecursions += 1 - if (ctx.base.underlyingRecursions < Config.LogPendingUnderlyingThreshold) + if ctx.base.underlyingRecursions < Config.LogPendingUnderlyingThreshold then op - else if (ctx.pendingUnderlying contains this) + else if ctx.pendingUnderlying.contains(this) then throw CyclicReference(symbol) else try { @@ -3465,8 +3464,8 @@ object Types extends TypeUtils { val bcs1set = BaseClassSet(bcs1) def recur(bcs2: List[ClassSymbol]): List[ClassSymbol] = bcs2 match { case bc2 :: bcs2rest => - if (bcs1set contains bc2) - if (bc2.is(Trait)) recur(bcs2rest) + if bcs1set.contains(bc2) then + if bc2.is(Trait) then recur(bcs2rest) else bcs1 // common class, therefore rest is the same in both sequences else bc2 :: recur(bcs2rest) case nil => bcs1 @@ -3562,9 +3561,8 @@ object Types extends TypeUtils { val bcs1set = BaseClassSet(bcs1) def recur(bcs2: List[ClassSymbol]): List[ClassSymbol] = bcs2 match { case bc2 :: bcs2rest => - if (bcs1set contains bc2) - if (bc2.is(Trait)) bc2 :: recur(bcs2rest) - else bcs2 + if bcs1set.contains(bc2) then + if bc2.is(Trait) then bc2 :: recur(bcs2rest) else bcs2 else recur(bcs2rest) case nil => bcs2 @@ -5757,11 +5755,11 @@ object Types extends TypeUtils { parent.hashIsStable override def eql(that: Type): Boolean = that match - case that: AnnotatedType => (parent eq that.parent) && (annot eql that.annot) + case that: AnnotatedType => (parent eq that.parent) && annot.eql(that.annot) case _ => false override def iso(that: Any, bs: BinderPairs): Boolean = that match - case that: AnnotatedType => parent.equals(that.parent, bs) && (annot eql that.annot) + case that: AnnotatedType => parent.equals(that.parent, bs) && annot.eql(that.annot) case _ => false } @@ -6354,7 +6352,7 @@ object Types extends TypeUtils { tp.derivedClassInfo(prefix1, parents1, tp.decls, selfInfo1) end DeepTypeMap - @sharable object IdentityTypeMap extends TypeMap()(NoContext) { + @sharable object IdentityTypeMap extends TypeMap()(using NoContext) { def apply(tp: Type): Type = tp } @@ -6827,7 +6825,7 @@ object Types extends TypeUtils { def maybeAdd(xs: List[NamedType], tp: NamedType): List[NamedType] = if p(tp) then tp :: xs else xs val seen = util.HashSet[Type]() def apply(xs: List[NamedType], tp: Type): List[NamedType] = - if seen contains tp then xs + if seen.contains(tp) then xs else seen += tp tp match @@ -7006,7 +7004,7 @@ object Types extends TypeUtils { object fieldFilter extends NameFilter { def apply(pre: Type, name: Name)(using Context): Boolean = - name.isTermName && (pre member name).hasAltWith(!_.symbol.is(Method)) + name.isTermName && pre.member(name).hasAltWith(!_.symbol.is(Method)) def isStable = true }