Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typedFunction checks arity before SAM conversion #10778

Open
hrhino opened this issue Mar 14, 2018 · 0 comments
Open

typedFunction checks arity before SAM conversion #10778

hrhino opened this issue Mar 14, 2018 · 0 comments

Comments

@hrhino
Copy link
Member

hrhino commented Mar 14, 2018

scala> trait MassiveFn { def apply(a:Int,b:Int,c:Int,d:Int,e:Int,f:Int,g:Int,h:Int,i:Int,j:Int,k:Int,l:Int,m:Int,n:Int,o:Int,p:Int,q:Int,r:Int,s:Int,t:Int,u:Int,v:Int,w:Int,x:Int,y:Int,z:Int): Int }
defined trait MassiveFn

scala> val x : MassiveFn = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z) => 1
<console>:12: error: implementation restricts functions to 22 parameters
       val x : MassiveFn = (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z) => 1
                                                                                 ^

The implementation restriction should be that you can't make scala.FunctionN for N > 22, but if you have a SAM with enough parameters you should be fine.

Ditto for eta expansion:

scala> trait MassiveFn { def apply(a:Int,b:Int,c:Int,d:Int,e:Int,f:Int,g:Int,h:Int,i:Int,j:Int,k:Int,l:Int,m:Int,n:Int,o:Int,p:Int,q:Int,r:Int,s:Int,t:Int,u:Int,v:Int,w:Int,x:Int,y:Int,z:Int): Int }
defined trait MassiveFn

scala> def massiveMethod(a:Int,b:Int,c:Int,d:Int,e:Int,f:Int,g:Int,h:Int,i:Int,j:Int,k:Int,l:Int,m:Int,n:Int,o:Int,p:Int,q:Int,r:Int,s:Int,t:Int,u:Int,v:Int,w:Int,x:Int,y:Int,z:Int): Int = 1
massiveMethod: (a: Int, b: Int, c: Int, d: Int, e: Int, f: Int, g: Int, h: Int, i: Int, j: Int, k: Int, l: Int, m: Int, n: Int, o: Int, p: Int, q: Int, r: Int, s: Int, t: Int, u: Int, v: Int, w: Int, x: Int, y: Int, z: Int)Int

scala> massiveMethod _ : MassiveFn
<console>:14: error: implementation restricts functions to 22 parameters
       massiveMethod _ : MassiveFn
       ^
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant