Skip to content

Commit d94a22f

Browse files
committed
change isGround
1 parent 368095d commit d94a22f

File tree

2 files changed

+7
-28
lines changed

2 files changed

+7
-28
lines changed

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6967,11 +6967,15 @@ object Types extends TypeUtils {
69676967
end NamedPartsAccumulator
69686968

69696969
class isGroundAccumulator(using Context) extends TypeAccumulator[Boolean] {
6970+
var tparams = util.HashSet[TypeLambda](initialCapacity = 8)
69706971
def apply(x: Boolean, tp: Type): Boolean = x && {
69716972
tp match {
6972-
case _: TypeParamRef => false
6973+
case tp: TypeParamRef => tparams.contains(tp.binder)
69736974
case tp: TypeVar => apply(x, tp.underlying)
69746975
case tp: AppliedType => tp.isGround(this)
6976+
case tp: HKTypeLambda =>
6977+
tparams.add(tp)
6978+
apply(x, tp.resType)
69756979
case _ => foldOver(x, tp)
69766980
}
69776981
}

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4357,34 +4357,9 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
43574357
else formals1
43584358
implicitArgs(formals2, argIndex + 1, pt)
43594359

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-
43864360
val pt1 = pt.deepenProtoTrans
4387-
tryConstrainType(pt1)
4361+
if (pt1 `ne` pt) && (pt1 ne sharpenedPt) && pt1.isGround then
4362+
constrainResult(tree.symbol, wtp, pt1)
43884363
val arg = inferImplicitArg(formal, tree.span.endPos)
43894364

43904365
def canProfitFromMoreConstraints =

0 commit comments

Comments
 (0)