Skip to content

Fix #241 #1000

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 69 commits into from
Dec 15, 2015
Merged

Fix #241 #1000

merged 69 commits into from
Dec 15, 2015

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Dec 14, 2015

Finally works now. Note that this needs the previous fixes to go in as well. Only two commits are new here. I tried on master, but this caused many errors which go away when using branch fix-#939.

Review by @smarter or @samuelgruetter (only last two commits).

It seems to complciate things with no real purpose.
Done in order to keep the basics as simple as possible.
Treating existentially bound parameters as still instantiatable type
parameters does not seem to add anything fundamental, and makes the
type system less regular.
Also: fix adaptArgs and LambdaTrait to make it work.
Also: fix EtaExpansion.
Also: Add some debug code to Applications, awaiting further fixes.
typeSymbols always have empty type parameter list.
Previous implementation died because
TermRef had no denotation.
Printing bounds omits the "<:" otherwise.
Arg bounds do not count is bindings.
Arg bounds do not count is bindings.
Also: TypeLambda's $Apply binding should be covariant,
because the parameter is (not sure it matters though).
Taking typeAlias is illegal in that case.
This prevents propagation changes leading to long
recompiles when a printer is changed.
All Lambda abstractions, not just eta expansions, should
use actual parameter bounds, not the one retrieved from
the parameter symbols.
by bringing homogenization of # $Apply projections back.
Seems to be a hk-type inference issue. Needs further investigation but
is not high priority right now.
ParamForwarding converts some parameters to nullary methods, yet
it does not update the references to these parameters. Their signature
is still NotAMethod, which is wrong. Causes subtle differences in
peckle tests: a param accessor get type T before pickling (which is
wrong), gets => T when reading back (which is right). Test case in
pickling/selfSym.scala.
This is needed to ensure that the type of a definition node
(ValDef, TypeDef, or DefDef) always refers to the symbol of
that definition.

Caused a spurious error in selfReq to go away (so error count was
updated).
We do not allow same-named class members in supertraits
of a mixin composition anymore. This commit gives a
better error message and avoids a crash in RefChecks.
`super` has no meaning for type membes. Harmonizing the
prefix to `this` avoids spurious incompatibilities.
A SuperType should behave just as the underlying ThisType in asSeenFrom.
Without this patch, compiling the ...ViewLike hierarachy crashes with
a YCheck error in resolveSuper. The underlying issue is that the very
complicated tangle of supercalls does not type check because an asSeenFrom
with a SuperType prefix does not compute the right type.
We now get a cyclic reference when inheriting from an inner class
with the same name in an outer supertype. Since this was legal
in Scala2 it's good to explain that particular case. Test case
in overrideClass.scala
Otherwise we'd get a failure due to an overloaded `get` definition
whenever we typecheck a case class that is also a Map (because maps
inherit a `get`).
Generalize overriding checking from isDefined
to all methods added by desugar to a case class.
None of these methods has an override so we
need to add one in case they do override another method
(previously we would flag this as an error).
Without the fix and the later commit that checks types for overriding
we get a Ycheck failure in t3452h.scala.
@smarter
Copy link
Member

smarter commented Dec 14, 2015

OK, I'm not exactly sure what the proper fix is but:

  1. In ClassInfo#typeRef, if this is ClassInfo(Mix___eFoo_I_wBar__f, class I), then the owner of the class I is Foo_I_ which is different from this.prefix, so clsDenot return cls.denot.copySymDenotation(info = this).
  2. In NamedType#computeDenot we call prefix.isTightPrefix(d.owner) to check if we need to recompute the denotation of this type. The prefix of the TypeRef computed by the method in step 1 is Mix___eFoo_I_wBar__f, but the owner is Foo_I_, so we end up recomputing the denot, which leads to subtyping checks, which leads to a loop.

Since we don't allow class overriding in Dotty I think we can just bypass the isTightPrefix check when the denotation is a ClassDenotation like this: https://github.com/smarter/dotty/commits/fix-%23241

Alternatively, we could change the owner of the denot returned by clsDenot in ClassInfo#typeRef so that isTightPrefix return true.

@odersky
Copy link
Contributor Author

odersky commented Dec 14, 2015

In general we can't prevent the recomputation of the denotation without
giving it a fixed sym. That's what symbolicTypeRef does.

On Mon, Dec 14, 2015 at 10:45 PM, Guillaume Martres <
[email protected]> wrote:

OK, I'm not exactly sure what the proper fix is but:

  1. In ClassInfo#typeRef, if this is ClassInfo(Mix___eFoo_I_wBar__f,
    class I), then the owner of the class I is Foo_I_ which is different
    from this.prefix, so clsDenot return cls.denot.copySymDenotation(info
    = this).
  2. In NamedType#computeDenot we call prefix.isTightPrefix(d.owner) to
    check if we need to recompute the denotation of this type. The prefix of
    the TypeRef computed by the method in step 1 is Mix___eFoo_I_wBar__f,
    but the owner is Foo_I_, so we end up recomputing the denot, which
    leads to subtyping checks, which leads to a loop.

Since we don't allow class overriding in Dotty I think we can just bypass
the isTightPrefix check when the denotation is a ClassDenotation like
this: https://github.com/smarter/dotty/commits/fix-%23241

Alternatively, we could change the owner of the denot returned by clsDenot
in ClassInfo#typeRef.


Reply to this email directly or view it on GitHub
#1000 (comment).

Martin Odersky
EPFL

@smarter
Copy link
Member

smarter commented Dec 14, 2015

OK, so why can't we always call symbolicTypeRef in typeRef?

@odersky
Copy link
Contributor Author

odersky commented Dec 15, 2015

Symbolic refs go stale on reload.

On Tue, Dec 15, 2015 at 12:58 AM, Guillaume Martres <
[email protected]> wrote:

OK, so why can't we always call symbolicTypeRef in typeRef?


Reply to this email directly or view it on GitHub
#1000 (comment).

Martin Odersky
EPFL

@smarter
Copy link
Member

smarter commented Dec 15, 2015

LGTM, I think I get it, but:

In general we can't prevent the recomputation of the denotation without giving it a fixed sym

I think that ClassInfo#typeRef always returns a type with a SymDenotation valid for the current run, so the only reason for recomputing the denotation is if the prefix is not tight:

          case d: SymDenotation =>
            if (this.isInstanceOf[WithFixedSym]) d.current
            else if (d.validFor.runId == ctx.runId || ctx.stillValid(d))
              if (d.exists && prefix.isTightPrefix(d.owner) || d.isConstructor) d.current
              else recomputeMember(d) // symbol could have been overridden, recompute membership
            else {
              val newd = loadDenot
              if (newd.exists) newd else d.staleSymbolError
            }

So just disabling the isTightPrefix for class denotations should work, but maybe there's some cases I'm missing.

@smarter
Copy link
Member

smarter commented Dec 15, 2015

(I said LGTM but the frozen_<:< still need to be added before this is merged).

@odersky
Copy link
Contributor Author

odersky commented Dec 15, 2015

Is it OK with people if we merge the whole PR? At this stage everything before the PR feels very outdated, and I would not want to base anything on it.

@smarter
Copy link
Member

smarter commented Dec 15, 2015

Fine with me.

odersky added a commit that referenced this pull request Dec 15, 2015
@odersky odersky merged commit c864e11 into scala:master Dec 15, 2015
@smarter smarter mentioned this pull request Dec 18, 2015
@allanrenucci allanrenucci deleted the fix-#241 branch December 14, 2017 19:18
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