Reputation: 5543
I am experimentin with Scala Macros, which are part of Scala 2.10, but as I try to compile (Using sbt) I get the following error:
[error] .../API.scala:9: not enough arguments for constructor OAuth:
(requestMethod: String, consumerSecret: String, consumerKey: String,
signatureMethod: String, version: String)jm.oauth.OAuth
[error] private val oauth = new OAuth(OAuth.POST, oauthConsumerSecret,
oauthConsumerKey, OAuth.HMAC_SHA1)
You can find the implementation of the OAuth
class here.
Is there any incompatibility between scala 2.10 and optional parameters?
The very same code, compiled with scala 2.9.1, worked perfectly.
Upvotes: 4
Views: 512
Reputation: 139038
If you create a file containing only this class definition:
class Optional(x: Int = 0)
Then compile it with Scala 2.9.2 and run javap
on the resulting class, you'll see this:
public class Optional implements scala.ScalaObject {
public static final int init$default$1();
public Optional(int);
}
Compile it again with 2.10.0-RC2 and javap
it, and you get this instead:
public class Optional {
public static int $lessinit$greater$default$1();
public Optional(int);
}
So no, default arguments are perfectly fine in 2.10, you've just run into a concrete example of the lack of binary compatibility between major Scala versions.
Upvotes: 7