-
Notifications
You must be signed in to change notification settings - Fork 21
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
Dynamic calls get broken by completely unrelated uses of vararg wildcard calls #7420
Comments
Imported From: https://issues.scala-lang.org/browse/SI-7420?orig=1 |
@xeno-by said: Since the entire typer context business is very brittle, I have hard time coming up with an immediate fix here. In the meanwhile, something that might work as a workaround is refactoring the code a bit, so that contexts line up correctly. E.g. writing |
Kazuhiro Sera (seratch) said: |
Otto Chrons (ochrons) said (edited on Aug 9, 2016 8:40:47 PM UTC): editor.xyz = "" // this fails, because of the :_* later
editor.completers = js.Array(JsVal.obj(
"getCompletions" -> { (editor: Dyn, session: Dyn, pos: Dyn, prefix: Dyn, callback: Dyn) => {
Future.successful(Seq(("hauki", "kala"))).map {
_.map { case (name, value) =>
JsVal.obj(
"value" -> value,
"caption" -> (value + name)
).value
}
}.foreach { things => callback(null, js.Array(things: _*)) }
}
}
).value) |
@paulp said: import scala.language.dynamics
class ArtifactGroup(org: String, pre: String, rev: String) extends scala.Dynamic {
def selectDynamic(name: String) = s"$org:$pre-$name:$rev"
}
object Test {
object scalaz extends ArtifactGroup("org.scalaz", "scalaz", "7.2.4")
/* ok */ def f = Seq(scalaz.core, scalaz.effect)
/* ok */ def g = Seq(f: _*)
/* fail */ def h = Seq(Seq(scalaz.core, scalaz.effect): _*)
// a.scala:12: error: applyDynamic does not support passing a vararg parameter
// def h = Seq(Seq(scalaz.core, scalaz.effect): _*)
// ^
} |
When searching the context for the tree in question, make sure to actually check that the tree under scrutiny matches the one we're looking for. This means that the check for varargs won't give a false positive if the context is too large. Fixes scala/bug#7420. Adjust the "vararg not supported" error so it doesn't hide other errors.
Take this simple piece of code which works fine:
Uncommenting the line with the wildcard vararg call (no matter if it occurs before or after the otherwise working selectDynamic call) makes it fail with the following error:
The text was updated successfully, but these errors were encountered: