File tree Expand file tree Collapse file tree 5 files changed +16
-8
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 5 files changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -696,6 +696,10 @@ trait Applications extends Compatibility {
696696 fail(MissingArgument (methodType.paramNames(n), methString))
697697
698698 def tryDefault (n : Int , args1 : List [Arg ]): Unit = {
699+ if ! success then
700+ missingArg(n) // fail fast before forcing the default arg tpe, to avoid cyclic errors
701+ return
702+
699703 val sym = methRef.symbol
700704 val testOnly = this .isInstanceOf [TestApplication [? ]]
701705
Original file line number Diff line number Diff line change 88 | writer =
99 | /* ambiguous: both given instance given_Writer_JsValue and given instance given_Writer_JsObject match type Writer[B] */
1010 | summon[Writer[B]]
11- | ,
12- | this.given_BodySerializer_B$default$2[B])
11+ | )
1312 |
1413 |But both given instance given_Writer_JsValue and given instance given_Writer_JsObject match type Writer[B].
Original file line number Diff line number Diff line change 88 | evidence$1 =
99 | /* ambiguous: both given instance given_Writer_JsValue and given instance given_Writer_JsObject match type Writer[B] */
1010 | summon[Writer[B]]
11- | ,
12- | this.given_BodySerializer_B$default$2[B])
11+ | )
1312 |
1413 |But both given instance given_Writer_JsValue and given instance given_Writer_JsObject match type Writer[B].
Original file line number Diff line number Diff line change 11-- [E172] Type Error: tests/neg/given-ambiguous-default-2.scala:18:23 --------------------------------------------------
2218 |def f: Unit = summon[C] // error: Ambiguous given instances
33 | ^
4- |No best given instance of type C was found for parameter x of method summon in object Predef.
5- |I found:
4+ | No best given instance of type C was found for parameter x of method summon in object Predef.
5+ | I found:
66 |
7- | given_C(a = /* ambiguous: both given instance a1 and given instance a2 match type A */summon[A], this.given_C$default$2 )
7+ | given_C(a = /* ambiguous: both given instance a1 and given instance a2 match type A */summon[A])
88 |
9- |But both given instance a1 and given instance a2 match type A.
9+ | But both given instance a1 and given instance a2 match type A.
Original file line number Diff line number Diff line change 1+ class Lang (name : String )
2+ object Lang {
3+ val Default = Lang (" " )
4+ def apply (language : String ): Lang = ???
5+ def apply (maybeLang : Option [String ], default : Lang = Default ): Lang = ???
6+ }
You can’t perform that action at this time.
0 commit comments