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 fix :remove unsed #914

Closed
He-Pin opened this issue Dec 1, 2018 · 9 comments · Fixed by #1978
Closed

error fix :remove unsed #914

He-Pin opened this issue Dec 1, 2018 · 9 comments · Fixed by #1978

Comments

@He-Pin
Copy link

He-Pin commented Dec 1, 2018

before :

    private var upstreamFailed: OptionVal[Throwable] = OptionVal.None

after

    OptionVal.None

source :akka.stream.impl.fusing.ActorGraphInterpreter.ActorOutputBoundary

@He-Pin
Copy link
Author

He-Pin commented Dec 1, 2018

image

@marcelocenerine
Copy link
Contributor

marcelocenerine commented Dec 2, 2018

@hepin1989, looks like this behavior is intentional (see tests: input / output). The reason is that the the LHS RHS of a val/var definition may contain side effects. Thus, removing the entire line could change the behavior of the program. However, if the LHS RHS is a literal, then the rule does remove the entire thing.

@He-Pin
Copy link
Author

He-Pin commented Dec 2, 2018

@marcelocenerine after you removed that ,Akka did not compile:)

@olafurpg
Copy link
Contributor

olafurpg commented Dec 2, 2018

@hepin1989 what is the resulting compile error?

We can probably remove the right-hand side if it only references vals. We can try to reproduce what the compiler does

@marcelocenerine
Copy link
Contributor

sorry, I meant RHS in my previous comment.

@marcelocenerine
Copy link
Contributor

The following causes a compiler error:

  • Input:
  private val opt: Option[String] = None
  private val num: Integer = { println("foo"); 1 }
  • Output:
  None
  { println("foo"); 1 }
None.type does not take parameters
[error]   { println("foo"); 1 }
[error]   ^

@olafurpg
Copy link
Contributor

olafurpg commented Dec 2, 2018

Aah yes :) that is a good test case! Thank you @marcelocenerine

@He-Pin
Copy link
Author

He-Pin commented Dec 2, 2018

@olafurpg could not find the symbol.

@He-Pin
Copy link
Author

He-Pin commented Dec 2, 2018

@olafurpg I only make use of scalafix for remove the unused import now.the problem presents when I use the default settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants