Skip to content

Fix/overriding #228

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 9 commits into from
Nov 18, 2014
Merged

Fix/overriding #228

merged 9 commits into from
Nov 18, 2014

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Nov 14, 2014

Fixes missing overriding checks. Builds on #227. Review by @smarter

productArity is a method defined in ProductN which is inherited from
case classes. It is possible that it will be usewd in the implementation
of pattern matching in the future. The previous implementation used
the same name to mean something else: Not the arity of the case class
itself but the arity of the pattern/type it represented.

Renaming to prodArity avoids the confusion.
Previously, two denotations with types => T and ()T could not
be merged, only their types could be, but then the denotation
would no longer be a SymDenotation. We now treat the two types
as equivalent so that it will select the symbol in a subclass.
This fixes a problem where, once overrding pairs are made to
work (see following commit), in core/Types we get an error "overriding
final method "hashCode".
OverridingPairs had several bugs which caused pairs to be lost, which caused
missing overrides checks. Fixing OverridingPairs revealed several test failures
(and a problem in Synthetics generation which was fixed in the last commit).
Tests that became negative are all moved into neg/overrides.scala, and the
original versions in pos were fixed.
to make it easier to understand.
These may raise real errors, so we cannot exclude them from
overriding pairs a priori. But we can avoid reporting any
errors if other override errors were reported previously for
the same class.
(1) Type arguments now get a coordinate.
(2) They are labeled Override

(2) avoids having to special case TypeArgs in OverridingPairs.
`override` was not recognized at all on types.
@smarter
Copy link
Member

smarter commented Nov 17, 2014

Note that the following:

class A
class B

class X {
  def f: A = ???
}
class Y extends X {
  override def f: B = ???
}

Still compiles without any error.

Somehow this was lost in porting (or was this done somewhere else
in scalac?).
@odersky
Copy link
Contributor Author

odersky commented Nov 18, 2014

Added overriding checks for types, which catch @smarter's last example.

@smarter
Copy link
Member

smarter commented Nov 18, 2014

LGTM with smarter@06ca2b0 or something similar added and a TODO for dotty-staging@387bdf9#commitcomment-8616457

odersky added a commit that referenced this pull request Nov 18, 2014
@odersky odersky merged commit 8bdc690 into scala:master Nov 18, 2014
@smarter smarter mentioned this pull request Nov 24, 2014
@allanrenucci allanrenucci deleted the fix/overriding branch December 14, 2017 19:22
WojciechMazur pushed a commit to WojciechMazur/dotty that referenced this pull request May 8, 2025
Backport "No outdent at eof" 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.

2 participants