Skip to content

Fix #10016: Bypass normalize for context function closure arguments #10317

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Applications.scala
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,9 @@ trait Applications extends Compatibility {
*/
class ApplicableToTrees(methRef: TermRef, args: List[Tree], resultType: Type)(using Context)
extends TestApplication(methRef, methRef.widen, args, resultType) {
def argType(arg: Tree, formal: Type): Type = normalize(arg.tpe, formal)
def argType(arg: Tree, formal: Type): Type =
if untpd.isContextualClosure(arg) && defn.isContextFunctionType(formal) then arg.tpe
else normalize(arg.tpe, formal)
def treeToArg(arg: Tree): Tree = arg
def isVarArg(arg: Tree): Boolean = tpd.isWildcardStarArg(arg)
def typeOfArg(arg: Tree): Type = arg.tpe
Expand Down
3 changes: 2 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,8 @@ object ProtoTypes {
normalize(et.resultType, pt)
case wtp =>
val iftp = defn.asContextFunctionType(wtp)
if (iftp.exists) normalize(iftp.dropDependentRefinement.argInfos.last, pt) else tp
if iftp.exists then normalize(iftp.dropDependentRefinement.argInfos.last, pt)
else tp
}
}

Expand Down
5 changes: 5 additions & 0 deletions tests/run/i10016.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
def f(init: Int ?=> Int) : Int = 1
def f(s: String)(init: Int ?=> Int) : Int = 2

@main def Test() =
assert(f((using x:Int) => x) == 1)