Skip to content

Commit ceeab65

Browse files
committed
Fix isPlainFunctionClass
Previous implementation is incorrect, as scala.Function1$ would qualify.
1 parent 3b8d05b commit ceeab65

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

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

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

11991199
/** Is a function class where
1200-
* - FunctionN for N >= 0
1200+
* - FunctionN for N >= 0 and N != XXL
12011201
*/
1202-
def isPlainFunctionClass(cls: Symbol) = scalaClassName(cls).isPlainFunction
1202+
def isPlainFunctionClass(cls: Symbol) = isVarArityClass(cls, str.Function)
12031203

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

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)