File tree 2 files changed +15
-1
lines changed
src/compiler/crystal/semantic
2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -1061,4 +1061,18 @@ describe "Semantic: class" do
1061
1061
) ,
1062
1062
" undefined method 'bar' for Foo:Class"
1063
1063
end
1064
+
1065
+ it " inherits self twice (#5495)" do
1066
+ assert_type(%(
1067
+ class Foo
1068
+ class Bar < self
1069
+ end
1070
+
1071
+ class Baz < self
1072
+ end
1073
+ end
1074
+
1075
+ { {{ Foo::Bar.superclass }}, {{ Foo::Baz.superclass }} }
1076
+ ) ) { tuple_of [types[" Foo" ].metaclass, types[" Foo" ].metaclass] }
1077
+ end
1064
1078
end
Original file line number Diff line number Diff line change @@ -137,7 +137,7 @@ class Crystal::TopLevelVisitor < Crystal::SemanticVisitor
137
137
# type parameters because they will always be unbound.
138
138
superclass = lookup_type(node_superclass,
139
139
free_vars: free_vars,
140
- find_root_generic_type_parameters: false )
140
+ find_root_generic_type_parameters: false ).devirtualize
141
141
case superclass
142
142
when GenericClassType
143
143
node_superclass.raise " wrong number of type vars for #{ superclass } (given 0, expected #{ superclass.type_vars.size } )"
You can’t perform that action at this time.
0 commit comments