[TypeChecker] add defensive nullptr checks
[TypeChecker] add defensive nullptr checks

should resolve rdar://97339014

benlangmuir/swift,glessard/swift,glessard/swift,glessard/swift,apple/swift,glessard/swift,benlangmuir/swift,benlangmuir/swift,apple/swift,roambotics/swift,benlangmuir/swift,glessard/swift,apple/swift,glessard/swift,benlangmuir/swift,apple/swift,apple/swift,roambotics/swift,roambotics/swift,benlangmuir/swift,roambotics/swift,roambotics/swift,apple/swift,roambotics/swift