From b4daf6e98284dfd5fae90c2ff0f48be3d3059bff Mon Sep 17 00:00:00 2001 From: Michael Gottesman Date: Tue, 20 Feb 2018 11:07:25 -0800 Subject: [PATCH] [ownership-verifier] SuperMethod can take a metatype. rdar://34222540 --- lib/SIL/SILOwnershipVerifier.cpp | 2 +- test/SIL/ownership-verifier/use_verifier.sil | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/SIL/SILOwnershipVerifier.cpp b/lib/SIL/SILOwnershipVerifier.cpp index 4a9784e17bc78..3b67fff1352b9 100644 --- a/lib/SIL/SILOwnershipVerifier.cpp +++ b/lib/SIL/SILOwnershipVerifier.cpp @@ -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? @@ -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) diff --git a/test/SIL/ownership-verifier/use_verifier.sil b/test/SIL/ownership-verifier/use_verifier.sil index a57963cc9d6e1..6e787b581fe00 100644 --- a/test/SIL/ownership-verifier/use_verifier.sil +++ b/test/SIL/ownership-verifier/use_verifier.sil @@ -55,6 +55,7 @@ struct TupleContainingNonTrivialStruct { class SuperKlass { func d() {} + static func f() {} } class SubKlass : SuperKlass {} class X { @@ -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 : $() +}