Skip to content

Commit

Permalink
[ownership-verifier] SuperMethod can take a metatype.
Browse files Browse the repository at this point in the history
rdar://34222540
  • Loading branch information
gottesmm committed Feb 23, 2018
1 parent 1785855 commit b4daf6e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/SIL/SILOwnershipVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ ACCEPTS_ANY_OWNERSHIP_INST(ValueToBridgeObject)
ACCEPTS_ANY_NONTRIVIAL_OWNERSHIP_OR_METATYPE(MustBeLive, ClassMethod)
ACCEPTS_ANY_NONTRIVIAL_OWNERSHIP_OR_METATYPE(MustBeLive, ObjCMethod)
ACCEPTS_ANY_NONTRIVIAL_OWNERSHIP_OR_METATYPE(MustBeLive, ObjCSuperMethod)
ACCEPTS_ANY_NONTRIVIAL_OWNERSHIP_OR_METATYPE(MustBeLive, SuperMethod)
#undef ACCEPTS_ANY_NONTRIVIAL_OWNERSHIP_OR_METATYPE

// Trivial if trivial typed, otherwise must accept owned?
Expand All @@ -598,7 +599,6 @@ ACCEPTS_ANY_NONTRIVIAL_OWNERSHIP_OR_METATYPE(MustBeLive, ObjCSuperMethod)
!compatibleWithOwnership(ValueOwnershipKind::Trivial); \
return {compatible, UseLifetimeConstraint::USE_LIFETIME_CONSTRAINT}; \
}
ACCEPTS_ANY_NONTRIVIAL_OWNERSHIP(MustBeLive, SuperMethod)
ACCEPTS_ANY_NONTRIVIAL_OWNERSHIP(MustBeLive, BridgeObjectToWord)
ACCEPTS_ANY_NONTRIVIAL_OWNERSHIP(MustBeLive, ClassifyBridgeObject)
ACCEPTS_ANY_NONTRIVIAL_OWNERSHIP(MustBeLive, CopyBlock)
Expand Down
10 changes: 10 additions & 0 deletions test/SIL/ownership-verifier/use_verifier.sil
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ struct TupleContainingNonTrivialStruct {

class SuperKlass {
func d() {}
static func f() {}
}
class SubKlass : SuperKlass {}
class X {
Expand Down Expand Up @@ -1004,3 +1005,12 @@ bb3:
%9999 = tuple()
return %9999 : $()
}

sil @super_method_metatype_test : $@convention(thin) (@thick SubKlass.Type) -> () {
bb0(%0 : @trivial $@thick SubKlass.Type):
%1 = upcast %0 : $@thick SubKlass.Type to $@thick SuperKlass.Type
%2 = class_method %1 : $@thick SuperKlass.Type, #SuperKlass.f!1 : (SuperKlass.Type) -> () -> (), $@convention(method) (@thick SuperKlass.Type) -> ()
apply %2(%1) : $@convention(method) (@thick SuperKlass.Type) -> ()
%9999 = tuple()
return %9999 : $()
}

0 comments on commit b4daf6e

Please sign in to comment.