Skip to content

Commit 1685e92

Browse files
authored
Merge pull request #60109 from xedin/rdar-95990526
[AST] SE-0347: Don't check default expression status in type request
2 parents a35df66 + fd4acbe commit 1685e92

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

lib/AST/TypeCheckRequests.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,10 +1214,7 @@ Optional<Type> DefaultArgumentTypeRequest::getCachedResult() const {
12141214
if (!defaultInfo)
12151215
return None;
12161216

1217-
if (!defaultInfo->InitContextAndIsTypeChecked.getInt())
1218-
return None;
1219-
1220-
return defaultInfo->ExprType;
1217+
return defaultInfo->ExprType ? defaultInfo->ExprType : Optional<Type>();
12211218
}
12221219

12231220
void DefaultArgumentTypeRequest::cacheResult(Type type) const {

test/Constraints/type_inference_from_default_exprs.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// RUN: %empty-directory(%t)
2-
// RUN: %target-swift-frontend-emit-module -emit-module-path %t/InferViaDefaults.swiftmodule -module-name InferViaDefaults %S/Inputs/type_inference_via_defaults_other_module.swift
3-
// RUN: %target-swift-frontend -module-name main -typecheck -verify -I %t %s %S/Inputs/type_inference_via_defaults_other_module.swift
2+
// RUN: %target-build-swift -parse-as-library -emit-library -emit-module-path %t/InferViaDefaults.swiftmodule -module-name InferViaDefaults %S/Inputs/type_inference_via_defaults_other_module.swift -o %t/%target-library-name(InferViaDefaults)
3+
// RUN: %target-swift-frontend -typecheck -verify -lInferViaDefaults -module-name main -I %t -L %t %s
4+
5+
import InferViaDefaults
46

57
func testInferFromResult<T>(_: T = 42) -> T { fatalError() } // Ok
68

@@ -136,8 +138,8 @@ func main() {
136138
testMultiple(a: 0.0, b: "a") // Ok
137139

138140
// From a different module
139-
with_defaults() // Ok
140-
with_defaults("") // Ok
141+
InferViaDefaults.with_defaults() // Ok
142+
InferViaDefaults.with_defaults("") // Ok
141143

142144
_ = S()[] // Ok
143145
_ = S()[B()] // Ok

0 commit comments

Comments
 (0)