summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-11-08 20:11:41 +0000
committerPaul Phillips <paulp@improving.org>2010-11-08 20:11:41 +0000
commitb2559b3cf4516f751ad050480c50e348e03952d7 (patch)
treefd4859c561a1abacb572cf1ee4162b5f2349c53b
parent71f765bc4f9ef4599855a7550dd79347c4c578ba (diff)
downloadscala-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.
-rw-r--r--src/compiler/scala/tools/nsc/ast/TreeGen.scala4
-rw-r--r--src/compiler/scala/tools/nsc/backend/icode/GenICode.scala4
-rw-r--r--src/compiler/scala/tools/nsc/transform/CleanUp.scala8
-rw-r--r--src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala2
-rw-r--r--src/compiler/scala/tools/nsc/transform/LambdaLift.scala2
-rw-r--r--src/compiler/scala/tools/nsc/transform/UnCurry.scala6
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala4
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala9
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/SyntheticMethods.scala4
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala2
-rw-r--r--src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala2
-rwxr-xr-xsrc/library/scala/collection/JavaConverters.scala84
-rw-r--r--src/library/scala/reflect/Print.scala2
-rw-r--r--test/files/neg/overloaded-implicit.check7
-rw-r--r--test/files/neg/overloaded-implicit.flags1
-rw-r--r--test/files/neg/overloaded-implicit.scala17
-rw-r--r--test/files/pos/bug3688-redux.scala8
17 files changed, 119 insertions, 47 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/TreeGen.scala b/src/compiler/scala/tools/nsc/ast/TreeGen.scala
index 073bebad04..2acfa20c50 100644
--- a/src/compiler/scala/tools/nsc/ast/TreeGen.scala
+++ b/src/compiler/scala/tools/nsc/ast/TreeGen.scala
@@ -378,7 +378,7 @@ abstract class TreeGen {
if (treeInfo.isPureExpr(expr)) {
within(() => if (used) expr.duplicate else { used = true; expr })
} else {
- val temp = owner.newValue(expr.pos.makeTransparent, unit.fresh.newName(expr.pos, "ev$"))
+ val temp = owner.newValue(expr.pos.makeTransparent, unit.fresh.newName("ev$"))
.setFlag(SYNTHETIC).setInfo(expr.tpe)
val containing = within(() => Ident(temp) setPos temp.pos.focus setType expr.tpe)
ensureNonOverlapping(containing, List(expr))
@@ -398,7 +398,7 @@ abstract class TreeGen {
() => if (used(idx)) expr.duplicate else { used(idx) = true; expr }
}
} else {
- val temp = owner.newValue(expr.pos.makeTransparent, unit.fresh.newName(expr.pos, "ev$"))
+ val temp = owner.newValue(expr.pos.makeTransparent, unit.fresh.newName("ev$"))
.setFlag(SYNTHETIC).setInfo(expr.tpe)
vdefs += ValDef(temp, expr)
exprs1 += (() => Ident(temp) setPos temp.pos.focus setType expr.tpe)
diff --git a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
index d68b678610..ca9ab7007c 100644
--- a/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
+++ b/src/compiler/scala/tools/nsc/backend/icode/GenICode.scala
@@ -1771,7 +1771,7 @@ abstract class GenICode extends SubComponent {
val sym = t.symbol
def getLabel(pos: Position, name: Name) =
labels.getOrElseUpdate(sym,
- method.newLabel(sym.pos, unit.fresh.newName(pos, name.toString)) setInfo sym.tpe
+ method.newLabel(sym.pos, unit.fresh.newName(name.toString)) setInfo sym.tpe
)
t match {
@@ -2028,7 +2028,7 @@ abstract class GenICode extends SubComponent {
/** Make a fresh local variable. It ensures the 'name' is unique. */
def makeLocal(pos: Position, tpe: Type, name: String): Local = {
- val sym = method.symbol.newVariable(pos, unit.fresh.newName(pos, name))
+ val sym = method.symbol.newVariable(pos, unit.fresh.newName(name))
.setInfo(tpe)
.setFlag(Flags.SYNTHETIC)
this.method.addLocal(new Local(sym, toTypeKind(tpe), false))
diff --git a/src/compiler/scala/tools/nsc/transform/CleanUp.scala b/src/compiler/scala/tools/nsc/transform/CleanUp.scala
index af41bb97e9..73886420c1 100644
--- a/src/compiler/scala/tools/nsc/transform/CleanUp.scala
+++ b/src/compiler/scala/tools/nsc/transform/CleanUp.scala
@@ -92,8 +92,8 @@ abstract class CleanUp extends Transform with ast.TreeDSL {
* type variable. */
case ad@ApplyDynamic(qual0, params) =>
def mkName(s: String = "") =
- if (s == "") unit.fresh newName ad.pos
- else unit.fresh.newName(ad.pos, s)
+ if (s == "") unit.fresh.newName()
+ else unit.fresh.newName(s)
def mkTerm(s: String = "") = newTermName(mkName(s))
val typedPos = typedWithPos(ad.pos) _
@@ -553,7 +553,7 @@ abstract class CleanUp extends Transform with ast.TreeDSL {
case theTry @ Try(block, catches, finalizer)
if theTry.tpe.typeSymbol != definitions.UnitClass && theTry.tpe.typeSymbol != definitions.NothingClass =>
val tpe = theTry.tpe.widen
- val tempVar = currentOwner.newVariable(theTry.pos, unit.fresh.newName(theTry.pos, nme.EXCEPTION_RESULT_PREFIX)).setInfo(tpe)
+ val tempVar = currentOwner.newVariable(theTry.pos, unit.fresh.newName(nme.EXCEPTION_RESULT_PREFIX)).setInfo(tpe)
def assignBlock(rhs: Tree) = super.transform(BLOCK(Ident(tempVar) === transform(rhs)))
val newBlock = assignBlock(block)
@@ -627,7 +627,7 @@ abstract class CleanUp extends Transform with ast.TreeDSL {
*/
private def getSymbolStaticField(pos: Position, symname: String, rhs: Tree, tree: Tree): Symbol =
symbolsStoredAsStatic.getOrElseUpdate(symname, {
- val freshname = unit.fresh.newName(pos, "symbol$")
+ val freshname = unit.fresh.newName("symbol$")
val theTyper = typer.atOwner(tree, currentClass)
// create a symbol for the static field
diff --git a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala
index 9f6117dcf1..7a25df6dc3 100644
--- a/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala
+++ b/src/compiler/scala/tools/nsc/transform/ExplicitOuter.scala
@@ -353,7 +353,7 @@ abstract class ExplicitOuter extends InfoTransform
var nselector = transform(selector)
def makeGuardDef(vs: List[Symbol], guard: Tree) = {
- val gdname = unit.fresh.newName(guard.pos, "gd")
+ val gdname = unit.fresh.newName("gd")
val method = currentOwner.newMethod(tree.pos, gdname) setFlag SYNTHETIC
val fmls = vs map (_.tpe)
val tpe = new MethodType(method newSyntheticValueParams fmls, BooleanClass.tpe)
diff --git a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala
index e3f1427360..b32f0ed6bf 100644
--- a/src/compiler/scala/tools/nsc/transform/LambdaLift.scala
+++ b/src/compiler/scala/tools/nsc/transform/LambdaLift.scala
@@ -254,7 +254,7 @@ abstract class LambdaLift extends InfoTransform {
sym.owner.name + "$"
else ""
)
- val fresh = unit.fresh.newName(sym.pos, base)
+ val fresh = unit.fresh.newName(base)
sym.name = if (sym.name.isTypeName) fresh.toTypeName else fresh
if (settings.debug.value) log("renamed: " + sym.name)
}
diff --git a/src/compiler/scala/tools/nsc/transform/UnCurry.scala b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
index 45fbf7b708..eaaff2d2de 100644
--- a/src/compiler/scala/tools/nsc/transform/UnCurry.scala
+++ b/src/compiler/scala/tools/nsc/transform/UnCurry.scala
@@ -206,7 +206,7 @@ abstract class UnCurry extends InfoTransform with TypingTransformers {
/** Return non-local return key for given method */
private def nonLocalReturnKey(meth: Symbol) =
nonLocalReturnKeys.getOrElseUpdate(meth, {
- meth.newValue(meth.pos, unit.fresh.newName(meth.pos, "nonLocalReturnKey"))
+ meth.newValue(meth.pos, unit.fresh.newName("nonLocalReturnKey"))
.setFlag (SYNTHETIC)
.setInfo (ObjectClass.tpe)
})
@@ -500,7 +500,7 @@ abstract class UnCurry extends InfoTransform with TypingTransformers {
def liftTree(tree: Tree) = {
if (settings.debug.value)
log("lifting tree at: " + (tree.pos))
- val sym = currentOwner.newMethod(tree.pos, unit.fresh.newName(tree.pos, "liftedTree"))
+ val sym = currentOwner.newMethod(tree.pos, unit.fresh.newName("liftedTree"))
sym.setInfo(MethodType(List(), tree.tpe))
new ChangeOwnerTraverser(currentOwner, sym).traverse(tree)
localTyper.typed {
@@ -654,7 +654,7 @@ abstract class UnCurry extends InfoTransform with TypingTransformers {
case Try(body, catches, finalizer) =>
if (catches forall treeInfo.isCatchCase) tree
else {
- val exname = unit.fresh.newName(tree.pos, "ex$")
+ val exname = unit.fresh.newName("ex$")
val cases =
if ((catches exists treeInfo.isDefaultCase) || (catches.last match { // bq: handle try { } catch { ... case ex:Throwable => ...}
case CaseDef(Typed(Ident(nme.WILDCARD), tpt), EmptyTree, _) if (tpt.tpe =:= ThrowableClass.tpe) =>
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) }
diff --git a/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala b/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala
index 3eb4b70ad1..d40c573ffe 100644
--- a/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala
+++ b/src/continuations/plugin/scala/tools/selectivecps/SelectiveANFTransform.scala
@@ -350,7 +350,7 @@ abstract class SelectiveANFTransform extends PluginComponent with Transform with
val valueTpe = removeAllCPSAnnotations(expr.tpe)
- val sym = currentOwner.newValue(tree.pos, unit.fresh.newName(tree.pos, "tmp"))
+ val sym = currentOwner.newValue(tree.pos, unit.fresh.newName("tmp"))
.setInfo(valueTpe)
.setFlag(Flags.SYNTHETIC)
.setAnnotations(List(AnnotationInfo(MarkerCPSSym.tpe, Nil, Nil)))
diff --git a/src/library/scala/collection/JavaConverters.scala b/src/library/scala/collection/JavaConverters.scala
index cb4c56fd59..2e7429884a 100755
--- a/src/library/scala/collection/JavaConverters.scala
+++ b/src/library/scala/collection/JavaConverters.scala
@@ -6,8 +6,6 @@
** |/ **
\* */
-
-
package scala.collection
/** <p>
@@ -64,6 +62,10 @@ object JavaConverters {
import java.util.{ concurrent => juc }
import JavaConversions._
+ // TODO: I cleaned all this documentation up in JavaConversions, but the
+ // documentation in here is basically the pre-cleaned-up version with minor
+ // additions. Would be nice to have in one place.
+
// Conversion decorator classes
/** Generic class containing the `asJava` converter method */
@@ -173,8 +175,8 @@ object JavaConverters {
* @param b The <code>Buffer</code> to be converted.
* @return An object with an `asJava` method that returns a Java <code>List</code> view of the argument.
*/
- implicit def asJavaListConverter[A](b : mutable.Buffer[A]): AsJava[ju.List[A]] =
- new AsJava(asJavaList(b))
+ implicit def bufferAsJavaListConverter[A](b : mutable.Buffer[A]): AsJava[ju.List[A]] =
+ new AsJava(bufferAsJavaList(b))
/**
* Adds an `asJava` method that implicitly converts a Scala mutable <code>Seq</code> to a Java <code>List</code>.
@@ -189,8 +191,8 @@ object JavaConverters {
* @param b The <code>Seq</code> to be converted.
* @return An object with an `asJava` method that returns a Java <code>List</code> view of the argument.
*/
- implicit def asJavaListConverter[A](b : mutable.Seq[A]): AsJava[ju.List[A]] =
- new AsJava(asJavaList(b))
+ implicit def mutableSeqAsJavaListConverter[A](b : mutable.Seq[A]): AsJava[ju.List[A]] =
+ new AsJava(mutableSeqAsJavaList(b))
/**
* Adds an `asJava` method that implicitly converts a Scala <code>Seq</code> to a Java <code>List</code>.
@@ -205,8 +207,15 @@ object JavaConverters {
* @param b The <code>Seq</code> to be converted.
* @return An object with an `asJava` method that returns a Java <code>List</code> view of the argument.
*/
- implicit def asJavaListConverter[A](b : Seq[A]): AsJava[ju.List[A]] =
- new AsJava(asJavaList(b))
+ implicit def seqAsJavaListConverter[A](b : Seq[A]): AsJava[ju.List[A]] =
+ new AsJava(seqAsJavaList(b))
+
+ @deprecated("Use bufferAsJavaListConverter instead")
+ def asJavaListConverter[A](b : mutable.Buffer[A]): AsJava[ju.List[A]] = bufferAsJavaListConverter(b)
+ @deprecated("Use mutableSeqAsJavaListConverter instead")
+ def asJavaListConverter[A](b : mutable.Seq[A]): AsJava[ju.List[A]] = mutableSeqAsJavaListConverter(b)
+ @deprecated("Use seqAsJavaListConverter instead")
+ def asJavaListConverter[A](b : Seq[A]): AsJava[ju.List[A]] = seqAsJavaListConverter(b)
/**
* Adds an `asJava` method that implicitly converts a Scala mutable <code>Set</code> to a Java <code>Set</code>.
@@ -221,8 +230,11 @@ object JavaConverters {
* @param s The <code>Set</code> to be converted.
* @return An object with an `asJava` method that returns a Java <code>Set</code> view of the argument.
*/
- implicit def asJavaSetConverter[A](s : mutable.Set[A]): AsJava[ju.Set[A]] =
- new AsJava(asJavaSet(s))
+ implicit def mutableSetAsJavaSetConverter[A](s : mutable.Set[A]): AsJava[ju.Set[A]] =
+ new AsJava(mutableSetAsJavaSet(s))
+
+ @deprecated("Use mutableSetAsJavaSetConverter instead")
+ def asJavaSetConverter[A](s : mutable.Set[A]): AsJava[ju.Set[A]] = mutableSetAsJavaSetConverter(s)
/**
* Adds an `asJava` method that implicitly converts a Scala <code>Set</code> to a Java <code>Set</code>.
@@ -237,8 +249,11 @@ object JavaConverters {
* @param s The <code>Set</code> to be converted.
* @return An object with an `asJava` method that returns a Java <code>Set</code> view of the argument.
*/
- implicit def asJavaSetConverter[A](s : Set[A]): AsJava[ju.Set[A]] =
- new AsJava(asJavaSet(s))
+ implicit def setAsJavaSetConverter[A](s : Set[A]): AsJava[ju.Set[A]] =
+ new AsJava(setAsJavaSet(s))
+
+ @deprecated("Use setAsJavaSetConverter instead")
+ def asJavaSetConverter[A](s : Set[A]): AsJava[ju.Set[A]] = setAsJavaSetConverter(s)
/**
* Adds an `asJava` method that implicitly converts a Scala mutable <code>Map</code> to a Java <code>Map</code>.
@@ -253,8 +268,11 @@ object JavaConverters {
* @param m The <code>Map</code> to be converted.
* @return An object with an `asJava` method that returns a Java <code>Map</code> view of the argument.
*/
- implicit def asJavaMapConverter[A, B](m : mutable.Map[A, B]): AsJava[ju.Map[A, B]] =
- new AsJava(asJavaMap(m))
+ implicit def mutableMapAsJavaMapConverter[A, B](m : mutable.Map[A, B]): AsJava[ju.Map[A, B]] =
+ new AsJava(mutableMapAsJavaMap(m))
+
+ @deprecated("use mutableMapAsJavaMapConverter instead")
+ def asJavaMapConverter[A, B](m : mutable.Map[A, B]): AsJava[ju.Map[A, B]] = mutableMapAsJavaMapConverter(m)
/**
* Adds an `asJavaDictionary` method that implicitly converts a Scala mutable <code>Map</code> to a Java <code>Dictionary</code>.
@@ -285,8 +303,11 @@ object JavaConverters {
* @param m The <code>Map</code> to be converted.
* @return An object with an `asJava` method that returns a Java <code>Map</code> view of the argument.
*/
- implicit def asJavaMapConverter[A, B](m : Map[A, B]): AsJava[ju.Map[A, B]] =
- new AsJava(asJavaMap(m))
+ implicit def mapAsJavaMapConverter[A, B](m : Map[A, B]): AsJava[ju.Map[A, B]] =
+ new AsJava(mapAsJavaMap(m))
+
+ @deprecated("Use mapAsJavaMapConverter instead")
+ def asJavaMapConverter[A, B](m : Map[A, B]): AsJava[ju.Map[A, B]] = mapAsJavaMapConverter(m)
/**
* Adds an `asJava` method that implicitly converts a Scala mutable `ConcurrentMap` to a Java `ConcurrentMap`.
@@ -349,8 +370,11 @@ object JavaConverters {
* @param i The <code>Iterable</code> to be converted.
* @return An object with an `asScala` method that returns a Scala <code>Iterable</code> view of the argument.
*/
- implicit def asScalaIterableConverter[A](i : jl.Iterable[A]): AsScala[Iterable[A]] =
- new AsScala(asScalaIterable(i))
+ implicit def iterableAsScalaIterableConverter[A](i : jl.Iterable[A]): AsScala[Iterable[A]] =
+ new AsScala(iterableAsScalaIterable(i))
+
+ @deprecated("Use iterableAsScalaIterableConverter instead")
+ def asScalaIterableConverter[A](i : jl.Iterable[A]): AsScala[Iterable[A]] = iterableAsScalaIterableConverter(i)
/**
* Adds an `asScala` method that implicitly converts a Java <code>Collection</code> to an Scala <code>Iterable</code>.
@@ -362,8 +386,11 @@ object JavaConverters {
* @param i The <code>Collection</code> to be converted.
* @return An object with an `asScala` method that returns a Scala <code>SizedIterable</code> view of the argument.
*/
- implicit def asScalaIterableConverter[A](i : ju.Collection[A]): AsScala[Iterable[A]] =
- new AsScala(asScalaIterable(i))
+ implicit def collectionAsScalaIterableConverter[A](i : ju.Collection[A]): AsScala[Iterable[A]] =
+ new AsScala(collectionAsScalaIterable(i))
+
+ @deprecated("Use collectionAsScalaIterableConverter instead")
+ def asScalaIterableConverter[A](i : ju.Collection[A]): AsScala[Iterable[A]] = collectionAsScalaIterableConverter(i)
/**
* Adds an `asScala` method that implicitly converts a Java <code>List</code> to a Scala mutable <code>Buffer</code>.
@@ -389,7 +416,7 @@ object JavaConverters {
* <p>
* If the Java <code>Set</code> was previously obtained from an implicit or
* explicit call of <code>asSet(scala.collection.mutable.Set)</code> then the original
- * ScalaThe reported problems have to do with dependent method types, which is currently an experimental feature in Scala and is still under development. We emphasize that these problems are related to type-inference and, as stated in the paper, it is possible to run and type-check the programs with additional annotations. <code>Set</code> will be returned.
+ * Scala <code>Set</code> will be returned.
*
* @param s The <code>Set</code> to be converted.
* @return An object with an `asScala` method that returns a Scala mutable <code>Set</code> view of the argument.
@@ -410,8 +437,11 @@ object JavaConverters {
* @param m The <code>Map</code> to be converted.
* @return An object with an `asScala` method that returns a Scala mutable <code>Map</code> view of the argument.
*/
- implicit def asScalaMapConverter[A, B](m : ju.Map[A, B]): AsScala[mutable.Map[A, B]] =
- new AsScala(asScalaMap(m))
+ implicit def mapAsScalaMapConverter[A, B](m : ju.Map[A, B]): AsScala[mutable.Map[A, B]] =
+ new AsScala(mapAsScalaMap(m))
+
+ @deprecated("Use mapAsScalaMapConverter instead")
+ def asScalaMapConverter[A, B](m : ju.Map[A, B]): AsScala[mutable.Map[A, B]] = mapAsScalaMapConverter(m)
/**
* Adds an `asScala` method that implicitly converts a Java <code>ConcurrentMap</code> to a Scala mutable <code>ConcurrentMap</code>.
@@ -450,7 +480,11 @@ object JavaConverters {
* @param m The <code>Properties</code> to be converted.
* @return An object with an `asScala` method that returns a Scala mutable <code>Map[String, String]</code> view of the argument.
*/
- implicit def asScalaMapConverter(p: ju.Properties): AsScala[mutable.Map[String, String]] =
- new AsScala(asScalaMap(p))
+ implicit def propertiesAsScalaMapConverter(p: ju.Properties): AsScala[mutable.Map[String, String]] =
+ new AsScala(propertiesAsScalaMap(p))
+
+ @deprecated("Use propertiesAsScalaMapConverter instead")
+ def asScalaMapConverter(p: ju.Properties): AsScala[mutable.Map[String, String]] =
+ propertiesAsScalaMapConverter(p)
}
diff --git a/src/library/scala/reflect/Print.scala b/src/library/scala/reflect/Print.scala
index adf3860f88..a84e024c36 100644
--- a/src/library/scala/reflect/Print.scala
+++ b/src/library/scala/reflect/Print.scala
@@ -102,7 +102,7 @@ object Print extends Function1[Any, String] {
case reflect.MethodType(formals, resultType) =>
formals.map(Print).mkString("(", ", ", ")") + " => " + Print(resultType)
case reflect.PolyType(typeParams, typeBounds, resultType) =>
- val z = (typeParams, typeBounds).zip map { case (tp, tb) => "[" + Print(tb._1) + " :> " + Print(tp) + " :> " + Print(tb._2) + "]" }
+ val z = (typeParams, typeBounds).zipped map ((tp, tb) => "[" + Print(tb._1) + " :> " + Print(tp) + " :> " + Print(tb._2) + "]")
z.mkString("[", ", ", "]") + " -> " + Print(resultType)
case _ =>
"???"
diff --git a/test/files/neg/overloaded-implicit.check b/test/files/neg/overloaded-implicit.check
new file mode 100644
index 0000000000..bdbe6a89d5
--- /dev/null
+++ b/test/files/neg/overloaded-implicit.check
@@ -0,0 +1,7 @@
+overloaded-implicit.scala:2: error: parameterized overloaded implicit methods are not visible as view bounds
+ implicit def imp1[T](x: List[T]): Map[T, T] = Map()
+ ^
+overloaded-implicit.scala:3: error: parameterized overloaded implicit methods are not visible as view bounds
+ implicit def imp1[T](x: Set[T]): Map[T, T] = Map()
+ ^
+two errors found
diff --git a/test/files/neg/overloaded-implicit.flags b/test/files/neg/overloaded-implicit.flags
new file mode 100644
index 0000000000..85d8eb2ba2
--- /dev/null
+++ b/test/files/neg/overloaded-implicit.flags
@@ -0,0 +1 @@
+-Xfatal-warnings
diff --git a/test/files/neg/overloaded-implicit.scala b/test/files/neg/overloaded-implicit.scala
new file mode 100644
index 0000000000..68b1ceaa30
--- /dev/null
+++ b/test/files/neg/overloaded-implicit.scala
@@ -0,0 +1,17 @@
+object Test {
+ implicit def imp1[T](x: List[T]): Map[T, T] = Map()
+ implicit def imp1[T](x: Set[T]): Map[T, T] = Map()
+
+ def f[T <% Map[Int, Int]](x: T): Double = 1.0d
+
+ // not parameterized, no warning
+ implicit def imp2(x: List[Int]): String = "a"
+ implicit def imp2(x: Set[Int]): String = "b"
+
+ def g[T <% String](x: T): Double = 2.0d
+
+ def main(args: Array[String]): Unit = {
+ // println(f(List(1)))
+ println(g(List(1)))
+ }
+}
diff --git a/test/files/pos/bug3688-redux.scala b/test/files/pos/bug3688-redux.scala
new file mode 100644
index 0000000000..e601cf240c
--- /dev/null
+++ b/test/files/pos/bug3688-redux.scala
@@ -0,0 +1,8 @@
+import collection.JavaConverters._
+import java.{ util => ju }
+import scala.collection.{ mutable, immutable }
+
+object Test {
+ def m[P <% AsJava[ju.List[Int]]](l: P) = 1
+ m(List(1))
+} \ No newline at end of file