Commit f1faab6
committed
safe_&: handle higher-kinded arguments like regular &
Unfortunately, i9346.scala has to be put in pending because it
still crashes (due to a cycle involving a LazyRef) after this fix, and
because `safe_&` is only called from `recoverable_&` when there is some
sort of cycle in the first place, I haven't been able to make another
testcase that exercises this codepath.
It would be good if we could figure out how to get i9346.scala to
compile (see also #9346 for discussions). It is is a minimization of a
pattern heavily used in akka-stream, similar to the use of the `CC` type
parameter in the scala-library collections but using a type member
instead. Unfortunately, it seems that Dotty is not really prepared to
handle F-bounds in type members currently. I was able to get the
testcase as well as akka-stream to compile by tweaking `findMember` to
not compute an intersection when the refinement is an alias:
```diff
--- compiler/src/dotty/tools/dotc/core/Types.scala
+++ compiler/src/dotty/tools/dotc/core/Types.scala
@@ -671,7 +671,8 @@ object Types {
val rinfo = tp.refinedInfo
if (name.isTypeName && !pinfo.isInstanceOf[ClassInfo]) { // simplified case that runs more efficiently
val jointInfo =
- if (ctx.base.pendingMemberSearches.contains(name)) pinfo safe_& rinfo
+ if (rinfo.isInstanceOf[TypeAlias]) rinfo
+ else if (ctx.base.pendingMemberSearches.contains(name)) pinfo safe_& rinfo
else pinfo recoverable_& rinfo
pdenot.asSingleDenotation.derivedSingleDenotation(pdenot.symbol, jointInfo)
}
```
This seems to work, but to be sound it means that we need to check for
invalid bounds in PostTyper (see tests/neg/i5556.scala for an example
where this matters), like we do for type parameters in
`checkAppliedType`.1 parent dfcc0b1 commit f1faab6
File tree
3 files changed
+23
-3
lines changed- compiler/src/dotty/tools/dotc/core
- tests/pending/pos
3 files changed
+23
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2078 | 2078 | | |
2079 | 2079 | | |
2080 | 2080 | | |
2081 | | - | |
| 2081 | + | |
2082 | 2082 | | |
2083 | 2083 | | |
2084 | 2084 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1018 | 1018 | | |
1019 | 1019 | | |
1020 | 1020 | | |
1021 | | - | |
1022 | | - | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
1023 | 1026 | | |
1024 | 1027 | | |
1025 | 1028 | | |
| |||
2934 | 2937 | | |
2935 | 2938 | | |
2936 | 2939 | | |
| 2940 | + | |
| 2941 | + | |
| 2942 | + | |
| 2943 | + | |
2937 | 2944 | | |
2938 | 2945 | | |
2939 | 2946 | | |
| |||
3020 | 3027 | | |
3021 | 3028 | | |
3022 | 3029 | | |
| 3030 | + | |
| 3031 | + | |
| 3032 | + | |
| 3033 | + | |
3023 | 3034 | | |
3024 | 3035 | | |
3025 | 3036 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
0 commit comments