mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Some notes: 1. I implemented this as a contextual keyword that can only apply directly to lvalues. This ensures that we can still call functions called copy, define variables named copy, etc. I added tests for both the c++ and swift-syntax based parsers to validate this. So there shouldn't be any source breaks. 2. I did a little bit of type checker work to ensure that we do not treat copy_expr's result as an lvalue. Otherwise, one could call mutating functions on it or assign to it, which we do not want since the result of copy_value is 3. As expected, by creating a specific expr, I was able to have much greater control of the SILGen codegen and thus eliminate extraneous copies and other weirdness than if we used a function and had to go through SILGenApply. rdar://101862423
8 lines
276 B
Swift
8 lines
276 B
Swift
// RUN: %empty-directory(%t)
|
|
// RUN: %target-swift-ide-test -batch-code-completion -source-filename %s -filecheck %raw-FileCheck -completion-output-dir %t
|
|
|
|
func test(myParam: Int) {
|
|
copy #^COPY^#
|
|
// COPY: Decl[LocalVar]/Local: myParam[#Int#]; name=myParam
|
|
}
|