diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2014-07-16 18:40:44 +0200 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2015-06-23 08:43:54 +1000 |
commit | f8d816086f56096c05dfc769aa1ab0f6e583bb5a (patch) | |
tree | 5ad9bacae9a00d06f1b4fc3c7419b1451c4863f6 /src/compiler | |
parent | 1531900bffb2bed6288eda4e0945b0e6dea3f23d (diff) | |
download | scala-f8d816086f56096c05dfc769aa1ab0f6e583bb5a.tar.gz scala-f8d816086f56096c05dfc769aa1ab0f6e583bb5a.tar.bz2 scala-f8d816086f56096c05dfc769aa1ab0f6e583bb5a.zip |
SI-8777 Avoid redundant disambiguation in error messages
When printing types in error messages, we attempt to disambiguate
symbol names by qualifying them in various ways.
Type paramters symbols are qualified by adding `(in someMethod)`.
However, the type errors generated by higher kinded subtyping
can contain clones of type parameter symbols, as creater in
`isPolySubType`. The disambiguation tries fruitlessly to distinguish
them but ended up adding the same suffix to both names repeatedly.
```
found : [F[_]]Foo[[X(in type L)(in type L)(in type L)(in type L)(in type L)(in type L)(in type L)(in type L)]Bar[F,X(in type L)(in type L)(in type L)(in type L)(in type L)(in type L)(in type L)(in type L)]]
required: Foo[[X(in type L)(in type L)(in type L)(in type L)(in type L)(in type L)(in type L)(in type L)]Bar[[X]Or[String,X],X(in type L)(in type L)(in type L)(in type L)(in type L)(in type L)(in type L)(in type L)]]
```
This commit limits the post qualification of type parameter symbols
to a single attempt to limit the damage. An alternative might
be to mark a clone (we could determine its status by checking whether
it is a type parameter of its owner.) But I'm not sure how to present
this information in a comphrenensible way, so for now I'm limiting
my ambitions to stopping the stutter.
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala index 059981aa37..65dea3178b 100644 --- a/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala +++ b/src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala @@ -309,6 +309,7 @@ trait TypeDiagnostics { // save the name because it will be mutated until it has been // distinguished from the other types in the same error message private val savedName = sym.name + private var postQualifiedWith: List[Symbol] = Nil def restoreName() = sym.name = savedName def modifyName(f: String => String) = sym setName newTypeName(f(sym.name.toString)) @@ -322,7 +323,7 @@ trait TypeDiagnostics { // functions to manipulate the name def preQualify() = modifyName(trueOwner.fullName + "." + _) - def postQualify() = modifyName(_ + "(in " + trueOwner + ")") + def postQualify() = if (!(postQualifiedWith contains trueOwner)) { postQualifiedWith ::= trueOwner; modifyName(_ + "(in " + trueOwner + ")") } def typeQualify() = if (sym.isTypeParameterOrSkolem) postQualify() def nameQualify() = if (trueOwner.isPackageClass) preQualify() else postQualify() |