mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[TypeCheckEffects] AbstractFunction: Parameter types should be mapped into context
Parameter type could be represented by an associated type which is bound to a concrete type by an extension, `AbstractFunction::getType()` should map it into context before returning because the construct is that it always produces a function type. Resolves: rdar://156955193 (cherry picked from commit32b97d0e2a) (cherry picked from commit7f652915d9)
This commit is contained in:
@@ -395,7 +395,10 @@ public:
|
||||
}
|
||||
case Kind::Closure: return getClosure()->getType();
|
||||
case Kind::Parameter:
|
||||
return getParameter()->getInterfaceType()->lookThroughAllOptionalTypes();
|
||||
auto *param = getParameter();
|
||||
auto *dc = param->getDeclContext();
|
||||
return dc->mapTypeIntoContext(param->getInterfaceType())
|
||||
->lookThroughAllOptionalTypes();
|
||||
}
|
||||
llvm_unreachable("bad kind");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
// RUN: %target-typecheck-verify-swift
|
||||
|
||||
protocol Definition {
|
||||
associatedtype Delegate
|
||||
}
|
||||
|
||||
enum Kind {
|
||||
case normal
|
||||
case other
|
||||
}
|
||||
|
||||
struct Payload {
|
||||
}
|
||||
|
||||
extension Definition where Delegate == ((Kind, Payload) -> Void) {
|
||||
static func invokeDelegate(_ delegate: Delegate, kind: Kind, payload: Payload) {
|
||||
delegate(kind, payload)
|
||||
}
|
||||
}
|
||||
|
||||
extension Definition where Delegate == ((Kind, Payload) -> Void)? {
|
||||
static func invokeOptionalDelegate(_ delegate: Delegate, kind: Kind, payload: Payload) {
|
||||
delegate?(kind, payload)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user