Skip to content

Fix/#329 and others #339

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 8 commits into from
Feb 7, 2015
Merged

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Jan 27, 2015

Fix of #329 and SI 3252. Review by @olhotak.

@olhotak
Copy link
Contributor

olhotak commented Jan 27, 2015

The last two commits fixing #329 LGTM.

@odersky odersky force-pushed the fix/#329-and-others branch from 68d9657 to 2514c3b Compare January 28, 2015 18:05
@odersky odersky mentioned this pull request Jan 29, 2015
@retronym
Copy link
Member

I notice that matchingParams differs from Scalac in that it no longer equates a Java defined Object with a Scala defined Any.

% tail sandbox/{A.java,B.scala}
==> sandbox/A.java <==
public interface A {
    void o(Object o);
}

==> sandbox/B.scala <==
trait T { def t(o: Object): Unit }

class B extends A with T {
  override def o(o: Any): Unit = ()

  override def t(o: AnyRef): Unit = ()
}

% scalac-hash v2.11.5 sandbox/{A.java,B.scala}

% ../dotty/bin/dotc sandbox/{A.java,B.scala}
sandbox/B.scala:4: error: method o overrides nothing
  override def o(o: Any): Unit = ()
                 ^
one error found

See scala/scala@e2fd411 / scala/scala@e572f29 for the history.

@retronym
Copy link
Member

Although I wasn't able to exploit it, I wonder if underlyingIfRepeated could ever spuriously associate signatures like def foo(s: Seq[Any]) and def foo(a: Any*). A comment to explain why this isn't the case would be welcome in the code.

UPDATE Actually, I found a way to break it:

% cat sandbox/test.scala
trait T {
  def t(a: Any*) = 0
}
class C extends T {
  override def t(a: Seq[Any]) = 0
}

% ~/code/scala scalac-hash v2.11.5 sandbox/test.scala
sandbox/test.scala:5: error: method t overrides nothing.
Note: the super classes of class C contain the following, non final members named t:
def t(a: Any*): Int
  override def t(a: Seq[Any]) = 0
               ^
one error found

% (cd ../dotty; git log --oneline -1)
eeee941 More negative override tests

% ../dotty/bin/dotc sandbox/test.scala

@odersky
Copy link
Contributor Author

odersky commented Jan 31, 2015

@retronym I added the failing Java/Scala override as a test.

Regarding underlyingIfRepeated, I'll revert that one.

Overriding pairs needs to match ExprTypes with field types. Closes scala#329.
Reformulated matchign spec and implemented accordingly. Previous
fix for scala#329 would have missed third new error case in over.scala.
1) Drop redundant signature comparison in overriding pairs
2) Abstract from repeated parameters when calculating matches
As noticed by @retronym, Any and Object are not identified when matching Scala and Java methods. I believe this is because the Java method does not have the Java flag set. @olhotak can you take a look?
This was a left-over from a failed attempt to have OverridingPiars work exclusively by comparing signatures.
If we do that then repeated and underlying do have the same signature and therefore are supposed to match.
But as @retronym notes, this leads to problems. In any case, we no longer try to make overriding pairs
work that way, because it fails for other reasons as well.
@odersky odersky force-pushed the fix/#329-and-others branch from 7df36a3 to 976ed6f Compare February 7, 2015 16:33
@odersky
Copy link
Contributor Author

odersky commented Feb 7, 2015

Rebased to current master

@odersky
Copy link
Contributor Author

odersky commented Feb 7, 2015

I am going to merge now since reviewers comments are taken care of and there are other PRs based on this one.

odersky added a commit that referenced this pull request Feb 7, 2015
@odersky odersky merged commit 9641b2a into scala:master Feb 7, 2015
@allanrenucci allanrenucci deleted the fix/#329-and-others branch December 14, 2017 19:21
tgodzik added a commit to tgodzik/scala3 that referenced this pull request Apr 29, 2025
Backport "Revert unconditional lint of Inlined expansion" 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