@@ -67,7 +67,7 @@ import {
6767 isAliasInvocation ,
6868} from '../utils/ast-utils' ;
6969import { isMemberContainer } from './utils' ;
70- import { mapBuiltinTypeToExpressionType , mappedRawExpressionTypeToResolvedShape } from './validator/utils' ;
70+ import { mapBuiltinTypeToExpressionType } from './validator/utils' ;
7171
7272interface DefaultReference extends Reference {
7373 _ref ?: AstNode | LinkingError ;
@@ -312,19 +312,18 @@ export class ZModelLinker extends DefaultLinker {
312312 } else if ( isFutureExpr ( node ) ) {
313313 // future() function is resolved to current model
314314 node . $resolvedType = { decl : getContainingDataModel ( node ) } ;
315- } else if ( isAliasInvocation ( node ) || ! ! getContainerOfType ( node , isAliasDecl ) ) {
315+ } else if ( isAliasInvocation ( node ) ) {
316316 // function is resolved to matching alias declaration
317- const expressionType = funcDecl . expression ?. $type ;
318- if ( ! expressionType ) {
319- this . createLinkingError ( {
320- reference : node . function ,
321- container : node ,
322- property : 'alias' ,
323- } ) ;
324- return ;
317+ const containingAlias = getContainerOfType ( node , isAliasDecl ) ;
318+ const allAlias = getContainerOfType ( node , isModel ) ?. declarations . filter ( isAliasDecl ) ?? [ ] ;
319+ const matchingAlias =
320+ isAliasInvocation ( node ) && ! containingAlias
321+ ? allAlias . find ( ( alias ) => alias . name === node . function . $refText )
322+ : containingAlias ;
323+
324+ if ( matchingAlias ) {
325+ node . $resolvedType = { decl : matchingAlias , nullable : false } ;
325326 }
326- const mappedType = mappedRawExpressionTypeToResolvedShape ( expressionType ) ;
327- this . resolveToBuiltinTypeOrDecl ( node , mappedType ) ;
328327 } else {
329328 this . resolveToDeclaredType ( node , ( funcDecl as FunctionDecl ) . returnType ) ;
330329 }
0 commit comments