File tree Expand file tree Collapse file tree 3 files changed +44
-16
lines changed Expand file tree Collapse file tree 3 files changed +44
-16
lines changed Original file line number Diff line number Diff line change @@ -2753,29 +2753,34 @@ namespace {
27532753 OS << " )" ;
27542754 }
27552755
2756+ void printMetatypeRepresentation (MetatypeRepresentation representation) {
2757+ OS << " " ;
2758+ switch (representation) {
2759+ case MetatypeRepresentation::Thin:
2760+ OS << " @thin" ;
2761+ break ;
2762+ case MetatypeRepresentation::Thick:
2763+ OS << " @thick" ;
2764+ break ;
2765+ case MetatypeRepresentation::ObjC:
2766+ OS << " @objc" ;
2767+ break ;
2768+ }
2769+ }
2770+
27562771 void visitMetatypeType (MetatypeType *T, StringRef label) {
27572772 printCommon (T, label, " metatype_type" );
2758- if (T->hasRepresentation ()) {
2759- OS << " " ;
2760- switch (T->getRepresentation ()) {
2761- case MetatypeRepresentation::Thin:
2762- OS << " @thin" ;
2763- break ;
2764- case MetatypeRepresentation::Thick:
2765- OS << " @thick" ;
2766- break ;
2767- case MetatypeRepresentation::ObjC:
2768- OS << " @objc" ;
2769- break ;
2770- }
2771- }
2773+ if (T->hasRepresentation ())
2774+ printMetatypeRepresentation (T->getRepresentation ());
27722775 printRec (T->getInstanceType ());
27732776 OS << " )" ;
27742777 }
27752778
27762779 void visitExistentialMetatypeType (ExistentialMetatypeType *T,
27772780 StringRef label) {
27782781 printCommon (T, label, " existential_metatype_type" );
2782+ if (T->hasRepresentation ())
2783+ printMetatypeRepresentation (T->getRepresentation ());
27792784 printRec (T->getInstanceType ());
27802785 OS << " )" ;
27812786 }
Original file line number Diff line number Diff line change @@ -1491,8 +1491,9 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
14911491 if (auto dynamicSelf = dyn_cast<DynamicSelfType>(formalObjectType)) {
14921492 formalObjectType = dynamicSelf->getSelfType ()->getCanonicalType ();
14931493 }
1494- return ((loweredOptionalKind == formalOptionalKind) &&
1495- loweredObjectType == formalObjectType);
1494+ return loweredOptionalKind == formalOptionalKind &&
1495+ isLoweringOf (SILType::getPrimitiveAddressType (loweredObjectType),
1496+ formalObjectType);
14961497 }
14971498
14981499 // Metatypes preserve their instance type through lowering.
Original file line number Diff line number Diff line change 1+ // RUN: %target-sil-opt -module-name Swift %s
2+ // REQUIRES: asserts
3+ //
4+ // Make sure that we properly verify the lowering of optional value
5+ // metatypes. This shouldn't crash.
6+ //
7+ // rdar://28536812
8+
9+ enum Optional<T> {
10+ case none
11+ case some(T)
12+ }
13+
14+ sil @foo : $@convention(thin) () -> () {
15+ %0 = enum $Optional<@thick Any.Type>, #Optional.none!enumelt
16+ %1 = alloc_stack $Optional<@thick Any.Type>
17+ store %0 to %1 : $*Optional<@thick Any.Type>
18+ %2 = value_metatype $@thick Optional<Any.Type>.Type, %1 : $*Optional<@thick Any.Type>
19+ dealloc_stack %1 : $*Optional<@thick Any.Type>
20+ %3 = tuple()
21+ return %3 : $()
22+ }
You can’t perform that action at this time.
0 commit comments