Skip to content
This repository was archived by the owner on Sep 1, 2020. It is now read-only.

Commit 4a61719

Browse files
committed
SI-8892 Fix incorrect qualification in error message
Since beadafa, we've ended up with nutty error messages for type errors involving aliases that target types in `java.lang` and `scala` packages. I think the intent of that change was to force the error messages to qualify types like `String` when needed, but to leave them unqualified by default. However, this led to this flat out wrong message in the enclosed test. found : B required: C.this.java.lang.B (which expands to) String I've changed the heuristic slightly limit this code to aliases that are eponymous with their targets. Still feels pretty kludgy, but we can at least book a little progress.
1 parent f8d8160 commit 4a61719

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ trait TypeDiagnostics {
318318
*/
319319
def qualifyDefaultNamespaces() = {
320320
val intersect = Set(trueOwner, aliasOwner) intersect UnqualifiedOwners
321-
if (intersect.nonEmpty) preQualify()
321+
if (intersect.nonEmpty && tp.typeSymbolDirect.name == tp.typeSymbol.name) preQualify()
322322
}
323323

324324
// functions to manipulate the name

test/files/neg/t8892.check

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
t8892.scala:2: error: type mismatch;
2+
found : B
3+
required: C.this.B
4+
(which expands to) String
5+
class C[B](x: B) extends A { def f: B = x }
6+
^
7+
one error found

test/files/neg/t8892.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
trait A { type B = String }
2+
class C[B](x: B) extends A { def f: B = x }

0 commit comments

Comments
 (0)