thread analysis options into the error verifier and type resolver
Change-Id: I6f48f01040280b0c74dc4077b47e717912985b74
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337640
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
diff --git a/pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart b/pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart
index e1f2813..9720cfb 100644
--- a/pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart
@@ -403,8 +403,13 @@
//
// Use the ErrorVerifier to compute errors.
//
- ErrorVerifier errorVerifier = ErrorVerifier(errorReporter, _libraryElement,
- _typeProvider, _inheritance, _libraryVerificationContext);
+ ErrorVerifier errorVerifier = ErrorVerifier(
+ errorReporter,
+ _libraryElement,
+ _typeProvider,
+ _inheritance,
+ _libraryVerificationContext,
+ _analysisOptions);
unit.accept(errorVerifier);
// Verify constraints on FFI uses. The CFE enforces these constraints as
diff --git a/pkg/analyzer/lib/src/dart/resolver/typed_literal_resolver.dart b/pkg/analyzer/lib/src/dart/resolver/typed_literal_resolver.dart
index bca46ca..ba7b8b3 100644
--- a/pkg/analyzer/lib/src/dart/resolver/typed_literal_resolver.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/typed_literal_resolver.dart
@@ -52,17 +52,18 @@
final bool _strictInference;
final bool _isNonNullableByDefault;
- factory TypedLiteralResolver(ResolverVisitor resolver, FeatureSet featureSet,
- TypeSystemImpl typeSystem, TypeProviderImpl typeProvider) {
- var library = resolver.definingLibrary;
- var analysisOptions = library.context.analysisOptions;
- var analysisOptionsImpl = analysisOptions as AnalysisOptionsImpl;
+ factory TypedLiteralResolver(
+ ResolverVisitor resolver,
+ FeatureSet featureSet,
+ TypeSystemImpl typeSystem,
+ TypeProviderImpl typeProvider,
+ AnalysisOptionsImpl analysisOptions) {
return TypedLiteralResolver._(
resolver,
typeSystem,
typeProvider,
resolver.errorReporter,
- analysisOptionsImpl.strictInference,
+ analysisOptions.strictInference,
featureSet.isEnabled(Feature.non_nullable));
}
diff --git a/pkg/analyzer/lib/src/generated/error_verifier.dart b/pkg/analyzer/lib/src/generated/error_verifier.dart
index 12bbf31..7545d9a 100644
--- a/pkg/analyzer/lib/src/generated/error_verifier.dart
+++ b/pkg/analyzer/lib/src/generated/error_verifier.dart
@@ -156,7 +156,7 @@
late final InterfaceType _intType;
/// The options for verification.
- late final AnalysisOptionsImpl _options;
+ final AnalysisOptionsImpl _options;
/// The object providing access to the types defined by the language.
final TypeProvider _typeProvider;
@@ -242,7 +242,7 @@
/// Initialize a newly created error verifier.
ErrorVerifier(this.errorReporter, this._currentLibrary, this._typeProvider,
- this._inheritanceManager, this.libraryVerificationContext)
+ this._inheritanceManager, this.libraryVerificationContext, this._options)
: _uninstantiatedBoundChecker =
_UninstantiatedBoundChecker(errorReporter),
_checkUseVerifier = UseResultVerifier(errorReporter),
@@ -258,7 +258,6 @@
_isInConstructorInitializer = false;
_intType = _typeProvider.intType;
typeSystem = _currentLibrary.typeSystem;
- _options = _currentLibrary.context.analysisOptions as AnalysisOptionsImpl;
_typeArgumentsVerifier =
TypeArgumentsVerifier(_options, _currentLibrary, errorReporter);
_constructorFieldsVerifier = ConstructorFieldsVerifier(
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
index 7a6c944..b5fb4cf 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -363,9 +363,6 @@
nullSafetyEnabled: definingLibrary.isNonNullableByDefault,
patternsEnabled:
definingLibrary.featureSet.isEnabled(Feature.patterns)) {
- var analysisOptions =
- definingLibrary.context.analysisOptions as AnalysisOptionsImpl;
-
nullableDereferenceVerifier = NullableDereferenceVerifier(
typeSystem: typeSystem,
errorReporter: errorReporter,
@@ -378,8 +375,8 @@
errorReporter: errorReporter,
nullableDereferenceVerifier: nullableDereferenceVerifier,
);
- _typedLiteralResolver =
- TypedLiteralResolver(this, _featureSet, typeSystem, typeProvider);
+ _typedLiteralResolver = TypedLiteralResolver(
+ this, _featureSet, typeSystem, typeProvider, analysisOptions);
extensionResolver = ExtensionMemberResolver(this);
typePropertyResolver = TypePropertyResolver(this);
inferenceHelper = InvocationInferenceHelper(