Skip to content

Commit 507eb90

Browse files
committed
Add default arguments to derivedRefinedType
[Cherry-picked ab9f882][modified]
1 parent 070d1bb commit 507eb90

File tree

8 files changed

+14
-12
lines changed

8 files changed

+14
-12
lines changed

compiler/src/dotty/tools/dotc/cc/CheckCaptures.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ class CheckCaptures extends Recheck, SymTransformer:
783783
adaptTypeFun(actual, rinfo.resType, expected, covariant, insertBox,
784784
ares1 =>
785785
val rinfo1 = rinfo.derivedLambdaType(rinfo.paramNames, rinfo.paramInfos, ares1)
786-
val actual1 = actual.derivedRefinedType(actual.parent, actual.refinedName, rinfo1)
786+
val actual1 = actual.derivedRefinedType(refinedInfo = rinfo1)
787787
actual1
788788
)
789789
case _ =>

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ trait ConstraintHandling {
681681
case tp: AndType =>
682682
tp.derivedAndType(tp.tp1.hardenUnions, tp.tp2.hardenUnions)
683683
case tp: RefinedType =>
684-
tp.derivedRefinedType(tp.parent.hardenUnions, tp.refinedName, tp.refinedInfo)
684+
tp.derivedRefinedType(parent = tp.parent.hardenUnions)
685685
case tp: RecType =>
686686
tp.rebind(tp.parent.hardenUnions)
687687
case tp: HKTypeLambda =>

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1731,7 +1731,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
17311731
private def fixRecs(anchor: SingletonType, tp: Type): Type = {
17321732
def fix(tp: Type): Type = tp.stripTypeVar match {
17331733
case tp: RecType => fix(tp.parent).substRecThis(tp, anchor)
1734-
case tp @ RefinedType(parent, rname, rinfo) => tp.derivedRefinedType(fix(parent), rname, rinfo)
1734+
case tp: RefinedType => tp.derivedRefinedType(parent = fix(tp.parent))
17351735
case tp: TypeParamRef => fixOrElse(bounds(tp).hi, tp)
17361736
case tp: TypeProxy => fixOrElse(tp.superType, tp)
17371737
case tp: AndType => tp.derivedAndType(fix(tp.tp1), fix(tp.tp2))

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

+5-3
Original file line numberDiff line numberDiff line change
@@ -1328,7 +1328,7 @@ object Types {
13281328
case tp: AndType =>
13291329
tp.derivedAndType(tp.tp1.widenUnionWithoutNull, tp.tp2.widenUnionWithoutNull)
13301330
case tp: RefinedType =>
1331-
tp.derivedRefinedType(tp.parent.widenUnion, tp.refinedName, tp.refinedInfo)
1331+
tp.derivedRefinedType(parent = tp.parent.widenUnion)
13321332
case tp: RecType =>
13331333
tp.rebind(tp.parent.widenUnion)
13341334
case tp: HKTypeLambda =>
@@ -3152,7 +3152,9 @@ object Types {
31523152

31533153
def checkInst(using Context): this.type = this // debug hook
31543154

3155-
def derivedRefinedType(parent: Type, refinedName: Name, refinedInfo: Type)(using Context): Type =
3155+
final def derivedRefinedType
3156+
(parent: Type = this.parent, refinedName: Name = this.refinedName, refinedInfo: Type = this.refinedInfo)
3157+
(using Context): Type =
31563158
if ((parent eq this.parent) && (refinedName eq this.refinedName) && (refinedInfo eq this.refinedInfo)) this
31573159
else RefinedType(parent, refinedName, refinedInfo)
31583160

@@ -4056,7 +4058,7 @@ object Types {
40564058
case tp @ AppliedType(tycon, args) if defn.isFunctionNType(tp) =>
40574059
wrapConvertible(tp.derivedAppliedType(tycon, args.init :+ addInto(args.last)))
40584060
case tp @ defn.RefinedFunctionOf(rinfo) =>
4059-
wrapConvertible(tp.derivedRefinedType(tp.parent, tp.refinedName, addInto(rinfo)))
4061+
wrapConvertible(tp.derivedRefinedType(refinedInfo = addInto(rinfo)))
40604062
case tp: MethodOrPoly =>
40614063
tp.derivedLambdaType(resType = addInto(tp.resType))
40624064
case ExprType(resType) =>

compiler/src/dotty/tools/dotc/core/unpickleScala2/Scala2Unpickler.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -730,8 +730,8 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
730730
val info1 = info.symbol.info
731731
assert(info1.derivesFrom(defn.SingletonClass))
732732
RefinedType(parent1, name, info1.mapReduceAnd(removeSingleton)(_ & _))
733-
case info =>
734-
tp.derivedRefinedType(parent1, name, info)
733+
case _ =>
734+
tp.derivedRefinedType(parent = parent1)
735735
}
736736
case tp @ AppliedType(tycon, args) =>
737737
val tycon1 = tycon.safeDealias

compiler/src/dotty/tools/dotc/typer/Checking.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,7 @@ trait Checking {
10771077
case tp @ AppliedType(tycon, args) =>
10781078
tp.derivedAppliedType(tycon, args.mapConserve(checkGoodBounds))
10791079
case tp: RefinedType =>
1080-
tp.derivedRefinedType(tp.parent, tp.refinedName, checkGoodBounds(tp.refinedInfo))
1080+
tp.derivedRefinedType(refinedInfo = checkGoodBounds(tp.refinedInfo))
10811081
case _ =>
10821082
tp
10831083
}

compiler/src/dotty/tools/dotc/typer/Inferencing.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ object Inferencing {
537537
}
538538
if tparams.isEmpty then tp else tp.derivedAppliedType(tycon, args1)
539539
case tp: AndOrType => tp.derivedAndOrType(captureWildcards(tp.tp1), captureWildcards(tp.tp2))
540-
case tp: RefinedType => tp.derivedRefinedType(captureWildcards(tp.parent), tp.refinedName, tp.refinedInfo)
540+
case tp: RefinedType => tp.derivedRefinedType(parent = captureWildcards(tp.parent))
541541
case tp: RecType => tp.derivedRecType(captureWildcards(tp.parent))
542542
case tp: LazyRef => captureWildcards(tp.ref)
543543
case tp: AnnotatedType => tp.derivedAnnotatedType(captureWildcards(tp.parent), tp.annot)

compiler/src/dotty/tools/dotc/typer/Synthesizer.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -727,8 +727,8 @@ class Synthesizer(typer: Typer)(using @constructorOnly c: Context):
727727
def recur(handlers: SpecialHandlers): TreeWithErrors = handlers match
728728
case (cls, handler) :: rest =>
729729
def baseWithRefinements(tp: Type): Type = tp.dealias match
730-
case tp @ RefinedType(parent, rname, rinfo) =>
731-
tp.derivedRefinedType(baseWithRefinements(parent), rname, rinfo)
730+
case tp: RefinedType =>
731+
tp.derivedRefinedType(parent = baseWithRefinements(tp.parent))
732732
case _ =>
733733
tp.baseType(cls)
734734
val base = baseWithRefinements(formal)

0 commit comments

Comments
 (0)