Skip to content

Commit f539be3

Browse files
authored
Merge pull request #9697 from github/redsun82/swift-stop-stub-reverts
Swift: fix stub revert prevention
2 parents eb1b3f8 + a9bd784 commit f539be3

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

swift/codegen/generators/qlgen.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ def _is_generated_stub(file, check_modification=False):
103103
# no lines
104104
return False
105105
if check_modification:
106-
# one line already read, if we can read 4 other we are past the normal stub generation
107-
line_threshold = 4
106+
# one line already read, if we can read 5 other we are past the normal stub generation
107+
line_threshold = 5
108108
if sum(1 for _ in zip(range(line_threshold), contents)) == line_threshold:
109109
raise ModifiedStubMarkedAsGeneratedError(
110110
f"{file.name} stub was modified but is still marked as generated")

swift/codegen/test/test_qlgen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ def test_non_empty_cleanup(opts, generate, renderer):
378378

379379
def test_modified_stub_still_generated(qlgen_opts, renderer):
380380
stub = qlgen_opts.ql_stub_output / "A.qll"
381-
write(stub, "// generated\n\n\n\nsomething\n")
381+
write(stub, "// generated\nprivate import foo\n\nclass Bar extends BarBase {\n int x() { none() }\n}\n")
382382
with pytest.raises(qlgen.ModifiedStubMarkedAsGeneratedError):
383383
run_generation(qlgen.generate, qlgen_opts, renderer)
384384

0 commit comments

Comments
 (0)