Last active
November 21, 2019 08:24
-
-
Save 623637646/c0ed7c8d5a712cae7c3f44e6f644e139 to your computer and use it in GitHub Desktop.
A bug of AutoreleasingUnsafeMutablePointer compiling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class ViewController: UIViewController { | |
struct OneStruct { | |
} | |
class OneClass { | |
} | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// compile failed | |
var oneStruct: OneStruct? | |
test(&oneStruct) | |
assert(oneStruct != nil) | |
// compile success and run success | |
// var oneClass: OneClass? | |
// test2(&oneClass) | |
// assert(oneClass != nil) | |
} | |
func test(_ p: AutoreleasingUnsafeMutablePointer<OneStruct?>) { | |
p.pointee = OneStruct() | |
} | |
func test2(_ p: AutoreleasingUnsafeMutablePointer<OneClass?>) { | |
p.pointee = OneClass() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment