diff options
author | Guillaume Martres <smarter@ubuntu.com> | 2016-01-12 17:52:27 +0100 |
---|---|---|
committer | Guillaume Martres <smarter@ubuntu.com> | 2016-01-17 18:40:42 +0100 |
commit | 0a2b676e97d1325e6ddd3861b7681f8f8db955b9 (patch) | |
tree | 95b90a1c09b8f153f758146dd37b64c8b0ed9410 /LICENSE.md | |
parent | c2513a639df2585f9991d40d6be9fce23b5d4699 (diff) | |
download | dotty-0a2b676e97d1325e6ddd3861b7681f8f8db955b9.tar.gz dotty-0a2b676e97d1325e6ddd3861b7681f8f8db955b9.tar.bz2 dotty-0a2b676e97d1325e6ddd3861b7681f8f8db955b9.zip |
Fix caching bug: don't assume that tvars instantiation cannot be retracted
When TypeVar#inst is empty but an instantiation exists in the typer
state, we should set ephemeral to true, because this instantiation will
be retracted if we throw away the current typer state.
This makes hkrange.scala pass, it compiled before but the type parameter
of `f` was inferred to be `Nothing` because of this bug, and this failed
Ycheck.
For anyone who wonders how caching bugs manifest themselves, here's what
happened in details in hkrange.scala:
1. In an ExploreTyperState we set `CC` to be `IndexedSeq` in the
constraint set
2. In that same typer state the TypeRef `CC[Int]` (it's a TypeRef
because `CC` is a type lambda) gets the denotation `IndexedSeq[Int]`,
which is correct, but the denotation is cached since `ephemeral` is
false, which is wrong.
3. Later, we retract the ExplorerTyperState, so `CC` is uninstantiated
again and unconstrained.
4. Then we do the subtyping check `CC[Int] <:< IndexedSeq[Int]`, because
the denotation of `CC[Int]` was cached, this returns true, but `CC` stays
unconstrained.
5. This means that when we instantiate `CC`, we get `Nothing`
After this fix, the TypeRef denotation is no longer cached, so when we
do `CC[Int] <:< IndexedSeq[Int]`, `CC` gets constrained as expected.
Diffstat (limited to 'LICENSE.md')
0 files changed, 0 insertions, 0 deletions