diff options
author | Martin Odersky <odersky@gmail.com> | 2015-02-28 11:55:14 +0100 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2015-03-18 11:14:12 +0100 |
commit | dd5be327395cb4a6380467e5e7c85cc0d7a5e70d (patch) | |
tree | 6b47afc03c39440a05e28b58b5c12e3614649cfb /src | |
parent | 42333cebbb7329a4488b7ebe1896ff2a723f4cb2 (diff) | |
download | dotty-dd5be327395cb4a6380467e5e7c85cc0d7a5e70d.tar.gz dotty-dd5be327395cb4a6380467e5e7c85cc0d7a5e70d.tar.bz2 dotty-dd5be327395cb4a6380467e5e7c85cc0d7a5e70d.zip |
Fix implicit problem in RefinedPrinter.
The implicit def was shadowed by a following import. Scalac did not detect the problem probably because
the import and the def were in the same scope. But selecting the member explicitly would have caused an error
because the import came after the definition. So arguably this was in error, but scalac did not detect
it correctly.
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/printing/RefinedPrinter.scala | 10 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Implicits.scala | 2 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/src/dotty/tools/dotc/printing/RefinedPrinter.scala index a420f900c..286bcccfa 100644 --- a/src/dotty/tools/dotc/printing/RefinedPrinter.scala +++ b/src/dotty/tools/dotc/printing/RefinedPrinter.scala @@ -147,10 +147,6 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { override def toText[T >: Untyped](tree: Tree[T]): Text = controlled { - /** Print modifiers form symbols if tree has type, overriding the untpd behavior. */ - implicit def modsDeco(mdef: MemberDef[_]): tpd.ModsDeco = - tpd.modsDeco(mdef.asInstanceOf[tpd.MemberDef]) - def optDotPrefix(name: Name) = optText(name)(_ ~ ".") def optAscription(tpt: untpd.Tree) = optText(tpt)(": " ~ _) @@ -218,7 +214,11 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { def nameIdText(tree: untpd.NameTree): Text = toText(tree.name) ~ idText(tree) - import untpd._ + import untpd.{modsDeco => _, _} + + /** Print modifiers form symbols if tree has type, overriding the untpd behavior. */ + implicit def modsDeco(mdef: untpd.MemberDef)(implicit ctx: Context): untpd.ModsDeco = + tpd.modsDeco(mdef.asInstanceOf[tpd.MemberDef]).asInstanceOf[untpd.ModsDeco] var txt: Text = tree match { case id: Trees.BackquotedIdent[_] => diff --git a/src/dotty/tools/dotc/typer/Implicits.scala b/src/dotty/tools/dotc/typer/Implicits.scala index 53968ae91..23938ea99 100644 --- a/src/dotty/tools/dotc/typer/Implicits.scala +++ b/src/dotty/tools/dotc/typer/Implicits.scala @@ -501,7 +501,7 @@ trait Implicits { self: Typer => if (ctx.typerState.reporter.hasErrors) nonMatchingImplicit(ref) else if (contextual && !shadowing.tpe.isError && !refMatches(shadowing)) { - implicits.println(i"SHADOWING $ref is shadowed by $shadowing") + implicits.println(i"SHADOWING $ref in ${ref.termSymbol.owner} is shadowed by $shadowing in ${shadowing.symbol.owner}") shadowedImplicit(ref, methPart(shadowing).tpe) } else |