Repository navigation
Conversation
…acts All 92 removed @invariant, @requires, and @ensures annotations in Commit #1 (8e06d86b824a2716db3b4716b4d5c5951f93eab0) checked that AssetId.package.isNotEmpty and/or AssetId.path.isNotEmpty. These conditions are completely guaranteed by the checks added in AssetId's sole generative constructor (tightening _packageRegExp so package cannot be empty, and throwing ArgumentError.value in _normalizePath when path.isEmpty, with p.posix.normalize always returning a non-empty string) combined with the finality of AssetId.package and AssetId.path. | File | Target | Removed Contract | Enforced By | | --- | --- | --- | --- | | `build_runner/lib/src/build/build_state/build_state.dart` | `BuildState` | `@Invariant('_partData.keys.every((id) => id.package.isNotEmpty && id.path.isNotEmpty)')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package) where _packageRegExp requires >=1 char) and _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) | | `build_runner/lib/src/build/build_state/build_state.dart` | `BuildState` | `@Invariant('_librariesWithRebuiltPart.every((id) => id.package.isNotEmpty && id.path.isNotEmpty)')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) and _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) | | `build_runner/lib/src/build/build_state/build_state.dart` | `BuildState.addPartContribution` | `@Requires('libraryId.package.isNotEmpty')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) | | `build_runner/lib/src/build/build_state/build_state.dart` | `BuildState.addPartContribution` | `@Requires('libraryId.path.isNotEmpty')` | build/lib/src/asset_id.dart: _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) in AssetId constructor initializer | | `build_runner/lib/src/build/build_state/build_state.dart` | `BuildState.copyPartContribution` | `@Requires('fromPart == null \|\| libraryId.package.isNotEmpty')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) | | `build_runner/lib/src/build/build_state/build_state.dart` | `BuildState.copyPartContribution` | `@Requires('fromPart == null \|\| libraryId.path.isNotEmpty')` | build/lib/src/asset_id.dart: _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) in AssetId constructor initializer | | `build_runner/lib/src/build/build_state/build_state.dart` | `BuildState.addSourceForTest` | `@Requires('id.package.isNotEmpty')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) | | `build_runner/lib/src/build/build_state/build_state.dart` | `BuildState.addSourceForTest` | `@Requires('id.path.isNotEmpty')` | build/lib/src/asset_id.dart: _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) in AssetId constructor initializer | | `build_runner/lib/src/build/build_state/build_step_id.dart` | `BuildStepId` | `@Invariant('primaryInput.package.isNotEmpty')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) | | `build_runner/lib/src/build/build_state/build_step_id.dart` | `BuildStepId` | `@Invariant('primaryInput.path.isNotEmpty')` | build/lib/src/asset_id.dart: _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) in AssetId constructor initializer | | `build_runner/lib/src/build/build_state/build_step_result.dart` | `BuildStepResult` | `@Invariant('outputs.every((id) => id.package.isNotEmpty && id.path.isNotEmpty)')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) and _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) | | `build_runner/lib/src/build/build_state/build_step_result.dart` | `BuildStepResult` | `@Invariant('inputs.every((id) => id.package.isNotEmpty && id.path.isNotEmpty)')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) and _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) | | `build_runner/lib/src/build/build_state/build_step_result.dart` | `BuildStepResult` | `@Invariant('resolverEntrypoints.every((id) => id.package.isNotEmpty && id.path.isNotEmpty)')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) and _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) | | `build_runner/lib/src/build/build_state/finished_build_state.dart` | `FinishedBuildState` | `@Invariant('sharedParts.keys.every((id) => id.package.isNotEmpty && id.path.isNotEmpty)')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) and _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) | | `build_runner/lib/src/build/build_state/glob_result.dart` | `GlobResult` | `@Invariant('inputs.every((id) => id.package.isNotEmpty && id.path.isNotEmpty)')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) and _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) | | `build_runner/lib/src/build/build_state/glob_result.dart` | `GlobResult` | `@Invariant('results.every((id) => id.package.isNotEmpty && id.path.isNotEmpty)')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) and _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) | | `build_runner/lib/src/build/build_state/incremental_build_state.dart` | `IncrementalBuildState` | `@Invariant('sources.every((id) => id.package.isNotEmpty && id.path.isNotEmpty)')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) and _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) | | `build_runner/lib/src/build/build_state/incremental_build_state.dart` | `IncrementalBuildState` | `@Invariant('digests.keys.every((id) => id.package.isNotEmpty && id.path.isNotEmpty)')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) and _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) | | `build_runner/lib/src/build/build_state/post_process_build_step_id.dart` | `PostProcessBuildStepId` | `@Invariant('input.package.isNotEmpty')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) | | `build_runner/lib/src/build/build_state/post_process_build_step_id.dart` | `PostProcessBuildStepId` | `@Invariant('input.path.isNotEmpty')` | build/lib/src/asset_id.dart: _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) in AssetId constructor initializer | | `build_runner/lib/src/build/build_state/post_process_build_step_result.dart` | `PostProcessBuildStepResult` | `@Invariant('outputs.every((id) => id.package.isNotEmpty && id.path.isNotEmpty)')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) and _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) | | `build_runner/lib/src/build/build_step_impl.dart` | `BuildStepImpl` | `@Invariant('inputId.package.isNotEmpty')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) | | `build_runner/lib/src/build/build_step_impl.dart` | `BuildStepImpl` | `@Invariant('inputId.path.isNotEmpty')` | build/lib/src/asset_id.dart: _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) in AssetId constructor initializer | | `build_runner/lib/src/build/build_step_impl.dart` | `BuildStepImpl` | `@Invariant('allowedOutputs.every((id) => id.package.isNotEmpty && id.path.isNotEmpty)')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) and _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) | | `build_runner/lib/src/build/build_step_impl.dart` | `BuildStepImpl` | `@Invariant('outputs.keys.every((id) => id.package.isNotEmpty && id.path.isNotEmpty)')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) and _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) | | `build_runner/lib/src/build/build_step_impl.dart` | `BuildStepImpl.canRead` | `@Requires('id.package.isNotEmpty')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) | | `build_runner/lib/src/build/build_step_impl.dart` | `BuildStepImpl.canRead` | `@Requires('id.path.isNotEmpty')` | build/lib/src/asset_id.dart: _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) in AssetId constructor initializer | | `build_runner/lib/src/build/build_step_impl.dart` | `BuildStepImpl.readAsBytes` | `@Requires('id.package.isNotEmpty')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) | | `build_runner/lib/src/build/build_step_impl.dart` | `BuildStepImpl.readAsBytes` | `@Requires('id.path.isNotEmpty')` | build/lib/src/asset_id.dart: _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) in AssetId constructor initializer | | `build_runner/lib/src/build/build_step_impl.dart` | `BuildStepImpl.readAsString` | `@Requires('id.package.isNotEmpty')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) | | `build_runner/lib/src/build/build_step_impl.dart` | `BuildStepImpl.readAsString` | `@Requires('id.path.isNotEmpty')` | build/lib/src/asset_id.dart: _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) in AssetId constructor initializer | | `build_runner/lib/src/build/build_step_impl.dart` | `BuildStepImpl.writeAsBytes` | `@Requires('id.package.isNotEmpty')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) | | `build_runner/lib/src/build/build_step_impl.dart` | `BuildStepImpl.writeAsBytes` | `@Requires('id.path.isNotEmpty')` | build/lib/src/asset_id.dart: _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) in AssetId constructor initializer | | `build_runner/lib/src/build/build_step_impl.dart` | `BuildStepImpl.writeAsString` | `@Requires('id.package.isNotEmpty')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) | | `build_runner/lib/src/build/build_step_impl.dart` | `BuildStepImpl.writeAsString` | `@Requires('id.path.isNotEmpty')` | build/lib/src/asset_id.dart: _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) in AssetId constructor initializer | | `build_runner/lib/src/build/build_step_impl.dart` | `BuildStepImpl.digest` | `@Requires('id.package.isNotEmpty')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) | | `build_runner/lib/src/build/build_step_impl.dart` | `BuildStepImpl.digest` | `@Requires('id.path.isNotEmpty')` | build/lib/src/asset_id.dart: _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) in AssetId constructor initializer | | `build_runner/lib/src/build/builder_filesystem.dart` | `BuilderFilesystem.addBuildStepResult` | `@Requires('step.primaryInput.package.isNotEmpty')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) | | `build_runner/lib/src/build/builder_filesystem.dart` | `BuilderFilesystem.addBuildStepResult` | `@Requires('step.primaryInput.path.isNotEmpty')` | build/lib/src/asset_id.dart: _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) in AssetId constructor initializer | | `build_runner/lib/src/build/builder_filesystem.dart` | `BuilderFilesystem.addPostProcessBuildStepResult` | `@Requires('step.input.package.isNotEmpty')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) | | `build_runner/lib/src/build/builder_filesystem.dart` | `BuilderFilesystem.addPostProcessBuildStepResult` | `@Requires('step.input.path.isNotEmpty')` | build/lib/src/asset_id.dart: _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) in AssetId constructor initializer | | `build_runner/lib/src/build/builder_filesystem.dart` | `BuilderFilesystem.checkInvalidInput` | `@Requires('id.package.isNotEmpty')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) | | `build_runner/lib/src/build/builder_filesystem.dart` | `BuilderFilesystem.checkInvalidInput` | `@Requires('id.path.isNotEmpty')` | build/lib/src/asset_id.dart: _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) in AssetId constructor initializer | | `build_runner/lib/src/build/builder_filesystem.dart` | `BuilderFilesystem.contentOf` | `@Requires('id.package.isNotEmpty')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) | | `build_runner/lib/src/build/builder_filesystem.dart` | `BuilderFilesystem.contentOf` | `@Requires('id.path.isNotEmpty')` | build/lib/src/asset_id.dart: _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) in AssetId constructor initializer | | `build_runner/lib/src/build/builder_filesystem.dart` | `BuilderFilesystem.isReadable` | `@Requires('id.package.isNotEmpty')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) | | `build_runner/lib/src/build/builder_filesystem.dart` | `BuilderFilesystem.isReadable` | `@Requires('id.path.isNotEmpty')` | build/lib/src/asset_id.dart: _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) in AssetId constructor initializer | | `build_runner/lib/src/build/builder_filesystem.dart` | `BuilderFilesystem.isReadableId` | `@Requires('id.package.isNotEmpty')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) | | `build_runner/lib/src/build/builder_filesystem.dart` | `BuilderFilesystem.isReadableId` | `@Requires('id.path.isNotEmpty')` | build/lib/src/asset_id.dart: _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) in AssetId constructor initializer | | `build_runner/lib/src/build/builder_filesystem.dart` | `BuilderFilesystem.readPhased` | `@Requires('id.package.isNotEmpty')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) | | `build_runner/lib/src/build/builder_filesystem.dart` | `BuilderFilesystem.readPhased` | `@Requires('id.path.isNotEmpty')` | build/lib/src/asset_id.dart: _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) in AssetId constructor initializer | | `build_runner/lib/src/build/input_tracker.dart` | `InputTracker` | `@Invariant('_inputs.every((id) => id.package.isNotEmpty && id.path.isNotEmpty)')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) and _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) | | `build_runner/lib/src/build/input_tracker.dart` | `InputTracker` | `@Invariant('_resolverEntrypoints.every((id) => id.package.isNotEmpty && id.path.isNotEmpty)')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) and _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) | | `build_runner/lib/src/build/input_tracker.dart` | `InputTracker` | `@Invariant('primaryInput == null \|\| (primaryInput!.package.isNotEmpty && primaryInput!.path.isNotEmpty)')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) and _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) | | `build_runner/lib/src/build/input_tracker.dart` | `InputTracker.add` | `@Requires('input.package.isNotEmpty')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) | | `build_runner/lib/src/build/input_tracker.dart` | `InputTracker.add` | `@Requires('input.path.isNotEmpty')` | build/lib/src/asset_id.dart: _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) in AssetId constructor initializer | | `build_runner/lib/src/build/input_tracker.dart` | `InputTracker.addResolverEntrypoint` | `@Requires('graph.package.isNotEmpty')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) | | `build_runner/lib/src/build/input_tracker.dart` | `InputTracker.addResolverEntrypoint` | `@Requires('graph.path.isNotEmpty')` | build/lib/src/asset_id.dart: _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) in AssetId constructor initializer | | `build_runner/lib/src/build/library_cycle_graph/asset_deps.dart` | `AssetDeps` | `@Invariant('deps.every((id) => id.package.isNotEmpty && id.path.isNotEmpty)')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) and _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) | | `build_runner/lib/src/build/library_cycle_graph/library_cycle.dart` | `LibraryCycle` | `@Invariant('ids.every((id) => id.package.isNotEmpty && id.path.isNotEmpty)')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) and _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) | | `build_runner/lib/src/build/library_cycle_graph/phased_asset_deps.dart` | `PhasedAssetDeps` | `@Invariant('assetDeps.keys.every((id) => id.package.isNotEmpty && id.path.isNotEmpty)')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) and _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) | | `build_runner/lib/src/build/shared_part_accumulator.dart` | `SharedPartAccumulator` | `@Invariant('libraryId.package.isNotEmpty')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) | | `build_runner/lib/src/build/shared_part_accumulator.dart` | `SharedPartAccumulator` | `@Invariant('libraryId.path.isNotEmpty')` | build/lib/src/asset_id.dart: _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) in AssetId constructor initializer | | `build_runner/lib/src/build_plan/build_inputs.dart` | `BuildInputs` | `@Invariant('sources.every((id) => id.package.isNotEmpty && id.path.isNotEmpty)')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) and _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) | | `build_runner/lib/src/build_plan/build_inputs.dart` | `BuildInputs` | `@Invariant('sharedParts.keys.every((id) => id.package.isNotEmpty && id.path.isNotEmpty)')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) and _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) | | `build_runner/lib/src/build_plan/build_step_plan.dart` | `BuildStepPlan` | `@Invariant('buildStepsByDeclaredOutput.keys.every((id) => id.package.isNotEmpty && id.path.isNotEmpty)')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) and _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) | | `build_runner/lib/src/build_plan/build_step_plan.dart` | `BuildStepPlan.isDeclaredOutput` | `@Requires('id.package.isNotEmpty')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) | | `build_runner/lib/src/build_plan/build_step_plan.dart` | `BuildStepPlan.isDeclaredOutput` | `@Requires('id.path.isNotEmpty')` | build/lib/src/asset_id.dart: _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) in AssetId constructor initializer | | `build_runner/lib/src/build_plan/build_step_plan.dart` | `BuildStepPlan.stepForDeclaredOutputOrNull` | `@Requires('id.package.isNotEmpty')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) | | `build_runner/lib/src/build_plan/build_step_plan.dart` | `BuildStepPlan.stepForDeclaredOutputOrNull` | `@Requires('id.path.isNotEmpty')` | build/lib/src/asset_id.dart: _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) in AssetId constructor initializer | | `build_runner/lib/src/build_plan/build_step_plan.dart` | `BuildStepPlan.declaredOutputsOf` | `@Requires('id.package.isNotEmpty')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) | | `build_runner/lib/src/build_plan/build_step_plan.dart` | `BuildStepPlan.declaredOutputsOf` | `@Requires('id.path.isNotEmpty')` | build/lib/src/asset_id.dart: _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) in AssetId constructor initializer | | `build_runner/lib/src/build_plan/previous_build.dart` | `PreviousBuild` | `@Invariant('incompatibleBuildOutputsToDelete.every((id) => id.package.isNotEmpty && id.path.isNotEmpty)')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) and _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) | | `build_runner/lib/src/io/asset_tracker.dart` | `AssetTracker.findFiles` | `@Ensures('result.every((f) => f.id.package.isNotEmpty && f.id.path.isNotEmpty)')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) and _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) | | `build_runner/lib/src/io/asset_tracker.dart` | `AssetTracker.findArtifactTreeFiles` | `@Ensures('result.every((id) => id.package.isNotEmpty && id.path.isNotEmpty)')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) and _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) | | `build_runner/lib/src/io/asset_tracker.dart` | `AssetTracker.findInputSources` | `@Ensures('result.every((id) => id.package.isNotEmpty && id.path.isNotEmpty)')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) and _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) | | `build_runner/lib/src/io/build_output_reader.dart` | `BuildOutputReader.pathFor` | `@Requires('id.package.isNotEmpty')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) | | `build_runner/lib/src/io/build_output_reader.dart` | `BuildOutputReader.pathFor` | `@Requires('id.path.isNotEmpty')` | build/lib/src/asset_id.dart: _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) in AssetId constructor initializer | | `build_runner/lib/src/io/build_output_reader.dart` | `BuildOutputReader.read` | `@Requires('id.package.isNotEmpty')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) | | `build_runner/lib/src/io/build_output_reader.dart` | `BuildOutputReader.read` | `@Requires('id.path.isNotEmpty')` | build/lib/src/asset_id.dart: _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) in AssetId constructor initializer | | `build_runner/lib/src/io/build_output_reader.dart` | `BuildOutputReader.canRead` | `@Requires('id.package.isNotEmpty')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) | | `build_runner/lib/src/io/build_output_reader.dart` | `BuildOutputReader.canRead` | `@Requires('id.path.isNotEmpty')` | build/lib/src/asset_id.dart: _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) in AssetId constructor initializer | | `build_runner/lib/src/io/reader_writer.dart` | `ReaderWriter._pathFor` | `@Requires('id.package.isNotEmpty && id.path.isNotEmpty')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) and _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) | | `build_runner/lib/src/io/reader_writer.dart` | `ReaderWriter.canRead` | `@Requires('id.package.isNotEmpty && id.path.isNotEmpty')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) and _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) | | `build_runner/lib/src/io/reader_writer.dart` | `ReaderWriter.readAsBytes` | `@Requires('id.package.isNotEmpty && id.path.isNotEmpty')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) and _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) | | `build_runner/lib/src/io/reader_writer.dart` | `ReaderWriter.readAsString` | `@Requires('id.package.isNotEmpty && id.path.isNotEmpty')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) and _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) | | `build_runner/lib/src/io/reader_writer.dart` | `ReaderWriter.writeAsBytes` | `@Requires('id.package.isNotEmpty && id.path.isNotEmpty')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) and _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) | | `build_runner/lib/src/io/reader_writer.dart` | `ReaderWriter.writeAsString` | `@Requires('id.package.isNotEmpty && id.path.isNotEmpty')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) and _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) | | `build_runner/lib/src/io/reader_writer.dart` | `ReaderWriter.digest` | `@Requires('id.package.isNotEmpty && id.path.isNotEmpty')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) and _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) | | `build_runner/lib/src/io/reader_writer.dart` | `ReaderWriter.delete` | `@Requires('file.id.package.isNotEmpty && file.id.path.isNotEmpty')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) and _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) | | `build_runner/lib/src/io/reader_writer.dart` | `ReaderWriter.deleteDirectory` | `@Requires('id.package.isNotEmpty && id.path.isNotEmpty')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) and _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) | | `build_runner/lib/src/io/reader_writer.dart` | `BuildPackagesAssetFinder._fileToAssetId` | `@Ensures('result.package.isNotEmpty && result.path.isNotEmpty')` | build/lib/src/asset_id.dart: AssetId constructor (!_packageRegExp.hasMatch(package)) and _normalizePath (if (path.isEmpty) throw ArgumentError.value(...)) |
…t contracts
All 3 removed contracts (`@Invariant('phaseNumber >= 0')` on `BuildStepId` and `@Requires('step.phaseNumber >= 0')` on `BuildState.addBuildStepResult` and `BuilderFilesystem.addBuildStepResult`) are completely guaranteed by the `assert(phaseNumber >= 0)` check added in `BuildStepId._()` together with the finality of `_$BuildStepId.phaseNumber`.
| File | Target | Removed Contract | Enforced By |
| --- | --- | --- | --- |
| `build_runner/lib/src/build/build_state/build_state.dart` | `BuildState.addBuildStepResult` | `@Requires('step.phaseNumber >= 0')` | BuildStepId._() (`assert(phaseNumber >= 0)`) |
| `build_runner/lib/src/build/build_state/build_step_id.dart` | `BuildStepId` | `@Invariant('phaseNumber >= 0')` | BuildStepId._() (`assert(phaseNumber >= 0)`) |
| `build_runner/lib/src/build/builder_filesystem.dart` | `BuilderFilesystem.addBuildStepResult` | `@Requires('step.phaseNumber >= 0')` | BuildStepId._() (`assert(phaseNumber >= 0)`) |
…ove redundant contracts
All 3 removed contract annotations (`@Invariant('actionNumber >= 0')` on `PostProcessBuildStepId` and `@Requires('step.actionNumber >= 0')` on `BuildState.addPostProcessBuildStepResult` and `BuilderFilesystem.addPostProcessBuildStepResult`) are completely guaranteed by `assert(actionNumber >= 0)` in `PostProcessBuildStepId._()` and the immutability of `PostProcessBuildStepId.actionNumber`.
| File | Target | Removed Contract | Enforced By |
| --- | --- | --- | --- |
| `build_runner/lib/src/build/build_state/build_state.dart` | `BuildState.addPostProcessBuildStepResult` | `@Requires('step.actionNumber >= 0')` | PostProcessBuildStepId._() (`assert(actionNumber >= 0)`) |
| `build_runner/lib/src/build/build_state/post_process_build_step_id.dart` | `PostProcessBuildStepId` | `@Invariant('actionNumber >= 0')` | PostProcessBuildStepId._() (`assert(actionNumber >= 0)`) |
| `build_runner/lib/src/build/builder_filesystem.dart` | `BuilderFilesystem.addPostProcessBuildStepResult` | `@Requires('step.actionNumber >= 0')` | PostProcessBuildStepId._() (`assert(actionNumber >= 0)`) |
All three @invariant annotations removed from GlobId are directly replaced by equivalent assert statements in the GlobId._() constructor, which executes on every instance construction after the immutable Built fields are initialized. | File | Target | Removed Contract | Enforced By | | --- | --- | --- | --- | | `build_runner/lib/src/build/build_state/glob_id.dart` | `GlobId` | `@Invariant('package.isNotEmpty')` | GlobId._(): assert(package.isNotEmpty) | | `build_runner/lib/src/build/build_state/glob_id.dart` | `GlobId` | `@Invariant('glob.isNotEmpty')` | GlobId._(): assert(glob.isNotEmpty) | | `build_runner/lib/src/build/build_state/glob_id.dart` | `GlobId` | `@Invariant('phaseNumber >= 0')` | GlobId._(): assert(phaseNumber >= 0) |
Verified that the removed @invariant('results.every((id) => inputs.contains(id))') on GlobResult is completely enforced by assert(results.every(inputs.contains)) in GlobResult._() together with the immutability of BuiltSet<AssetId> fields on the Built value class. | File | Target | Removed Contract | Enforced By | | --- | --- | --- | --- | | `build_runner/lib/src/build/build_state/glob_result.dart` | `GlobResult` | `@Invariant('results.every((id) => inputs.contains(id))')` | GlobResult._() constructor: assert(results.every(inputs.contains)) |
…contracts Both @invariant annotations removed from BuildStepResult are directly replaced by identical assert(...) checks in BuildStepResult._(), which executes after _$BuildStepResult._ initializes all final, immutable fields (result, outputs, errors). | File | Target | Removed Contract | Enforced By | | --- | --- | --- | --- | | `build_runner/lib/src/build/build_state/build_step_result.dart` | `BuildStepResult` | `@Invariant('hasRun \|\| (outputs.isEmpty && errors.isEmpty)')` | BuildStepResult._(): assert(hasRun \|\| (outputs.isEmpty && errors.isEmpty)) | | `build_runner/lib/src/build/build_state/build_step_result.dart` | `BuildStepResult` | `@Invariant('!succeeded \|\| errors.isEmpty')` | BuildStepResult._(): assert(!succeeded \|\| errors.isEmpty) |
… contracts
Verified that `assert(ids.isNotEmpty)` in `LibraryCycle._()`, together with the immutability of the `final BuiltSet<AssetId> ids` field initialized in `_$LibraryCycle._` prior to `: super._()`, completely guarantees both removed contracts (`@Invariant('ids.isNotEmpty')` on `LibraryCycle` and `@Requires('newCycles.every((cycle) => cycle.ids.isNotEmpty)')` on `LibraryCycleGraphLoader._buildGraphs`).
| File | Target | Removed Contract | Enforced By |
| --- | --- | --- | --- |
| `build_runner/lib/src/build/library_cycle_graph/library_cycle.dart` | `LibraryCycle` | `@Invariant('ids.isNotEmpty')` | LibraryCycle._() (assert(ids.isNotEmpty)) |
| `build_runner/lib/src/build/library_cycle_graph/library_cycle_graph_loader.dart` | `LibraryCycleGraphLoader._buildGraphs` | `@Requires('newCycles.every((cycle) => cycle.ids.isNotEmpty)')` | LibraryCycle._() (assert(ids.isNotEmpty)) |
… contract Verified that the removed @invariant('children.every((c) => c.root != root)') on LibraryCycleGraph is completely enforced by the identical assert(children.every((c) => c.root != root)) added in LibraryCycleGraph._(), together with the immutability of Built fields `root` and `children`. | File | Target | Removed Contract | Enforced By | | --- | --- | --- | --- | | `build_runner/lib/src/build/library_cycle_graph/library_cycle_graph.dart` | `LibraryCycleGraph` | `@Invariant('children.every((c) => c.root != root)')` | LibraryCycleGraph._(): assert(children.every((c) => c.root != root)) |
…tracts All four @invariant annotations on BuildPackage and the @requires('packageNode.name.isNotEmpty') annotation on BuildPackagesAssetFinder._fileToAssetId are completely guaranteed by the assertions added to BuildPackage's sole generative constructor together with the finality and immutability of BuildPackage's fields (name, path, and BuiltSet<String> dependencies). | File | Target | Removed Contract | Enforced By | | --- | --- | --- | --- | | `build_runner/lib/src/build_plan/build_package.dart` | `BuildPackage` | `@Invariant('name.isNotEmpty')` | BuildPackage constructor initializer assert(name.isNotEmpty) | | `build_runner/lib/src/build_plan/build_package.dart` | `BuildPackage` | `@Invariant('path.isNotEmpty')` | BuildPackage constructor body assert(this.path.isNotEmpty) | | `build_runner/lib/src/build_plan/build_package.dart` | `BuildPackage` | `@Invariant('!dependencies.contains(name)')` | BuildPackage constructor body assert(!this.dependencies.contains(name)) | | `build_runner/lib/src/build_plan/build_package.dart` | `BuildPackage` | `@Invariant('dependencies.every((d) => d.isNotEmpty)')` | BuildPackage constructor body assert(this.dependencies.every((d) => d.isNotEmpty)) | | `build_runner/lib/src/io/reader_writer.dart` | `BuildPackagesAssetFinder._fileToAssetId` | `@Requires('packageNode.name.isNotEmpty')` | BuildPackage constructor initializer assert(name.isNotEmpty) |
…tracts All three @invariant annotations removed from InBuildPhase (package.isNotEmpty, key.isNotEmpty, displayName.isNotEmpty) are directly enforced by constructor initializer assertions in the sole generative constructor InBuildPhase._ (to which the public InBuildPhase constructor redirects), and package, key, and displayName are final String fields. | File | Target | Removed Contract | Enforced By | | --- | --- | --- | --- | | `build_runner/lib/src/build_plan/phase.dart` | `InBuildPhase` | `@Invariant('package.isNotEmpty')` | InBuildPhase._ constructor initializer: assert(package.isNotEmpty) | | `build_runner/lib/src/build_plan/phase.dart` | `InBuildPhase` | `@Invariant('key.isNotEmpty')` | InBuildPhase._ constructor initializer: assert(key.isNotEmpty) | | `build_runner/lib/src/build_plan/phase.dart` | `InBuildPhase` | `@Invariant('displayName.isNotEmpty')` | InBuildPhase._ constructor initializer: assert(displayName.isNotEmpty) |
…tors and remove redundant contracts
All 4 removed contract annotations are completely guaranteed by the constructor assertions added in PartContribution._(), BuilderDefinition(), PostProcessBuilderDefinition(), and PostProcessBuilderDefinition.fromConfig(), combined with field finality/immutability.
| File | Target | Removed Contract | Enforced By |
| --- | --- | --- | --- |
| `build_runner/lib/src/build/build_state/build_state.dart` | `BuildState.addPartContribution` | `@Requires('contribution.builderKey.isNotEmpty')` | PartContribution._(): assert(builderKey.isNotEmpty) |
| `build_runner/lib/src/build/shared_part_accumulator.dart` | `SharedPartAccumulator.addContribution` | `@Requires('contribution.builderKey.isNotEmpty')` | PartContribution._(): assert(builderKey.isNotEmpty) |
| `build_runner/lib/src/build_plan/builder_definition.dart` | `BuilderDefinition` | `@Invariant('key.isNotEmpty')` | BuilderDefinition(): assert(key.isNotEmpty) |
| `build_runner/lib/src/build_plan/builder_definition.dart` | `PostProcessBuilderDefinition` | `@Invariant('key.isNotEmpty')` | PostProcessBuilderDefinition() and PostProcessBuilderDefinition.fromConfig(): assert(key.isNotEmpty) |
…undant contracts
Verified that both `@Invariant` annotations removed from `BuildOutputReadResult` are directly enforced by matching `assert(...)` checks in both of its generative constructors (`BuildOutputReadResult.unreadable` and `BuildOutputReadResult.available`), and all fields on `BuildOutputReadResult` are `final`.
| File | Target | Removed Contract | Enforced By |
| --- | --- | --- | --- |
| `build_runner/lib/src/io/build_output_read_result.dart` | `BuildOutputReadResult` | `@Invariant('canRead == (unreadableReason == null)')` | BuildOutputReadResult.unreadable and BuildOutputReadResult.available: assert(canRead == (unreadableReason == null)) |
| `build_runner/lib/src/io/build_output_read_result.dart` | `BuildOutputReadResult` | `@Invariant('canRead == (_content != null)')` | BuildOutputReadResult.unreadable and BuildOutputReadResult.available: assert(canRead == (_content != null)) |
…racts Both @invariant annotations removed from BuildPhases are directly enforced by matching assertions in the single BuildPhases constructor body (and by construction via _digestsOf on final fields). | File | Target | Removed Contract | Enforced By | | --- | --- | --- | --- | | `build_runner/lib/src/build_plan/build_phases.dart` | `BuildPhases` | `@Invariant('inBuildPhasesOptionsDigests.length == inBuildPhases.length')` | BuildPhases constructor: assert(inBuildPhasesOptionsDigests.length == this.inBuildPhases.length) (plus _digestsOf(inBuildPhases) and final BuiltList fields) | | `build_runner/lib/src/build_plan/build_phases.dart` | `BuildPhases` | `@Invariant('postBuildActionsOptionsDigests.length == postBuildPhase.builderActions.length')` | BuildPhases constructor: assert(postBuildActionsOptionsDigests.length == this.postBuildPhase.builderActions.length) (plus _digestsOf(postBuildPhase?.builderActions ?? []) and final fields) |
…racts All three @invariant annotations removed from BuildResult are directly enforced by equivalent assertions in BuildResult's sole generative constructor, and all referenced fields (status, failureType, buildOutputReader, buildState, outputs) are final and immutable. | File | Target | Removed Contract | Enforced By | | --- | --- | --- | --- | | `build_runner/lib/src/build/build_result.dart` | `BuildResult` | `@Invariant('status == BuildStatus.failure ? failureType != null : failureType == null')` | BuildResult constructor body: assert(status == BuildStatus.failure ? this.failureType != null : this.failureType == null) | | `build_runner/lib/src/build/build_result.dart` | `BuildResult` | `@Invariant('status != BuildStatus.success \|\| buildOutputReader != null')` | BuildResult constructor initializer: assert(status != BuildStatus.success \|\| buildOutputReader != null) | | `build_runner/lib/src/build/build_result.dart` | `BuildResult` | `@Invariant('buildState == null \|\| outputs.every((id) => buildState!.isActualOutput(id) \|\| buildState!.isActualPostOutput(id) \|\| buildState!.hasSharedPart(id))')` | BuildResult constructor body: assert(buildState == null \|\| this.outputs.every((id) => buildState!.isActualOutput(id) \|\| buildState!.isActualPostOutput(id) \|\| buildState!.hasSharedPart(id))) |
…ove redundant contracts All 6 @invariant annotations on BuildPackages and all 6 @requires annotations on BuildPackages.compute and BuildPackages.singlePackageBuild are replaced with equivalent assert(...) statements in the sole generative constructor initializer list and factory constructor bodies. Because all relevant fields on BuildPackages (currentPackage, outputRoot, packages, outputPackages) are final and immutable (String, BuiltMap, BuiltSet), the constructor initializer asserts enforce the class invariants for the lifetime of the object. | File | Target | Removed Contract | Enforced By | | --- | --- | --- | --- | | `build_runner/lib/src/build_plan/build_packages.dart` | `BuildPackages` | `@Invariant('currentPackage.isNotEmpty')` | BuildPackages(...) initializer list: assert(currentPackage.isNotEmpty) | | `build_runner/lib/src/build_plan/build_packages.dart` | `BuildPackages` | `@Invariant('outputRoot.isNotEmpty')` | BuildPackages(...) initializer list: assert(outputRoot.isNotEmpty) | | `build_runner/lib/src/build_plan/build_packages.dart` | `BuildPackages` | `@Invariant('packages.isNotEmpty')` | BuildPackages(...) initializer list: assert(packages.isNotEmpty) | | `build_runner/lib/src/build_plan/build_packages.dart` | `BuildPackages` | `@Invariant('packages.containsKey(currentPackage)')` | BuildPackages(...) initializer list: assert(packages.containsKey(currentPackage)) | | `build_runner/lib/src/build_plan/build_packages.dart` | `BuildPackages` | `@Invariant('outputPackages.isNotEmpty')` | BuildPackages(...) initializer list: assert(outputPackages.isNotEmpty) | | `build_runner/lib/src/build_plan/build_packages.dart` | `BuildPackages` | `@Invariant('outputPackages.every((p) => packages.containsKey(p))')` | BuildPackages(...) initializer list: assert(outputPackages.every(packages.containsKey)) | | `build_runner/lib/src/build_plan/build_packages.dart` | `BuildPackages.compute` | `@Requires('currentPackage.isNotEmpty')` | BuildPackages.compute: assert(currentPackage.isNotEmpty) | | `build_runner/lib/src/build_plan/build_packages.dart` | `BuildPackages.compute` | `@Requires('outputRoot.isNotEmpty')` | BuildPackages.compute: assert(outputRoot.isNotEmpty) | | `build_runner/lib/src/build_plan/build_packages.dart` | `BuildPackages.compute` | `@Requires('packages.containsKey(currentPackage)')` | BuildPackages.compute: assert(packages.containsKey(currentPackage)) | | `build_runner/lib/src/build_plan/build_packages.dart` | `BuildPackages.compute` | `@Requires('singlePackageToBuild == null \|\| packages.containsKey(singlePackageToBuild)')` | BuildPackages.compute: assert(singlePackageToBuild == null \|\| packages.containsKey(singlePackageToBuild)) | | `build_runner/lib/src/build_plan/build_packages.dart` | `BuildPackages.compute` | `@Requires('singlePackageToBuild == null \|\| packages[singlePackageToBuild]!.isOutput')` | BuildPackages.compute: assert(singlePackageToBuild == null \|\| packages[singlePackageToBuild]!.isOutput) | | `build_runner/lib/src/build_plan/build_packages.dart` | `BuildPackages.singlePackageBuild` | `@Requires('packages.any((p) => p.name == package && p.isOutput)')` | BuildPackages.singlePackageBuild: assert(packages.any((p) => p.name == package && p.isOutput)) |
…undant contracts
Both `@Invariant` annotations removed from `BuildRunnerFileContent` are identically enforced via initializer-list `assert` checks in its sole generative constructor, and all fields on `BuildRunnerFileContent` are `final` and of immutable primitive/String types.
| File | Target | Removed Contract | Enforced By |
| --- | --- | --- | --- |
| `build_runner/lib/src/build/resolver/analysis_driver_filesystem.dart` | `BuildRunnerFileContent` | `@Invariant('path.startsWith("/")')` | BuildRunnerFileContent(...) constructor: assert(path.startsWith('/')) |
| `build_runner/lib/src/build/resolver/analysis_driver_filesystem.dart` | `BuildRunnerFileContent` | `@Invariant('exists \|\| (content.isEmpty && contentHash.isEmpty && phase == -1)')` | BuildRunnerFileContent(...) constructor: assert(exists \|\| (content.isEmpty && contentHash.isEmpty && phase == -1)) |
…port
Both removed `@Requires` annotations on `LibrarySourceSinkImpl.addImport` are already enforced by the existing `if (!as.startsWith(importPrefix)) throw ArgumentError.value(...)` check in the method body (since `importPrefix` is guaranteed non-empty, `as.startsWith(importPrefix)` also guarantees `as.isNotEmpty`), and `LibrarySourceSinkImpl` is never subclassed.
| File | Target | Removed Contract | Enforced By |
| --- | --- | --- | --- |
| `build_runner/lib/src/build/library_source_sink_impl.dart` | `LibrarySourceSinkImpl.addImport` | `@Requires('as.isNotEmpty')` | if (!as.startsWith(importPrefix)) { throw ArgumentError.value(as, 'as', 'must start with $importPrefix'); } (with non-empty importPrefix invariant/assert) |
| `build_runner/lib/src/build/library_source_sink_impl.dart` | `LibrarySourceSinkImpl.addImport` | `@Requires('as.startsWith(importPrefix)')` | if (!as.startsWith(importPrefix)) { throw ArgumentError.value(as, 'as', 'must start with $importPrefix'); } |
Removing @requires('exists(path)') on AnalysisDriverFilesystem.read is safe because the method immediately checks if (!exists(path)) throw StateError('Read of non-existent file.'); on its first line, and AnalysisDriverFilesystem is not subclassed or overridden anywhere in the repository. | File | Target | Removed Contract | Enforced By | | --- | --- | --- | --- | | `build_runner/lib/src/build/resolver/analysis_driver_filesystem.dart` | `AnalysisDriverFilesystem.read` | `@Requires('exists(path)')` | if (!exists(path)) throw StateError('Read of non-existent file.'); |
…hToUri
Removing `@Requires('path.startsWith("/")')` from `AnalysisDriverFilesystem.pathToUri` is safe because the method immediately enforces the identical precondition via `if (!path.startsWith('/')) { throw ArgumentError.value(...); }` and `AnalysisDriverFilesystem` is not subclassed.
| File | Target | Removed Contract | Enforced By |
| --- | --- | --- | --- |
| `build_runner/lib/src/build/resolver/analysis_driver_filesystem.dart` | `AnalysisDriverFilesystem.pathToUri` | `@Requires('path.startsWith("/")')` | if (!path.startsWith('/')) { throw ArgumentError.value('path', path, 'Must start with "/". '); } in AnalysisDriverFilesystem.pathToUri |
Removing `@Ensures('_sources.every((id) => !buildStepPlan.isDeclaredOutput(id))')` from the `BuildState` constructor is safe because the constructor body already loops over `_sources` and throws an `ArgumentError` if `buildStepPlan.isDeclaredOutput(id)` is true for any source, and `BuildState` is not subclassed.
| File | Target | Removed Contract | Enforced By |
| --- | --- | --- | --- |
| `build_runner/lib/src/build/build_state/build_state.dart` | `BuildState.new` | `@Ensures('_sources.every((id) => !buildStepPlan.isDeclaredOutput(id))')` | for (final id in _sources) { if (buildStepPlan.isDeclaredOutput(id)) { throw ArgumentError('Source $id clashes with declared output in buildStepPlan.'); } } |
…dContribution
Removing `@ThrowEnsures(StateError, 'contributions.containsKey(phase)')` on `SharedPartAccumulator.addContribution` is safe because the method body already checks `if (_contributions[phase] != null)` and throws a `StateError` when a contribution for `phase` is already present, and `SharedPartAccumulator` has no subclasses.
| File | Target | Removed Contract | Enforced By |
| --- | --- | --- | --- |
| `build_runner/lib/src/build/shared_part_accumulator.dart` | `SharedPartAccumulator.addContribution` | `@ThrowEnsures(StateError, 'contributions.containsKey(phase)')` | if (_contributions[phase] != null) { throw StateError('Contribution for phase $phase already added.'); } |
…ontent
Removing `@ThrowEnsures(StateError, '!isSource(id)')` on `BuildState.updateSourceContent` is safe because the method body immediately checks `if (!isSource(id)) { throw StateError(...); }` before updating `_contents`, and `BuildState` is not subclassed.
| File | Target | Removed Contract | Enforced By |
| --- | --- | --- | --- |
| `build_runner/lib/src/build/build_state/build_state.dart` | `BuildState.updateSourceContent` | `@ThrowEnsures(StateError, '!isSource(id)')` | BuildState.updateSourceContent (`if (!isSource(id)) throw StateError(...)`) |
…esult
Removing `@ThrowEnsures(StateError, 'stepResultOrNull(step) != null')` from `BuildState.addBuildStepResult` is safe because the only `StateError` thrown in the method body is guarded by `if (results.containsKey(step.phaseNumber))` on `_buildStepResultsByPrimaryInput[step.primaryInput]`, which guarantees `stepResultOrNull(step) != null` whenever `StateError` is thrown, and `BuildState` has no subclasses.
| File | Target | Removed Contract | Enforced By |
| --- | --- | --- | --- |
| `build_runner/lib/src/build/build_state/build_state.dart` | `BuildState.addBuildStepResult` | `@ThrowEnsures(StateError, 'stepResultOrNull(step) != null')` | if (results.containsKey(step.phaseNumber)) { throw StateError('Already had build step result for $step.'); } (lines 295-297) |
…sBuildStepResult
Removing `@ThrowEnsures(StateError, 'postProcessBuildStepResultFor(step) != null')` on `BuildState.addPostProcessBuildStepResult` is safe because the only `StateError` thrown in the method is directly guarded by `if (results.containsKey(step.actionNumber)) throw StateError(...)` (where `results` is `_postProcessResultsByInput[step.input]` with non-nullable values, matching `postProcessBuildStepResultFor(step) != null`), and `BuildState` is not subclassed.
| File | Target | Removed Contract | Enforced By |
| --- | --- | --- | --- |
| `build_runner/lib/src/build/build_state/build_state.dart` | `BuildState.addPostProcessBuildStepResult` | `@ThrowEnsures(StateError, 'postProcessBuildStepResultFor(step) != null')` | BuildState.addPostProcessBuildStepResult (`if (results.containsKey(step.actionNumber)) { throw StateError('Already had post process result for $step.'); }` at lines 443-445) |
…redundant contracts Removing both @invariant annotations is safe because ExpiringValue._() now asserts `expiresAfter == null || expiresAfter! >= 0` on construction, `ExpiringValue.expiresAfter` is a deeply immutable `final int?` field on `_$ExpiringValue`, and `PhasedValue.values` is an immutable `final BuiltList<ExpiringValue<T>>` whose elements each enforce that invariant on construction. | File | Target | Removed Contract | Enforced By | | --- | --- | --- | --- | | `build_runner/lib/src/build/library_cycle_graph/phased_value.dart` | `ExpiringValue` | `@Invariant('expiresAfter == null \|\| expiresAfter! >= 0')` | ExpiringValue._ constructor: assert(expiresAfter == null \|\| expiresAfter! >= 0) | | `build_runner/lib/src/build/library_cycle_graph/phased_value.dart` | `PhasedValue` | `@Invariant('values.every((v) => v.expiresAfter == null \|\| v.expiresAfter! >= 0)')` | ExpiringValue._ constructor: assert(expiresAfter == null \|\| expiresAfter! >= 0) |
…edundant contract
Removing `@Invariant('builderLabel == null || builderLabel!.isNotEmpty')` on `InputTracker` is safe because `builderLabel` is a `final` field of immutable type `String?` and the sole constructor enforces `assert(builderLabel == null || builderLabel.isNotEmpty)` upon initialization.
| File | Target | Removed Contract | Enforced By |
| --- | --- | --- | --- |
| `build_runner/lib/src/build/input_tracker.dart` | `InputTracker` | `@Invariant('builderLabel == null \|\| builderLabel!.isNotEmpty')` | InputTracker constructor initializer `assert(builderLabel == null \|\| builderLabel.isNotEmpty)` |
…ndant contracts
Both removed `@Invariant` annotations on `LibrarySourceSinkImpl` only reference `final` `String`/`String?` fields (`importPrefix` and `languageVersion`), which are deeply immutable. Checking these conditions via `assert(...)` in `LibrarySourceSinkImpl`'s sole constructor guarantees they hold throughout the object's lifetime without needing repeated invariant checks on method calls.
| File | Target | Removed Contract | Enforced By |
| --- | --- | --- | --- |
| `build_runner/lib/src/build/library_source_sink_impl.dart` | `LibrarySourceSinkImpl` | `@Invariant('importPrefix.isNotEmpty')` | LibrarySourceSinkImpl constructor: assert(importPrefix.isNotEmpty) |
| `build_runner/lib/src/build/library_source_sink_impl.dart` | `LibrarySourceSinkImpl` | `@Invariant('languageVersion == null \|\| languageVersion!.isNotEmpty')` | LibrarySourceSinkImpl constructor: assert(languageVersion == null \|\| languageVersion.isNotEmpty) |
…contract
Removing `@Invariant('phase >= 0')` from `AssetDepsLoader` is safe because `phase` is a `final int` (deeply immutable) and the added constructor `assert(phase >= 0)` guarantees the condition holds for the lifetime of the instance.
| File | Target | Removed Contract | Enforced By |
| --- | --- | --- | --- |
| `build_runner/lib/src/build/library_cycle_graph/asset_deps_loader.dart` | `AssetDepsLoader` | `@Invariant('phase >= 0')` | AssetDepsLoader constructor assert(phase >= 0) |
…ntract
Removing `@Invariant('phase >= 0')` on `BuildStepImpl` is safe because `phase` is a `final int` field (deeply immutable) and the sole `BuildStepImpl` constructor enforces `assert(phase >= 0)` in its initializer list.
| File | Target | Removed Contract | Enforced By |
| --- | --- | --- | --- |
| `build_runner/lib/src/build/build_step_impl.dart` | `BuildStepImpl` | `@Invariant('phase >= 0')` | BuildStepImpl constructor initializer assert(phase >= 0) |
… remove redundant contracts
Removing the two final-field `@Invariant` annotations (and the supporting `@ContractImport`) on `SharedPartAccumulator` is safe because both invariants depend solely on `final`, deeply immutable fields (`AssetId libraryId` and `String? languageVersion`) and are now enforced at construction time by initializer-list `assert` checks in the class's sole generative constructor.
| File | Target | Removed Contract | Enforced By |
| --- | --- | --- | --- |
| `build_runner/lib/src/build/shared_part_accumulator.dart` | `SharedPartAccumulator` | `@Invariant('libraryId.sharedPartId != null')` | SharedPartAccumulator constructor initializer assert(libraryId.sharedPartId != null) (line 58) and final deeply immutable AssetId field libraryId |
| `build_runner/lib/src/build/shared_part_accumulator.dart` | `SharedPartAccumulator` | `@Invariant('languageVersion == null \|\| languageVersion!.isNotEmpty')` | SharedPartAccumulator constructor initializer assert(languageVersion == null \|\| languageVersion.isNotEmpty) (line 59) and final immutable String? field languageVersion |
…move redundant contract
Removing `@Requires('phase >= 0')` on `BuilderFilesystem.isReadableId` is safe because it is directly replaced by `assert(phase >= 0);` at the top of the method body, and `BuilderFilesystem` has no subclasses overriding `isReadableId`.
| File | Target | Removed Contract | Enforced By |
| --- | --- | --- | --- |
| `build_runner/lib/src/build/builder_filesystem.dart` | `BuilderFilesystem.isReadableId` | `@Requires('phase >= 0')` | assert(phase >= 0) at method entry of BuilderFilesystem.isReadableId (line 194) |
…and remove redundant contracts
Removing `@Requires('package.isNotEmpty')` and `@Requires('phase >= 0')` on `BuilderFilesystem.findAssets` is safe because both preconditions are directly enforced by `assert(package.isNotEmpty)` and `assert(phase >= 0)` at the entry of `findAssets`, and `BuilderFilesystem` is not subclassed.
| File | Target | Removed Contract | Enforced By |
| --- | --- | --- | --- |
| `build_runner/lib/src/build/builder_filesystem.dart` | `BuilderFilesystem.findAssets` | `@Requires('package.isNotEmpty')` | assert(package.isNotEmpty) at BuilderFilesystem.findAssets entry (line 229) |
| `build_runner/lib/src/build/builder_filesystem.dart` | `BuilderFilesystem.findAssets` | `@Requires('phase >= 0')` | assert(phase >= 0) at BuilderFilesystem.findAssets entry (line 230) |
…ve redundant contract Removing @requires('phase >= 0') on BuilderFilesystem.readPhased is safe because it is directly replaced by an identical assert(phase >= 0) at the entry of the method body, and BuilderFilesystem has no subclasses that override readPhased. | File | Target | Removed Contract | Enforced By | | --- | --- | --- | --- | | `build_runner/lib/src/build/builder_filesystem.dart` | `BuilderFilesystem.readPhased` | `@Requires('phase >= 0')` | assert(phase >= 0); at the start of BuilderFilesystem.readPhased (line 262) |
…nd remove redundant contract Removing @requires('uri.isNotEmpty') from LibrarySourceSinkImpl.addImport is safe because the identical condition is enforced by assert(uri.isNotEmpty) at the start of the method body, and LibrarySourceSinkImpl has no subclasses overriding addImport. | File | Target | Removed Contract | Enforced By | | --- | --- | --- | --- | | `build_runner/lib/src/build/library_source_sink_impl.dart` | `LibrarySourceSinkImpl.addImport` | `@Requires('uri.isNotEmpty')` | assert(uri.isNotEmpty) at LibrarySourceSinkImpl.addImport entry (line 56) |
…th asserts and remove redundant contracts
Both `@Requires` preconditions on `SharedPartAccumulator.addContribution` (`phase >= 0` and `contributions.keys.every((p) => p <= phase)`) are replaced with identical `assert(...)` checks at the top of the method body, and `SharedPartAccumulator` has no subclasses that could override `addContribution`.
| File | Target | Removed Contract | Enforced By |
| --- | --- | --- | --- |
| `build_runner/lib/src/build/shared_part_accumulator.dart` | `SharedPartAccumulator.addContribution` | `@Requires('phase >= 0')` | assert(phase >= 0); at SharedPartAccumulator.addContribution entry |
| `build_runner/lib/src/build/shared_part_accumulator.dart` | `SharedPartAccumulator.addContribution` | `@Requires('contributions.keys.every((p) => p <= phase)')` | assert(contributions.keys.every((p) => p <= phase)); at SharedPartAccumulator.addContribution entry |
…remove redundant contract
Removing `@Requires('phase >= -1')` from `SharedPartAccumulator.contentAt` is safe because the exact condition is checked by `assert(phase >= -1)` at the start of the method body, and `SharedPartAccumulator` has no subclasses overriding `contentAt`.
| File | Target | Removed Contract | Enforced By |
| --- | --- | --- | --- |
| `build_runner/lib/src/build/shared_part_accumulator.dart` | `SharedPartAccumulator.contentAt` | `@Requires('phase >= -1')` | assert(phase >= -1) at method entry in SharedPartAccumulator.contentAt (line 80) |
…d remove redundant contracts
Both `@Requires` preconditions on `BuildState.addPartContribution` are directly replaced by equivalent method-entry `assert(...)` statements (`assert(libraryId.sharedPartId != null)` and `assert(phase >= 0)`), and `BuildState` is not subclassed.
| File | Target | Removed Contract | Enforced By |
| --- | --- | --- | --- |
| `build_runner/lib/src/build/build_state/build_state.dart` | `BuildState.addPartContribution` | `@Requires('libraryId.sharedPartId != null')` | assert(libraryId.sharedPartId != null); at BuildState.addPartContribution entry |
| `build_runner/lib/src/build/build_state/build_state.dart` | `BuildState.addPartContribution` | `@Requires('phase >= 0')` | assert(phase >= 0); at BuildState.addPartContribution entry |
…nd remove redundant contracts
Removing the two `@Requires` annotations on `BuildState.copyPartContribution` is safe because identical `assert(phase >= 0)` and `assert(fromPart == null || libraryId.sharedPartId != null)` statements are added at the top of the method body, and `BuildState` is never subclassed or implemented.
| File | Target | Removed Contract | Enforced By |
| --- | --- | --- | --- |
| `build_runner/lib/src/build/build_state/build_state.dart` | `BuildState.copyPartContribution` | `@Requires('phase >= 0')` | assert(phase >= 0); at entry of BuildState.copyPartContribution (line 386) |
| `build_runner/lib/src/build/build_state/build_state.dart` | `BuildState.copyPartContribution` | `@Requires('fromPart == null \|\| libraryId.sharedPartId != null')` | assert(fromPart == null \|\| libraryId.sharedPartId != null); at entry of BuildState.copyPartContribution (line 387) |
…emove redundant contracts
Both `@Requires` annotations removed from `BuildState.addSourceForTest` are directly replaced by identical `assert(...)` checks at the entry of `addSourceForTest`. Because `BuildState` is not subclassed and `addSourceForTest` is never overridden, the preconditions are guaranteed on every call.
| File | Target | Removed Contract | Enforced By |
| --- | --- | --- | --- |
| `build_runner/lib/src/build/build_state/build_state.dart` | `BuildState.addSourceForTest` | `@Requires('!buildStepPlan.isDeclaredOutput(id)')` | assert(!buildStepPlan.isDeclaredOutput(id)) at the top of BuildState.addSourceForTest (build_runner/lib/src/build/build_state/build_state.dart:495) |
| `build_runner/lib/src/build/build_state/build_state.dart` | `BuildState.addSourceForTest` | `@Requires('!id.isBrOutput')` | assert(!id.isBrOutput) at the top of BuildState.addSourceForTest (build_runner/lib/src/build/build_state/build_state.dart:496) |
…dundant contract
Removing `@Requires('phase >= 0')` on `PhasedValue.isExpiredAt` is safe because the identical precondition is enforced by `assert(phase >= 0)` at the start of the method body, and `isExpiredAt` is not overridden by any subclass.
| File | Target | Removed Contract | Enforced By |
| --- | --- | --- | --- |
| `build_runner/lib/src/build/library_cycle_graph/phased_value.dart` | `PhasedValue.isExpiredAt` | `@Requires('phase >= 0')` | assert(phase >= 0) at method entry in PhasedValue.isExpiredAt |
…e redundant contract
Removing `@Requires('phase >= 0')` on `PhasedValue.expiringValueAt` is safe because the method now enforces `assert(phase >= 0)` directly at method entry, and `PhasedValue` has no subclass that overrides `expiringValueAt`.
| File | Target | Removed Contract | Enforced By |
| --- | --- | --- | --- |
| `build_runner/lib/src/build/library_cycle_graph/phased_value.dart` | `PhasedValue.expiringValueAt` | `@Requires('phase >= 0')` | assert(phase >= 0) at the top of PhasedValue.expiringValueAt (line 124) |
…ant contract
Removing `@Requires('phase >= 0')` on `PhasedValue.valueAt` is safe because it is directly replaced by `assert(phase >= 0)` at the top of `valueAt` (and is also checked at the start of `expiringValueAt`, which `valueAt` immediately calls), and `valueAt` is never overridden by the single generated subclass `_$PhasedValue`.
| File | Target | Removed Contract | Enforced By |
| --- | --- | --- | --- |
| `build_runner/lib/src/build/library_cycle_graph/phased_value.dart` | `PhasedValue.valueAt` | `@Requires('phase >= 0')` | assert(phase >= 0) at entry of PhasedValue.valueAt (build_runner/lib/src/build/library_cycle_graph/phased_value.dart) |
…d remove redundant contracts Removing the two @requires annotations on AnalysisDriverFilesystem.phase= and @invariant('_phase >= 0') on AnalysisDriverFilesystem is safe because the preconditions are directly enforced by the new method-entry asserts in phase=, _phase is private and only assigned 0 (at initialization and in startBuild) or a validated phase value in phase=, and AnalysisDriverFilesystem has no subclasses. | File | Target | Removed Contract | Enforced By | | --- | --- | --- | --- | | `build_runner/lib/src/build/resolver/analysis_driver_filesystem.dart` | `AnalysisDriverFilesystem` | `@Invariant('_phase >= 0')` | assert(phase >= 0) at entry of AnalysisDriverFilesystem.phase= (along with _phase initialized to 0 and reset to 0 in startBuild) | | `build_runner/lib/src/build/resolver/analysis_driver_filesystem.dart` | `AnalysisDriverFilesystem.phase=` | `@Requires('phase >= 0')` | assert(phase >= 0) at entry of AnalysisDriverFilesystem.phase= | | `build_runner/lib/src/build/resolver/analysis_driver_filesystem.dart` | `AnalysisDriverFilesystem.phase=` | `@Requires('phase <= _builderFilesystem.buildStepPlan.buildStepsByPhase.length')` | assert(phase <= _builderFilesystem.buildStepPlan.buildStepsByPhase.length) at entry of AnalysisDriverFilesystem.phase= |
…h assert and remove redundant contract
Removing `@Requires('isDeclaredOutput(id)')` from `BuildStepPlan.stepForDeclaredOutput` is safe because the exact precondition is enforced by `assert(isDeclaredOutput(id))` at method entry, and `stepForDeclaredOutput` is not overridden by the generated `_$BuildStepPlan` subclass.
| File | Target | Removed Contract | Enforced By |
| --- | --- | --- | --- |
| `build_runner/lib/src/build_plan/build_step_plan.dart` | `BuildStepPlan.stepForDeclaredOutput` | `@Requires('isDeclaredOutput(id)')` | assert(isDeclaredOutput(id)) at the top of BuildStepPlan.stepForDeclaredOutput |
…and remove redundant contract
Removing `@Requires('phase >= 0')` from `LibraryCycleGraphLoader._loadAtPhase` is safe because the exact precondition is enforced by `assert(phase >= 0)` at the start of the private method body, which cannot be overridden outside the library and has no overrides within it.
| File | Target | Removed Contract | Enforced By |
| --- | --- | --- | --- |
| `build_runner/lib/src/build/library_cycle_graph/library_cycle_graph_loader.dart` | `LibraryCycleGraphLoader._loadAtPhase` | `@Requires('phase >= 0')` | assert(phase >= 0) at entry of LibraryCycleGraphLoader._loadAtPhase |
…ert and remove redundant contract
Removing `@Requires('upToPhase >= 0')` on `LibraryCycleGraphLoader._hasIdToLoad` is safe because the exact precondition is enforced by `assert(upToPhase >= 0);` at the top of the method body, and `_hasIdToLoad` is a private method with no subclass overrides.
| File | Target | Removed Contract | Enforced By |
| --- | --- | --- | --- |
| `build_runner/lib/src/build/library_cycle_graph/library_cycle_graph_loader.dart` | `LibraryCycleGraphLoader._hasIdToLoad` | `@Requires('upToPhase >= 0')` | assert(upToPhase >= 0); at the start of LibraryCycleGraphLoader._hasIdToLoad |
…sert and remove redundant contract
Removing `@Requires('upToPhase >= 0')` from `LibraryCycleGraphLoader._nextIdToLoad` is safe because it is directly replaced by `assert(upToPhase >= 0);` at the entry of the private, non-overridden method.
| File | Target | Removed Contract | Enforced By |
| --- | --- | --- | --- |
| `build_runner/lib/src/build/library_cycle_graph/library_cycle_graph_loader.dart` | `LibraryCycleGraphLoader._nextIdToLoad` | `@Requires('upToPhase >= 0')` | assert(upToPhase >= 0) at the top of LibraryCycleGraphLoader._nextIdToLoad (line 147) |
…ert and remove redundant contract
Removing `@Requires('upToPhase >= 0')` from `LibraryCycleGraphLoader._buildCycles` is safe because the precondition is directly enforced by `assert(upToPhase >= 0);` at the entry of `_buildCycles`, which is a library-private method that is never overridden.
| File | Target | Removed Contract | Enforced By |
| --- | --- | --- | --- |
| `build_runner/lib/src/build/library_cycle_graph/library_cycle_graph_loader.dart` | `LibraryCycleGraphLoader._buildCycles` | `@Requires('upToPhase >= 0')` | assert(upToPhase >= 0); at method entry of LibraryCycleGraphLoader._buildCycles |
…and remove redundant contract
Removing `@Requires('phase >= 0')` on `LibraryCycleGraphLoader._buildGraphs` is safe because it is directly replaced by `assert(phase >= 0);` at the entry of `_buildGraphs`, a private method that is never overridden.
| File | Target | Removed Contract | Enforced By |
| --- | --- | --- | --- |
| `build_runner/lib/src/build/library_cycle_graph/library_cycle_graph_loader.dart` | `LibraryCycleGraphLoader._buildGraphs` | `@Requires('phase >= 0')` | assert(phase >= 0); at entry of LibraryCycleGraphLoader._buildGraphs (line 373) |
Removing `@Ensures('inputs.contains(input)')` on `InputTracker.add` is safe because its single-expression body `_inputs.add(input)` directly inserts `input` into the `HashSet<AssetId>` returned by `inputs`, and `InputTracker` has no subclasses overriding `add`.
| File | Target | Removed Contract | Enforced By |
| --- | --- | --- | --- |
| `build_runner/lib/src/build/input_tracker.dart` | `InputTracker.add` | `@Ensures('inputs.contains(input)')` | _inputs.add(input) (with Set<AssetId> get inputs => _inputs) |
…trypoint
Removing `@Ensures('resolverEntrypoints.contains(graph)')` on `InputTracker.addResolverEntrypoint` is safe because its 1-line body `_resolverEntrypoints.add(graph)` directly inserts `graph` into the `HashSet<AssetId>` returned by `resolverEntrypoints`, with no intervening mutations and no subclasses overriding the method.
| File | Target | Removed Contract | Enforced By |
| --- | --- | --- | --- |
| `build_runner/lib/src/build/input_tracker.dart` | `InputTracker.addResolverEntrypoint` | `@Ensures('resolverEntrypoints.contains(graph)')` | _resolverEntrypoints.add(graph) (with Set<AssetId> get resolverEntrypoints => _resolverEntrypoints) |
Removing the three `@Ensures` annotations on `InputTracker.clear` is safe because its 3-line body directly calls `.clear()` on the private `HashSet` fields (`_inputs`, `_resolverEntrypoints`, and `_globsEvaluated`) exposed directly by the `inputs`, `resolverEntrypoints`, and `globsEvaluated` getters, with no intervening mutations or subclasses overriding `clear`.
| File | Target | Removed Contract | Enforced By |
| --- | --- | --- | --- |
| `build_runner/lib/src/build/input_tracker.dart` | `InputTracker.clear` | `@Ensures('inputs.isEmpty')` | _inputs.clear(); (where Set<AssetId> get inputs => _inputs;) |
| `build_runner/lib/src/build/input_tracker.dart` | `InputTracker.clear` | `@Ensures('resolverEntrypoints.isEmpty')` | _resolverEntrypoints.clear(); (where Set<AssetId> get resolverEntrypoints => _resolverEntrypoints;) |
| `build_runner/lib/src/build/input_tracker.dart` | `InputTracker.clear` | `@Ensures('globsEvaluated.isEmpty')` | _globsEvaluated.clear(); (where Set<GlobId> get globsEvaluated => _globsEvaluated;) |
…ckAndStartBuild
Removing `@Ensures('_lock != null')` on `AnalysisDriverModel.takeLockAndStartBuild` is safe because its two-statement body assigns `_lock = await _pool.request()` (where `Pool.request()` returns a non-nullable `Future<PoolResource>`) and then synchronously calls `filesystem.startBuild(...)` without mutating `_lock` or yielding before returning, and `AnalysisDriverModel` has no subclasses.
| File | Target | Removed Contract | Enforced By |
| --- | --- | --- | --- |
| `build_runner/lib/src/build/resolver/analysis_driver_model.dart` | `AnalysisDriverModel.takeLockAndStartBuild` | `@Ensures('_lock != null')` | _lock = await _pool.request(); |
…ldAndUnlock
Removing `@Ensures('_lock == null')` on `AnalysisDriverModel.endBuildAndUnlock` is safe because the 3-line method body unconditionally executes `_lock = null;` as its last statement before returning, and `AnalysisDriverModel` has no subclasses overriding the method.
| File | Target | Removed Contract | Enforced By |
| --- | --- | --- | --- |
| `build_runner/lib/src/build/resolver/analysis_driver_model.dart` | `AnalysisDriverModel.endBuildAndUnlock` | `@Ensures('_lock == null')` | _lock = null; (line 60 of analysis_driver_model.dart) |
…hase=
Removing `@Ensures('_phase == phase')` on `AnalysisDriverFilesystem.phase=` is safe because the setter either returns early when `phase == _phase` already holds or immediately assigns `_phase = phase;` with no subsequent mutation to `_phase` before returning and no subclasses overriding the setter.
| File | Target | Removed Contract | Enforced By |
| --- | --- | --- | --- |
| `build_runner/lib/src/build/resolver/analysis_driver_filesystem.dart` | `AnalysisDriverFilesystem.phase=` | `@Ensures('_phase == phase')` | `if (phase == _phase) return;` and `_phase = phase;` in `AnalysisDriverFilesystem.phase=` (lines 53, 55) |
Removing @ensures('result == _data[path]!.content') on AnalysisDriverFilesystem.read is safe because the 2-line method body either throws StateError when !exists(path) or directly returns _data[path]!.content on its sole normal return path, and no subclasses override the method. | File | Target | Removed Contract | Enforced By | | --- | --- | --- | --- | | `build_runner/lib/src/build/resolver/analysis_driver_filesystem.dart` | `AnalysisDriverFilesystem.read` | `@Ensures('result == _data[path]!.content')` | return _data[path]!.content; (line 201) |
…athToUri
Removing `@Ensures('result.isScheme("package") || result.isScheme("asset")')` on `AnalysisDriverFilesystem.pathToUri` is safe because the only two normal return paths in the method directly construct and return a `Uri` with `scheme: 'package'` or `scheme: 'asset'`, and no subclass overrides `pathToUri`.
| File | Target | Removed Contract | Enforced By |
| --- | --- | --- | --- |
| `build_runner/lib/src/build/resolver/analysis_driver_filesystem.dart` | `AnalysisDriverFilesystem.pathToUri` | `@Ensures('result.isScheme("package") \|\| result.isScheme("asset")')` | if (pathSegments[2] == 'lib') { return Uri(scheme: 'package', ...); } else { return Uri(scheme: 'asset', ...); } |
Removing `@Ensures('result.isNotEmpty')` on `ReaderWriter._pathFor` is safe because `_pathFor` is a library-private single-statement method that cannot be overridden and directly returns `assetPathProvider.pathFor(...)`. Every `AssetPathProvider` implementation (`BuildPackages.pathFor` via `p.join(package.path, id.platformPath)` and `InMemoryAssetPathProvider.pathFor` via `id.toString()`) returns a non-empty string because `AssetId` enforces non-empty `package` and `path`.
| File | Target | Removed Contract | Enforced By |
| --- | --- | --- | --- |
| `build_runner/lib/src/io/reader_writer.dart` | `ReaderWriter._pathFor` | `@Ensures('result.isNotEmpty')` | return assetPathProvider.pathFor(id, inArtifactTree: inArtifactTree && !forceToPackagePathsForTesting, checkWriteAllowed: checkWriteAllowed); (where BuildPackages.pathFor returns p.join(package.path, id.platformPath) and InMemoryAssetPathProvider.pathFor returns id.toString(), both non-empty given non-empty AssetId.package and AssetId.path) |
…ntent
Removing both `@Ensures` postconditions on `BuildState.updateSourceContent` is safe because the 4-line method body explicitly throws a `StateError` if `!isSource(id)` and then executes `_contents[id] = content;` as its final statement before returning, with no intervening mutations and no subclasses overriding the method.
| File | Target | Removed Contract | Enforced By |
| --- | --- | --- | --- |
| `build_runner/lib/src/build/build_state/build_state.dart` | `BuildState.updateSourceContent` | `@Ensures('isSource(id)')` | if (!isSource(id)) { throw StateError('Tried to update content of non-source $id.'); } (build_state.dart:187-189) |
| `build_runner/lib/src/build/build_state/build_state.dart` | `BuildState.updateSourceContent` | `@Ensures('_contents[id] == content')` | _contents[id] = content; (build_state.dart:190) |
PR HealthChangelog Entry ❗
Changes to files need to be accounted for in their respective changelogs. This check can be disabled by tagging the PR with |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces simple
_contract_weaverannotations (@Invariant,@Requires,@Ensures,@ThrowEnsures) inbuild_runnerwith standard DartArgumentError(inAssetId) andassert(...)checks in constructors and methods, leaving the genuinely complex stateful and cross-collection contracts intact.build_runner/lib/: reduced from 271 -> 70 (201 removed, ~74% reduction):@Requires:109 -> 0@ThrowEnsures:4 -> 0@Ensures:43 -> 21@Invariant:115 -> 49_contract_weaver: reduced from 37 -> 15 (22 files no longer importcontracts.dart).Structure of the Commit Stack (63 Self-Contained Commits)
This PR is structured to be reviewed commit by commit. Every commit is self-contained, pairs a check (or existing check) with the exact contract annotations it makes redundant, and includes a Markdown table in the commit message mapping each removed contract annotation to the check that enforces it:
BuiltClasses (140 annotations removed)packageandpathinAssetId(ArgumentError.value) and remove 90 redundantpackage.isNotEmpty/path.isNotEmptycontract annotations (plus simplify 2 combined@Requiresannotations) across 21 files inbuild_runner.@Invariants onBuiltclasses (BuildStepId,PostProcessBuildStepId,GlobId,GlobResult,BuildStepResult,LibraryCycle,LibraryCycleGraph) into theirClassName._()constructors (assert(...)) and remove redundant caller@Requires.@Invariants (and factory@Requires) on immutablebuild_runnerclasses (BuildPackage,InBuildPhase,BuilderDefinition/PostProcessBuilderDefinition/PartContribution,BuildOutputReadResult,BuildPhases,BuildResult,BuildPackages,BuildRunnerFileContent) into constructorassert(...)checks.@Requires,@Ensures, and@ThrowEnsuresannotations that duplicate an existingif (...) throw ArgumentError / StateErrorcheck in the same method body (LibrarySourceSinkImpl.addImport,AnalysisDriverFilesystem.read,AnalysisDriverFilesystem.pathToUri,BuildStateconstructor,SharedPartAccumulator.addContribution,BuildState.updateSourceContent,BuildState.addBuildStepResult,BuildState.addPostProcessBuildStepResult).final-field@Invariants on stateful classes (ExpiringValue,InputTracker,LibrarySourceSinkImpl,AssetDepsLoader,BuildStepImpl,SharedPartAccumulator) with constructorassert(...)checks.@Requirespreconditions on non-overridden methods (BuildFileIndex,BuilderFilesystem,LibrarySourceSinkImpl,SharedPartAccumulator,BuildState,PhasedValue,AnalysisDriverFilesystem,BuildStepPlan,LibraryCycleGraphLoader) withassert(...)at method entry.@Ensurespostconditions (InputTracker,AnalysisDriverModel,AnalysisDriverFilesystem,ReaderWriter,BuildState.updateSourceContent).