diff options
author | Paul Phillips <paulp@improving.org> | 2010-11-08 20:11:41 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-11-08 20:11:41 +0000 |
commit | b2559b3cf4516f751ad050480c50e348e03952d7 (patch) | |
tree | fd4859c561a1abacb572cf1ee4162b5f2349c53b /src/compiler/scala/tools/nsc/typechecker | |
parent | 71f765bc4f9ef4599855a7550dd79347c4c578ba (diff) | |
download | scala-b2559b3cf4516f751ad050480c50e348e03952d7.tar.gz scala-b2559b3cf4516f751ad050480c50e348e03952d7.tar.bz2 scala-b2559b3cf4516f751ad050480c50e348e03952d7.zip |
Deprecation patrol.
the same issues as JavaConversions with respect to overloading implicit
methods making them inaccessible to view bounds. Fixed JavaConverters.
Added a warning for when people overload parameterized implicits: in
almost all cases the name is irrelevant so there's little point in
unwittingly suffering degraded functionality. No review.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker')
4 files changed, 12 insertions, 7 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala index 151a851f23..9ad7776898 100644 --- a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala +++ b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala @@ -148,7 +148,7 @@ trait NamesDefaults { self: Analyzer => // never used for constructor calls, they always have a stable qualifier def blockWithQualifier(qual: Tree, selected: Name) = { - val sym = blockTyper.context.owner.newValue(qual.pos, unit.fresh.newName(qual.pos, "qual$")) + val sym = blockTyper.context.owner.newValue(qual.pos, unit.fresh.newName("qual$")) .setInfo(qual.tpe) blockTyper.context.scope.enter(sym) val vd = atPos(sym.pos)(ValDef(sym, qual).setType(NoType)) @@ -258,7 +258,7 @@ trait NamesDefaults { self: Analyzer => case _ => (seqType(arg.tpe), true) } else (arg.tpe, false) - val s = context.owner.newValue(arg.pos, unit.fresh.newName(arg.pos, "x$")) + val s = context.owner.newValue(arg.pos, unit.fresh.newName("x$")) val valType = if (byName) functionType(List(), argTpe) else if (repeated) argTpe else argTpe diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index c49acf3f01..b524f2e99a 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -96,7 +96,7 @@ abstract class RefChecks extends InfoTransform { var checkedCombinations = Set[List[Type]]() // only one overloaded alternative is allowed to define default arguments - private def checkDefaultsInOverloaded(clazz: Symbol) { + private def checkOverloadedRestrictions(clazz: Symbol) { def check(members: List[Symbol]): Unit = members match { case x :: xs => if (x.hasParamWhich(_.hasDefaultFlag) && !nme.isProtectedAccessorName(x.name)) { @@ -116,6 +116,11 @@ abstract class RefChecks extends InfoTransform { check(xs) case _ => () } + clazz.info.decls filter (x => x.isImplicit && x.typeParams.nonEmpty) foreach { sym => + val alts = clazz.info.decl(sym.name).alternatives + if (alts.size > 1) + alts foreach (x => unit.warning(x.pos, "parameterized overloaded implicit methods are not visible as view bounds")) + } check(clazz.info.members) } @@ -1293,7 +1298,7 @@ abstract class RefChecks extends InfoTransform { case Template(parents, self, body) => localTyper = localTyper.atOwner(tree, currentOwner) validateBaseTypes(currentOwner) - checkDefaultsInOverloaded(currentOwner) + checkOverloadedRestrictions(currentOwner) val bridges = addVarargBridges(currentOwner) checkAllOverrides(currentOwner) diff --git a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala index 545aab4c79..d4cb11b122 100644 --- a/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala +++ b/src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala @@ -182,7 +182,7 @@ trait SyntheticMethods extends ast.TreeDSL { // returns (Apply, Bind) def makeTrees(acc: Symbol, cpt: Type): (Tree, Bind) = { - val varName = context.unit.fresh.newName(clazz.pos.focus, acc.name + "$") + val varName = context.unit.fresh.newName(acc.name + "$") val isRepeated = isRepeatedParamType(cpt) val binding = if (isRepeated) Star(WILD()) else WILD() val eqMethod: Tree = @@ -221,7 +221,7 @@ trait SyntheticMethods extends ast.TreeDSL { def newAccessorMethod(tree: Tree): Tree = tree match { case DefDef(_, _, _, _, _, rhs) => var newAcc = tree.symbol.cloneSymbol - newAcc.name = context.unit.fresh.newName(tree.symbol.pos.focus, tree.symbol.name + "$") + newAcc.name = context.unit.fresh.newName(tree.symbol.name + "$") newAcc setFlag SYNTHETIC resetFlag (ACCESSOR | PARAMACCESSOR | PRIVATE | PROTECTED) newAcc.privateWithin = NoSymbol newAcc = newAcc.owner.info.decls enter newAcc diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 6911d226bf..3d3fbae811 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -3916,7 +3916,7 @@ trait Typers { self: Analyzer => val params = for (i <- List.range(0, arity)) yield atPos(tree.pos.focusStart) { ValDef(Modifiers(PARAM | SYNTHETIC), - unit.fresh.newName(tree.pos, "x" + i + "$"), TypeTree(), EmptyTree) + unit.fresh.newName("x" + i + "$"), TypeTree(), EmptyTree) } val ids = for (p <- params) yield Ident(p.name) val selector1 = atPos(tree.pos.focusStart) { if (arity == 1) ids.head else gen.mkTuple(ids) } |