55// DO NOT EDIT. This file was generated from async_environment.dart.
66// See tool/grind/synchronize.dart for details.
77//
8- // Checksum: add8a3972aec53ef29de3639af2bc84edcbde9e7
8+ // Checksum: 72b802e4004aae8a84f7aa78ec728861339b846b
99//
1010// ignore_for_file: unused_import
1111
@@ -128,6 +128,10 @@ final class Environment {
128128 UserDefinedCallable <Environment >? get content => _content;
129129 UserDefinedCallable <Environment >? _content;
130130
131+ /// The set of variable names that could be configured when loading the
132+ /// module.
133+ final Set <String > _configurableVariables;
134+
131135 /// Whether the environment is lexically at the root of the document.
132136 bool get atRoot => _variables.length == 1 ;
133137
@@ -167,27 +171,28 @@ final class Environment {
167171 _functions = [{}],
168172 _functionIndices = {},
169173 _mixins = [{}],
170- _mixinIndices = {};
174+ _mixinIndices = {},
175+ _configurableVariables = {};
171176
172177 Environment ._(
173- this ._modules,
174- this ._namespaceNodes,
175- this ._globalModules,
176- this ._importedModules,
177- this ._forwardedModules,
178- this ._nestedForwardedModules,
179- this ._allModules,
180- this ._variables,
181- this ._variableNodes,
182- this ._functions,
183- this ._mixins,
184- this ._content,
185- )
186- // Lazily fill in the indices rather than eagerly copying them from the
187- // existing environment in closure() because the copying took a lot of
188- // time and was rarely helpful. This saves a bunch of time on Susy's
189- // tests.
190- : _variableIndices = {},
178+ this ._modules,
179+ this ._namespaceNodes,
180+ this ._globalModules,
181+ this ._importedModules,
182+ this ._forwardedModules,
183+ this ._nestedForwardedModules,
184+ this ._allModules,
185+ this ._variables,
186+ this ._variableNodes,
187+ this ._functions,
188+ this ._mixins,
189+ this ._content,
190+ this ._configurableVariables)
191+ // Lazily fill in the indices rather than eagerly copying them from the
192+ // existing environment in closure() because the copying took a lot of
193+ // time and was rarely helpful. This saves a bunch of time on Susy's
194+ // tests.
195+ : _variableIndices = {},
191196 _functionIndices = {},
192197 _mixinIndices = {};
193198
@@ -209,6 +214,9 @@ final class Environment {
209214 _functions.toList (),
210215 _mixins.toList (),
211216 _content,
217+ // Closures are always in nested contexts where configurable variables
218+ // are never added.
219+ const {},
212220 );
213221
214222 /// Returns a new environment to use for an imported file.
@@ -229,6 +237,7 @@ final class Environment {
229237 _functions.toList (),
230238 _mixins.toList (),
231239 _content,
240+ _configurableVariables,
232241 );
233242
234243 /// Adds [module] to the set of modules visible in this environment.
@@ -648,6 +657,15 @@ final class Environment {
648657 _variableNodes[index][name] = nodeWithSpan;
649658 }
650659
660+ /// Records that [name] is a variable that could have been configured for this
661+ /// module, whether or not it actually was.
662+ ///
663+ /// This is used to determine whether to throw an error when passing a new
664+ /// configuration through `@forward` to an already-loaded module.
665+ void markVariableConfigurable (String name) {
666+ _configurableVariables.add (name);
667+ }
668+
651669 /// Returns the value of the function named [name] , optionally with the given
652670 /// [namespace] , or `null` if no such variable is declared.
653671 ///
@@ -1080,6 +1098,26 @@ final class _EnvironmentModule implements Module<Callable> {
10801098 return module == null ? this : module.variableIdentity (name);
10811099 }
10821100
1101+ bool couldHaveBeenConfigured (Set <String > variables) =>
1102+ // Check if this module defines a configurable variable with any of the
1103+ // given names.
1104+ (variables.length < _environment._configurableVariables.length
1105+ ? variables.any (_environment._configurableVariables.contains)
1106+ : _environment._configurableVariables.any (variables.contains)) ||
1107+ // Find forwarded modules whose variables overlap with [variables] and
1108+ // check if they define configurable variables with any of the given
1109+ // names.
1110+ (variables.length < _modulesByVariable.length
1111+ ? {
1112+ for (var variable in variables)
1113+ if (_modulesByVariable[variable] case var module? ) module
1114+ }
1115+ : {
1116+ for (var (variable, module) in _modulesByVariable.pairs)
1117+ if (variables.contains (variable)) module
1118+ })
1119+ .any ((module) => module.couldHaveBeenConfigured (variables));
1120+
10831121 Module <Callable > cloneCss () {
10841122 if (! transitivelyContainsCss) return this ;
10851123
0 commit comments