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?(Union)) &&
(described_type = what.resolve?).is_a?(TypeNode) %}
private def described_class
{{described_type}}
private macro described_class
{{what}}
end
{% if described_type < Reference || described_type < Value %}
subject { described_class.new }
{% else %}
private def subject
subject do
{% if described_type.class? || described_type.struct? %}
described_class.new
{% else %}
described_class
end
{% end %}
{% end %}
end
{% else %}
private def _spectator_implicit_subject
{{what}}