File tree Expand file tree Collapse file tree 2 files changed +28
-4
lines changed Expand file tree Collapse file tree 2 files changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -1771,10 +1771,18 @@ pub fn (mut t Table) generic_insts_to_concrete() {
1771
1771
}
1772
1772
}
1773
1773
for i in 0 .. variants.len {
1774
- if t_typ := t.resolve_generic_to_concrete (variants[i], generic_names,
1775
- info.concrete_types)
1776
- {
1777
- variants[i] = t_typ
1774
+ if variants[i].has_flag (.generic) {
1775
+ sym := t.get_type_symbol (variants[i])
1776
+ if sym.kind == .struct_ && variants[i].idx () != info.parent_idx {
1777
+ variants[i] = t.unwrap_generic_type (variants[i], generic_names,
1778
+ info.concrete_types)
1779
+ } else {
1780
+ if t_typ := t.resolve_generic_to_concrete (variants[i],
1781
+ generic_names, info.concrete_types)
1782
+ {
1783
+ variants[i] = t_typ
1784
+ }
1785
+ }
1778
1786
}
1779
1787
}
1780
1788
typ.info = SumType{
Original file line number Diff line number Diff line change
1
+ struct Foo < T> {
2
+ x T
3
+ }
4
+
5
+ struct Bar < T> {
6
+ x T
7
+ }
8
+
9
+ type MyType< T> = Bar< T> | Foo< T>
10
+
11
+ fn test_generic_sumtype_insts () {
12
+ f := Foo< string > {'hi' }
13
+ t := MyType <string >(f)
14
+ println (t.type_name ())
15
+ assert t.type_name () == 'Foo<string>'
16
+ }
You can’t perform that action at this time.
0 commit comments