Skip to content

Fix #7119: Don't infer given arguments if explicit ones are given #7141

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
Sep 3, 2019
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
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ object ProtoTypes {
/** Create a new TypeVar that represents a dependent method parameter singleton */
def newDepTypeVar(tp: Type)(implicit ctx: Context): TypeVar =
newTypeVar(TypeBounds.upper(AndType(tp.widenExpr, defn.SingletonClass.typeRef)))

/** The result type of `mt`, where all references to parameters of `mt` are
* replaced by either wildcards (if typevarsMissContext) or TypeParamRefs.
*/
Expand Down
9 changes: 8 additions & 1 deletion compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2575,7 +2575,14 @@ class Typer extends Namer
readaptSimplified(tpd.Apply(tree, args))
}
}
addImplicitArgs(argCtx(tree))
pt.revealIgnored match {
case pt: FunProto if pt.isGivenApply =>
// We can end up here if extension methods are called with explicit given arguments.
// See for instance #7119.
tree
case _ =>
addImplicitArgs(argCtx(tree))
}
}

/** A synthetic apply should be eta-expanded if it is the apply of an implicit function
Expand Down
9 changes: 9 additions & 0 deletions tests/pos/i7119.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Impl

def (impl: Impl) prop given Int = ???//the[Int]


def main(args: Array[String]): Unit = {
given as Int = 3
println(new Impl().prop given 3)
}