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
Weird behavior with default arguments on traits when using FSC #5167
Comments
Imported From: https://issues.scala-lang.org/browse/SI-5167?orig=1
|
Pavel Fatin (pavel.fatin) said: |
Barry Kaplan (memelet1) said: trait SadTrait {
def buggyMethod(arg1: String, argWithDefault: String = "default") = ...
}
class SadClass extends SadTrait {
buggyMethod(arg1 = "foo")
} The error is: error: not found: value arg1
Error occurred in an application involving default arguments.
arg1 = Invoking the method without then named arg seems to work. |
Barry Kaplan (memelet1) said (edited on Feb 22, 2012 4:01:36 AM UTC): trait SadTrait {
def buggyMethod(arg1: String, argWithDefault: String = "default") = {
val arg1_alias = arg1
val argWithDefault_alias = argWithDefault
// then use those aliases ...
} |
@OlegYch said: trait a {
def notified(title: String, layout: Component, width: Int, height: Int)(implicit app: com.vaadin.Application) {}
def notified(title: String, layout: Component, width: Int, height: Int, action: () => Unit)(implicit app: com.vaadin.Application) {}
}
class b extends a {
notified("", new VerticalLayout, width = 380, height = 430, action = () => ())
} error: overloaded method value notified with alternatives:
(title: String,layout: com.vaadin.ui.Component,width$3: Int,height$3: Int,action$1: () => Unit)(implicit app$3: com.vaadin.Application)Unit <and>
(title: String,layout: com.vaadin.ui.Component,width: Int,height: Int)(implicit app: com.vaadin.Application)Unit
cannot be applied to (java.lang.String, vaadin.scala.VerticalLayout, width: Int, height: Int, action: () => Unit)
Error occurred in an application involving default arguments.
notified("", new VerticalLayout, width = 380, height = 430, action = () => ()) although it's really flaky, i tried to define a methods with same signatures but with a different name and wasn't able to reproduce |
@retronym said (edited on Jun 1, 2012 7:20:45 PM UTC): ~/code/scratch/20120601 JAVA_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5006" ~/code/scala/build/quick/bin/scalac -Xresident -classpath out -d out
Listening for transport dt_socket at address: 5006
nsc> t5167_1.scala
nsc> t5167_2.scala
t5167_2.scala:5: error: not enough arguments for method buggyMethod: (argWithDefault$1: String)Unit
SadObject.buggyMethod()
^
The type of the invoked method shows up as: (argWithDefault$1: String)Unit The symbol of the parameter of (qual, name, member(qual, name).owner, member(qual, name).info.params.head.owner.owner)
= (SadObject,buggyMethod,trait SadTrait,class SadTrait$class) It then tries and fails to find the default getter |
@som-snytt said: It's not flaky or hard to reproduce, so it seems assailable. I also have to catch up on the last few episodes of Fringe. |
@som-snytt said: |
@retronym said: TypeHistory(posterasure:3,(argWithDefault: String)Unit,TypeHistory(tailcalls:3,(argWithDefault: String)Unit,TypeHistory(namer:5,(argWithDefault$1: String)Unit,null))) |
@retronym said: private def implMethodDef(tree: Tree): Tree = (
implMethodMap get tree.symbol
map (impl => new ChangeOwnerAndReturnTraverser(tree.symbol, impl)(tree setSymbol impl))
getOrElse abort("implMethod missing for " + tree.symbol)
) |
@retronym said: https://github.com/retronym/scala/compare/ticket/5167 I haven't run the tests to see if it breaks anything else, yet. Open questions:
|
@retronym said: |
@retronym said:
That wasn't accurate: |
Okay, this is a weird one. I suspect it's a bug against FSC, but honestly it could be the IntelliJ Scala plugin's fault; I just don't know.
In one file, in src:
In another file, in test:
With FSC disabled, this compiles fine. With FSC on, this complains:
This appears to be a minimal repro to me; the problem goes away if:
Fortunately, the fourth bullet point is a pretty general workaround for this problem, so I'm not blocked on it... but weird, right?
The text was updated successfully, but these errors were encountered: