Skip to content

Fix/double bindings #115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Apr 8, 2014
Merged

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Apr 4, 2014

Builds on #113 and #114.

Main addition is that we now test for double bindings. The PR contains the necessary fixes so that the tests pass.

@odersky
Copy link
Contributor Author

odersky commented Apr 4, 2014

Review by @DarkDimius @sjrd please. (@sjrd: need to look only at last 6 commits).


protected def sig: Signature = Signature.NotAMethod

private[dotc] def withDenot(denot: Denotation)(implicit ctx: Context): ThisType =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let us not introduce more withX methods that mutate this, shall we?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that there's setDenot and withDenot. setDenot is the mutator. withDenot returns potentially a new tree and, where it does not, verifies that it does not overwrite any existing denotations. So I think the name is appropriate.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah ok.

@sjrd
Copy link
Member

sjrd commented Apr 4, 2014

The last commit message says

Another fix is about import symbols. They are now referenced with NonMemberTermRefs. With this fix, the test suite passes with no double def violations.

But I don't see any code related to that.

@sjrd
Copy link
Member

sjrd commented Apr 4, 2014

The last two commits should probably be squashed. I don't see how the introduction of inheritedName can be considered a commit of its own, without the code that uses it.

@sjrd
Copy link
Member

sjrd commented Apr 4, 2014

That is all from me.

@odersky
Copy link
Contributor Author

odersky commented Apr 4, 2014

@sjrd The code related to passing the test suite is in Config.scala. checkNoDoubleBindings is now on.

@odersky
Copy link
Contributor Author

odersky commented Apr 7, 2014

I just pushed an addiitional commit which removes the method with the confusing comment and also contains a fix for overriddenSymbol prompted by Jason's example. It does not fix a test case, however.

@odersky odersky closed this Apr 7, 2014
@odersky odersky reopened this Apr 7, 2014
odersky added 10 commits April 8, 2014 16:55
Cannot discard a symbol simply because the other side's type is weaker.
If in (A | B)#m A and B resolve to different symbols `m`, the resulting denotation
cannot have either `m` as symbol; it must be NoSymbol instead.
Implemented splitting operations

As a side effect, this contains a test ruling out structural term member dispatch.
Tests 0586 and 0625 which used structural dispatch got moved to neg.
Used to print <none> for denotations with a symbol,
now prints "some I" where I is the denotation's info.Reworked phases.
... to check whether tree types make sense. Still produces errors when enabled.
Retyping should not create new symbols and that includes local dummys.
The main problem with TermRef handling was that signatures were not always tracked correctly.

New invariant: A TermRef that points to a symbol is always a TermRefWithSig, and the signature
is the one of the corresponding member.

We achieve this by sometimes generating a new TermRefWithSig if a TermRef gets a denotation.

One possible simplification would be to always store a signature in a TermRef.

There's still a problem in TermRefWithSig#newLikeThis, which currently works only if the previously stored
denotation references a symbol. We will need to generalize JointRefDenotation to contain multiple symbols for
a complete fix.
A self name may no longer have the same name as a parameterless
class member (or param accessor). The restriction makes sense because
otherwise scoping is confusing. It's needed because otherwise we get
TermRefs that have the same name and prefix but denote different things.

Moved some code which exercises this from pos/typers to neg/typers
A double binding is if a named type gets assigned two denotations in the same period. This is
a side-effect and also a race condition, so it's very bad. I am trying to eliminate all causes of this. But one cause which will likely remain are double defitions in a prgram, if a user writes

    class C {
      val x: Int
      val x: Int
    }

Then it's really hard to avoid setting two meanings of C.this.x! That's why the testing
against double bindings is enabled by a -YnoDoubleBindings option. The understanding is that
-YnoDoubleBindings should be set only if there are no double def errors anticipated. Otherwise
the program might fail with an assertion error before the double def error is reported.
Conflicts:
	src/dotty/tools/dotc/transform/Splitter.scala
In TypeAssigner#ensureAccible we sometimes pick an inherited public
member as the denotation of a NamedType instead of an inaccessible
private one. The problem is that both are denotations for the same type,
which caused a noDoubleBindings assert failure. We now solve this problem
by creating a "shadowed" named type to hold the inherited member.

The shadowed named type is distinguished by its name, which reads

    (inherited)originalName

In the future, we should make this more robust by using a general
tagging scheme to create shadowed names.

Another fix is about import symbols. They are now referenced with
NonMemberTermRefs. With this fix, the test suite passes with no
double def violations.
DarkDimius added a commit that referenced this pull request Apr 8, 2014
@DarkDimius DarkDimius merged commit 6bc463d into scala:master Apr 8, 2014
This was referenced Apr 8, 2014
WojciechMazur pushed a commit to WojciechMazur/dotty that referenced this pull request Mar 19, 2025
Backport "improvement: Update mtags to 1.4.1 and backport remaining changes" to 3.3 LTS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants