mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Sema] Limit optional type variable hole propagation only to OptionalEvaluationExpr binding
This commit is contained in:
@@ -1993,7 +1993,8 @@ bool TypeVariableBinding::attempt(ConstraintSystem &cs) const {
|
||||
// without any contextual information, so even though `x` would get
|
||||
// bound to result type of the chain, underlying type variable wouldn't
|
||||
// be resolved, so we need to propagate holes up the conversion chain.
|
||||
if (TypeVar->getImpl().canBindToHole()) {
|
||||
if (TypeVar->getImpl().canBindToHole() &&
|
||||
srcLocator->directlyAt<OptionalEvaluationExpr>()) {
|
||||
if (auto objectTy = type->getOptionalObjectType()) {
|
||||
if (auto *typeVar = objectTy->getAs<TypeVariableType>())
|
||||
cs.recordPotentialHole(typeVar);
|
||||
|
||||
12
test/Constraints/try_swift5.swift
Normal file
12
test/Constraints/try_swift5.swift
Normal file
@@ -0,0 +1,12 @@
|
||||
// RUN: %target-typecheck-verify-swift -swift-version 5
|
||||
|
||||
// https://github.com/apple/swift/issues/58661
|
||||
class I58661 {
|
||||
func throwing<T>() throws -> T { // expected-note{{in call to function 'throwing()'}}
|
||||
throw Swift.fatalError()
|
||||
}
|
||||
|
||||
func reproduce() {
|
||||
let check = try? throwing() // expected-error{{generic parameter 'T' could not be inferred}}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user