Skip to content

Commit

Permalink
SILGen: Substitute initializer's interface type into thunk's context …
Browse files Browse the repository at this point in the history
…in emitForeignToNativeThunk.

rdar://problem/32331915
  • Loading branch information
jckarter committed May 22, 2017
1 parent ae6ce20 commit 85e4456
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lib/SILGen/SILGenBridging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1241,6 +1241,9 @@ void SILGenFunction::emitForeignToNativeThunk(SILDeclRef thunk) {
allocatorSelfType = forwardedParameters[0]
->getInterfaceType(getASTContext())
->getLValueOrInOutObjectType();
if (F.getGenericEnvironment())
allocatorSelfType = F.getGenericEnvironment()
->mapTypeIntoContext(allocatorSelfType);
forwardedParameters = forwardedParameters.slice(1);
}

Expand Down
5 changes: 5 additions & 0 deletions test/SILGen/Inputs/objc_required_designated_init.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@import Foundation;

@interface NSBoom<T> : NSObject

@end
6 changes: 6 additions & 0 deletions test/SILGen/Inputs/objc_required_designated_init_2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,9 @@ open class Boom: NSObject {
}
}

open class Badaboom<U>: NSBoom<NSString> {
public override required init() {
super.init()
}
}

10 changes: 8 additions & 2 deletions test/SILGen/objc_required_designated_init.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// RUN: rm -rf %t && mkdir -p %t
// RUN: %target-swift-frontend -emit-module %S/Inputs/objc_required_designated_init_2.swift -module-name Booms -o %t/Booms.swiftmodule
// RUN: %target-swift-frontend -I %t -emit-silgen -verify %s
// RUN: %target-swift-frontend -emit-module %S/Inputs/objc_required_designated_init_2.swift -module-name Booms -o %t/Booms.swiftmodule -import-objc-header %S/Inputs/objc_required_designated_init.h
// RUN: %target-swift-frontend -I %t -emit-silgen -verify %s -import-objc-header %S/Inputs/objc_required_designated_init.h

// REQUIRES: objc_interop

import Booms
Expand All @@ -11,3 +12,8 @@ class Baboom: Boom {
}
}

class BigBadaBoom<V>: Badaboom<V> {
required init() {
super.init()
}
}

0 comments on commit 85e4456

Please sign in to comment.