-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Make Class
and all metaclasses non-abstract
#11190
base: master
Are you sure you want to change the base?
Make Class
and all metaclasses non-abstract
#11190
Conversation
I believe the example in the OP should be |
Looks good, but CI is failing and we don't have access to the logs anymore. I will close and open it again to re-run the checks (🤷 ) |
The problem is in this spec, which now incorrectly fails saying that abstract class Foo
end
class Bar < Foo
def initialize(@x : Int32)
end
def x
@x
end
end
ptr = Pointer(Foo.class).malloc(1_u64)
ptr.value = Bar
bar = ptr.value.new(1)
bar.x |
There is also this on the Windows CI now:
I believe both of these cases indeed should be rejected, but it looks like we have to guard this behind a flag now. @asterite what do you think? Is there a way to make only |
I think here we should be a bit more relaxed. The code should compile, but if it ends up calling that method in the base abstract type then a runtime error is produced. Then reason is that it's unlikely that will actually happen. |
This indeed couldn't happen via |
Resolves #11132. Resolves #9959. The following code will now fail to compile:
This is because the value of
x
can also beA
, so a definition forA.foo
must be present. Currently, ifx
is indeedA
, callingx.foo
leads to undefined behaviour whenever multiple target defs are available, because virtual dispatch onx
does not produce a branch forA.class
.Does not affect #3835, because
.new
is still implicitly available on all metaclasses (and.allocate
on all class metaclasses). Also related to #5956.Making
Class
non-abstract doesn't seem to have any significant consequences yet.