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, "")
|
nsr.ResolveName(t, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, a := range n.TraitAdaptationList.Adaptations {
|
if n.TraitAdaptationList != nil {
|
||||||
switch aa := a.(type) {
|
for _, a := range n.TraitAdaptationList.Adaptations {
|
||||||
case *stmt.TraitUsePrecedence:
|
switch aa := a.(type) {
|
||||||
refTrait := aa.Ref.(*stmt.TraitMethodRef).Trait
|
case *stmt.TraitUsePrecedence:
|
||||||
if refTrait != nil {
|
refTrait := aa.Ref.(*stmt.TraitMethodRef).Trait
|
||||||
nsr.ResolveName(refTrait, "")
|
if refTrait != nil {
|
||||||
}
|
nsr.ResolveName(refTrait, "")
|
||||||
for _, insteadOf := range aa.Insteadof {
|
}
|
||||||
nsr.ResolveName(insteadOf, "")
|
for _, insteadOf := range aa.Insteadof {
|
||||||
}
|
nsr.ResolveName(insteadOf, "")
|
||||||
|
}
|
||||||
|
|
||||||
case *stmt.TraitUseAlias:
|
case *stmt.TraitUseAlias:
|
||||||
refTrait := aa.Ref.(*stmt.TraitMethodRef).Trait
|
refTrait := aa.Ref.(*stmt.TraitMethodRef).Trait
|
||||||
if refTrait != nil {
|
if refTrait != nil {
|
||||||
nsr.ResolveName(refTrait, "")
|
nsr.ResolveName(refTrait, "")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
@ -348,6 +348,7 @@ func TestResolveGroupUse(t *testing.T) {
|
|||||||
func TestResolveTraitUse(t *testing.T) {
|
func TestResolveTraitUse(t *testing.T) {
|
||||||
nameAB := &name.Name{Parts: []node.Node{&name.NamePart{Value: "A"}, &name.NamePart{Value: "B"}}}
|
nameAB := &name.Name{Parts: []node.Node{&name.NamePart{Value: "A"}, &name.NamePart{Value: "B"}}}
|
||||||
nameB := &name.Name{Parts: []node.Node{&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"}}}
|
fullyQualifiedNameB := &name.FullyQualified{Parts: []node.Node{&name.NamePart{Value: "B"}}}
|
||||||
fullyQualifiedNameBC := &name.FullyQualified{Parts: []node.Node{&name.NamePart{Value: "B"}, &name.NamePart{Value: "C"}}}
|
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{
|
expected := map[node.Node]string{
|
||||||
nameB: "A\\B",
|
nameB: "A\\B",
|
||||||
|
nameD: "D",
|
||||||
relativeNameB: "B",
|
relativeNameB: "B",
|
||||||
fullyQualifiedNameB: "B",
|
fullyQualifiedNameB: "B",
|
||||||
fullyQualifiedNameBC: "B\\C",
|
fullyQualifiedNameBC: "B\\C",
|
||||||
|
Loading…
Reference in New Issue
Block a user