Skip to content

Commit a1aff7b

Browse files
committed
IRGen: Handle PackArchetypeType in getExemplarArchetype()
1 parent 837075c commit a1aff7b

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

lib/IRGen/GenType.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1966,14 +1966,14 @@ const TypeInfo &TypeConverter::getCompleteTypeInfo(CanType T) {
19661966
}
19671967

19681968
ArchetypeType *TypeConverter::getExemplarArchetype(ArchetypeType *t) {
1969-
// Get the primary archetype.
1970-
auto root = t->getRoot();
1971-
1972-
// If there is no primary (IOW, it's an opened archetype), the archetype is
1973-
// an exemplar.
1974-
if (!isa<PrimaryArchetypeType>(root) && !isa<VariadicSequenceType>(root))
1969+
if (isa<LocalArchetypeType>(t) || isa<OpaqueTypeArchetypeType>(t))
19751970
return t;
19761971

1972+
assert(isa<PrimaryArchetypeType>(t) || isa<PackArchetypeType>(t));
1973+
1974+
// Get the root archetype.
1975+
auto root = t->getRoot();
1976+
19771977
// Retrieve the generic environment of the archetype.
19781978
auto genericEnv = root->getGenericEnvironment();
19791979

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: %target-swift-frontend -emit-ir %s -enable-experimental-feature VariadicGenerics
2+
3+
// Because of -enable-experimental-feature VariadicGenerics
4+
// REQUIRES: asserts
5+
6+
// This would crash.
7+
public struct G<T> {}
8+
9+
public struct GG<each T> {
10+
public var variables: (repeat G<each T>)
11+
12+
public init() {
13+
fatalError()
14+
}
15+
}

0 commit comments

Comments
 (0)