From 4a1b8bcc729e7817aa4017a7494f2c61fd7b7a22 Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Fri, 21 Aug 2009 17:23:12 +0000 Subject: in the end had to disable conforms as view in t... in the end had to disable conforms as view in tryImplicit (see comment in removeNames in NamesDefaults) fixed check file for viewtest added newTermName for conforms to StdNames, so removed the previous weirdness --- src/compiler/scala/tools/nsc/symtab/Definitions.scala | 1 + src/compiler/scala/tools/nsc/symtab/StdNames.scala | 4 +--- src/compiler/scala/tools/nsc/typechecker/Implicits.scala | 4 ++-- src/compiler/scala/tools/nsc/typechecker/NamesDefaults.scala | 6 +++--- 4 files changed, 7 insertions(+), 8 deletions(-) (limited to 'src/compiler') 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), -- cgit v1.2.3