Observe some -Xlint recommendations#6806
Conversation
lrytz
left a comment
There was a problem hiding this comment.
I think we can remove unused code in general, the only exception I spotted is the check methods in ChampHashSet/Map, these probably make sense to keep in comments.
|
|
||
| def printWriter() = new PrintWriter(outputStream(), true) | ||
| def bufferedReader(implicit codec: Codec) = new BufferedReader(new InputStreamReader(inputStream())) | ||
| def bufferedReader(implicit codec: Codec) = new BufferedReader(new InputStreamReader(inputStream(), codec.decoder)) |
| }, | ||
| fork in run := true, | ||
| //scalacOptions += "-Xlint:-nullary-override,-by-name-right-associative,-inaccessible,_", | ||
| //scalacOptions ++= Seq("-Xmaxerrs", "5", "-Xmaxwarns", "5"), |
| val mods2 = toPreTyperModifiers(mods1, ddef.symbol) | ||
| ValDef(mods2, name1, tpt0, extractRhs(rhs0)) | ||
| } | ||
| */ |
There was a problem hiding this comment.
First, do no harm.
| val treeStrings = symMap(sym) map { t => | ||
| "%10s: %s".format(t.shortClass, t) | ||
| } | ||
| val treeStrings = symMap(sym).map(t => s"${t.shortClass}%10s: $t") |
There was a problem hiding this comment.
For a moment, I forgot the s interpolator. Luckily, -Xlint told me.
Actually, -Xlint complained about :+ on L182. Still need to follow up.
| in.bp = runtimeAnnotStart | ||
| val numAnnots = u2 | ||
| var i = 0 | ||
| val i = 0 |
There was a problem hiding this comment.
Not obvious whether it's a cut/paste bug.
There was a problem hiding this comment.
This is an oversight, i should be incremented in the loop. #6816
There was a problem hiding this comment.
You said you reverted it. Maybe you inverted it.
| // but for the rest of us pass in top as the expected type to avoid waste. | ||
| val pt = if (origTp <:< definitions.AnyTpe) definitions.AnyTpe else WildcardType | ||
| localTyper.typed(translated, definitions.AnyTpe) setType origTp | ||
| localTyper.typed(translated, pt) setType origTp |
There was a problem hiding this comment.
-Xlint would have told you that. -- Paul
| import infer._ | ||
|
|
||
| private def unit = context.unit | ||
| //private def unit = context.unit |
There was a problem hiding this comment.
can probably zap aliases.
| } | ||
|
|
||
| def typedTypeSelectionQualifier(tree: Tree, pt: Type = AnyRefTpe) = | ||
| def typedTypeSelectionQualifier(tree: Tree, pt: Type /*= AnyRefTpe*/) = |
There was a problem hiding this comment.
documentary default, removing unused default.
There was a problem hiding this comment.
Happy to have the default removed
There was a problem hiding this comment.
Made non-documentary.
|
|
||
| def typedSingletonTypeTree(tree: SingletonTypeTree) = { | ||
| val refTyped = typedTypeSelectionQualifier(tree.ref, WildcardType ) | ||
| val refTyped = typedTypeSelectionQualifier(tree.ref, WildcardType) |
There was a problem hiding this comment.
collateral whitespace change!
src/library/scala/Predef.scala
Outdated
| object <:< { | ||
| /** If `A <: B` and `B <: A`, then `A = B` (subtyping is antisymmetric) */ | ||
| def antisymm[A, B](implicit l: A <:< B, r: B <:< A): A =:= B = =:=.singleton.asInstanceOf[A =:= B] | ||
| def antisymm[A, B](implicit @deprecated("unused","shim") l: A <:< B, @deprecated("unused","shim") r: B <:< A): A =:= B = =:=.singleton.asInstanceOf[A =:= B] |
There was a problem hiding this comment.
Made a PR to ignore these cases.
| def mkRowBuilder() = ArrayBuilder.make[B](ClassTag[B](aClass.getComponentType)) | ||
| val bs = new ArrayOps(asArray(xs(0))).map((x: B) => mkRowBuilder()) | ||
| var j = 0 | ||
| //var j = 0 |
|
|
||
| /** A view that partitions an underlying collection into two views */ | ||
| @SerialVersionUID(3L) | ||
| //@SerialVersionUID(3L) |
There was a problem hiding this comment.
These warnings in the build should be resolved. Also, maybe the warning should sit behind a flag. -Xlint:serial? -Ywarn-serial? -Ywarn-srsly?
| */ | ||
| class Channel[A] { | ||
| class LinkedList[A] { | ||
| private class LinkedList { |
There was a problem hiding this comment.
we're all friends here.
| */ | ||
| @deprecated("use q\"new ${sym.toType}(..$args)\" instead", "2.10.1") | ||
| private[this] final val depstr_New = "use q\"new ${sym." + "toType}(..$args)\" instead" | ||
| @deprecated(depstr_New, "2.10.1") |
There was a problem hiding this comment.
implicitNotFound gets a pass, but actually all ordinary annotations? I think macros supplying constants would be OK.
| /* @group TypeTags */ | ||
| // This class only exists to silence MIMA complaining about a binary incompatibility. | ||
| // Only the top-level class (api.PredefTypeCreator) should be used. | ||
| @deprecated("This class only exists to silence MIMA complaining about a binary incompatibility.", since="forever") |
| super.prefixString | ||
| ) | ||
| // Suppressing case class copy method which risks subverting our single point of creation. | ||
| @deprecated("Suppressing case class copy method", since="forever") |
There was a problem hiding this comment.
also didn't work.
| // so we still see repeated parameter types (uncurry replaces them with Seq) | ||
| val isRepeated = origSym.info.paramss.flatten.map(sym => definitions.isRepeatedParamType(sym.tpe)) | ||
| val oldPs = newInfo.paramss.head | ||
| val _ = newInfo.paramss.head |
There was a problem hiding this comment.
wary of side effects, left it in.
| package reflect.io | ||
|
|
||
| import scala.reflect.internal.util.Statistics | ||
| //import scala.reflect.internal.util.Statistics |
There was a problem hiding this comment.
actually all that file is commented out.
| * Run with output muted both from ILoop and from the intp reporter. | ||
| */ | ||
| private def interpretPreamble = { | ||
| private def interpretPreamble() = { |
There was a problem hiding this comment.
left most "parens mean side effects" alone.
8957ad7 to
bb17366
Compare
|
Feedback is addressed. Hopefully will be merged before it fails to merge. |
| val REIFY_FREE_PREFIX: NameType = "free$" | ||
| val REIFY_FREE_THIS_SUFFIX: NameType = "$this" | ||
| val REIFY_FREE_VALUE_SUFFIX: NameType = "$value" | ||
| val REIFY_FREE_VALUE_SUFFIX: NameType = s"$$value" // looks like missing interpolator due to `value` in scopre |
There was a problem hiding this comment.
Unfortunately, StringContext name hides the interpolator. Ironic!
bb17366 to
49863d1
Compare
lrytz
left a comment
There was a problem hiding this comment.
Hopefully will be merged before it fails to merge.
😢
| in.bp = runtimeAnnotStart | ||
| val numAnnots = u2 | ||
| var i = 0 | ||
| val i = 0 |
There was a problem hiding this comment.
This is an oversight, i should be incremented in the loop. #6816
| } | ||
|
|
||
| def typedTypeSelectionQualifier(tree: Tree, pt: Type = AnyRefTpe) = | ||
| def typedTypeSelectionQualifier(tree: Tree, pt: Type /*= AnyRefTpe*/) = |
There was a problem hiding this comment.
Happy to have the default removed
| @@ -351,7 +358,7 @@ trait StdNames { | |||
| val MIRROR_UNTYPED: NameType = "$m$untyped" | |||
| val REIFY_FREE_PREFIX: NameType = "free$" | |||
| val REIFY_FREE_THIS_SUFFIX: NameType = "$this" | |||
There was a problem hiding this comment.
Sharp eyes! I'll wonder if this isPrivateLocal when I'm fully awake.
There was a problem hiding this comment.
I need a couple more days of sleep after the national election, then I'll wonder this. Or "$this".
| private class NameContext(s: String) { | ||
| def n(args: Any*): TermName = { require(args.isEmpty) ; createNameType("$" + s) } | ||
| } | ||
| private def StringContext(parts: String*) = { require(parts.size == 1) ; new NameContext(parts.head) } |
There was a problem hiding this comment.
The puzzler guy didn't like my one-liner StringContext puzzler. :( It was too improbable.
There was a problem hiding this comment.
For some reason, we aren't allowed to have fun things.
|
LGTM otherwise, let's merge quickly after the rebase. |
a2ddb96 to
a3f941e
Compare
The consequence of introducing `StringContext` is that you can't use it as one. Just rename it to something that says it's just a name.
A few `$name` happen to look like an interpolation of a value `name`. Avoid a lint warning by using an interpolator. To avoid the idiom for dollar literal, let the interpolator also add the dollar. Another day, another dollar. Also, name it the n-terpolator.
Not all unused things are removed outright.
a3f941e to
8911b4b
Compare
|
@lrytz Thanks for the review of tedious material. You make a PR better than it deserves to be! |
|
There are no plain strings. Added One could lint for format strings. Yesterday, in Java land, I added a private utility for the formatted message style my colleague prefers, Also the |
Not all unused things are removed outright.