-
Notifications
You must be signed in to change notification settings - Fork 185
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
Make val field in implicit class private #542
Comments
I took a stab at this. Can't really test right now because of #547 but will do. I do have one question though : Why does |
Cool @LeonardMeyer ! I will try to take a look at #547 in the coming week. Primary constructors can be curried which are represented as @ show(q"class A(a: Int)(b: String)".ctor)
Ctor.Primary(
List(),
_,
List(
List(Term.Param(List(), Term.Name("a"), Some(Type.Name("Int")), None)),
List(Term.Param(List(), Term.Name("b"), Some(Type.Name("String")), None))
)
) |
I literally realized this right before coming back here 😄 By the way, even private won't help with something like this : class A(val str: String) {
def doubled: String = str + str
}
implicit class B(override val str: String) extends A(str)
"test".str //visible |
New ImplicitClassPrivateParams rule #542
Testing scalafix. Due to scala2/3 compatibilities, we cannot enable some common rules, but at least scalacenter/scalafix#542 worked
I just observed that the
val
field in an implicit class is accesible as an extension methodA workaround to prevent this is to make the field private
It would be nice to have a scalafix rule to automatically fix this.
Context: https://gitter.im/scala/contributors?at=5a4e57685355812e57502b5b
The text was updated successfully, but these errors were encountered: