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

Error caused for generic apply calling #1785

Closed
scabug opened this issue Mar 11, 2009 · 5 comments

Comments

@scabug
Copy link

commented Mar 11, 2009

I cannot call generic apply call for new instances. But according to spec it must run well:

class A {
  def apply[T](x: Int) = 1
}

(new A)[Int](1)
@scabug

This comment has been minimized.

Copy link
Author

commented Mar 11, 2009

@scabug

This comment has been minimized.

Copy link
Author

commented Mar 11, 2009

@ingoem said:
In the future, please be more verbose about where you think the problem is exactly.

@scabug

This comment has been minimized.

Copy link
Author

commented Mar 11, 2009

@paulp said:
Presumably he thinks "(new A)Int" ought to say "res0: 1" instead of ":1: error: ';' expected but '[' found."

I agree in principle, and trunk already has several fixes allowing for apply methods to be called more flexibly, for instance this doesn't work in 2.7.3:

scala> def foo(x: Int, y: Int) = x + y
foo: (Int,Int)Int

scala> (foo _)(5, 10)
res0: Int = 15

However this would represent a rather more significant change to the parser and I'm not really convinced it's a good idea given that it works if you let the type argument be inferred or if you call apply explicitly.

scala> (new A)(1)
res0: Int = 1

scala> (new A).apply[Int](1)
res1: Int = 1

So I recategorized to enhancement.

@scabug

This comment has been minimized.

Copy link
Author

commented May 5, 2012

@scabug

This comment has been minimized.

Copy link
Author

commented May 6, 2012

@scabug scabug closed this May 6, 2012

@scabug scabug added the enhancement label Apr 6, 2017

@scabug scabug added this to the 2.10.0-M3 milestone Apr 6, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.