@@ -80,9 +80,15 @@ class CreateScopesVisitation extends Visitation {
80
80
'noSuchMethod' ,
81
81
};
82
82
83
- void visitObjCMethods (ObjCMethods node, Scope localScope) {
83
+ void visitObjCMethods (
84
+ ObjCMethods node,
85
+ ObjCInterface ? superType,
86
+ Scope classScope,
87
+ ) {
84
88
for (final m in node.methods) {
85
- createScope (m, localScope, m.originalName);
89
+ final parentScope =
90
+ _findRootWithMethod (superType, m)? .localScope ?? classScope;
91
+ createScope (m, parentScope, m.originalName);
86
92
}
87
93
}
88
94
@@ -92,6 +98,7 @@ class CreateScopesVisitation extends Visitation {
92
98
node.visitChildren (visitor, typeGraphOnly: orderedPass);
93
99
visitObjCMethods (
94
100
node,
101
+ node.parent,
95
102
createScope (
96
103
node,
97
104
node.parent.localScope,
@@ -111,6 +118,7 @@ class CreateScopesVisitation extends Visitation {
111
118
}
112
119
visitObjCMethods (
113
120
node,
121
+ node.superType,
114
122
createScope (
115
123
node,
116
124
node.superType? .localScope ?? context.rootScope,
@@ -127,6 +135,7 @@ class CreateScopesVisitation extends Visitation {
127
135
}
128
136
visitObjCMethods (
129
137
node,
138
+ null ,
130
139
createScope (
131
140
node,
132
141
context.rootScope,
@@ -135,4 +144,14 @@ class CreateScopesVisitation extends Visitation {
135
144
),
136
145
);
137
146
}
147
+
148
+ ObjCInterface ? _findRootWithMethod (ObjCInterface ? node, ObjCMethod method) {
149
+ ObjCInterface ? root;
150
+ for (var t = node; t != null ; t = t.superType) {
151
+ if (t.getSimilarMethod (method) == null ) break ;
152
+ root = t;
153
+ }
154
+ assert (root == null || root.getSimilarMethod (method) != null );
155
+ return root;
156
+ }
138
157
}
0 commit comments