Skip to content

Commit

Permalink
Be resilient to environment
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenprater committed Jan 10, 2025
1 parent 40830d9 commit 2571a08
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions lib/tapioca/dsl/compilers/delegate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ class << self

sig { override.returns(T::Enumerable[::Module]) }
def gather_constants
return [] unless defined?(Tapioca::Dsl::Compilers::Extensions::Module)

all_classes.select do |c|
c.singleton_class < Tapioca::Dsl::Compilers::Extensions::Module &&
T.unsafe(c).__tapioca_delegated_methods.any?
Expand Down Expand Up @@ -87,6 +89,8 @@ def decorate
signature_of(constant.instance_method(delegated_method[:to]))
end

next unless sig

delegate_klass = if delegated_method[:allow_nil]
sig.return_type.unwrap_nilable.raw_type
else
Expand Down
2 changes: 0 additions & 2 deletions lib/tapioca/dsl/extensions/delegate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
return
end

return unless Module.respond_to?(:delegate)

module Tapioca
module Dsl
module Compilers
Expand Down
3 changes: 3 additions & 0 deletions spec/tapioca/cli/dsl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2847,6 +2847,7 @@ class PostCompiler < Tapioca::Dsl::Compiler
Tapioca::Dsl::Compilers::ActiveRecordStore enabled
Tapioca::Dsl::Compilers::ActiveSupportConcern enabled
Tapioca::Dsl::Compilers::ActiveSupportCurrentAttributes enabled
Tapioca::Dsl::Compilers::Delegate enabled
Tapioca::Dsl::Compilers::MixedInClassAttributes enabled
Tapioca::Dsl::Compilers::SidekiqWorker enabled
Tapioca::Dsl::Compilers::SmartProperties enabled
Expand Down Expand Up @@ -2882,6 +2883,7 @@ class PostCompiler < Tapioca::Dsl::Compiler
Tapioca::Dsl::Compilers::ActiveRecordStore enabled
Tapioca::Dsl::Compilers::ActiveSupportConcern enabled
Tapioca::Dsl::Compilers::ActiveSupportCurrentAttributes enabled
Tapioca::Dsl::Compilers::Delegate enabled
Tapioca::Dsl::Compilers::MixedInClassAttributes enabled
Tapioca::Dsl::Compilers::SidekiqWorker enabled
Tapioca::Dsl::Compilers::SmartProperties disabled
Expand Down Expand Up @@ -2917,6 +2919,7 @@ class PostCompiler < Tapioca::Dsl::Compiler
Tapioca::Dsl::Compilers::ActiveRecordStore disabled
Tapioca::Dsl::Compilers::ActiveSupportConcern disabled
Tapioca::Dsl::Compilers::ActiveSupportCurrentAttributes disabled
Tapioca::Dsl::Compilers::Delegate disabled
Tapioca::Dsl::Compilers::MixedInClassAttributes disabled
Tapioca::Dsl::Compilers::SidekiqWorker disabled
Tapioca::Dsl::Compilers::SmartProperties enabled
Expand Down

0 comments on commit 2571a08

Please sign in to comment.