File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -118,10 +118,12 @@ function cloneAst<T extends InheritableNode>(
118118 clone . $container = newContainer ;
119119
120120 if ( isDataModel ( newContainer ) && isDataModelField ( node ) ) {
121- // walk up the hierarchy to find the model where the field is defined (delegate or abstract base)
122- const allBases = getRecursiveBases ( newContainer ) ;
123- clone . $inheritedFrom = allBases . find ( ( base ) => base . fields . some ( ( f ) => f . name === node . name ) ) ;
124- } else {
121+ // walk up the hierarchy to find the upper-most delegate ancestor that defines the field
122+ const delegateBases = getRecursiveBases ( newContainer ) . filter ( isDelegateModel ) ;
123+ clone . $inheritedFrom = delegateBases . findLast ( ( base ) => base . fields . some ( ( f ) => f . name === node . name ) ) ;
124+ }
125+
126+ if ( ! clone . $inheritedFrom ) {
125127 clone . $inheritedFrom = node . $inheritedFrom ?? getContainerOfType ( node , isDataModel ) ;
126128 }
127129
Original file line number Diff line number Diff line change @@ -460,7 +460,7 @@ export function isDelegateModel(node: AstNode) {
460460}
461461
462462export function isDiscriminatorField ( field : DataModelField ) {
463- const model = getInheritedFromDelegate ( field ) ?? field . $container ;
463+ const model = field . $inheritedFrom ?? field . $container ;
464464 const delegateAttr = getAttribute ( model , '@@delegate' ) ;
465465 if ( ! delegateAttr ) {
466466 return false ;
You can’t perform that action at this time.
0 commit comments