mirror of
https://github.com/github/codeql.git
synced 2026-04-27 01:35:13 +02:00
Swift: Remove the code related to constructor capture (and the related TODO). This cannot happen in Swift.
This commit is contained in:
@@ -942,7 +942,30 @@ private module CaptureInput implements VariableCapture::InputSig {
|
||||
}
|
||||
|
||||
class Callable extends S::Callable {
|
||||
predicate isConstructor() { this instanceof S::Initializer }
|
||||
predicate isConstructor() {
|
||||
// A class declaration cannot capture a variable in Swift. Consider this hypothetical example:
|
||||
// ```
|
||||
// protocol Interface { }
|
||||
// func foo() -> Interface {
|
||||
// let y = 42
|
||||
// class Impl : Interface {
|
||||
// let x : Int
|
||||
// init() {
|
||||
// x = y
|
||||
// }
|
||||
// }
|
||||
// let object = Impl()
|
||||
// return object
|
||||
// }
|
||||
// ```
|
||||
// The Swift compiler will reject this with an error message such as
|
||||
// ```
|
||||
// error: class declaration cannot close over value 'y' defined in outer scope
|
||||
// x = y
|
||||
// ^
|
||||
// ```
|
||||
none()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -964,8 +987,6 @@ private CaptureFlow::ClosureNode asClosureNode(Node n) {
|
||||
or
|
||||
result.(CaptureFlow::ThisParameterNode).getCallable() = n.(ClosureSelfParameterNode).getClosure()
|
||||
or
|
||||
result.(CaptureFlow::MallocNode).getClosureExpr() = n.getCfgNode().getNode().asAstNode() // TODO: figure out why the java version had PostUpdateNode logic here
|
||||
or
|
||||
exists(CaptureInput::VariableWrite write |
|
||||
result.(CaptureFlow::VariableWriteSourceNode).getVariableWrite() = write and
|
||||
n.asExpr() = write.getSource()
|
||||
|
||||
Reference in New Issue
Block a user