|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is a retry of #2801 after figuring out the range position
error. Should there be anyone out there who compiles with -Xdev,
know that this commit eliminates the 1406 errors one presently
incurs compiling src/library.
A val declared in source code receives only one tree from the
parser, but two are needed - one for the field and one for the
getter. I discovered long ago that if the val had an existential
type, this was creating issues with incompatible existentials
between the field and the getter. However the remedy for that
did not take into account the whole of the wide range of super
subtle issues which accompany tree duplication.
In particular, the duplicated tree must be given not only a
fresh TypeTree(), but that TypeTree cannot share the same
original without running afoul of range position invariants.
That's because typedTypeTree resurrects the original tree with
whatever position it has - so the "original" needs to be a
duplicate of the original with a focused position.
Should the call to TypeTree.duplicate also duplicate the original?
I think so, but I bequeath this question to others.
This commit also eliminated some duplicate error messages, because
duplicate suppression depends on the errors having the same position.
See c478eb770d, 7a6fa80937 for previous related work.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
There is a window of danger when multiple related elements are
being typed where something which is conceptually one thing can
slip into two things, and those two things can be incompatible
with one another. Less mysteriously, c478eb770d fixed this:
def f = { object Bob ; Bob } ; val g = f
But, it did not fix this:
def f = { case class Bob() ; Bob } ; val g = f
See test case pos/existentials-harmful.scala for an "in the wild"
code example fixed by this commit.
The root of the problem was that the getter and the field would each
independently derive the same existential type to describe Bob, but
those existentials were not the same as one another.
This has been the most elusive bug I have ever fixed. I want to cry when
I think of how much time I've put into it over the past half decade or
so. Unfortunately the way the repl works it is particularly good at
eliciting those grotesque found/required error messages and so I was
never able to let the thing go.
There is still a cosmetic issue (from the last commit really) where
compound types wind up with repeated parents.
Closes SI-1195, SI-1201.
|