sorbet-runtime 0.4.4269 → 0.4.4270
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/types/private/abstract/declare.rb +4 -0
- data/lib/types/struct.rb +11 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7e77f608cdc5b50f04e11fa6e9c9922878d0dbd
|
4
|
+
data.tar.gz: 5e658c10c0ffdaa4f6116f5619392b517b0fcac9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82273cec61baba7ae992fe7c99b9a73eea2a69c41eca906191a3b009d76bea02d35b5a89eb75f902f757e569c5a3467be5287630bac26794250879982a26ddbe
|
7
|
+
data.tar.gz: ebe1ae4d6ed52246350ef002d4db1e395b96043a0a42bf07892efd4e0cd92c569cb2c38f790c9d869a27fae93be8fad87a9ec6a86ad5b2e45c53412f6098dc86
|
@@ -18,6 +18,10 @@ module T::Private::Abstract::Declare
|
|
18
18
|
mod.extend(T::InterfaceWrapper::Helpers)
|
19
19
|
|
20
20
|
if mod.is_a?(Class)
|
21
|
+
if mod < T::Struct
|
22
|
+
raise "#{mod.name} is a subclass of T::Struct and cannot be declared abstract"
|
23
|
+
end
|
24
|
+
|
21
25
|
if type == :interface
|
22
26
|
# Since `interface!` is just `abstract!` with some extra validation, we could technically
|
23
27
|
# allow this, but it's unclear there are good use cases, and it might be confusing.
|
data/lib/types/struct.rb
CHANGED
@@ -1,8 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
# typed: true
|
3
3
|
|
4
|
-
class T::
|
4
|
+
class T::InexactStruct
|
5
5
|
include T::Props
|
6
6
|
include T::Props::Serializable
|
7
7
|
include T::Props::Constructor
|
8
8
|
end
|
9
|
+
|
10
|
+
class T::Struct < T::InexactStruct
|
11
|
+
def self.inherited(subclass)
|
12
|
+
super(subclass)
|
13
|
+
T::Private::ClassUtils.replace_method(subclass.singleton_class, :inherited) do |s|
|
14
|
+
super(s)
|
15
|
+
raise "#{self.name} is a subclass of T::Struct and cannot be subclassed"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|