@@ -67,23 +67,23 @@ object ProtoTypes {
6767 */
6868 def constrainResult (mt : Type , pt : Type )(using Context ): Boolean =
6969 inContext(ctx.addMode(Mode .ConstrainResult )) {
70- val savedConstraint = ctx.typerState.constraint
71- val res = pt.widenExpr match {
72- case pt : FunProto =>
73- mt match {
74- case mt : MethodType => constrainResult(resultTypeApprox(mt), pt.resultType)
75- case _ => true
76- }
77- case _ : ValueTypeOrProto if ! disregardProto(pt) =>
78- isCompatible(normalize(mt, pt), pt)
79- case pt : WildcardType if pt.optBounds.exists =>
80- isCompatible(normalize(mt, pt), pt)
81- case _ =>
82- true
70+ val savedConstraint = ctx.typerState.constraint
71+ val res = pt.widenExpr match {
72+ case pt : FunProto =>
73+ mt match {
74+ case mt : MethodType => constrainResult(resultTypeApprox(mt), pt.resultType)
75+ case _ => true
76+ }
77+ case _ : ValueTypeOrProto if ! disregardProto(pt) =>
78+ isCompatible(normalize(mt, pt), pt)
79+ case pt : WildcardType if pt.optBounds.exists =>
80+ isCompatible(normalize(mt, pt), pt)
81+ case _ =>
82+ true
83+ }
84+ if (! res) ctx.typerState.resetConstraintTo(savedConstraint)
85+ res
8386 }
84- if (! res) ctx.typerState.resetConstraintTo(savedConstraint)
85- res
86- }
8787
8888 /** Constrain result with special case if `meth` is an inlineable method in an inlineable context.
8989 * In that case, we should always succeed and not constrain type parameters in the expected type,
0 commit comments