diff options
5 files changed, 8 insertions, 15 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/Definitions.scala b/src/compiler/scala/tools/nsc/symtab/Definitions.scala index 0f6fd6a944..1a7ca0294d 100644 --- a/src/compiler/scala/tools/nsc/symtab/Definitions.scala +++ b/src/compiler/scala/tools/nsc/symtab/Definitions.scala @@ -112,6 +112,7 @@ trait Definitions { appliedType(ClassClass.tpe, List(classType)) else ClassClass.tpe def Predef_error = getMember(PredefModule, nme.error) + def Predef_conforms = getMember(PredefModule, nme.conforms) lazy val ConsoleModule: Symbol = getModule("scala.Console") lazy val ScalaRunTimeModule: Symbol = getModule("scala.runtime.ScalaRunTime") def SeqFactory = getMember(ScalaRunTimeModule, nme.Seq) diff --git a/src/compiler/scala/tools/nsc/symtab/StdNames.scala b/src/compiler/scala/tools/nsc/symtab/StdNames.scala index 885af91fdb..f3aa58f0ed 100644 --- a/src/compiler/scala/tools/nsc/symtab/StdNames.scala +++ b/src/compiler/scala/tools/nsc/symtab/StdNames.scala @@ -270,6 +270,7 @@ trait StdNames { val canEqual_ = newTermName("canEqual") val checkInitialized = newTermName("checkInitialized") val classOf = newTermName("classOf") + val conforms = newTermName("conforms") val copy = newTermName("copy") val dottype = newTermName(".type") val drop = newTermName("drop") @@ -402,9 +403,6 @@ trait StdNames { // Stores Java annotations on parameters with RetentionPolicy.RUNTIME val RuntimeParamAnnotationATTR = newTermName("RuntimeVisibleParameterAnnotations") val ScalaATTR = newTermName("Scala") - - newTermName("utterweirdness") // (adriaan) removed newTermName("identity"), - // but if I don't give something in return, quick.lib (after newstarr) fails with "error: not found: value Nil" } def encode(str: String): Name = newTermName(NameTransformer.encode(str)) diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala index bce3c4a5ee..4fc19182ef 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala @@ -420,8 +420,8 @@ self: Analyzer => */ def tryImplicit(info: ImplicitInfo): SearchResult = if (containsError(info.tpe) || - (isLocal && shadowed.contains(info.name)) //|| - // (isView && (info.sym == Predef_identity || info.sym == Predef_conforms})) //@M this condition prevents no-op conversions, which are a problem (besides efficiency), + (isLocal && shadowed.contains(info.name)) || + (isView && (info.sym == Predef_conforms)) //@M this condition prevents no-op conversions, which are a problem (besides efficiency), // one example is removeNames in NamesDefaults, which relies on the type checker failing in case of ambiguity between an assignment/named arg ) SearchFailure else typedImplicit(info) diff --git a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala index 9d485cc730..d86c9f3b44 100644 --- a/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala +++ b/src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala @@ -390,12 +390,12 @@ trait NamesDefaults { self: Analyzer => argPos(index) = pos rhs case t: Tree => - //@M was: errorTree(arg, ...) // this throws an exception that's caught in `tryTypedApply` (as it uses `silent`) // unfortunately, tryTypedApply recovers from the exception if you use errorTree(arg, ...) and conforms is allowed as a view (see tryImplicit in Implicits) // because it tries to produce a new qualifier (if the old one was P, the new one will be conforms.apply(P)), and if that works, it pretends nothing happened - // so, to make sure tryTypedApply fails, pass EmptyTree instead - errorTree(EmptyTree, "reference to "+ name +" is ambiguous; it is both, a parameter\n"+ + // so, to make sure tryTypedApply fails, would like to pass EmptyTree instead of arg, but can't do that because eventually setType(ErrorType) is called, and EmptyTree only accepts NoType as its tpe + // thus, we need to disable conforms as a view... + errorTree(arg, "reference to "+ name +" is ambiguous; it is both, a parameter\n"+ "name of the method and the name of a variable currently in scope.") } //@M note that we don't get here when an ambiguity was detected (during the computation of res), diff --git a/test/files/neg/viewtest.check b/test/files/neg/viewtest.check index a93f803fe2..21ed93a01c 100644 --- a/test/files/neg/viewtest.check +++ b/test/files/neg/viewtest.check @@ -3,10 +3,4 @@ viewtest.scala:43: error: type mismatch; required: List[a(in method view3)] case y1: List[a] => compareLists(x, y1) ^ -viewtest.scala:104: error: ambiguous implicit values: - both method view4 in object O of type [a](x: a)a - and method identity in object Predef of type [A](x: A)A - match expected type (test.Str) => test.Ordered[test.Str] - t = t insert Str(s) - ^ -two errors found +one error found |