Skip to content

Commit 55c87ca

Browse files
authored
Merge pull request #10317 from dotty-staging/fix-#10016
Fix #10016: Bypass normalize for context function closure arguments
2 parents 64d9f1d + 62c0c8d commit 55c87ca

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,9 @@ trait Applications extends Compatibility {
677677
*/
678678
class ApplicableToTrees(methRef: TermRef, args: List[Tree], resultType: Type)(using Context)
679679
extends TestApplication(methRef, methRef.widen, args, resultType) {
680-
def argType(arg: Tree, formal: Type): Type = normalize(arg.tpe, formal)
680+
def argType(arg: Tree, formal: Type): Type =
681+
if untpd.isContextualClosure(arg) && defn.isContextFunctionType(formal) then arg.tpe
682+
else normalize(arg.tpe, formal)
681683
def treeToArg(arg: Tree): Tree = arg
682684
def isVarArg(arg: Tree): Boolean = tpd.isWildcardStarArg(arg)
683685
def typeOfArg(arg: Tree): Type = arg.tpe

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,8 @@ object ProtoTypes {
632632
normalize(et.resultType, pt)
633633
case wtp =>
634634
val iftp = defn.asContextFunctionType(wtp)
635-
if (iftp.exists) normalize(iftp.dropDependentRefinement.argInfos.last, pt) else tp
635+
if iftp.exists then normalize(iftp.dropDependentRefinement.argInfos.last, pt)
636+
else tp
636637
}
637638
}
638639

tests/run/i10016.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
def f(init: Int ?=> Int) : Int = 1
2+
def f(s: String)(init: Int ?=> Int) : Int = 2
3+
4+
@main def Test() =
5+
assert(f((using x:Int) => x) == 1)

0 commit comments

Comments
 (0)