You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
macOS 10.15.7 (19H2)
Xcode 12.4 (12D4e)
Apple Swift version 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28)
Target: x86_64-apple-darwin19.6.0
Additional Detail from JIRA
Votes
0
Component/s
Foundation
Labels
Bug
Assignee
None
Priority
Medium
md5: 35d5828be2f7cc590e207d5b1f16599c
Issue Description:
There is my code.
enumAnimalType{case dog
case cat
}protocolAnimal:AnyObject{vardescription:String{get}}classDog:Animal{vardescription:String{return"Dog"}}classCat:Animal{vardescription:String{return"Cat"}}classFoo{
weak varanimal:Animal?}func f1(animalType:AnimalType){letanimal:Animal
switch animalType {case.dog:
animal =Dog()case.cat:
animal =Cat()}letfoo=Foo()
foo.animal = animal
if let a = foo.animal {print(a.description)// Debug}else{print("animal has been released")// Release}}f1(animalType:.dog)
This code can work in DEBUG mode, but not in RELEASE mode.
I add `init` and `deinit` for those class, and find local variable animal has been released right after `let foo = Foo()`
I find some way to let this code work in RELEASE mode.
Add `print(animal)` before end of f1 scope.
or
Remove switch case, use `let animal: Animal = Dog()`
The text was updated successfully, but these errors were encountered:
Environment
macOS 10.15.7 (19H2)
Xcode 12.4 (12D4e)
Apple Swift version 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28)
Target: x86_64-apple-darwin19.6.0
Additional Detail from JIRA
md5: 35d5828be2f7cc590e207d5b1f16599c
Issue Description:
There is my code.
This code can work in DEBUG mode, but not in RELEASE mode.
I add `init` and `deinit` for those class, and find local variable animal has been released right after `let foo = Foo()`
I find some way to let this code work in RELEASE mode.
Add `print(animal)` before end of f1 scope.
or
Remove switch case, use `let animal: Animal = Dog()`
The text was updated successfully, but these errors were encountered: