Skip to content

Commit 34443d6

Browse files
committed
fix #1446: better processing for ranges and channel types
1 parent e277091 commit 34443d6

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/com/goide/psi/impl/GoPsiImplUtil.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,9 @@ private static GoType processRangeClause(@NotNull GoVarDefinition o, @NotNull Go
529529
PsiElement resolve = typeRef.getReference().resolve();
530530
if (resolve instanceof GoTypeSpec) {
531531
type = ((GoTypeSpec)resolve).getType();
532+
if (type instanceof GoChannelType) {
533+
return type.getType();
534+
}
532535
}
533536
}
534537
if (type instanceof GoArrayOrSliceType && i == 1) return type.getType();

testData/highlighting/ranges.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,22 @@ func main() {
6060
for _, <error descr="Unused variable 'd'">d</error> := range <error descr="Unresolved reference 'd'">d</error>.Packets {
6161
}
6262
}
63-
func create() []*Person {return make([]*Person, 0)}
63+
func create() []*Person {return make([]*Person, 0)}
64+
65+
type myStruct struct {
66+
MyVal bool
67+
}
68+
69+
type myChanType chan myStruct
70+
71+
func chanFn(c myChanType) {
72+
for v := range c {
73+
fmt.Printf("Got %v\n", v.MyVal) // v.MyVal is unresolved
74+
}
75+
}
76+
77+
func <warning>main2</warning>() {
78+
ch := make(myChanType)
79+
go chanFn(ch)
80+
ch <- myStruct{true}
81+
}

0 commit comments

Comments
 (0)