Skip to content

Commit

Permalink
Showing 3 changed files with 40 additions and 1 deletion.
32 changes: 32 additions & 0 deletions spec/compiler/codegen/pointer_spec.cr
Original file line number Diff line number Diff line change
@@ -406,4 +406,36 @@ describe "Code gen: pointer" do
LibFoo.foo(Foo.new)
))
end

it "uses correct llvm module for typedef metaclass (#2877)" do
run(%(
require "prelude"
lib LibFoo
type Foo = Void*
type Bar = Void*
end
class Class
def foo
foo(1)
end
def foo(x)
end
end
struct Pointer
def foo
T.foo
end
end
foo = uninitialized LibFoo::Foo*
bar = uninitialized LibFoo::Bar*
foo.foo
bar.foo
1
))
end
end
2 changes: 1 addition & 1 deletion spec/compiler/codegen/super_spec.cr
Original file line number Diff line number Diff line change
@@ -398,7 +398,7 @@ describe "Codegen: super" do
end

it "calls super from virtual metaclass type (#2841)" do
codegen(%(
run(%(
require "prelude"
abstract class Foo
7 changes: 7 additions & 0 deletions src/compiler/crystal/types.cr
Original file line number Diff line number Diff line change
@@ -2627,6 +2627,13 @@ module Crystal
instance_type.virtual_type!.metaclass
end

def remove_typedef
if instance_type.is_a?(TypeDefType)
return instance_type.remove_typedef.metaclass
end
self
end

def to_s_with_options(io : IO, skip_union_parens : Bool = false, generic_args : Bool = true, codegen = false)
io << @name
end

0 comments on commit be4143f

Please sign in to comment.