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 {
2753
2753
OS << " )" ;
2754
2754
}
2755
2755
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
+
2756
2771
void visitMetatypeType (MetatypeType *T, StringRef label) {
2757
2772
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 ());
2772
2775
printRec (T->getInstanceType ());
2773
2776
OS << " )" ;
2774
2777
}
2775
2778
2776
2779
void visitExistentialMetatypeType (ExistentialMetatypeType *T,
2777
2780
StringRef label) {
2778
2781
printCommon (T, label, " existential_metatype_type" );
2782
+ if (T->hasRepresentation ())
2783
+ printMetatypeRepresentation (T->getRepresentation ());
2779
2784
printRec (T->getInstanceType ());
2780
2785
OS << " )" ;
2781
2786
}
Original file line number Diff line number Diff line change @@ -1491,8 +1491,9 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
1491
1491
if (auto dynamicSelf = dyn_cast<DynamicSelfType>(formalObjectType)) {
1492
1492
formalObjectType = dynamicSelf->getSelfType ()->getCanonicalType ();
1493
1493
}
1494
- return ((loweredOptionalKind == formalOptionalKind) &&
1495
- loweredObjectType == formalObjectType);
1494
+ return loweredOptionalKind == formalOptionalKind &&
1495
+ isLoweringOf (SILType::getPrimitiveAddressType (loweredObjectType),
1496
+ formalObjectType);
1496
1497
}
1497
1498
1498
1499
// 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