forked from apple/swift
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Sema] Stop visiting existential exprs an extra time checking for uses (
apple#27150) This was causing an exponential amount of time traversing the AST with deeply chained protocol extension methods, such as in the TestCodableRouter.swift test in Kitura. If the OpaqueValueExpr is referenced more than once within the OpenExistentialExpr it'll still get visited more than once, but that doesn't seem to happen in practice. If it turns out to be a problem, we can weaken the assertion I'm adding here. https://bugs.swift.org/browse/SR-11012
- Loading branch information
1 parent
e0160a4
commit dc59cd2
Showing
2 changed files
with
36 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
17 changes: 17 additions & 0 deletions
17
validation-test/compiler_scale/var_decl_usage_checker.swift.gyb
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// RUN: %scale-test --begin 1 --end 5 --step 1 --select VarDeclUsageCheckerExprVisits %s | ||
// REQUIRES: OS=macosx | ||
// REQUIRES: asserts | ||
|
||
protocol Proto {} | ||
extension Proto { | ||
var selfish: Proto { return self } | ||
} | ||
|
||
struct X: Proto {} | ||
|
||
func test(_ x: X) -> Proto { | ||
return x | ||
%for i in range(0, N*5): | ||
.selfish | ||
%end | ||
} |