Skip to content

Commit 267701d

Browse files
committed
Fix #7119: Don't infer given arguments if explicit ones are given
Don't infer given arguments if explicit ones are given, even if the explicit arguments are part of an IgnoredProto.
1 parent 96b0854 commit 267701d

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ object ProtoTypes {
520520
/** Create a new TypeVar that represents a dependent method parameter singleton */
521521
def newDepTypeVar(tp: Type)(implicit ctx: Context): TypeVar =
522522
newTypeVar(TypeBounds.upper(AndType(tp.widenExpr, defn.SingletonClass.typeRef)))
523-
523+
524524
/** The result type of `mt`, where all references to parameters of `mt` are
525525
* replaced by either wildcards (if typevarsMissContext) or TypeParamRefs.
526526
*/

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2575,7 +2575,14 @@ class Typer extends Namer
25752575
readaptSimplified(tpd.Apply(tree, args))
25762576
}
25772577
}
2578-
addImplicitArgs(argCtx(tree))
2578+
pt.revealIgnored match {
2579+
case pt: FunProto if pt.isGivenApply =>
2580+
// We can end up here if extension methods are called with explicit given arguments.
2581+
// See for instance #7119.
2582+
tree
2583+
case _ =>
2584+
addImplicitArgs(argCtx(tree))
2585+
}
25792586
}
25802587

25812588
/** A synthetic apply should be eta-expanded if it is the apply of an implicit function

tests/pos/i7119.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class Impl
2+
3+
def (impl: Impl) prop given Int = ???//the[Int]
4+
5+
6+
def main(args: Array[String]): Unit = {
7+
given as Int = 3
8+
println(new Impl().prop given 3)
9+
}

0 commit comments

Comments
 (0)