Commit a9b1e15
authored
Try to fix callee type inference in typedFunctionValue (#24732)
The callee part is separated from #24697 for further investigation
When typing a function literal's expression to infer the callee type, we
now create placeholder tree for each argument, and make sure the
function part does not refer to any parameter. This ensures that
references in the expression won't incorrectly resolve to outer scope
variables with the same names as the parameters.
Fix the following test:
```scala
def foo[T <: (B => Unit)](f: T) = ???
def transfer(in: A): Unit =
foo(in => transfer(in)) // error: Found: (in : B) Required: A
def transfer(in: B): Unit = ???
```File tree
2 files changed
+26
-15
lines changed- compiler/src/dotty/tools/dotc/typer
- tests/pos
2 files changed
+26
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1876 | 1876 | | |
1877 | 1877 | | |
1878 | 1878 | | |
| 1879 | + | |
| 1880 | + | |
| 1881 | + | |
| 1882 | + | |
| 1883 | + | |
| 1884 | + | |
| 1885 | + | |
| 1886 | + | |
| 1887 | + | |
| 1888 | + | |
| 1889 | + | |
1879 | 1890 | | |
1880 | 1891 | | |
1881 | 1892 | | |
| |||
1910 | 1921 | | |
1911 | 1922 | | |
1912 | 1923 | | |
1913 | | - | |
| 1924 | + | |
1914 | 1925 | | |
1915 | 1926 | | |
1916 | 1927 | | |
1917 | | - | |
| 1928 | + | |
1918 | 1929 | | |
1919 | 1930 | | |
1920 | | - | |
1921 | | - | |
| 1931 | + | |
| 1932 | + | |
| 1933 | + | |
1922 | 1934 | | |
1923 | 1935 | | |
1924 | 1936 | | |
1925 | | - | |
| 1937 | + | |
1926 | 1938 | | |
1927 | 1939 | | |
1928 | 1940 | | |
1929 | | - | |
1930 | | - | |
| 1941 | + | |
| 1942 | + | |
1931 | 1943 | | |
1932 | 1944 | | |
1933 | 1945 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
0 commit comments