Skip to content

Tighten comparison of skolem types #599

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 16 commits into from
Jun 19, 2015

Conversation

odersky
Copy link
Contributor

@odersky odersky commented May 23, 2015

Skolem types are =:= only if they are reference-equal. Two skolem types
with the same underlying type are not necessarily equal.

Tests continue to run under this tightened definition.

No review necessary yet. More commits will follow.

@odersky odersky force-pushed the add/existential-skolemization branch from 5fe845e to 1bb6703 Compare June 5, 2015 20:50
var res = asSeenFrom(tp, pre, cls, m)
if (m != null && m.unstable) asSeenFrom(tp, SkolemType(pre), cls) else res
}

final def asSeenFrom(tp: Type, pre: Type, cls: Symbol, theMap: AsSeenFromMap): Type = {
Copy link
Member

Choose a reason for hiding this comment

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

This method and its parameters should be documented.

@odersky
Copy link
Contributor Author

odersky commented Jun 6, 2015

The PR is now complete. I'll try to improve the documentation parts. This whole PR is pretty-subtle because it covers an essential, and largely unresearched part of path dependent types.

@odersky odersky closed this Jun 6, 2015
@odersky odersky reopened this Jun 6, 2015
odersky added 15 commits June 6, 2015 11:04
Skolem types are =:= only if they are reference-equal. Two skolem types
with the same underlying type are not necessarily equal.

Tests continue to run under this tightened definition.
A term ref is stable only if its prefix is also stable. At the same time, we
drop stability requirements where they no longer make sense (e.g. in isLegalPrefix).
Be more aggressive doing this than with lookupRefined in that we compute
the member of a projected name, instead of just analyzing the type structurally.
Reason: (1) If we do not follow aliases, skolemization will lose information
(2) Skolemization is applied rather late, less risk of cyclic references by
computing members.
(1) Refinements of stable types are stable
(2) TypeVars instantiated to stable types are stable.
Will use deskolemize later, when method result types
are inferred.
SkolemTypes need to behave differently form RefinedThis types in TypeMap
and TypeAccumulator. For skolem types these should follow through to the
underlying type. For RefinedThis types, these need to do nothing, in order
not to start an infinite recursion.
It's no longer needed in TypeComparer. We now deskolemize when locally inferring types of vals and defs.
Skolemize unstable prefixes in asSeenFrom provided

 - the prefix appears at least once in non-variant or contra-variant position
 - we are in phase typer.

After typer, we have already established soundness, so there's no need to
do skolemization again. We can simply do the (otherwise unsound) substitution
from this-type to prefix.
We want to establish the invariant (optionally checked by assertNoSkolems)
that symbols do not contain skolemized types as their info. This avoids unsoundness situations
where a skolem gets exported as part if the result type of a method, so different instantiations
look like their are the same instance.
neg/projections required certain types of the form C#T to be ill-formed.
This is no longer done.
@odersky odersky force-pushed the add/existential-skolemization branch from e0d2567 to 081b6ad Compare June 6, 2015 09:06
@odersky
Copy link
Contributor Author

odersky commented Jun 6, 2015

Rebased to master

@@ -103,10 +103,10 @@ Standard-Section: "ASTs" TopLevelStat*
TERMREFpkg fullyQualified_NameRef
TERMREF possiblySigned_NameRef qual_Type
THIS clsRef_Type
SKOLEMtype refinedType_ASTRef
REFINEDthis refinedType_ASTRef
SKOLEMtype Type_ASTRef
Copy link
Member

Choose a reason for hiding this comment

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

When can Skolems appear in typed trees?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They will be removed in a separate PR (#638).

@smarter
Copy link
Member

smarter commented Jun 9, 2015

Could this new SkolemType be used to replace ctx.newSkolem(https://github.com/lampepfl/dotty/blob/master/src/dotty/tools/dotc/core/Symbols.scala#L294-L297) or are they still different?

@odersky
Copy link
Contributor Author

odersky commented Jun 9, 2015

@smarter They are still different. In Applications, we need a TermRef for the method reference, which is what the newSkolem enables. SkolemType does not provide us with a method symbol.

@odersky odersky mentioned this pull request Jun 9, 2015
@odersky
Copy link
Contributor Author

odersky commented Jun 14, 2015

Would be great to see a review of this so we can get this in.

@odersky
Copy link
Contributor Author

odersky commented Jun 19, 2015

I am merging now, because the commit fixes an important unsoundness problem in Dotty. The longer we leave this open the more likely it is that other commits will introduce unsound code.

odersky added a commit that referenced this pull request Jun 19, 2015
@odersky odersky merged commit c89e85c into scala:master Jun 19, 2015
@allanrenucci allanrenucci deleted the add/existential-skolemization branch December 14, 2017 16:57
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.

2 participants