File tree Expand file tree Collapse file tree 2 files changed +48
-1
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 2 files changed +48
-1
lines changed Original file line number Diff line number Diff line change @@ -4113,7 +4113,14 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
4113
4113
* `SearchFailureType`.
4114
4114
*/
4115
4115
def issueErrors (fun : Tree , args : List [Tree ]): Tree =
4116
- def firstFailure = args.tpes.find(_.isInstanceOf [SearchFailureType ]).getOrElse(NoType )
4116
+ // Prefer other errors over ambiguities. If nested in outer searches a missing
4117
+ // implicit can be healed by simply dropping this alternative and tryng something
4118
+ // else. But an ambiguity is sticky and propagates outwards. If we have both
4119
+ // a missing implicit on one argument and an ambiguity on another the whole
4120
+ // branch should be classified as a missing implicit.
4121
+ val firstNonAmbiguous = args.tpes.find(tp => tp.isError && ! tp.isInstanceOf [AmbiguousImplicits ])
4122
+ def firstError = args.tpes.find(_.isInstanceOf [SearchFailureType ]).getOrElse(NoType )
4123
+ def firstFailure = firstNonAmbiguous.getOrElse(firstError)
4117
4124
val errorType =
4118
4125
firstFailure match
4119
4126
case tp : AmbiguousImplicits =>
Original file line number Diff line number Diff line change
1
+ trait CmdLineParser { outer =>
2
+
3
+ trait Opt [+ T ] {
4
+ val default : T
5
+ val names : Set [String ]
6
+ val help : String
7
+ }
8
+
9
+ trait IntOpt extends Opt [Int ] {
10
+ val parser = outer // <=== comment out this line, we get "true true"
11
+ }
12
+ }
13
+
14
+ object FirstParser extends CmdLineParser {
15
+ object OptMinSuccess extends IntOpt {
16
+ val default = 100
17
+ val names = Set (" bla" )
18
+ val help = " bla"
19
+ }
20
+
21
+ val opts = List (OptMinSuccess )
22
+ }
23
+
24
+ object SecondParser extends CmdLineParser {
25
+ object OptMinSuccess extends IntOpt {
26
+ val default = 50
27
+ val names = Set (" bla" )
28
+ val help = " help"
29
+ }
30
+ }
31
+ @ main def Test =
32
+
33
+ val a = SecondParser .OptMinSuccess .isInstanceOf [FirstParser .IntOpt ]
34
+
35
+ println(a)
36
+
37
+ (SecondParser .OptMinSuccess : SecondParser .IntOpt ) match {
38
+ case _ : FirstParser .IntOpt => println(" true" )
39
+ case _ => println(" false" )
40
+ }
You can’t perform that action at this time.
0 commit comments