Skip to content

Commit e5472f9

Browse files
committed
Add default arguments to derivedRefinedType
1 parent 6e45dd7 commit e5472f9

File tree

9 files changed

+19
-17
lines changed

9 files changed

+19
-17
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ class CheckCaptures extends Recheck, SymTransformer:
303303
case _ =>
304304
val t1 = t match
305305
case t @ defn.RefinedFunctionOf(rinfo: MethodType) =>
306-
t.derivedRefinedType(t.parent, t.refinedName, this(rinfo))
306+
t.derivedRefinedType(refinedInfo = this(rinfo))
307307
case _ =>
308308
mapOver(t)
309309
if variance > 0 then t1
@@ -859,7 +859,7 @@ class CheckCaptures extends Recheck, SymTransformer:
859859
adaptTypeFun(actual, rinfo.resType, expected, covariant, insertBox,
860860
ares1 =>
861861
val rinfo1 = rinfo.derivedLambdaType(rinfo.paramNames, rinfo.paramInfos, ares1)
862-
val actual1 = actual.derivedRefinedType(actual.parent, actual.refinedName, rinfo1)
862+
val actual1 = actual.derivedRefinedType(refinedInfo = rinfo1)
863863
actual1
864864
)
865865
case _ =>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,8 +447,8 @@ object Setup:
447447
* an embedded capture set variable from a part of `tp`.
448448
*/
449449
def decorate(tp: Type, addedSet: Type => CaptureSet)(using Context): Type = tp match
450-
case tp @ RefinedType(parent @ CapturingType(parent1, refs), rname, rinfo) =>
451-
CapturingType(tp.derivedRefinedType(parent1, rname, rinfo), refs, parent.isBoxed)
450+
case tp @ RefinedType(parent @ CapturingType(parent1, refs), _, _) =>
451+
CapturingType(tp.derivedRefinedType(parent = parent1), refs, parent.isBoxed)
452452
case tp: RecType =>
453453
tp.parent match
454454
case parent @ CapturingType(parent1, refs) =>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ trait ConstraintHandling {
689689
case tp: AndType =>
690690
tp.derivedAndType(tp.tp1.hardenUnions, tp.tp2.hardenUnions)
691691
case tp: RefinedType =>
692-
tp.derivedRefinedType(tp.parent.hardenUnions, tp.refinedName, tp.refinedInfo)
692+
tp.derivedRefinedType(parent = tp.parent.hardenUnions)
693693
case tp: RecType =>
694694
tp.rebind(tp.parent.hardenUnions)
695695
case tp: HKTypeLambda =>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1814,7 +1814,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
18141814
private def fixRecs(anchor: SingletonType, tp: Type): Type = {
18151815
def fix(tp: Type): Type = tp.stripTypeVar match {
18161816
case tp: RecType => fix(tp.parent).substRecThis(tp, anchor)
1817-
case tp @ RefinedType(parent, rname, rinfo) => tp.derivedRefinedType(fix(parent), rname, rinfo)
1817+
case tp: RefinedType => tp.derivedRefinedType(parent = fix(tp.parent))
18181818
case tp: TypeParamRef => fixOrElse(bounds(tp).hi, tp)
18191819
case tp: TypeProxy => fixOrElse(tp.superType, tp)
18201820
case tp: AndType => tp.derivedAndType(fix(tp.tp1), fix(tp.tp2))

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,7 +1348,7 @@ object Types {
13481348
case tp: AndType =>
13491349
tp.derivedAndType(tp.tp1.widenUnionWithoutNull, tp.tp2.widenUnionWithoutNull)
13501350
case tp: RefinedType =>
1351-
tp.derivedRefinedType(tp.parent.widenUnion, tp.refinedName, tp.refinedInfo)
1351+
tp.derivedRefinedType(parent = tp.parent.widenUnion)
13521352
case tp: RecType =>
13531353
tp.rebind(tp.parent.widenUnion)
13541354
case tp: HKTypeLambda =>
@@ -3195,7 +3195,9 @@ object Types {
31953195

31963196
def checkInst(using Context): this.type = this // debug hook
31973197

3198-
def derivedRefinedType(parent: Type, refinedName: Name, refinedInfo: Type)(using Context): Type =
3198+
final def derivedRefinedType
3199+
(parent: Type = this.parent, refinedName: Name = this.refinedName, refinedInfo: Type = this.refinedInfo)
3200+
(using Context): Type =
31993201
if ((parent eq this.parent) && (refinedName eq this.refinedName) && (refinedInfo eq this.refinedInfo)) this
32003202
else RefinedType(parent, refinedName, refinedInfo)
32013203

@@ -4101,7 +4103,7 @@ object Types {
41014103
case tp @ AppliedType(tycon, args) if defn.isFunctionNType(tp) =>
41024104
wrapConvertible(tp.derivedAppliedType(tycon, args.init :+ addInto(args.last)))
41034105
case tp @ defn.RefinedFunctionOf(rinfo) =>
4104-
wrapConvertible(tp.derivedRefinedType(tp.parent, tp.refinedName, addInto(rinfo)))
4106+
wrapConvertible(tp.derivedRefinedType(refinedInfo = addInto(rinfo)))
41054107
case tp: MethodOrPoly =>
41064108
tp.derivedLambdaType(resType = addInto(tp.resType))
41074109
case ExprType(resType) =>
@@ -5612,8 +5614,8 @@ object Types {
56125614
else hi
56135615
case (arg, _) => arg
56145616
tp.derivedAppliedType(tycon, args1)
5615-
case tp @ RefinedType(parent, name, info) =>
5616-
tp.derivedRefinedType(approxWildcardArgs(parent), name, info)
5617+
case tp: RefinedType =>
5618+
tp.derivedRefinedType(approxWildcardArgs(tp.parent))
56175619
case _ =>
56185620
tp
56195621
approxWildcardArgs(tp)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -734,8 +734,8 @@ class Scala2Unpickler(bytes: Array[Byte], classRoot: ClassDenotation, moduleClas
734734
val info1 = info.symbol.info
735735
assert(info1.derivesFrom(defn.SingletonClass))
736736
RefinedType(parent1, name, info1.mapReduceAnd(removeSingleton)(_ & _))
737-
case info =>
738-
tp.derivedRefinedType(parent1, name, info)
737+
case _ =>
738+
tp.derivedRefinedType(parent = parent1)
739739
}
740740
case tp @ AppliedType(tycon, args) =>
741741
val tycon1 = tycon.safeDealias

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,7 @@ trait Checking {
10971097
case tp @ AppliedType(tycon, args) =>
10981098
tp.derivedAppliedType(tycon, args.mapConserve(checkGoodBounds))
10991099
case tp: RefinedType =>
1100-
tp.derivedRefinedType(tp.parent, tp.refinedName, checkGoodBounds(tp.refinedInfo))
1100+
tp.derivedRefinedType(refinedInfo = checkGoodBounds(tp.refinedInfo))
11011101
case _ =>
11021102
tp
11031103
}

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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -743,8 +743,8 @@ class Synthesizer(typer: Typer)(using @constructorOnly c: Context):
743743
def recur(handlers: SpecialHandlers): TreeWithErrors = handlers match
744744
case (cls, handler) :: rest =>
745745
def baseWithRefinements(tp: Type): Type = tp.dealias match
746-
case tp @ RefinedType(parent, rname, rinfo) =>
747-
tp.derivedRefinedType(baseWithRefinements(parent), rname, rinfo)
746+
case tp: RefinedType =>
747+
tp.derivedRefinedType(parent = baseWithRefinements(tp.parent))
748748
case _ =>
749749
tp.baseType(cls)
750750
val base = baseWithRefinements(formal)

0 commit comments

Comments
 (0)