Details
-
Enhancement
-
Resolution: Fixed
-
P4
-
8, 8-repo-lambda
-
b100
Description
The current algorithm for doing bound incorporation is suboptimal and prone to execute same operations multiple times. Most times, the compiler will be able to detect the redundancies (i.e. same bound cannot be added twice to an inference var). However, there's little reason to execute assertions like these:
List<alpha> <: List<String>
multiple times, as they always end up with the same set of constraints being forced on alpha. In extreme cases, this can also be dangerous, if same bounds are added after type-variable substitution - i.e.:
alpha <: beta
beta = List<gamma>
gamma = String
Here we have that:
alpha <: List<String>
however, if we do another round and we consider same constraints as above, we could end up doing the work twice - as beta is not an upper bound of alpha after type-substitution. While the compiler detects this in most cases, there's a potential for infinite loops that should be avoided.
List<alpha> <: List<String>
multiple times, as they always end up with the same set of constraints being forced on alpha. In extreme cases, this can also be dangerous, if same bounds are added after type-variable substitution - i.e.:
alpha <: beta
beta = List<gamma>
gamma = String
Here we have that:
alpha <: List<String>
however, if we do another round and we consider same constraints as above, we could end up doing the work twice - as beta is not an upper bound of alpha after type-substitution. While the compiler detects this in most cases, there's a potential for infinite loops that should be avoided.