John Montgomery
John Montgomery

Reputation: 7096

Attempting to print Generic.self in debugger ends the session

Suppose I'm using a generic type like this:

class Foo<T> {
    init () {
        print(T.self)
        // Breakpoint here
    }
}

Foo<String>()

At first it prints "String" as expected, but then when paused on the breakpoint if I type po T.self into the debugger, instead of displaying the result it immediately ends the debugging session. po String.self works properly, so I assume it's something specific to generics.

Is this a bug in Xcode? Is there any way to work around it, to see the current type of a generic without having to add extra debugging lines to the code itself?

Upvotes: 0

Views: 211

Answers (1)

John Montgomery
John Montgomery

Reputation: 7096

Based on the comments that can't reproduce it, this might be a problem with my environment or something. However, I was able to avoid it by using po print(T.self) instead, so hopefully that should work if anyone else is experiencing the same issue.

Upvotes: 1

Related Questions