Change SpeculativeModel property to GetSpeculativeModel method.

上级 9318f446
......@@ -141,14 +141,11 @@ internal override MemberSemanticModel GetMemberModel(SyntaxNode node)
// We hide this property, as EnsureRootBoundForNullabilityIfNecessary can cause
// the cache to be populated.
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
protected NullableWalker.SnapshotManager SnapshotManager
protected NullableWalker.SnapshotManager GetSnapshotManager()
{
get
{
EnsureRootBoundForNullabilityIfNecessary();
return _lazySnapshotManager;
}
EnsureRootBoundForNullabilityIfNecessary();
Debug.Assert(_lazySnapshotManager is object || !Compilation.NullableSemanticAnalysisEnabled);
return _lazySnapshotManager;
}
internal sealed override bool TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticModel parentModel, int position, TypeSyntax type, SpeculativeBindingOption bindingOption, out SemanticModel speculativeModel)
......@@ -185,16 +182,13 @@ internal override BoundExpression GetSpeculativelyBoundExpression(int position,
return GetSpeculativelyBoundExpressionWithoutNullability(position, expression, bindingOption, out binder, out crefSymbols);
}
EnsureRootBoundForNullabilityIfNecessary();
Debug.Assert(SnapshotManager is object);
crefSymbols = default;
position = CheckAndAdjustPosition(position);
expression = SyntaxFactory.GetStandaloneExpression(expression);
var bindableNewExpression = GetBindableSyntaxNode(expression);
binder = GetEnclosingBinder(position);
var boundRoot = Bind(binder, bindableNewExpression, _ignoredDiagnostics);
return (BoundExpression)NullableWalker.AnalyzeAndRewriteSpeculation(position, boundRoot, binder, SnapshotManager, takeNewSnapshots: false, out _);
return (BoundExpression)NullableWalker.AnalyzeAndRewriteSpeculation(position, boundRoot, binder, GetSnapshotManager(), takeNewSnapshots: false, out _);
}
private Binder GetEnclosingBinderInternalWithinRoot(SyntaxNode node, int position)
......
......@@ -162,7 +162,7 @@ internal override bool TryGetSpeculativeSemanticModelCore(SyntaxTreeSemanticMode
var methodSymbol = (MethodSymbol)this.MemberSymbol;
binder = new ExecutableCodeBinder(statement, methodSymbol, binder);
speculativeModel = CreateSpeculative(parentModel, methodSymbol, statement, binder, SnapshotManager, position);
speculativeModel = CreateSpeculative(parentModel, methodSymbol, statement, binder, GetSnapshotManager(), position);
return true;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册