nsresolver fails on TraitUse without adaptations
This commit is contained in:
parent
bfc346ebab
commit
a98301f940
@ -156,25 +156,26 @@ func (nsr *NamespaceResolver) EnterNode(w walker.Walkable) bool {
|
||||
nsr.ResolveName(t, "")
|
||||
}
|
||||
|
||||
for _, a := range n.TraitAdaptationList.Adaptations {
|
||||
switch aa := a.(type) {
|
||||
case *stmt.TraitUsePrecedence:
|
||||
refTrait := aa.Ref.(*stmt.TraitMethodRef).Trait
|
||||
if refTrait != nil {
|
||||
nsr.ResolveName(refTrait, "")
|
||||
}
|
||||
for _, insteadOf := range aa.Insteadof {
|
||||
nsr.ResolveName(insteadOf, "")
|
||||
}
|
||||
if n.TraitAdaptationList != nil {
|
||||
for _, a := range n.TraitAdaptationList.Adaptations {
|
||||
switch aa := a.(type) {
|
||||
case *stmt.TraitUsePrecedence:
|
||||
refTrait := aa.Ref.(*stmt.TraitMethodRef).Trait
|
||||
if refTrait != nil {
|
||||
nsr.ResolveName(refTrait, "")
|
||||
}
|
||||
for _, insteadOf := range aa.Insteadof {
|
||||
nsr.ResolveName(insteadOf, "")
|
||||
}
|
||||
|
||||
case *stmt.TraitUseAlias:
|
||||
refTrait := aa.Ref.(*stmt.TraitMethodRef).Trait
|
||||
if refTrait != nil {
|
||||
nsr.ResolveName(refTrait, "")
|
||||
case *stmt.TraitUseAlias:
|
||||
refTrait := aa.Ref.(*stmt.TraitMethodRef).Trait
|
||||
if refTrait != nil {
|
||||
nsr.ResolveName(refTrait, "")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return true
|
||||
|
@ -348,6 +348,7 @@ func TestResolveGroupUse(t *testing.T) {
|
||||
func TestResolveTraitUse(t *testing.T) {
|
||||
nameAB := &name.Name{Parts: []node.Node{&name.NamePart{Value: "A"}, &name.NamePart{Value: "B"}}}
|
||||
nameB := &name.Name{Parts: []node.Node{&name.NamePart{Value: "B"}}}
|
||||
nameD := &name.Name{Parts: []node.Node{&name.NamePart{Value: "D"}}}
|
||||
|
||||
fullyQualifiedNameB := &name.FullyQualified{Parts: []node.Node{&name.NamePart{Value: "B"}}}
|
||||
fullyQualifiedNameBC := &name.FullyQualified{Parts: []node.Node{&name.NamePart{Value: "B"}, &name.NamePart{Value: "C"}}}
|
||||
@ -387,11 +388,17 @@ func TestResolveTraitUse(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
&stmt.TraitUse{
|
||||
Traits: []node.Node{
|
||||
nameD,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
expected := map[node.Node]string{
|
||||
nameB: "A\\B",
|
||||
nameD: "D",
|
||||
relativeNameB: "B",
|
||||
fullyQualifiedNameB: "B",
|
||||
fullyQualifiedNameBC: "B\\C",
|
||||
|
Loading…
Reference in New Issue
Block a user