File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
compiler/src/dotty/tools/dotc/transform Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ class SpecializeFunctions extends MiniPhase {
67
67
/** Dispatch to specialized `apply`s in user code when available */
68
68
override def transformApply (tree : Apply )(using Context ) =
69
69
tree match {
70
- case Apply (fun : NameTree , args) if fun.name == nme.apply && args.size <= 3 =>
70
+ case Apply (fun : NameTree , args) if fun.name == nme.apply && args.size <= 3 && fun.symbol.owner.isType =>
71
71
val argTypes = fun.tpe.widen.firstParamTypes.map(_.widenSingleton.dealias)
72
72
val retType = tree.tpe.widenSingleton.dealias
73
73
val isSpecializable =
Original file line number Diff line number Diff line change
1
+ object Main {
2
+ def main (args : Array [String ]): Unit = {
3
+ def apply (a : Int , b : Int ): Unit = {}
4
+ apply(1 , 2 )
5
+
6
+ // The following will work:
7
+ def f (a : Int , b : Int ): Unit = {}
8
+ f(1 , 2 )
9
+ }
10
+
11
+ def foo () = {
12
+ // The following will not work either:
13
+ def `apply` (a : Int ): Unit = {}
14
+ `apply`(1 )
15
+ }
16
+ }
You can’t perform that action at this time.
0 commit comments