-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduce projections of type aliases with class type prefixes (#19931)
Projections P # X are types that we would like to avoid. If X is a class type, there's nothing we can do. If X is an abstract type, we use skolemization and rewrite to (x?: P).X. If X is an alias type we should simply dealias but this was not done before. This caused an exponential blowup in #19892, where we constructed types of the form ZPartialServerEndpoint[R, A, B, I, E, O, -C] # EndpointType[A, I, E, T, R] ... # EndpointType[A, I, E, T, R] When the were 5 or more such selections, compile times blew up (33s for 5, timeout after 5 minutes for 6). I am still not quite sure where the blowup happened. Looking at stacktraces of random interrupts it seemed to be in a deep recursion of memberDenot and asSeenFrom calls.I believe it would still be interesting to find out more about this, in case there are other similar situations where combinations of deep projections with wide applications cannot be avoided. But for this precise problem, eagerly dealiasing fixes it. Fixes #19892
- Loading branch information
Showing
4 changed files
with
45 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
abstract class ZPartialServerEndpoint[R, A, B, I, E, O, -C] | ||
extends EndpointOps[A, I, E, O, C]{ | ||
override type ThisType[-_R] = ZPartialServerEndpoint[R, A, B, I, E, O, _R] | ||
override type EndpointType[_A, _I, _E, _O, -_R] =ZPartialServerEndpoint[R, _A, B, _I, _E, _O, _R] | ||
} | ||
|
||
trait EndpointOps[A, I, E, O, -R] { | ||
type EndpointType[_A, _I, _E, _O, -_R] | ||
type ThisType[-_R] | ||
def out[T]: EndpointType[A, I, E, T, R] | ||
def description(d: String): ThisType[R] | ||
} | ||
|
||
object Test { | ||
def basicEndpoint[R](): ZPartialServerEndpoint[R, Any, Any, Unit, Any, Unit, Any] = ??? | ||
|
||
// commonts next to `.out[Any]` contain information about compilation time when chaining up to N `out` functions | ||
val case1 = | ||
basicEndpoint() // 1.5s | ||
.out[Any] // 1.6s | ||
.out[Any] // 1.7s | ||
.out[Any] // 2s | ||
.out[Any] // 4s | ||
.out[Any] // 33s | ||
.out[Any] // aborted after 5 min | ||
} |