Skip to content

Commit 3c53431

Browse files
author
Eshed Shaham
committedDec 2, 2021
Fix crash when generating IR for a dependent objc generic.
1 parent 37649de commit 3c53431

4 files changed

+24
-0
lines changed
 

‎lib/AST/ClangTypeConverter.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,10 @@ clang::QualType ClangTypeConverter::visitArchetypeType(ArchetypeType *type) {
788788
return getClangIdType(ClangASTContext);
789789
}
790790

791+
clang::QualType ClangTypeConverter::visitDependentMemberType(DependentMemberType *type) {
792+
return convert(type->getBase());
793+
}
794+
791795
clang::QualType ClangTypeConverter::visitDynamicSelfType(DynamicSelfType *type) {
792796
// Dynamic Self is equivalent to 'instancetype', which is treated as
793797
// 'id' within the Objective-C type system.

‎lib/AST/ClangTypeConverter.h

+1
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ class ClangTypeConverter :
126126
clang::QualType visitBuiltinIntegerType(BuiltinIntegerType *type);
127127
clang::QualType visitBuiltinFloatType(BuiltinFloatType *type);
128128
clang::QualType visitArchetypeType(ArchetypeType *type);
129+
clang::QualType visitDependentMemberType(DependentMemberType *type);
129130
clang::QualType visitSILFunctionType(SILFunctionType *type);
130131
clang::QualType visitGenericTypeParamType(GenericTypeParamType *type);
131132
clang::QualType visitDynamicSelfType(DynamicSelfType *type);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@import Foundation;
2+
3+
@interface ObjCClass<V> : NSObject
4+
5+
- (void)barWithBlock:(nullable void (^)(V _Nullable))block;
6+
7+
@end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -emit-ir -primary-file %s -enable-objc-interop -import-objc-header %S/Inputs/objc_dependent_type_closure_argument.h
2+
3+
// Regression test for https://github.com/apple/swift/pull/40295
4+
public protocol SwiftProtocol {
5+
associatedtype T: AnyObject
6+
}
7+
8+
public class SwiftClass<S: SwiftProtocol> {
9+
static func foo(objcClass: ObjCClass<S.T>) {
10+
objcClass.bar(block: { _ in })
11+
}
12+
}

0 commit comments

Comments
 (0)