File tree Expand file tree Collapse file tree 2 files changed +7
-28
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 2 files changed +7
-28
lines changed Original file line number Diff line number Diff line change @@ -6967,11 +6967,15 @@ object Types extends TypeUtils {
6967
6967
end NamedPartsAccumulator
6968
6968
6969
6969
class isGroundAccumulator (using Context ) extends TypeAccumulator [Boolean ] {
6970
+ var tparams = util.HashSet [TypeLambda ](initialCapacity = 8 )
6970
6971
def apply (x : Boolean , tp : Type ): Boolean = x && {
6971
6972
tp match {
6972
- case _ : TypeParamRef => false
6973
+ case tp : TypeParamRef => tparams.contains(tp.binder)
6973
6974
case tp : TypeVar => apply(x, tp.underlying)
6974
6975
case tp : AppliedType => tp.isGround(this )
6976
+ case tp : HKTypeLambda =>
6977
+ tparams.add(tp)
6978
+ apply(x, tp.resType)
6975
6979
case _ => foldOver(x, tp)
6976
6980
}
6977
6981
}
Original file line number Diff line number Diff line change @@ -4357,34 +4357,9 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
4357
4357
else formals1
4358
4358
implicitArgs(formals2, argIndex + 1 , pt)
4359
4359
4360
- // try to constrain type before implicit search. See #18763
4361
- def tryConstrainType (pt1 : Type ): Boolean = {
4362
- // subst dummyArg into FunProto so that we don't have to search for nested implicit
4363
- val tm = new TypeMap :
4364
- def apply (t : Type ): Type = t match
4365
- case fp@ FunProto (args, resType) =>
4366
- fp.derivedFunProto(
4367
- args.map(arg =>
4368
- if (arg.isInstanceOf [untpd.TypedSplice ]) arg
4369
- else dummyArg(arg.typeOpt).withSpan(arg.span)
4370
- ),
4371
- mapOver(resType)
4372
- )
4373
- case _ =>
4374
- mapOver(t)
4375
- if ! formal.isGround
4376
- && (formal.simplified `ne` formal)
4377
- && (pt1 `ne` pt)
4378
- && (pt1 ne sharpenedPt) then
4379
- val approxRes = wildApprox(pt1.resultType)
4380
- val stripedApproxRes = tm(approxRes)
4381
- if ! stripedApproxRes.containsWildcardTypes then
4382
- return wtp.resultType <:< stripedApproxRes
4383
- false
4384
- }
4385
-
4386
4360
val pt1 = pt.deepenProtoTrans
4387
- tryConstrainType(pt1)
4361
+ if (pt1 `ne` pt) && (pt1 ne sharpenedPt) && pt1.isGround then
4362
+ constrainResult(tree.symbol, wtp, pt1)
4388
4363
val arg = inferImplicitArg(formal, tree.span.endPos)
4389
4364
4390
4365
def canProfitFromMoreConstraints =
You can’t perform that action at this time.
0 commit comments