Skip to content

Commit da0e1da

Browse files
authored
Merge pull request #41607 from DougGregor/sil-verify-concretized-objc
[SIL] Fix incorrect verifier check when generic functions have been made non-polymorphic
2 parents 7353c43 + 82aa82a commit da0e1da

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/SIL/Verifier/SILVerifier.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5832,7 +5832,9 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
58325832

58335833
// Make sure that our SILFunction only has context generic params if our
58345834
// SILFunctionType is non-polymorphic.
5835-
if (F->getGenericEnvironment()) {
5835+
if (F->getGenericEnvironment() &&
5836+
!F->getGenericEnvironment()->getGenericSignature()
5837+
->areAllParamsConcrete()) {
58365838
require(FTy->isPolymorphic(),
58375839
"non-generic function definitions cannot have a "
58385840
"generic environment");

test/SILGen/objc_generic_class.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,13 @@ class Generic<T>: NSObject {
4141
class SubGeneric1<U, V>: Generic<Int> {
4242
}
4343

44+
45+
// Ensure that the verifier doesn't reject @objc functions where all of the
46+
// generic parameters have been same-typed to concrete types.
47+
public struct GenericStruct<T> { }
48+
49+
public extension GenericStruct where T == String {
50+
public class Y {
51+
@objc public func f() -> String { "hello" }
52+
}
53+
}

0 commit comments

Comments
 (0)