Move toCtype to use Visitor
Merge pull request #3108 from yebblies/toctype

[refactor] Move toCtype to use Visitor