mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Generate the required AST-level thunk for subscript setters.
An Objective-C subscript setter has a type of the form (this) -> (value, index) -> () while a Swift subscript setter has a type of the form (this) -> (index) (value) -> () Introduce a Swift "thunk" with the latter signature that simply calls the underlying Objective-C method, and make sure that thunk gets type-checked and IR-generated appropriately. Swift SVN r3382
This commit is contained in:
@@ -473,10 +473,19 @@ void IRGenFunction::emitExternalDefinition(Decl *D) {
|
||||
case DeclKind::TopLevelCode:
|
||||
case DeclKind::TypeAlias:
|
||||
case DeclKind::Var:
|
||||
case DeclKind::Func:
|
||||
case DeclKind::Import:
|
||||
case DeclKind::Subscript:
|
||||
case DeclKind::Destructor:
|
||||
llvm_unreachable("Not a valid external definition for IRgen");
|
||||
|
||||
case DeclKind::Func:
|
||||
// The only functions available are subscript setters.
|
||||
assert(cast<FuncDecl>(D)->isGetterOrSetter() &&
|
||||
isa<SubscriptDecl>(cast<FuncDecl>(D)->getSetterDecl()) &&
|
||||
"Not a synthesized setter");
|
||||
IGM.emitInstanceMethod(cast<FuncDecl>(D));
|
||||
break;
|
||||
|
||||
case DeclKind::Constructor:
|
||||
if (D->getDeclContext()->getDeclaredTypeOfContext()
|
||||
->getClassOrBoundGenericClass()) {
|
||||
@@ -485,14 +494,6 @@ void IRGenFunction::emitExternalDefinition(Decl *D) {
|
||||
IGM.emitConstructor(cast<ConstructorDecl>(D));
|
||||
}
|
||||
break;
|
||||
|
||||
case DeclKind::Destructor:
|
||||
llvm_unreachable("Cannot handle destructors yet");
|
||||
break;
|
||||
|
||||
case DeclKind::Subscript:
|
||||
llvm_unreachable("Cannot handle subscripts yet");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user