Fix described_class

Must be a macro, otherwise the return type becomes a union of all nested 
described_class methods, which can cause weird errors.
This commit is contained in:
Michael Miller 2021-01-31 00:38:17 -07:00
parent a20b7cad80
commit 0363c43dff
No known key found for this signature in database
GPG key ID: F9A0C5C65B162436

View file

@ -86,17 +86,17 @@ module Spectator::DSL
what.is_a?(TypeNode) || what.is_a?(TypeNode) ||
what.is_a?(Union)) && what.is_a?(Union)) &&
(described_type = what.resolve?).is_a?(TypeNode) %} (described_type = what.resolve?).is_a?(TypeNode) %}
private def described_class private macro described_class
{{described_type}} {{what}}
end end
{% if described_type < Reference || described_type < Value %} subject do
subject { described_class.new } {% if described_type.class? || described_type.struct? %}
{% else %} described_class.new
private def subject {% else %}
described_class described_class
end {% end %}
{% end %} end
{% else %} {% else %}
private def _spectator_implicit_subject private def _spectator_implicit_subject
{{what}} {{what}}