diff options
author | Adriaan Moors <adriaan.moors@typesafe.com> | 2016-03-21 20:54:47 -0700 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@typesafe.com> | 2016-03-26 22:54:17 -0700 |
commit | 49d946d9039a6240765abd26375883875e5ff7e8 (patch) | |
tree | 571d95d5dee0c19510a31c2d59613a961539e46a /src/compiler/scala/tools/nsc/typechecker/Implicits.scala | |
parent | 2aa8eba5007f0e0eda3a2ef3fdffa1f468dc1fa4 (diff) | |
download | scala-49d946d9039a6240765abd26375883875e5ff7e8.tar.gz scala-49d946d9039a6240765abd26375883875e5ff7e8.tar.bz2 scala-49d946d9039a6240765abd26375883875e5ff7e8.zip |
Refactor flag juggling. Review feedback from Jason.
Sometimes booleans and a little duplication go a long way.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Implicits.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Implicits.scala | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala index 6412cc09f9..bee2ae8e99 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala @@ -49,11 +49,11 @@ trait Implicits { def inferImplicitByTypeSilent(pt: Type, context: Context, pos: Position = NoPosition): SearchResult = inferImplicit(EmptyTree, pt, reportAmbiguous = false, isView = false, context, saveAmbiguousDivergent = false, pos) - @deprecated("Unused in scalac") + @deprecated("Unused in scalac", "2.12.0-M4") def inferImplicit(tree: Tree, pt: Type, reportAmbiguous: Boolean, isView: Boolean, context: Context): SearchResult = inferImplicit(tree, pt, reportAmbiguous, isView, context, saveAmbiguousDivergent = true, tree.pos) - @deprecated("Unused in scalac") + @deprecated("Unused in scalac", "2.12.0-M4") def inferImplicit(tree: Tree, pt: Type, reportAmbiguous: Boolean, isView: Boolean, context: Context, saveAmbiguousDivergent: Boolean): SearchResult = inferImplicit(tree, pt, reportAmbiguous, isView, context, saveAmbiguousDivergent, tree.pos) @@ -111,12 +111,9 @@ trait Implicits { /** A friendly wrapper over inferImplicit to be used in macro contexts and toolboxes. */ def inferImplicit(tree: Tree, pt: Type, isView: Boolean, context: Context, silent: Boolean, withMacrosDisabled: Boolean, pos: Position, onError: (Position, String) => Unit): Tree = { - val result = - if (withMacrosDisabled) context.withMacrosDisabled { - inferImplicit(tree, pt, reportAmbiguous = true, isView = isView, context, saveAmbiguousDivergent = !silent, pos) - } else context.withMacrosEnabled { - inferImplicit(tree, pt, reportAmbiguous = true, isView = isView, context, saveAmbiguousDivergent = !silent, pos) - } + val result = context.withMacros(enabled = !withMacrosDisabled) { + inferImplicit(tree, pt, reportAmbiguous = true, isView = isView, context, saveAmbiguousDivergent = !silent, pos) + } if (result.isFailure && !silent) { val err = context.reporter.firstError |