diff options
author | Som Snytt <som.snytt@gmail.com> | 2016-12-08 14:45:40 -0800 |
---|---|---|
committer | Som Snytt <som.snytt@gmail.com> | 2016-12-14 12:34:01 -0800 |
commit | 32a05ddfef09ac27904d9771ddf0ed8b4380e94a (patch) | |
tree | 35a63415709e8006e18289924d2c6a400e1fce83 /src/compiler/scala/tools/nsc/ast/parser/Parsers.scala | |
parent | ca7bbcfb178c5a0c697a3cdd543e38f37b79f737 (diff) | |
download | scala-32a05ddfef09ac27904d9771ddf0ed8b4380e94a.tar.gz scala-32a05ddfef09ac27904d9771ddf0ed8b4380e94a.tar.bz2 scala-32a05ddfef09ac27904d9771ddf0ed8b4380e94a.zip |
SI-8704 Also warn if effectively multiple implicit
Current semantics are that leading implicit param
turns the parameter section into an implicit section
(though without making other params implicitly
implicit).
Warn if more than one head of a param section is
implicit, since that results in multiple implicit
param sections.
Diffstat (limited to 'src/compiler/scala/tools/nsc/ast/parser/Parsers.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/parser/Parsers.scala | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index 45c177f5b9..440e45c577 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -2272,6 +2272,12 @@ self => syntaxError(implicitOffset, "an implicit parameter section must be last") if (warnAt != -1) syntaxError(warnAt, "multiple implicit parameter sections are not allowed") + else if (settings.warnExtraImplicit) { + // guard against anomalous class C(private implicit val x: Int)(implicit s: String) + val ttl = vds.count { case ValDef(mods, _, _, _) :: _ => mods.isImplicit ; case _ => false } + if (ttl > 1) + warning(in.offset, s"$ttl parameter sections are effectively implicit") + } val result = vds.toList if (owner == nme.CONSTRUCTOR && (result.isEmpty || (result.head take 1 exists (_.mods.isImplicit)))) { in.token match { |