File tree 5 files changed +16
-8
lines changed
compiler/src/dotty/tools/dotc/typer
5 files changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -625,6 +625,10 @@ trait Applications extends Compatibility {
625
625
fail(MissingArgument (methodType.paramNames(n), methString))
626
626
627
627
def tryDefault (n : Int , args1 : List [Arg ]): Unit = {
628
+ if ! success then
629
+ missingArg(n) // fail fast before forcing the default arg tpe, to avoid cyclic errors
630
+ return
631
+
628
632
val sym = methRef.symbol
629
633
val testOnly = this .isInstanceOf [TestApplication [? ]]
630
634
Original file line number Diff line number Diff line change 8
8
| writer =
9
9
| /* ambiguous: both given instance given_Writer_JsValue and given instance given_Writer_JsObject match type Writer[B] */
10
10
| summon[Writer[B]]
11
- | ,
12
- | this.given_BodySerializer_B$default$2[B])
11
+ | )
13
12
|
14
13
|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 8
8
| evidence$1 =
9
9
| /* ambiguous: both given instance given_Writer_JsValue and given instance given_Writer_JsObject match type Writer[B] */
10
10
| summon[Writer[B]]
11
- | ,
12
- | this.given_BodySerializer_B$default$2[B])
11
+ | )
13
12
|
14
13
|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 1
1
-- [E172] Type Error: tests/neg/given-ambiguous-default-2.scala:18:23 --------------------------------------------------
2
2
18 |def f: Unit = summon[C] // error: Ambiguous given instances
3
3
| ^
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:
6
6
|
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])
8
8
|
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