Skip to content

Commit 511db08

Browse files
Retype collection fetches
And do some minor cleanup
1 parent 2f66408 commit 511db08

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

src/NHibernate/Hql/Ast/ANTLR/QueryTranslatorImpl.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public partial class QueryTranslatorImpl : IFilterTranslator
3737
private IStatement _sqlAst;
3838
private IDictionary<string, string> _tokenReplacements;
3939
private HqlSqlGenerator _generator;
40-
private IList<IASTNode> collectionFetches;
40+
private List<FromElement> collectionFetches;
4141

4242
/// <summary>
4343
/// Creates a new AST-based query translator.
@@ -292,7 +292,7 @@ public bool CanAddFetchedCollectionToCache
292292
{
293293
get
294294
{
295-
foreach (FromElement fromElement in CollectionFetches)
295+
foreach (var fromElement in CollectionFetches)
296296
{
297297
var hasCache = fromElement.QueryableCollection.HasCache;
298298

@@ -457,14 +457,14 @@ private bool ContainsRestrictionOnTable(FromElement fromElement)
457457
.Any(rn => rn.FromElement == fromElement);
458458
}
459459

460-
private IList<IASTNode> CollectionFetches
460+
private IList<FromElement> CollectionFetches
461461
{
462462
get
463463
{
464464
if (collectionFetches == null)
465465
{
466466
ErrorIfDML();
467-
collectionFetches = ((QueryNode) _sqlAst).FromClause.GetCollectionFetches() ?? new List<IASTNode>();
467+
collectionFetches = ((QueryNode) _sqlAst).FromClause.GetCollectionFetches().Cast<FromElement>().ToList();
468468
}
469469

470470
return collectionFetches;

src/NHibernate/Hql/Ast/ANTLR/Tree/FromClause.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99

1010
namespace NHibernate.Hql.Ast.ANTLR.Tree
1111
{
12+
// 6.0 TODO: consider retyping methods yielding IList<IASTNode> as IList<FromElement>
13+
// They all do actually yield FromElement, and most of their callers end up recasting
14+
// them.
1215
/// <summary>
1316
/// Represents the 'FROM' part of a query or subquery, containing all mapped class references.
1417
/// Author: josh

src/NHibernate/Hql/Ast/ANTLR/Util/ASTUtil.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,15 @@ public static IList<IASTNode> CollectChildren(IASTNode root, FilterPredicate pre
109109
/// </summary>
110110
internal static IEnumerable<TRequiredType> IterateChildrenOfType<TRequiredType>(IASTNode root, Func<TRequiredType, bool> skipSearchInChildrenWhen)
111111
{
112-
foreach(var child in root)
112+
foreach (var child in root)
113113
{
114-
bool searchInChildren = true;
114+
var searchInChildren = true;
115115
if (child is TRequiredType typedChild)
116116
{
117117
searchInChildren = !skipSearchInChildrenWhen(typedChild);
118118
yield return typedChild;
119119
}
120-
if(searchInChildren)
120+
if (searchInChildren)
121121
{
122122
foreach (var subChild in IterateChildrenOfType(child, skipSearchInChildrenWhen))
123123
{

0 commit comments

Comments
 (0)