Skip to content

Commit f7c00e6

Browse files
committed
Fix isPlainFunctionClass
Previous implementation is incorrect, as scala.Function1$ would qualify.
1 parent 189c331 commit f7c00e6

File tree

3 files changed

+6
-11
lines changed

3 files changed

+6
-11
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,9 +1198,9 @@ class Definitions {
11981198
def isFunctionClass(cls: Symbol): Boolean = scalaClassName(cls).isFunction
11991199

12001200
/** Is a function class where
1201-
* - FunctionN for N >= 0
1201+
* - FunctionN for N >= 0 and N != XXL
12021202
*/
1203-
def isPlainFunctionClass(cls: Symbol) = scalaClassName(cls).isPlainFunction
1203+
def isPlainFunctionClass(cls: Symbol) = isVarArityClass(cls, str.Function)
12041204

12051205
/** Is an context function class.
12061206
* - ContextFunctionN for N >= 0

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,6 @@ object NameOps {
182182
*/
183183
def isFunction: Boolean = (name eq tpnme.FunctionXXL) || functionArity >= 0
184184

185-
/** Is a function name
186-
* - FunctionN for N >= 0
187-
*/
188-
def isPlainFunction: Boolean = functionArityFor(str.Function) >= 0
189-
190185
/** Is an context function name, i.e one of ContextFunctionN for N >= 0 or ErasedContextFunctionN for N > 0
191186
*/
192187
def isContextFunction: Boolean =

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class SpecializedApplyMethods extends MiniPhase with InfoTransformer {
2222

2323
val phaseName = "specializedApplyMethods"
2424

25-
private def specApply(sym: Symbol, args: List[Type], ret: Type)(using Context): Symbol = {
25+
private def specApplySymbol(sym: Symbol, args: List[Type], ret: Type)(using Context): Symbol = {
2626
val name = nme.apply.specializedFunction(ret, args)
2727
newSymbol(sym, name, Flags.Method, MethodType(args, ret))
2828
}
@@ -55,17 +55,17 @@ class SpecializedApplyMethods extends MiniPhase with InfoTransformer {
5555
sym.name.functionArity match {
5656
case 0 =>
5757
val scope = tp.decls.cloneScope
58-
specFun0 { r => scope.enter(specApply(sym, Nil, r)) }
58+
specFun0 { r => scope.enter(specApplySymbol(sym, Nil, r)) }
5959
tp.derivedClassInfo(decls = scope)
6060

6161
case 1 =>
6262
val scope = tp.decls.cloneScope
63-
specFun1 { (t1, r) => scope.enter(specApply(sym, List(t1), r)) }
63+
specFun1 { (t1, r) => scope.enter(specApplySymbol(sym, List(t1), r)) }
6464
tp.derivedClassInfo(decls = scope)
6565

6666
case 2 =>
6767
val scope = tp.decls.cloneScope
68-
specFun2 { (t1, t2, r) => scope.enter(specApply(sym, List(t1, t2), r)) }
68+
specFun2 { (t1, t2, r) => scope.enter(specApplySymbol(sym, List(t1, t2), r)) }
6969
tp.derivedClassInfo(decls = scope)
7070

7171
case _ =>

0 commit comments

Comments
 (0)