Skip to content

Commit 0de0505

Browse files
committed
Add comments for isFunctionType-like functions
1 parent f499f88 commit 0de0505

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

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

+10-2
Original file line numberDiff line numberDiff line change
@@ -1483,7 +1483,6 @@ class Definitions {
14831483

14841484
/** Is any function class where
14851485
* - FunctionXXL
1486-
* - ErasedFunction
14871486
* - FunctionN for N >= 0
14881487
* - ContextFunctionN for N >= 0
14891488
*/
@@ -1675,14 +1674,23 @@ class Definitions {
16751674
skipRefined = false)
16761675
end isNonRefinedFunction
16771676

1678-
/** Is `tp` a representation of a (possibly dependent) function type or an alias of such? */
1677+
/** Returns whether `tp` is an instance or a refined instance of:
1678+
* - scala.FunctionN
1679+
* - scala.ContextFunctionN
1680+
*/
16791681
def isFunctionType(tp: Type)(using Context): Boolean =
16801682
isNonRefinedFunction(tp.dropDependentRefinement)
16811683

16821684
/** Is `tp` a specialized, refined function type? Either an `ErasedFunction` or a `PolyFunction`. */
16831685
def isRefinedFunctionType(tp: Type)(using Context): Boolean =
16841686
(tp.typeSymbol eq defn.PolyFunctionClass) || isErasedFunctionType(tp)
16851687

1688+
/** Returns whether `tp` is an instance or a refined instance of:
1689+
* - scala.FunctionN
1690+
* - scala.ContextFunctionN
1691+
* - ErasedFunction
1692+
* - PolyFunction
1693+
*/
16861694
def isFunctionOrPolyType(tp: Type)(using Context): Boolean =
16871695
isFunctionType(tp) || isRefinedFunctionType(tp)
16881696

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

+1-4
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,10 @@ object NameOps {
225225
private def checkedFunArity(suffixStart: Int)(using Context): Int =
226226
if isFunctionPrefix(suffixStart) then funArity(suffixStart) else -1
227227

228-
/** Is a function name, i.e one of FunctionXXL, FunctionN, ContextFunctionN, ErasedFunctionN, ErasedContextFunctionN for N >= 0
228+
/** Is a function name, i.e one of FunctionXXL, FunctionN, ContextFunctionN, ImpureFunctionN, ImpureContextFunctionN for N >= 0
229229
*/
230230
def isFunction(using Context): Boolean =
231231
(name eq tpnme.FunctionXXL)
232-
|| (name eq tpnme.ErasedFunction)
233232
|| checkedFunArity(functionSuffixStart) >= 0
234233

235234
/** Is a function name
@@ -248,8 +247,6 @@ object NameOps {
248247
/** Is a synthetic function name, i.e. one of
249248
* - FunctionN for N > 22
250249
* - ContextFunctionN for N >= 0
251-
* - ErasedFunctionN for N >= 0
252-
* - ErasedContextFunctionN for N >= 0
253250
*/
254251
def isSyntheticFunction(using Context): Boolean =
255252
val suffixStart = functionSuffixStart

0 commit comments

Comments
 (0)