Skip to content

Commit 8f0d84a

Browse files
authored
Merge pull request #60132 from xedin/rdar-959905260-5.7
[5.7][AST] SE-0347: Don't check default expression status in type request
2 parents 0e9e05f + 876f6e9 commit 8f0d84a

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
@@ -1230,10 +1230,7 @@ Optional<Type> DefaultArgumentTypeRequest::getCachedResult() const {
12301230
if (!defaultInfo)
12311231
return None;
12321232

1233-
if (!defaultInfo->InitContextAndIsTypeChecked.getInt())
1234-
return None;
1235-
1236-
return defaultInfo->ExprType;
1233+
return defaultInfo->ExprType ? defaultInfo->ExprType : Optional<Type>();
12371234
}
12381235

12391236
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)