@@ -92,7 +92,7 @@ object ProtoTypes {
92
92
case mt : MethodType =>
93
93
constrainResult(resultTypeApprox(mt), pt.resultType)
94
94
&& {
95
- if ctx.mode.is( Mode . ConstrainResultDeep ) then
95
+ if pt.constrainResultDeep then
96
96
if mt.isImplicitMethod == (pt.applyKind == ApplyKind .Using ) then
97
97
val tpargs = pt.args.lazyZip(mt.paramInfos).map(pt.typedArg)
98
98
tpargs.tpes.corresponds(mt.paramInfos)(_ <:< _)
@@ -300,9 +300,21 @@ object ProtoTypes {
300
300
/** A prototype for expressions that appear in function position
301
301
*
302
302
* [](args): resultType
303
+ *
304
+ * @param args The untyped arguments to which the function is applied
305
+ * @param resType The expeected result type
306
+ * @param typer The typer to use for typing the arguments
307
+ * @param applyKind The kind of application (regular/using/tupled infix operand)
308
+ * @param state The state object to use for tracking the changes to this prototype
309
+ * @param constrainResultDeep
310
+ * A flag to indicate that constrainResult on this prototype
311
+ * should typechec and compare the arguments.
303
312
*/
304
- case class FunProto (args : List [untpd.Tree ], resType : Type )(typer : Typer ,
305
- override val applyKind : ApplyKind , state : FunProtoState = new FunProtoState )(using protoCtx : Context )
313
+ case class FunProto (args : List [untpd.Tree ], resType : Type )(
314
+ typer : Typer ,
315
+ override val applyKind : ApplyKind ,
316
+ state : FunProtoState = new FunProtoState ,
317
+ val constrainResultDeep : Boolean = false )(using protoCtx : Context )
306
318
extends UncachedGroundType with ApplyingProto with FunOrPolyProto {
307
319
override def resultType (using Context ): Type = resType
308
320
@@ -314,8 +326,16 @@ object ProtoTypes {
314
326
typer.isApplicableType(tp, args, resultType, keepConstraint && ! args.exists(isPoly))
315
327
}
316
328
317
- def derivedFunProto (args : List [untpd.Tree ] = this .args, resultType : Type , typer : Typer = this .typer): FunProto =
318
- if ((args eq this .args) && (resultType eq this .resultType) && (typer eq this .typer)) this
329
+ def derivedFunProto (
330
+ args : List [untpd.Tree ] = this .args,
331
+ resultType : Type = this .resultType,
332
+ typer : Typer = this .typer,
333
+ constrainResultDeep : Boolean = this .constrainResultDeep): FunProto =
334
+ if (args eq this .args)
335
+ && (resultType eq this .resultType)
336
+ && (typer eq this .typer)
337
+ && constrainResultDeep == this .constrainResultDeep
338
+ then this
319
339
else new FunProto (args, resultType)(typer, applyKind)
320
340
321
341
/** @return True if all arguments have types.
@@ -444,10 +464,10 @@ object ProtoTypes {
444
464
ta(ta.foldOver(x, typedArgs().tpes), resultType)
445
465
446
466
override def deepenProto (using Context ): FunProto =
447
- derivedFunProto(args, resultType.deepenProto, typer )
467
+ derivedFunProto(args, resultType.deepenProto)
448
468
449
469
override def deepenProtoTrans (using Context ): FunProto =
450
- derivedFunProto(args, resultType.deepenProtoTrans, typer )
470
+ derivedFunProto(args, resultType.deepenProtoTrans, constrainResultDeep = true )
451
471
452
472
override def withContext (newCtx : Context ): ProtoType =
453
473
if newCtx `eq` protoCtx then this
0 commit comments