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

Local function definitions can't be overloaded #2219

Closed
scabug opened this issue Jul 31, 2009 · 3 comments
Closed

Local function definitions can't be overloaded #2219

scabug opened this issue Jul 31, 2009 · 3 comments

Comments

@scabug
Copy link

scabug commented Jul 31, 2009

abstract class test {
    def f[U](u:U,p:Int) : U = u
    def g = {
        val n = 0
        def f(p:Int):Int = this.f(n,p)
        def f[U](u:U) = this.f(u,n)
        ()
    }
}

This fails to compile at def fU = this.f(u,n) with the error : method f is defined twice, even though the signatures are quite different and an overload should be detected.

@scabug
Copy link
Author

scabug commented Jul 31, 2009

Imported From: https://issues.scala-lang.org/browse/SI-2219?orig=1
Reporter: yves

@scabug
Copy link
Author

scabug commented Jul 31, 2009

@paulp said:
Only methods can be overloaded. The defs you are declaring inside a def are function objects and must have unique names.

@scabug
Copy link
Author

scabug commented Jul 31, 2009

yves said:
Couldn't the compiler generate these unique names for me so that I can still benefit from overloading in that situation ?

@scabug scabug closed this as completed May 18, 2011
@SethTisue SethTisue closed this as not planned Won't fix, can't repro, duplicate, stale May 2, 2024
@SethTisue SethTisue changed the title overload in method Local function definitions can't be overloaded May 2, 2024
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

2 participants