Skip to content

Commit

Permalink
thread analysis options into the error verifier and type resolver
Browse files Browse the repository at this point in the history
Change-Id: I6f48f01040280b0c74dc4077b47e717912985b74
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/337640
Commit-Queue: Phil Quitslund <[email protected]>
Reviewed-by: Konstantin Shcheglov <[email protected]>
  • Loading branch information
pq authored and Commit Queue committed Nov 21, 2023
1 parent fc85488 commit 69666dc
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
9 changes: 7 additions & 2 deletions pkg/analyzer/lib/src/dart/analysis/library_analyzer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,13 @@ class LibraryAnalyzer {
//
// 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
Expand Down
13 changes: 7 additions & 6 deletions pkg/analyzer/lib/src/dart/resolver/typed_literal_resolver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,18 @@ class TypedLiteralResolver {
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));
}

Expand Down
5 changes: 2 additions & 3 deletions pkg/analyzer/lib/src/generated/error_verifier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
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;
Expand Down Expand Up @@ -242,7 +242,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>

/// 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),
Expand All @@ -258,7 +258,6 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
_isInConstructorInitializer = false;
_intType = _typeProvider.intType;
typeSystem = _currentLibrary.typeSystem;
_options = _currentLibrary.context.analysisOptions as AnalysisOptionsImpl;
_typeArgumentsVerifier =
TypeArgumentsVerifier(_options, _currentLibrary, errorReporter);
_constructorFieldsVerifier = ConstructorFieldsVerifier(
Expand Down
7 changes: 2 additions & 5 deletions pkg/analyzer/lib/src/generated/resolver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,6 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
nullSafetyEnabled: definingLibrary.isNonNullableByDefault,
patternsEnabled:
definingLibrary.featureSet.isEnabled(Feature.patterns)) {
var analysisOptions =
definingLibrary.context.analysisOptions as AnalysisOptionsImpl;

nullableDereferenceVerifier = NullableDereferenceVerifier(
typeSystem: typeSystem,
errorReporter: errorReporter,
Expand All @@ -378,8 +375,8 @@ class ResolverVisitor extends ThrowingAstVisitor<void>
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(
Expand Down

0 comments on commit 69666dc

Please sign in to comment.