-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed
Closed
Copy link
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.castingFeature: explicit casting (is, as, as? and as!)Feature: explicit casting (is, as, as? and as!)expressionsFeature: expressionsFeature: expressionsindexingArea → source tooling: AST indexingArea → source tooling: AST indexingsource toolingArea: IDE support, SourceKit, and other source toolingArea: IDE support, SourceKit, and other source toolingswift 5.1typesFeature: typesFeature: typesunexpected behaviorBug: Unexpected behavior or incorrect outputBug: Unexpected behavior or incorrect output
Description
Previous ID | SR-8616 |
Radar | None |
Original Reporter | rockbruno (JIRA User) |
Type | Bug |
Status | Resolved |
Resolution | Done |
Environment
SourceKit from Xcode 9.4.1 and Xcode 10 beta 6
Additional Detail from JIRA
Votes | 0 |
Component/s | Source Tooling |
Labels | Bug |
Assignee | rockbruno (JIRA) |
Priority | Medium |
md5: 22d8979ad62c340d645d65da483e3c6f
is duplicated by:
Issue Description:
struct Bar {}
func match() {
let foo: Int = 1
if foo is Bar {
print("matched")
}
}
When using the is
pattern with non-optionals, SourceKit will correctly index the matched type Bar
:
key.kind: source.lang.swift.decl.function.method.instance,
key.name: "match()",
key.usr: "s:4test32qUnffbxEdwYPExPcFQoiHlTghlbgoVIyC5matchyyF",
key.line: 15,
key.column: 10,
key.is_dynamic: 1,
key.entities: [
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int",
key.usr: "s:Si",
key.line: 16,
key.column: 18
},
{
key.kind: source.lang.swift.ref.struct,
key.name: "Bar",
key.usr: "s:4test32qUnffbxEdwYPExPcFQoiHlTghlbgoVIyC3BarV",
key.line: 17,
key.column: 19
},
{
key.kind: source.lang.swift.ref.function.free,
key.name: "print(_:separator:terminator:)",
key.usr: "s:s5printyypd_SS9separatorSS10terminatortF",
key.line: 18,
key.column: 13
}
]
If foo
is an optional however, Bar
will not index:
struct Bar {}
func match() {
let foo: Int? = 1
if foo is Bar {
print("matched")
}
}
key.kind: source.lang.swift.decl.function.method.instance,
key.name: "match()",
key.usr: "s:4test32qUnffbxEdwYPExPcFQoiHlTghlbgoVIyC5matchyyF",
key.line: 15,
key.column: 10,
key.is_dynamic: 1,
key.entities: [
{
key.kind: source.lang.swift.ref.struct,
key.name: "Int",
key.usr: "s:Si",
key.line: 16,
key.column: 18
},
{
key.kind: source.lang.swift.ref.function.free,
key.name: "print(_:separator:terminator:)",
key.usr: "s:s5printyypd_SS9separatorSS10terminatortF",
key.line: 18,
key.column: 13
}
]
You can see that Xcode will stop highlighting it.
I can gladly take a look at this if someone points me to the right direction!
Metadata
Metadata
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.castingFeature: explicit casting (is, as, as? and as!)Feature: explicit casting (is, as, as? and as!)expressionsFeature: expressionsFeature: expressionsindexingArea → source tooling: AST indexingArea → source tooling: AST indexingsource toolingArea: IDE support, SourceKit, and other source toolingArea: IDE support, SourceKit, and other source toolingswift 5.1typesFeature: typesFeature: typesunexpected behaviorBug: Unexpected behavior or incorrect outputBug: Unexpected behavior or incorrect output