File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -840,9 +840,15 @@ static function (string $variance): TemplateTypeVariance {
840840 return new ErrorType ();
841841 }
842842
843- // Check for a generic type alias (e.g. ProviderRequest<AppraisalFilter>) before
844- // falling through to class-based generic resolution.
845- $ genericTypeAlias = $ this ->findGenericTypeAlias ($ typeNode ->type ->name , $ nameScope );
843+ // Check for a generic type alias (e.g. MyList<string>) before falling through to
844+ // class-based generic resolution, but only when the name is not itself a resolvable
845+ // class — in that case the class-based path must win to preserve backward compatibility
846+ // (a type alias like BelongsTo<T, U> = \Eloquent\BelongsTo<T, U> should still produce
847+ // the same GenericObjectType that class-based resolution would have given).
848+ $ resolvedGenericName = $ nameScope ->resolveStringName ($ typeNode ->type ->name );
849+ $ genericTypeAlias = !$ this ->getReflectionProvider ()->hasClass ($ resolvedGenericName )
850+ ? $ this ->findGenericTypeAlias ($ typeNode ->type ->name , $ nameScope )
851+ : null ;
846852 if ($ genericTypeAlias !== null ) {
847853 $ templateNodes = $ genericTypeAlias ->getTemplateTagValueNodes ();
848854 $ totalParams = count ($ templateNodes );
You can’t perform that action at this time.
0 commit comments