diff options
author | Martin Odersky <odersky@gmail.com> | 2016-05-19 11:32:44 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-05-19 11:32:44 +0200 |
commit | c29e9754b94cc352337791c9e36131f5b8be385d (patch) | |
tree | de7a11d622af2bd7f1dd44ef8eaf494242afdad1 /src | |
parent | c9ac3d7267fe53dfbd3f57658049637ab218b3d5 (diff) | |
download | dotty-c29e9754b94cc352337791c9e36131f5b8be385d.tar.gz dotty-c29e9754b94cc352337791c9e36131f5b8be385d.tar.bz2 dotty-c29e9754b94cc352337791c9e36131f5b8be385d.zip |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/core/Types.scala | 6 |
1 files changed, 5 insertions, 1 deletions
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 = { |