diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2013-02-24 14:44:57 +0100 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2013-03-05 09:39:30 -0800 |
commit | fff0f50773b45690d571852b139bd6da7b6a45ae (patch) | |
tree | 9f53db9730fe2d07167e817d0692c3f53f483275 /src/compiler/scala/tools/nsc/typechecker | |
parent | c4341385629bd114b61c55103f1d83f26dce22f9 (diff) | |
download | scala-fff0f50773b45690d571852b139bd6da7b6a45ae.tar.gz scala-fff0f50773b45690d571852b139bd6da7b6a45ae.tar.bz2 scala-fff0f50773b45690d571852b139bd6da7b6a45ae.zip |
Name boolean arguments in src/compiler.
What would you prefer?
adaptToMemberWithArgs(tree, qual, name, mode, false, false)
Or:
adaptToMemberWithArgs(tree, qual, name, mode, reportAmbiguous = false, saveErrors = false)
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker')
9 files changed, 43 insertions, 43 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala index 3e5a61c673..429bd7d682 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala @@ -85,8 +85,8 @@ trait Contexts { self: Analyzer => else RootImports.completeList } - def rootContext(unit: CompilationUnit): Context = rootContext(unit, EmptyTree, false) - def rootContext(unit: CompilationUnit, tree: Tree): Context = rootContext(unit, tree, false) + def rootContext(unit: CompilationUnit): Context = rootContext(unit, EmptyTree, erasedTypes = false) + def rootContext(unit: CompilationUnit, tree: Tree): Context = rootContext(unit, tree, erasedTypes = false) def rootContext(unit: CompilationUnit, tree: Tree, erasedTypes: Boolean): Context = { var sc = startContext for (sym <- rootImports(unit)) { @@ -443,7 +443,7 @@ trait Contexts { self: Analyzer => else throw new TypeError(pos, msg1) } - def warning(pos: Position, msg: String): Unit = warning(pos, msg, false) + def warning(pos: Position, msg: String): Unit = warning(pos, msg, force = false) def warning(pos: Position, msg: String, force: Boolean) { if (reportErrors || force) unit.warning(pos, msg) else if (bufferErrors) warningsBuffer += ((pos, msg)) diff --git a/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala b/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala index 4fbb788c7b..80dfef6c7b 100644 --- a/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala +++ b/src/compiler/scala/tools/nsc/typechecker/EtaExpansion.scala @@ -98,7 +98,7 @@ trait EtaExpansion { self: Analyzer => case TypeApply(fn, args) => treeCopy.TypeApply(tree, liftoutPrefix(fn), args).clearType() case Select(qual, name) => - treeCopy.Select(tree, liftout(qual, false), name).clearType() setSymbol NoSymbol + treeCopy.Select(tree, liftout(qual, byName = false), name).clearType() setSymbol NoSymbol case Ident(name) => tree } diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala index b4ec90c53e..2331f82a58 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala @@ -34,7 +34,7 @@ trait Implicits { import global.typer.{ printTyping, deindentTyping, indentTyping, printInference } def inferImplicit(tree: Tree, pt: Type, reportAmbiguous: Boolean, isView: Boolean, context: Context): SearchResult = - inferImplicit(tree, pt, reportAmbiguous, isView, context, true, tree.pos) + inferImplicit(tree, pt, reportAmbiguous, isView, context, saveAmbiguousDivergent = true, tree.pos) def inferImplicit(tree: Tree, pt: Type, reportAmbiguous: Boolean, isView: Boolean, context: Context, saveAmbiguousDivergent: Boolean): SearchResult = inferImplicit(tree, pt, reportAmbiguous, isView, context, saveAmbiguousDivergent, tree.pos) @@ -112,7 +112,7 @@ trait Implicits { val tvars = tpars map (TypeVar untouchable _) val tpSubsted = tp.subst(tpars, tvars) - val search = new ImplicitSearch(EmptyTree, functionType(List(tpSubsted), AnyClass.tpe), true, context.makeImplicit(false)) + val search = new ImplicitSearch(EmptyTree, functionType(List(tpSubsted), AnyClass.tpe), true, context.makeImplicit(reportAmbiguousErrors = false)) search.allImplicitsPoly(tvars) } @@ -630,7 +630,7 @@ trait Implicits { printTyping(ptLine("" + info.sym, "tvars" -> tvars, "tvars.constr" -> tvars.map(_.constr))) val targs = solvedTypes(tvars, undetParams, undetParams map varianceInType(pt), - false, lubDepth(List(itree2.tpe, pt))) + upper = false, lubDepth(List(itree2.tpe, pt))) // #2421: check that we correctly instantiated type parameters outside of the implicit tree: checkBounds(itree2, NoPrefix, NoSymbol, undetParams, targs, "inferred ") @@ -1154,7 +1154,7 @@ trait Implicits { /** Re-wraps a type in a manifest before calling inferImplicit on the result */ def findManifest(tp: Type, manifestClass: Symbol = if (full) FullManifestClass else PartialManifestClass) = - inferImplicit(tree, appliedType(manifestClass, tp), true, false, context).tree + inferImplicit(tree, appliedType(manifestClass, tp), reportAmbiguous = true, isView = false, context).tree def findSubManifest(tp: Type) = findManifest(tp, if (full) FullManifestClass else OptManifestClass) def mot(tp0: Type, from: List[Symbol], to: List[Type]): SearchResult = { @@ -1289,7 +1289,7 @@ trait Implicits { val failstart = if (Statistics.canEnable) Statistics.startTimer(inscopeFailNanos) else null val succstart = if (Statistics.canEnable) Statistics.startTimer(inscopeSucceedNanos) else null - var result = searchImplicit(context.implicitss, true) + var result = searchImplicit(context.implicitss, isLocal = true) if (result.isFailure) { if (Statistics.canEnable) Statistics.stopTimer(inscopeFailNanos, failstart) @@ -1307,7 +1307,7 @@ trait Implicits { // `materializeImplicit` does some preprocessing for `pt` // is it only meant for manifests/tags or we need to do the same for `implicitsOfExpectedType`? - if (result.isFailure && !wasAmbigious) result = searchImplicit(implicitsOfExpectedType, false) + if (result.isFailure && !wasAmbigious) result = searchImplicit(implicitsOfExpectedType, isLocal = false) if (result.isFailure) { context.updateBuffer(previousErrs) @@ -1326,7 +1326,7 @@ trait Implicits { def allImplicits: List[SearchResult] = { def search(iss: Infoss, isLocal: Boolean) = applicableInfos(iss, isLocal).values - (search(context.implicitss, true) ++ search(implicitsOfExpectedType, false)).toList.filter(_.tree ne EmptyTree) + (search(context.implicitss, isLocal = true) ++ search(implicitsOfExpectedType, isLocal = false)).toList.filter(_.tree ne EmptyTree) } // find all implicits for some type that contains type variables diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala index a29cc93b6d..d4f402b747 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala @@ -491,7 +491,7 @@ trait Infer extends Checkable { } //println("try to solve "+tvars+" "+tparams) (solvedTypes(tvars, tparams, tparams map varianceInType(varianceType), - false, lubDepth(List(restpe, pt))), tvars) + upper = false, lubDepth(List(restpe, pt))), tvars) } catch { case ex: NoInstance => (null, null) } @@ -667,7 +667,7 @@ trait Infer extends Checkable { } val targs = solvedTypes( tvars, tparams, tparams map varianceInTypes(formals), - false, lubDepth(formals) max lubDepth(argtpes) + upper = false, lubDepth(formals) max lubDepth(argtpes) ) // Can warn about inferring Any/AnyVal as long as they don't appear // explicitly anywhere amongst the formal, argument, result, or expected type. @@ -914,7 +914,7 @@ trait Infer extends Checkable { */ private[typechecker] def isApplicableSafe(undetparams: List[Symbol], ftpe: Type, argtpes0: List[Type], pt: Type): Boolean = { - val silentContext = context.makeSilent(false) + val silentContext = context.makeSilent(reportAmbiguousErrors = false) val typer0 = newTyper(silentContext) val res1 = typer0.infer.isApplicable(undetparams, ftpe, argtpes0, pt) if (pt != WildcardType && silentContext.hasErrors) { @@ -1101,7 +1101,7 @@ trait Infer extends Checkable { } def checkKindBounds(tparams: List[Symbol], targs: List[Type], pre: Type, owner: Symbol): List[String] = { - checkKindBounds0(tparams, targs, pre, owner, true) map { + checkKindBounds0(tparams, targs, pre, owner, explainErrors = true) map { case (targ, tparam, kindErrors) => kindErrors.errorMessage(targ, tparam) } @@ -1263,7 +1263,7 @@ trait Infer extends Checkable { val variances = if (ctorTp.paramTypes.isEmpty) undetparams map varianceInType(ctorTp) else undetparams map varianceInTypes(ctorTp.paramTypes) - val targs = solvedTypes(tvars, undetparams, variances, true, lubDepth(List(resTp, pt))) + val targs = solvedTypes(tvars, undetparams, variances, upper = true, lubDepth(List(resTp, pt))) // checkBounds(tree, NoPrefix, NoSymbol, undetparams, targs, "inferred ") // no checkBounds here. If we enable it, test bug602 fails. // TODO: reinstate checkBounds, return params that fail to meet their bounds to undetparams @@ -1335,7 +1335,7 @@ trait Infer extends Checkable { val tvars1 = tvars map (_.cloneInternal) // Note: right now it's not clear that solving is complete, or how it can be made complete! // So we should come back to this and investigate. - solve(tvars1, tvars1 map (_.origin.typeSymbol), tvars1 map (_ => Variance.Covariant), false) + solve(tvars1, tvars1 map (_.origin.typeSymbol), tvars1 map (_ => Variance.Covariant), upper = false) } // this is quite nasty: it destructively changes the info of the syms of e.g., method type params diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index 3c5e484105..a1bf3a56c3 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -502,7 +502,7 @@ trait Namers extends MethodSynthesis { typer.permanentlyHiddenWarning(pos, to0, e.sym) else if (context ne context.enclClass) { val defSym = context.prefix.member(to) filter ( - sym => sym.exists && context.isAccessible(sym, context.prefix, false)) + sym => sym.exists && context.isAccessible(sym, context.prefix, superAccess = false)) defSym andAlso (typer.permanentlyHiddenWarning(pos, to0, _)) } diff --git a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala index d8cedd119b..1d28add6e0 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SuperAccessors.scala @@ -224,7 +224,7 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT transformTemplate case TypeApply(sel @ Select(This(_), name), args) => - mayNeedProtectedAccessor(sel, args, false) + mayNeedProtectedAccessor(sel, args, goToSuper = false) // set a flag for all type parameters with `@specialized` annotation so it can be pickled case typeDef: TypeDef if typeDef.symbol.deSkolemize.hasAnnotation(definitions.SpecializedClass) => @@ -274,7 +274,7 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT Select(Super(qual, tpnme.EMPTY) setPos qual.pos, sym.alias) }).asInstanceOf[Select] debuglog("alias replacement: " + tree + " ==> " + result); //debug - localTyper.typed(gen.maybeMkAsInstanceOf(transformSuperSelect(result), sym.tpe, sym.alias.tpe, true)) + localTyper.typed(gen.maybeMkAsInstanceOf(transformSuperSelect(result), sym.tpe, sym.alias.tpe, beforeRefChecks = true)) } else { /** * A trait which extends a class and accesses a protected member @@ -302,7 +302,7 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT ensureAccessor(sel) } else - mayNeedProtectedAccessor(sel, EmptyTree.asList, false) + mayNeedProtectedAccessor(sel, EmptyTree.asList, goToSuper = false) } case Super(_, mix) => @@ -315,7 +315,7 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT transformSuperSelect(sel) case _ => - mayNeedProtectedAccessor(sel, EmptyTree.asList, true) + mayNeedProtectedAccessor(sel, EmptyTree.asList, goToSuper = true) } } transformSelect @@ -324,7 +324,7 @@ abstract class SuperAccessors extends transform.Transform with transform.TypingT treeCopy.DefDef(tree, mods, name, tparams, vparamss, tpt, withInvalidOwner(transform(rhs))) case TypeApply(sel @ Select(qual, name), args) => - mayNeedProtectedAccessor(sel, args, true) + mayNeedProtectedAccessor(sel, args, goToSuper = true) case Assign(lhs @ Select(qual, name), rhs) => def transformAssign = { diff --git a/src/compiler/scala/tools/nsc/typechecker/Tags.scala b/src/compiler/scala/tools/nsc/typechecker/Tags.scala index 45aa1bcbdb..d2d7f57aef 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Tags.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Tags.scala @@ -15,11 +15,11 @@ trait Tags { wrapper(inferImplicit( EmptyTree, taggedTp, - /*reportAmbiguous =*/ true, - /*isView =*/ false, - /*context =*/ context, - /*saveAmbiguousDivergent =*/ true, - /*pos =*/ pos + reportAmbiguous = true, + isView = false, + context, + saveAmbiguousDivergent = true, + pos ).tree) } diff --git a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala index 98c5e31ffe..46740cd03c 100644 --- a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala +++ b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala @@ -236,8 +236,8 @@ trait TypeDiagnostics { val invariant = param.variance.isInvariant if (conforms) Some("") - else if ((arg <:< reqArg) && invariant) mkMsg(true) // covariant relationship - else if ((reqArg <:< arg) && invariant) mkMsg(false) // contravariant relationship + else if ((arg <:< reqArg) && invariant) mkMsg(isSubtype = true) // covariant relationship + else if ((reqArg <:< arg) && invariant) mkMsg(isSubtype = false) // contravariant relationship else None // we assume in other cases our ham-fisted advice will merely serve to confuse } val messages = relationships.flatten @@ -546,7 +546,7 @@ trait TypeDiagnostics { // It is presumed if you are using a -Y option you would really like to hear // the warnings you've requested. if (settings.warnDeadCode.value && context.unit.exists && treeOK(tree) && exprOK) - context.warning(tree.pos, "dead code following this construct", true) + context.warning(tree.pos, "dead code following this construct", force = true) tree } diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 9680b911e0..1781dc1932 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -112,7 +112,7 @@ trait Typers extends Adaptations with Tags { override def isCoercible(tp: Type, pt: Type): Boolean = undoLog undo { // #3281 tp.isError || pt.isError || context0.implicitsEnabled && // this condition prevents chains of views - inferView(EmptyTree, tp, pt, false) != EmptyTree + inferView(EmptyTree, tp, pt, reportAmbiguous = false) != EmptyTree } } @@ -136,7 +136,7 @@ trait Typers extends Adaptations with Tags { for(ar <- argResultsBuff) paramTp = paramTp.subst(ar.subst.from, ar.subst.to) - val res = if (paramFailed || (paramTp.isError && {paramFailed = true; true})) SearchFailure else inferImplicit(fun, paramTp, context.reportErrors, false, context) + val res = if (paramFailed || (paramTp.isError && {paramFailed = true; true})) SearchFailure else inferImplicit(fun, paramTp, context.reportErrors, isView = false, context) argResultsBuff += res if (res.isSuccess) { @@ -179,7 +179,7 @@ trait Typers extends Adaptations with Tags { } def inferView(tree: Tree, from: Type, to: Type, reportAmbiguous: Boolean): Tree = - inferView(tree, from, to, reportAmbiguous, true) + inferView(tree, from, to, reportAmbiguous, saveErrors = true) /** Infer an implicit conversion (`view`) between two types. * @param tree The tree which needs to be converted. @@ -201,7 +201,7 @@ trait Typers extends Adaptations with Tags { case PolyType(_, _) => EmptyTree case _ => def wrapImplicit(from: Type): Tree = { - val result = inferImplicit(tree, functionType(from.withoutAnnotations :: Nil, to), reportAmbiguous, true, context, saveErrors) + val result = inferImplicit(tree, functionType(from.withoutAnnotations :: Nil, to), reportAmbiguous, isView = true, context, saveAmbiguousDivergent = saveErrors) if (result.subst != EmptyTreeTypeSubstituter) { result.subst traverse tree notifyUndetparamsInferred(result.subst.from, result.subst.to) @@ -723,7 +723,7 @@ trait Typers extends Adaptations with Tags { featureTrait.owner.ownerChain.takeWhile(_ != languageFeatureModule.moduleClass).reverse val featureName = (nestedOwners map (_.name + ".")).mkString + featureTrait.name def action(): Boolean = { - def hasImport = inferImplicit(EmptyTree: Tree, featureTrait.tpe, true, false, context).isSuccess + def hasImport = inferImplicit(EmptyTree: Tree, featureTrait.tpe, reportAmbiguous = true, isView = false, context).isSuccess def hasOption = settings.language.value exists (s => s == featureName || s == "_") val OK = hasImport || hasOption if (!OK) { @@ -1142,7 +1142,7 @@ trait Typers extends Adaptations with Tags { if (context.implicitsEnabled && !pt.isError && !tree.isErrorTyped) { // (14); the condition prevents chains of views debuglog("inferring view from " + tree.tpe + " to " + pt) - val coercion = inferView(tree, tree.tpe, pt, true) + val coercion = inferView(tree, tree.tpe, pt, reportAmbiguous = true) if (coercion != EmptyTree) { def msg = "inferred view from " + tree.tpe + " to " + pt + " = " + coercion + ":" + coercion.tpe if (settings.logImplicitConv.value) @@ -1320,7 +1320,7 @@ trait Typers extends Adaptations with Tags { reportError } - silent(_.adaptToMember(qual, HasMember(name), false)) orElse (err => + silent(_.adaptToMember(qual, HasMember(name), reportAmbiguous = false)) orElse (err => onError { if (reportAmbiguous) context issue err setError(tree) @@ -3880,7 +3880,7 @@ trait Typers extends Adaptations with Tags { val targs = args map (_.tpe) checkBounds(tree, NoPrefix, NoSymbol, tparams, targs, "") if (fun.symbol == Predef_classOf) - typedClassOf(tree, args.head, true) + typedClassOf(tree, args.head, noGen = true) else { if (!isPastTyper && fun.symbol == Any_isInstanceOf && targs.nonEmpty) { val scrutineeType = fun match { @@ -4383,7 +4383,7 @@ trait Typers extends Adaptations with Tags { } def tryTypedArgs(args: List[Tree], mode: Mode): Option[List[Tree]] = { - val c = context.makeSilent(false) + val c = context.makeSilent(reportAmbiguousErrors = false) c.retyping = true try { val res = newTyper(c).typedArgs(args, mode) @@ -4442,7 +4442,7 @@ trait Typers extends Adaptations with Tags { tryTypedArgs(args, forArgMode(fun, mode)) match { case Some(args1) => val qual1 = - if (!pt.isError) adaptToArguments(qual, name, args1, pt, true, true) + if (!pt.isError) adaptToArguments(qual, name, args1, pt, reportAmbiguous = true, saveErrors = true) else qual if (qual1 ne qual) { val tree1 = Apply(Select(qual1, name) setPos fun.pos, args1) setPos tree.pos @@ -4672,7 +4672,7 @@ trait Typers extends Adaptations with Tags { // member. Added `| PATTERNmode` to allow enrichment in patterns (so we can add e.g., an // xml member to StringContext, which in turn has an unapply[Seq] method) if (name != nme.CONSTRUCTOR && mode.inExprModeOr(PATTERNmode)) { - val qual1 = adaptToMemberWithArgs(tree, qual, name, mode, true, true) + val qual1 = adaptToMemberWithArgs(tree, qual, name, mode, reportAmbiguous = true, saveErrors = true) if ((qual1 ne qual) && !qual1.isErrorTyped) return typed(treeCopy.Select(tree, qual1, name), mode, pt) } @@ -4757,7 +4757,7 @@ trait Typers extends Adaptations with Tags { case _ if accessibleError.isDefined => // don't adapt constructor, SI-6074 val qual1 = if (name == nme.CONSTRUCTOR) qual - else adaptToMemberWithArgs(tree, qual, name, mode, false, false) + else adaptToMemberWithArgs(tree, qual, name, mode, reportAmbiguous = false, saveErrors = false) if (!qual1.isErrorTyped && (qual1 ne qual)) typed(Select(qual1, name) setPos tree.pos, mode, pt) else |