File tree Expand file tree Collapse file tree 2 files changed +33
-5
lines changed
packages/schema/src/language-server
tests/integration/tests/regression Expand file tree Collapse file tree 2 files changed +33
-5
lines changed Original file line number Diff line number Diff line change @@ -519,12 +519,17 @@ export class ZModelLinker extends DefaultLinker {
519
519
520
520
private resolveDataModel ( node : DataModel , document : LangiumDocument < AstNode > , extraScopes : ScopeProvider [ ] ) {
521
521
if ( node . superTypes . length > 0 ) {
522
- const providers = node . superTypes . map (
523
- ( superType ) => ( name : string ) => superType . ref ?. fields . find ( ( f ) => f . name === name )
524
- ) ;
525
- extraScopes = [ ...providers , ...extraScopes ] ;
522
+ const superTypeProviders : ScopeProvider [ ] = [ ] ;
523
+ // build scope providers for super types recursively with breadth-first search
524
+ const queue = node . superTypes . map ( ( t ) => t . ref ! ) ;
525
+ while ( queue . length > 0 ) {
526
+ const superType = queue . shift ( ) ! ;
527
+ const provider = ( name : string ) => superType . fields . find ( ( f ) => f . name === name ) ;
528
+ superTypeProviders . push ( provider ) ;
529
+ queue . push ( ...superType . superTypes . map ( ( t ) => t . ref ! ) ) ;
530
+ }
531
+ extraScopes = [ ...superTypeProviders , ...extraScopes ] ;
526
532
}
527
-
528
533
return this . resolveDefault ( node , document , extraScopes ) ;
529
534
}
530
535
Original file line number Diff line number Diff line change
1
+ import { loadSchema } from '@zenstackhq/testtools' ;
2
+
3
+ describe ( 'Regression: issue 971' , ( ) => {
4
+ it ( 'regression' , async ( ) => {
5
+ await loadSchema (
6
+ `
7
+ abstract model Level1 {
8
+ id String @id @default(cuid())
9
+ URL String?
10
+ @@validate(URL != null, "URL must be provided") // works
11
+ }
12
+ abstract model Level2 extends Level1 {
13
+ @@validate(URL != null, "URL must be provided") // works
14
+ }
15
+ abstract model Level3 extends Level2 {
16
+ @@validate(URL != null, "URL must be provided") // doesn't work
17
+ }
18
+ model Foo extends Level3 {
19
+ }
20
+ `
21
+ ) ;
22
+ } ) ;
23
+ } ) ;
You can’t perform that action at this time.
0 commit comments