From a87db212098a5e69176652c93284f425bb7e1b09 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Sun, 5 Oct 2014 10:26:02 +1000 Subject: SI-8291 Fix implicitNotFound message with type aliases This pattern of code is typically a bug: if (f(tp.typeSymbol)) { g(tp.typeArgs) } Intead, one needs to take the base type of `tp` wrt `tp.typeSymbol`. This commit does exactly that when formatting the `@implicitNotFound` custom error message. Patch found on the back of an envelope in the handwriting of @adriaanm --- src/compiler/scala/tools/nsc/typechecker/Implicits.scala | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/compiler/scala/tools/nsc/typechecker/Implicits.scala') diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala index b85c8e6d42..74c28122a1 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala @@ -1478,8 +1478,10 @@ trait Implicits { }) private lazy val typeParamNames: List[String] = sym.typeParams.map(_.decodedName) + private def typeArgsAtSym(paramTp: Type) = paramTp.baseType(sym).typeArgs + + def format(paramName: Name, paramTp: Type): String = format(typeArgsAtSym(paramTp) map (_.toString)) - def format(paramName: Name, paramTp: Type): String = format(paramTp.typeArgs map (_.toString)) def format(typeArgs: List[String]): String = interpolate(msg, Map((typeParamNames zip typeArgs): _*)) // TODO: give access to the name and type of the implicit argument, etc? -- cgit v1.2.3