From f8d816086f56096c05dfc769aa1ab0f6e583bb5a Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Wed, 16 Jul 2014 18:40:44 +0200 Subject: 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. --- test/files/neg/t6895b.check | 4 ++-- test/files/neg/t8777.check | 6 ++++++ test/files/neg/t8777.scala | 4 ++++ 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 test/files/neg/t8777.check create mode 100644 test/files/neg/t8777.scala (limited to 'test') diff --git a/test/files/neg/t6895b.check b/test/files/neg/t6895b.check index 3ebdb69309..565925127b 100644 --- a/test/files/neg/t6895b.check +++ b/test/files/neg/t6895b.check @@ -2,8 +2,8 @@ t6895b.scala:20: error: could not find implicit value for parameter e: Foo[[X]Ba implicitly[Foo[({type L[X] = Bar[StringOr, X]})#L]] ^ t6895b.scala:23: error: polymorphic expression cannot be instantiated to expected type; - 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)]] + found : [F[_]]Foo[[X(in type L)]Bar[F,X(in type L)]] + required: Foo[[X(in type L)]Bar[[X]Or[String,X],X(in type L)]] barFoo(null) : Foo[({type L[X] = Bar[StringOr, X]})#L] ^ two errors found diff --git a/test/files/neg/t8777.check b/test/files/neg/t8777.check new file mode 100644 index 0000000000..cd05f1ec11 --- /dev/null +++ b/test/files/neg/t8777.check @@ -0,0 +1,6 @@ +t8777.scala:3: error: type mismatch; + found : Foo.this.TreePrinter(in trait Printers) + required: Foo.this.TreePrinter(in trait Printers) + super.newCodePrinter(out, tree, printRootPkg) + ^ +one error found diff --git a/test/files/neg/t8777.scala b/test/files/neg/t8777.scala new file mode 100644 index 0000000000..5b7d123202 --- /dev/null +++ b/test/files/neg/t8777.scala @@ -0,0 +1,4 @@ +trait Foo extends scala.tools.nsc.Global { + override def newCodePrinter(out: java.io.PrintWriter, tree: Tree, printRootPkg: Boolean): TreePrinter = + super.newCodePrinter(out, tree, printRootPkg) +} -- cgit v1.2.3