From c29e9754b94cc352337791c9e36131f5b8be385d Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Thu, 19 May 2016 11:32:44 +0200 Subject: Fix dotc bootstrap failure During an attempted dotty bootstrap it was noted that Types.scala did not compile anymore, because `checkUnique` threw a `TypeError` during erasure. The issue was an overloaded member `name` in TermrefWithSig. In NamedType: def name: Name In TermRef: def name: TermName Before erasure, there's one member `name`, after erasure there are two (because after erasure result type counts). The error arose when trying to recompute a member of a `TermRefWithSig` where the name is `name` and the expected signature is `(Nil, ?)`. Since there are two members that match the name and the signature, `checkUnique` triggered a `TypeError`. Before adding `checkUnique`, the previous `atSignature` call would just have returned an arbitrary choice among the two alternative definitions of `name`. The fix is not to use `checkUnique` but to fall back to `d.current` in the case where several alternatives appear. Interestingly, the failure only triggers when -Ycheck options are *disabled*. I added a new test that compiles Types.scala without checks, so we catch this and possibly similar bugs in the future. --- src/dotty/tools/dotc/core/Types.scala | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/dotty/tools/dotc/core/Types.scala') diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index 3ad43a05e..114e6c908 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -1437,7 +1437,11 @@ object Types { asMemberOf(prefix) match { case NoDenotation => d.current case newd: SingleDenotation => newd - case newd => newd.atSignature(d.signature).checkUnique.orElse(d.current) + case newd => + newd.atSignature(d.signature) match { + case newd1: SingleDenotation if newd1.exists => newd1 + case _ => d.current + } } private def denotOfSym(sym: Symbol)(implicit ctx: Context): Denotation = { -- cgit v1.2.3