Skip to content

Commit 1969f39

Browse files
committed
Simplify DependentFunctionRefinementOf
1 parent 785c8d4 commit 1969f39

File tree

6 files changed

+14
-13
lines changed

6 files changed

+14
-13
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ class CheckCaptures extends Recheck, SymTransformer:
532532
meth.updateInfoBetween(preRecheckPhase, thisPhase, completer)
533533
pt.dealias match
534534
case defn.NonDependentFunctionOf(ptformals, _, _) => recheckFunction(ptformals)
535-
case defn.DependentFunctionRefinementOf(_, mt) => recheckFunction(mt.paramInfos)
535+
case defn.DependentFunctionRefinementOf(mt) => recheckFunction(mt.paramInfos)
536536
case _ =>
537537
mdef.rhs match
538538
case rhs @ closure(_, _, _) =>
@@ -711,7 +711,7 @@ class CheckCaptures extends Recheck, SymTransformer:
711711
else CapturingType(eparent1, refs, boxed = expected0.isBoxed)
712712
case defn.NonDependentFunctionOf(args, resultType, isContextual) =>
713713
actual match
714-
case defn.DependentFunctionRefinementOf(_, _) =>
714+
case defn.DependentFunctionRefinementOf(_) =>
715715
toDepFun(args, resultType, isContextual)
716716
case _ =>
717717
expected

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,9 +1198,10 @@ class Definitions {
11981198
*
11991199
* Pattern: `$ft { def apply: $mt }`
12001200
*/
1201-
def unapply(ft: Type)(using Context): Option[(Type, MethodType)] = ft.dealias match
1202-
case RefinedType(parent, nme.apply, mt: MethodType) if isFunctionNType(parent) && mt.isResultDependent =>
1203-
Some((parent, mt))
1201+
def unapply(ft: Type)(using Context): Option[MethodType] = ft.dealias match
1202+
case RefinedType(parent, nme.apply, mt: MethodType)
1203+
if isFunctionNType(parent) && mt.isResultDependent =>
1204+
Some(mt)
12041205
case _ => None
12051206
}
12061207

compiler/src/dotty/tools/dotc/transform/ContextFunctionResults.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ object ContextFunctionResults:
2020
*/
2121
def annotateContextResults(mdef: DefDef)(using Context): Unit =
2222
def contextResultCount(rhs: Tree, tp: Type): Int = tp match
23-
case defn.DependentFunctionRefinementOf(_, mt) if mt.isContextualMethod =>
23+
case defn.DependentFunctionRefinementOf(mt) if mt.isContextualMethod =>
2424
rhs match
2525
case closureDef(meth) => 1 + contextResultCount(meth.rhs, mt.resType)
2626
case _ => 0
@@ -62,7 +62,7 @@ object ContextFunctionResults:
6262
*/
6363
def contextResultsAreErased(sym: Symbol)(using Context): Boolean =
6464
def allErased(tp: Type): Boolean = tp.dealias match
65-
case ft @ defn.DependentFunctionRefinementOf(_, mt) if mt.isContextualMethod =>
65+
case ft @ defn.DependentFunctionRefinementOf(mt) if mt.isContextualMethod =>
6666
!defn.erasedFunctionParams(ft).contains(false) && allErased(mt.resType)
6767
case ft @ defn.NonDependentContextFunctionOf(_, resTpe) =>
6868
!defn.erasedFunctionParams(ft).contains(false) && allErased(resTpe)
@@ -79,8 +79,8 @@ object ContextFunctionResults:
7979
integrateContextResults(rt, crCount)
8080
case tp: MethodOrPoly =>
8181
tp.derivedLambdaType(resType = integrateContextResults(tp.resType, crCount))
82-
case defn.DependentFunctionRefinementOf(base, mt) if mt.isContextualMethod =>
83-
integrateContextResults(base, crCount)
82+
case defn.DependentFunctionRefinementOf(mt) if mt.isContextualMethod =>
83+
mt.derivedLambdaType(resType = integrateContextResults(mt.resultType, crCount - 1))
8484
case defn.NonDependentContextFunctionOf(argTypes, resType) =>
8585
MethodType(argTypes, integrateContextResults(resType, crCount - 1))
8686

@@ -128,7 +128,7 @@ object ContextFunctionResults:
128128
case Select(qual, name) =>
129129
if name == nme.apply then
130130
qual.tpe match
131-
case defn.DependentFunctionRefinementOf(_, mt) if mt.isContextualMethod =>
131+
case defn.DependentFunctionRefinementOf(mt) if mt.isContextualMethod =>
132132
integrateSelect(qual, n + 1)
133133
case defn.NonDependentContextFunctionOf(_, _) =>
134134
integrateSelect(qual, n + 1)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1893,7 +1893,7 @@ class Namer { typer: Typer =>
18931893
val originalTp = defaultParamType
18941894
val approxTp = wildApprox(originalTp)
18951895
approxTp.stripPoly match
1896-
case defn.DependentFunctionRefinementOf(_, mt) if mt.isContextualMethod =>
1896+
case defn.DependentFunctionRefinementOf(mt) if mt.isContextualMethod =>
18971897
// in this case `resType` is lying, gives us only the non-dependent upper bound
18981898
originalTp
18991899
case atp @ defn.NonDependentContextFunctionOf(_, resType)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1330,7 +1330,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
13301330
case ft @ defn.PolyFunctionOf(mt @ MethodTpe(_, formals, restpe)) =>
13311331
if formals.length != defaultArity then fallbackProto
13321332
else (formals, untpd.InLambdaTypeTree(isResult = true, (_, syms) => restpe.substParams(mt, syms.map(_.termRef))))
1333-
case ft @ defn.DependentFunctionRefinementOf(_, mt @ MethodTpe(_, formals, restpe)) =>
1333+
case ft @ defn.DependentFunctionRefinementOf(mt @ MethodTpe(_, formals, restpe)) =>
13341334
if formals.length != defaultArity then fallbackProto
13351335
else (formals, untpd.InLambdaTypeTree(isResult = true, (_, syms) => restpe.substParams(mt, syms.map(_.termRef))))
13361336
case SAMType(mt @ MethodTpe(_, formals, _), samParent) =>

compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1800,7 +1800,7 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
18001800
case _ => false
18011801
def isDependentFunctionType: Boolean =
18021802
self match
1803-
case dotc.core.Symbols.defn.DependentFunctionRefinementOf(_, _) => true
1803+
case dotc.core.Symbols.defn.DependentFunctionRefinementOf(_) => true
18041804
case _ => false
18051805
def isTupleN: Boolean =
18061806
dotc.core.Symbols.defn.isTupleNType(self)

0 commit comments

Comments
 (0)