Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-5573] Any.Type is GenericType returning true instead of false #48145

Open
swift-ci opened this issue Jul 28, 2017 · 2 comments
Open

[SR-5573] Any.Type is GenericType returning true instead of false #48145

swift-ci opened this issue Jul 28, 2017 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-5573
Radar rdar://problem/33626514
Original Reporter tannernelson (JIRA User)
Type Bug
Environment

macOS 10.12.5

Tested with both:
Swift 4.0 2017-07-27
Swift 3.1.1

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

md5: d07d4015e89a04e4adc1b6fb355d798f

Issue Description:

It appears that the `is` operator is incorrectly returning true in the following code.

public protocol EmptyProtocol {}
public protocol ClassRestrictedEmptyProtocol: class { }

public class EmptyClassA: EmptyProtocol {}
public class EmptyClassB: ClassRestrictedEmptyProtocol {}

func type<P>(_ type: Any.Type, conformsTo p: P.Type) -> Bool {
    return type is P
}

print(type(EmptyClassA.self, conformsTo: EmptyProtocol.self)) // false
print(type(EmptyClassB.self, conformsTo: ClassRestrictedEmptyProtocol.self)) // true (should be false)

https://twitter.com/jckarter/status/891006142368817152

@belkadan
Copy link
Contributor

cc @jckarter

@belkadan
Copy link
Contributor

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself
Projects
None yet
Development

No branches or pull requests

2 participants