@@ -10,7 +10,9 @@ class AbstractClassSpec < Minitest::Spec
1010 class AbstractClass
1111 abstract!
1212
13- abstract def m1 ; end
13+ def m1 ; end
14+ abstract ( :m1 )
15+
1416 abstract def m2 ; end
1517
1618 def concrete_method = "AbstractClass#concrete_method"
@@ -45,8 +47,7 @@ def m2 = "PartiallyInheritsItsImpl#m2"
4547
4648 describe "An abstract class" do
4749 it "cannot be instantiated" do
48- skip "Not implemented yet"
49- assert_raises { AbstractClass . new }
50+ assert_raises ( CannotInstantiateAbstractClassError ) { AbstractClass . new }
5051 end
5152
5253 describe ".abstract_instance_methods" do
@@ -83,9 +84,20 @@ def m2 = "PartiallyInheritsItsImpl#m2"
8384 @class = NonImpl
8485 end
8586
86- it "cannot be instantiated" do
87- skip "Not implemented yet"
88- assert_raises { NonImpl . new }
87+ it "can be instantiated" do
88+ # ...despite not implementing all the abstract methods. This matches sorbet runtime's behaviour.
89+ #
90+ # The Sorbet static typechecker ensures that when you subclass an abstract class, you must either:
91+ # 1. Implement all of its abstract methods.
92+ # 2. Mark the subclass as abstract! as well.
93+ #
94+ # Attempting to call actually any of the abstract methods will still raise, like usual.
95+ refute_nil @class . new
96+ end
97+
98+ it "does not respond to .__original_new_impl" do
99+ # binding.irb
100+ assert_raises ( NoMethodError ) { @class . __original_new_impl }
89101 end
90102
91103 # describe "a method with the same name as another interface's members" do
0 commit comments