Skip to content

[SR-1054] Casting [AnyObject] to generic type is not consistent with casting to non-generic types #43666

@swift-ci

Description

@swift-ci
Previous ID SR-1054
Radar None
Original Reporter sulthan (JIRA User)
Type Bug
Environment

Xcode 7.3, Swift 2.2

Additional Detail from JIRA
Votes 1
Component/s
Labels Bug, Runtime
Assignee None
Priority Medium

md5: 32776caf1482818306e70c7e8df3a15b

Issue Description:

See the following example

class GenericClass<T> {
    func someMethod() {
        let anyObjectArray: [AnyObject] = ["test1", "test2", "test3"]

        print(T) //Array<String>
        print(T.self == Array<String>.self) //true

        print(anyObjectArray is [String]) //true
        print(anyObjectArray is T) //false - BUG
    }
}

let instance = GenericClass<[String]>()
instance.someMethod()

Might be connected to SR-1024

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.runtimeThe Swift Runtime

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions