Skip to content

Commit 758b721

Browse files
committed
Allow contextual functions with erased parameters to be integrated
1 parent b70698d commit 758b721

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1509,7 +1509,6 @@ class Definitions {
15091509

15101510
/** Is an context function class.
15111511
* - ContextFunctionN for N >= 0
1512-
* - ErasedContextFunctionN for N > 0
15131512
*/
15141513
def isContextFunctionClass(cls: Symbol): Boolean = scalaClassName(cls).isContextFunction
15151514

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

Lines changed: 10 additions & 3 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.ContextFunctionType(_, resTpe, erasedParams) if !erasedParams.contains(true) /* Only enable for non-erased functions */ =>
23+
case defn.ContextFunctionType(_, resTpe, _) =>
2424
rhs match
2525
case closureDef(meth) => 1 + contextResultCount(meth.rhs, resTpe)
2626
case _ => 0
@@ -116,8 +116,15 @@ object ContextFunctionResults:
116116
atPhase(erasurePhase)(integrateSelect(tree, n))
117117
else tree match
118118
case Select(qual, name) =>
119-
if name == nme.apply && defn.isContextFunctionClass(tree.symbol.maybeOwner) then
120-
integrateSelect(qual, n + 1)
119+
if name == nme.apply then
120+
qual.tpe match
121+
case defn.ContextFunctionType(_, _, _) =>
122+
integrateSelect(qual, n + 1)
123+
case _ if defn.isContextFunctionClass(tree.symbol.maybeOwner) => // for TermRefs
124+
// assert(qual.tpe.isInstanceOf[TermRef])
125+
integrateSelect(qual, n + 1)
126+
case _ =>
127+
n > 0 && contextResultCount(tree.symbol) >= n
121128
else
122129
n > 0 && contextResultCount(tree.symbol) >= n
123130
case Ident(name) =>

0 commit comments

Comments
 (0)