File tree Expand file tree Collapse file tree 2 files changed +62
-3
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 2 files changed +62
-3
lines changed Original file line number Diff line number Diff line change @@ -1564,7 +1564,7 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
1564
1564
case x => x
1565
1565
}
1566
1566
1567
- def sizeFits (alt : TermRef ): Boolean = alt.widen.stripPoly match {
1567
+ def sizeFits (alt : TermRef , followApply : Boolean ): Boolean = alt.widen.stripPoly match {
1568
1568
case tp : MethodType =>
1569
1569
val ptypes = tp.paramInfos
1570
1570
val numParams = ptypes.length
@@ -1575,11 +1575,12 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
1575
1575
else if (numParams > numArgs + 1 ) hasDefault
1576
1576
else isVarArgs || hasDefault
1577
1577
case tp =>
1578
- numArgs == 0 || onMethod(tp, followApply = true )(sizeFits)
1578
+ numArgs == 0 ||
1579
+ followApply && onMethod(tp, followApply = true )(sizeFits(_, followApply = false ))
1579
1580
}
1580
1581
1581
1582
def narrowBySize (alts : List [TermRef ]): List [TermRef ] =
1582
- alts.filter(sizeFits)
1583
+ alts.filter(sizeFits(_, followApply = true ) )
1583
1584
1584
1585
def narrowByShapes (alts : List [TermRef ]): List [TermRef ] = {
1585
1586
if (normArgs exists untpd.isFunctionWithUnknownParamType)
Original file line number Diff line number Diff line change @@ -6,4 +6,62 @@ object B {
6
6
def f (x : Any ): Int = 2
7
7
lazy val f = new A {}
8
8
val x = f(null ) // error: ambiguous
9
+ }
10
+
11
+ object Test {
12
+ def f (x : Any ) = 10
13
+ val f : Foo123 = f(1 ) // error: Not found: type Foo123
14
+
15
+ }
16
+
17
+ object Test2 {
18
+ trait A {
19
+ def apply (x : AnyRef ): Int
20
+ }
21
+ object B {
22
+ def f (e : Any ): A = ???
23
+ val f : A = f(null )
24
+ }
25
+ }
26
+
27
+ object Test3 {
28
+ trait A {
29
+ def apply (x : String ): Int
30
+ }
31
+ object B {
32
+ def f (e : CharSequence ): A = ???
33
+ val f : A = f(null )
34
+ }
35
+ }
36
+
37
+
38
+ object Test4 {
39
+ trait A {
40
+ def apply (x : Any ): Int
41
+ }
42
+ object B {
43
+ def f (e : Any ): A = ???
44
+ val f : A = f(null )
45
+ }
46
+ }
47
+
48
+ object Test5 {
49
+ trait A {
50
+ def apply (x : Any ): Int
51
+ }
52
+ object B {
53
+ def f (e : AnyRef ): A = ???
54
+ val f : A = f(null )
55
+ }
56
+ }
57
+
58
+
59
+ object Test6 {
60
+ trait A {
61
+ def apply (x : CharSequence ): Int
62
+ }
63
+ object B {
64
+ def f (e : String ): A = ???
65
+ val f : A = f(null )
66
+ }
9
67
}
You can’t perform that action at this time.
0 commit comments