Skip to content

Commit e623b15

Browse files
authored
Merge pull request #10015 from som-snytt/issue/evidence-pos
2 parents a051c92 + 6bda2f1 commit e623b15

File tree

5 files changed

+21
-13
lines changed

5 files changed

+21
-13
lines changed

src/compiler/scala/tools/nsc/ast/parser/Parsers.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2600,8 +2600,10 @@ self =>
26002600
contextBoundBuf += atPos(in.skipToken())(makeFunctionTypeTree(List(Ident(pname)), typ()))
26012601
}
26022602
while (in.token == COLON) {
2603-
contextBoundBuf += atPos(in.skipToken()) {
2604-
AppliedTypeTree(typ(), List(Ident(pname)))
2603+
in.nextToken()
2604+
val colonBound = typ()
2605+
contextBoundBuf += atPos(colonBound.pos) {
2606+
AppliedTypeTree(colonBound, List(Ident(pname)))
26052607
}
26062608
}
26072609
}

src/compiler/scala/tools/nsc/ast/parser/TreeBuilder.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,11 @@ abstract class TreeBuilder {
154154
if (contextBounds.isEmpty) vparamss
155155
else {
156156
val mods = Modifiers(if (owner.isTypeName) PARAMACCESSOR | LOCAL | PRIVATE else PARAM)
157-
def makeEvidenceParam(tpt: Tree) = ValDef(mods | IMPLICIT | SYNTHETIC, freshTermName(nme.EVIDENCE_PARAM_PREFIX), tpt, EmptyTree)
158-
val evidenceParams = contextBounds map makeEvidenceParam
157+
def makeEvidenceParam(tpt: Tree) = atPos(tpt.pos)(ValDef(mods | IMPLICIT | SYNTHETIC, freshTermName(nme.EVIDENCE_PARAM_PREFIX), tpt, EmptyTree))
158+
val evidenceParams = contextBounds.map(makeEvidenceParam)
159159

160-
val vparamssLast = if(vparamss.nonEmpty) vparamss.last else Nil
161-
if(vparamssLast.nonEmpty && vparamssLast.head.mods.hasFlag(IMPLICIT))
160+
val vparamssLast = if (vparamss.nonEmpty) vparamss.last else Nil
161+
if (vparamssLast.nonEmpty && vparamssLast.head.mods.hasFlag(IMPLICIT))
162162
vparamss.init ::: List(evidenceParams ::: vparamssLast)
163163
else
164164
vparamss ::: List(evidenceParams)

src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -751,8 +751,14 @@ trait TypeDiagnostics extends splain.SplainDiagnostics {
751751
&& !isImplementation(s.owner)
752752
&& !isConvention(s)
753753
)
754-
for (s <- unusedPrivates.unusedParams if warnable(s))
755-
emitUnusedWarning(s.pos, s"parameter $s in ${if (s.owner.isAnonymousFunction) "anonymous function" else s.owner} is never used", WarningCategory.UnusedParams, s)
754+
for (s <- unusedPrivates.unusedParams if warnable(s)) {
755+
val what =
756+
if (s.name.startsWith(nme.EVIDENCE_PARAM_PREFIX)) s"evidence parameter ${s.name} of type ${s.tpe}"
757+
else s"parameter ${s/*.name*/}"
758+
val where =
759+
if (s.owner.isAnonymousFunction) "anonymous function" else s.owner
760+
emitUnusedWarning(s.pos, s"$what in $where is never used", WarningCategory.UnusedParams, s)
761+
}
756762
}
757763
}
758764
def apply(unit: CompilationUnit): Unit = if (warningsEnabled && !unit.isJava && !typer.context.reporter.hasErrors) {

test/files/neg/classmanifests_new_deprecations.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
classmanifests_new_deprecations.scala:4: warning: type ClassManifest in package reflect is deprecated (since 2.10.0): use scala.reflect.ClassTag instead
22
def rcm1[T: scala.reflect.ClassManifest] = ???
3-
^
3+
^
44
classmanifests_new_deprecations.scala:5: warning: type ClassManifest in package reflect is deprecated (since 2.10.0): use scala.reflect.ClassTag instead
55
def rcm2[T](implicit evidence$1: scala.reflect.ClassManifest[T]) = ???
66
^

test/files/neg/warn-unused-params.check

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ warn-unused-params.scala:97: warning: parameter value i in anonymous function is
3131
warn-unused-params.scala:101: warning: parameter value ctx in method f is never used
3232
def f[A](implicit ctx: Context[A]) = answer
3333
^
34-
warn-unused-params.scala:102: warning: parameter value evidence$1 in method g is never used
34+
warn-unused-params.scala:102: warning: evidence parameter evidence$1 of type Context[A] in method g is never used
3535
def g[A: Context] = answer
36-
^
37-
warn-unused-params.scala:104: warning: parameter value evidence$2 in class Bound is never used
36+
^
37+
warn-unused-params.scala:104: warning: evidence parameter evidence$2 of type Context[A] in class Bound is never used
3838
class Bound[A: Context]
39-
^
39+
^
4040
error: No warnings can be incurred under -Werror.
4141
13 warnings
4242
1 error

0 commit comments

Comments
 (0)