Skip to content

Abstract members wrongly implemented by class arguments #1531

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

Closed
OlivierBlanvillain opened this issue Sep 22, 2016 · 1 comment
Closed

Abstract members wrongly implemented by class arguments #1531

OlivierBlanvillain opened this issue Sep 22, 2016 · 1 comment
Assignees

Comments

@OlivierBlanvillain
Copy link
Contributor

The following code compiles:

trait T {
  def f: Int
}

class A(f: Int) extends T

I would expect to fail with following error like it does in scalac:

error: class A needs to be abstract, since def f: => Int is not defined

@OlivierBlanvillain
Copy link
Contributor Author

Example of it failing at runtime:

scala> trait T {
         def f: Int
       } 
defined trait T
scala>  
scala> class A(f: Int) extends T 
defined class A
scala> new A(1) 
res0: A = A@ca263c2
scala> res0.f 
java.lang.AbstractMethodError: Method A.f()I is abstract
        at A.f(<console>)
        at .<init>(<console>:8)
        at .<clinit>(<console>)
        at RequestResult$.<init>(<console>:3)
        at RequestResult$.<clinit>(<console>)
        at RequestResult$result(<console>)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

odersky added a commit to dotty-staging/dotty that referenced this issue Oct 14, 2016
Private members do not override abstract ones. So when looking for
abstract members we need to search with `nonPrivateMember`, not
`member`.

Fixes scala#1531. Review by @smarter.
@odersky odersky self-assigned this Oct 14, 2016
smarter added a commit that referenced this issue Oct 14, 2016
Fix #1531: Ignore private members when looking for abstract ones
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants