Skip to content

Commit cd1a92e

Browse files
committed
Drop unused code
1 parent c6d7d89 commit cd1a92e

File tree

2 files changed

+20
-50
lines changed

2 files changed

+20
-50
lines changed

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

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -99,34 +99,6 @@ object ContextFunctionResults:
9999
normalParamCount(sym.info)
100100
end totalParamCount
101101

102-
/** The rightmost context function type in the result type of `meth`
103-
* that represents `paramCount` curried, non-erased parameters that
104-
* are included in the `contextResultCount` of `meth`.
105-
* Example:
106-
*
107-
* Say we have `def m(x: A): B ?=> (C1, C2, C3) ?=> D ?=> E ?=> F`,
108-
* paramCount == 4, and the contextResultCount of `m` is 3.
109-
* Then we return the type `(C1, C2, C3) ?=> D ?=> E ?=> F`, since this
110-
* type covers the 4 rightmost parameters C1, C2, C3 and D before the
111-
* contextResultCount runs out at E ?=> F.
112-
* Erased parameters are ignored; they contribute nothing to the
113-
* parameter count.
114-
*/
115-
def contextFunctionResultTypeCovering(meth: Symbol, paramCount: Int)(using Context) =
116-
atPhase(erasurePhase) {
117-
// Recursive instances return pairs of context types and the
118-
// # of parameters they represent.
119-
def missingCR(tp: Type, crCount: Int): (Type, Int) =
120-
if crCount == 0 then (tp, 0)
121-
else
122-
val defn.ContextFunctionType(formals, resTpe, isErased) = tp: @unchecked
123-
val result @ (rt, nparams) = missingCR(resTpe, crCount - 1)
124-
assert(nparams <= paramCount)
125-
if nparams == paramCount || isErased then result
126-
else (tp, nparams + formals.length)
127-
missingCR(meth.info.finalResultType, contextResultCount(meth))._1
128-
}
129-
130102
/** The `depth` levels nested context function type in the result type of `meth` */
131103
def contextFunctionResultTypeAfter(meth: Symbol, depth: Int)(using Context) =
132104
def recur(tp: Type, n: Int): Type =

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

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class Erasure extends Phase with DenotTransformer {
5757
case _ => false
5858
}
5959
}
60+
6061
def erasedName =
6162
if ref.is(Flags.Method)
6263
&& contextResultsAreErased(ref.symbol)
@@ -381,29 +382,26 @@ object Erasure {
381382
*/
382383
def adaptToType(tree: Tree, pt: Type)(using Context): Tree = pt match
383384
case _: FunProto | AnyFunctionProto => tree
384-
case _ =>
385-
/*val ahead = tree.attachmentOrElse(needsEta, 0)
386-
if ahead > 0 then etaExpand(tree, ahead, pt)
387-
else*/ tree.tpe.widen match
388-
case mt: MethodType if tree.isTerm =>
389-
assert(mt.paramInfos.isEmpty)
390-
adaptToType(tree.appliedToNone, pt)
391-
case tpw =>
392-
if (pt.isInstanceOf[ProtoType] || tree.tpe <:< pt)
393-
tree
394-
else if (tpw.isErasedValueType)
395-
if (pt.isErasedValueType) then
396-
tree.asInstance(pt)
397-
else
398-
adaptToType(box(tree), pt)
399-
else if (pt.isErasedValueType)
400-
adaptToType(unbox(tree, pt), pt)
401-
else if (tpw.isPrimitiveValueType && !pt.isPrimitiveValueType)
402-
adaptToType(box(tree), pt)
403-
else if (pt.isPrimitiveValueType && !tpw.isPrimitiveValueType)
404-
adaptToType(unbox(tree, pt), pt)
385+
case _ => tree.tpe.widen match
386+
case mt: MethodType if tree.isTerm =>
387+
assert(mt.paramInfos.isEmpty)
388+
adaptToType(tree.appliedToNone, pt)
389+
case tpw =>
390+
if (pt.isInstanceOf[ProtoType] || tree.tpe <:< pt)
391+
tree
392+
else if (tpw.isErasedValueType)
393+
if (pt.isErasedValueType) then
394+
tree.asInstance(pt)
405395
else
406-
cast(tree, pt)
396+
adaptToType(box(tree), pt)
397+
else if (pt.isErasedValueType)
398+
adaptToType(unbox(tree, pt), pt)
399+
else if (tpw.isPrimitiveValueType && !pt.isPrimitiveValueType)
400+
adaptToType(box(tree), pt)
401+
else if (pt.isPrimitiveValueType && !tpw.isPrimitiveValueType)
402+
adaptToType(unbox(tree, pt), pt)
403+
else
404+
cast(tree, pt)
407405
end adaptToType
408406

409407
/** The following code:

0 commit comments

Comments
 (0)