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
Closed

Error caused for generic apply calling #1785

scabug opened this issue Mar 11, 2009 · 5 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug 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
Copy link
Author

scabug commented Mar 11, 2009

Imported From: https://issues.scala-lang.org/browse/SI-1785?orig=1
Reporter: @Alefas

@scabug
Copy link
Author

scabug commented Mar 11, 2009

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

@scabug
Copy link
Author

scabug 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
Copy link
Author

scabug commented May 5, 2012

@retronym said:
scala/scala#477

@scabug
Copy link
Author

scabug commented May 6, 2012

@retronym said:
scala/scala@74be136

@scabug scabug closed this as completed May 6, 2012
@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
Development

No branches or pull requests

2 participants