Skip to content

Commit

Permalink
Showing 2 changed files with 30 additions and 1 deletion.
16 changes: 16 additions & 0 deletions spec/compiler/semantic/alias_spec.cr
Original file line number Diff line number Diff line change
@@ -248,4 +248,20 @@ describe "Semantic: alias" do
Alias
)) { static_array_of(uint8, 10).metaclass }
end

it "looks up alias for macro resolution (#3548)" do
assert_type(%(
class Foo
class Bar
def self.baz
1
end
end
end
alias Baz = Foo
Baz::Bar.baz
)) { int32 }
end
end
15 changes: 14 additions & 1 deletion src/compiler/crystal/types.cr
Original file line number Diff line number Diff line change
@@ -2232,7 +2232,20 @@ module Crystal
end

delegate lookup_defs, lookup_defs_with_modules, lookup_first_def,
lookup_macro, lookup_macros, types, types?, to: aliased_type
lookup_macro, lookup_macros, to: aliased_type

def types?
process_value
if aliased_type = @aliased_type
aliased_type.types?
else
nil
end
end

def types
types?.not_nil!
end

def remove_alias
process_value

0 comments on commit c534cb4

Please sign in to comment.