Skip to content

Commit

Permalink
Fix autoloading issues
Browse files Browse the repository at this point in the history
  • Loading branch information
joeldrapper committed Nov 28, 2024
1 parent e774e7a commit 28a8275
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 57 deletions.
36 changes: 18 additions & 18 deletions lib/literal/transforms.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@
ceil: Integer,
chr: String,
denominator: Integer,
even?: Literal::Types::BooleanType,
even?: Literal::Types::BooleanType::Instance,
floor: Integer,
hash: Integer,
inspect: String,
integer?: true,
magnitude: Integer,
negative?: Literal::Types::BooleanType,
negative?: Literal::Types::BooleanType::Instance,
next: Integer,
numerator: Integer,
odd?: Literal::Types::BooleanType,
odd?: Literal::Types::BooleanType::Instance,
ord: Integer,
positive?: Literal::Types::BooleanType,
positive?: Literal::Types::BooleanType::Instance,
pred: Integer,
round: Integer,
size: Integer,
Expand All @@ -29,17 +29,17 @@
to_r: Rational,
to_s: String,
truncate: Integer,
zero?: Literal::Types::BooleanType,
zero?: Literal::Types::BooleanType::Instance,
},
String => {
ascii_only?: Literal::Types::BooleanType,
ascii_only?: Literal::Types::BooleanType::Instance,
bytesize: Integer,
capitalize: String,
chomp: String,
chop: String,
downcase: String,
dump: String,
empty?: Literal::Types::BooleanType,
empty?: Literal::Types::BooleanType::Instance,
hash: Integer,
inspect: String,
length: Integer,
Expand All @@ -53,7 +53,7 @@
swapcase: String,
to_str: String,
upcase: String,
valid_encoding?: Literal::Types::BooleanType,
valid_encoding?: Literal::Types::BooleanType::Instance,
},
Numeric => {
to_i: Integer,
Expand All @@ -63,13 +63,13 @@
Array => {
size: Integer,
length: Integer,
empty?: Literal::Types::BooleanType,
empty?: Literal::Types::BooleanType::Instance,
sort: Array,
to_a: Array,
to_ary: Array,
},
Hash => {
empty?: Literal::Types::BooleanType,
empty?: Literal::Types::BooleanType::Instance,
inspect: String,
keys: Array,
length: Integer,
Expand All @@ -80,7 +80,7 @@
values: Array,
},
Set => {
empty?: Literal::Types::BooleanType,
empty?: Literal::Types::BooleanType::Instance,
inspect: String,
length: Integer,
size: Integer,
Expand All @@ -91,17 +91,17 @@
abs: Float,
ceil: Integer,
floor: Integer,
nan?: Literal::Types::BooleanType,
negative?: Literal::Types::BooleanType,
positive?: Literal::Types::BooleanType,
nan?: Literal::Types::BooleanType::Instance,
negative?: Literal::Types::BooleanType::Instance,
positive?: Literal::Types::BooleanType::Instance,
round: Integer,
to_i: Integer,
to_s: String,
truncate: Integer,
zero?: Literal::Types::BooleanType,
zero?: Literal::Types::BooleanType::Instance,
},
Symbol => {
empty?: Literal::Types::BooleanType,
empty?: Literal::Types::BooleanType::Instance,
inspect: String,
length: Integer,
size: Integer,
Expand All @@ -111,7 +111,7 @@
Range => {
begin: Object,
end: Object,
exclude_end?: Literal::Types::BooleanType,
exclude_end?: Literal::Types::BooleanType::Instance,
first: Object,
last: Object,
max: Object,
Expand All @@ -121,7 +121,7 @@
to_s: String,
},
Regexp => {
casefold?: Literal::Types::BooleanType,
casefold?: Literal::Types::BooleanType::Instance,
inspect: String,
source: String,
to_s: String,
Expand Down
18 changes: 9 additions & 9 deletions lib/literal/types.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ module Literal::Types
CallableType = InterfaceType.new(:call).freeze
LambdaType = ConstraintType.new(Proc, lambda?: true).freeze

NilableBooleanType = NilableType.new(BooleanType).freeze
NilableBooleanType = NilableType.new(BooleanType::Instance).freeze
NilableCallableType = NilableType.new(CallableType).freeze
NilableJSONDataType = NilableType.new(JSONDataType).freeze
NilableLambdaType = NilableType.new(LambdaType).freeze
NilableProcableType = NilableType.new(ProcableType).freeze

# Matches any value except `nil`. Use `_Any?` or `_Void` to match any value including `nil`.
def _Any
AnyType
AnyType::Instance
end

def _Any?
VoidType
VoidType::Instance
end

# Matches if the value is an `Array` and all the elements match the given type.
Expand All @@ -58,7 +58,7 @@ def _Array?(...)

# Matches if the value is `true` or `false`.
def _Boolean
BooleanType
BooleanType::Instance
end

# Nilable version of `_Boolean`
Expand Down Expand Up @@ -128,7 +128,7 @@ def _Enumerable?(...)

# Matches *"falsy"* values (`nil` and `false`).
def _Falsy
FalsyType
FalsyType::Instance
end

# Matches if the value is a `Float` and matches the given constraints.
Expand Down Expand Up @@ -211,7 +211,7 @@ def _Intersection?(...)

# Ensures the value is valid JSON data (i.e. it came from JSON.parse).
def _JSONData
JSONDataType
JSONDataType::Instance
end

# Nilable version of `_JSONData`
Expand Down Expand Up @@ -242,7 +242,7 @@ def _Map?(...)

# Never matches any value.
def _Never
NeverType
NeverType::Instance
end

# Matches if the value is either `nil` or the given type.
Expand Down Expand Up @@ -316,7 +316,7 @@ def _Symbol?(...)

# Matches *"truthy"* values (anything except `nil` and `false`).
def _Truthy
TruthyType
TruthyType::Instance
end

# Matches if the value is an `Array` and each element matches the given types in order.
Expand Down Expand Up @@ -344,6 +344,6 @@ def _Union?(...)
end

def _Void
VoidType
VoidType::Instance
end
end
6 changes: 3 additions & 3 deletions lib/literal/types/any_type.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# frozen_string_literal: true

# @api private
class Literal::Types::AnyTypeClass
class Literal::Types::AnyType
Instance = new.freeze

include Literal::Type

def inspect
Expand All @@ -18,5 +20,3 @@ def >=(other)

freeze
end

Literal::Types::AnyType = Literal::Types::AnyTypeClass.new.freeze
8 changes: 4 additions & 4 deletions lib/literal/types/boolean_type.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# frozen_string_literal: true

# @api private
class Literal::Types::BooleanTypeClass
class Literal::Types::BooleanType
Instance = new.freeze

include Literal::Type

def inspect
Expand All @@ -14,7 +16,7 @@ def ===(value)

def >=(other)
case other
when true, false, Literal::Types::BooleanTypeClass
when true, false, Literal::Types::BooleanType
true
else
false
Expand All @@ -23,5 +25,3 @@ def >=(other)

freeze
end

Literal::Types::BooleanType = Literal::Types::BooleanTypeClass.new.freeze
8 changes: 4 additions & 4 deletions lib/literal/types/falsy_type.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# frozen_string_literal: true

# @api private
class Literal::Types::FalsyTypeClass
class Literal::Types::FalsyType
Instance = new.freeze

include Literal::Type

def initialize
Expand All @@ -18,7 +20,7 @@ def ===(value)

def >=(other)
case other
when Literal::Types::FalsyTypeClass, nil, false
when Literal::Types::FalsyType, nil, false
true
else
false
Expand All @@ -27,5 +29,3 @@ def >=(other)

freeze
end

Literal::Types::FalsyType = Literal::Types::FalsyTypeClass.new.freeze
11 changes: 5 additions & 6 deletions lib/literal/types/json_data_type.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# frozen_string_literal: true

# @api private
class Literal::Types::JSONDataTypeClass
include Literal::Type
class Literal::Types::JSONDataType
Instance = new.freeze

# This needs to be defined here so it can be referenced in the COMPATIBLE_TYPES constant.
Literal::Types::JSONDataType = Literal::Types::JSONDataTypeClass.new.freeze
include Literal::Type

COMPATIBLE_TYPES = Set[
Integer,
Expand All @@ -14,8 +13,8 @@ class Literal::Types::JSONDataTypeClass
true,
false,
nil,
Literal::Types::BooleanType,
Literal::Types::JSONDataType
Literal::Types::BooleanType::Instance,
Instance
].freeze

def inspect = "_JSONData"
Expand Down
6 changes: 3 additions & 3 deletions lib/literal/types/never_type.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# frozen_string_literal: true

# @api private
class Literal::Types::NeverTypeClass
class Literal::Types::NeverType
Instance = new.freeze

include Literal::Type

def inspect
Expand All @@ -23,5 +25,3 @@ def >=(other)

freeze
end

Literal::Types::NeverType = Literal::Types::NeverTypeClass.new.freeze
13 changes: 7 additions & 6 deletions lib/literal/types/truthy_type.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# frozen_string_literal: true

# @api private
class Literal::Types::TruthyTypeClass
class Literal::Types::TruthyType
Instance = new.freeze
include Literal::Type

def inspect
Expand All @@ -13,15 +14,15 @@ def ===(value)
end

def >=(other)
return false if other == Literal::Types::FalseyType

case other
when Literal::Types::TruthyType, true
true
else
when false, nil
false
else
true
end
end

freeze
end

Literal::Types::TruthyType = Literal::Types::TruthyTypeClass.new.freeze
2 changes: 1 addition & 1 deletion lib/literal/types/tuple_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def record_literal_type_errors(context)
while i < len
actual = context.actual[i]
if !(expected = @types[i])
context.add_child(label: "[#{i}]", expected: Literal::Types::NeverType, actual:)
context.add_child(label: "[#{i}]", expected: Literal::Types::NeverType::Instance, actual:)
elsif !(expected === actual)
context.add_child(label: "[#{i}]", expected:, actual:)
end
Expand Down
6 changes: 3 additions & 3 deletions lib/literal/types/void_type.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# frozen_string_literal: true

# @api private
class Literal::Types::VoidTypeClass
class Literal::Types::VoidType
Instance = new.freeze

include Literal::Type

def inspect
Expand All @@ -18,5 +20,3 @@ def >=(_)

freeze
end

Literal::Types::VoidType = Literal::Types::VoidTypeClass.new.freeze

0 comments on commit 28a8275

Please sign in to comment.