You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Specificity of overloaded constructor of generic class
There are two phases to picking a winning overload for the
constructor of a polymorphic class, but the type params
are not handled consistently:
- isApplicable: we put the class's type params in undetparams
- isAsSpecific: the constructor's info is a method type,
the class's type params appear unbound.
The second one is a problem because specificity should be able
to infer different type args for those parameters, as it's doing
a bunch of `isApplicable` calls itself to score the overloads.
To fix this, we push the class's poly type down to the constructor's
info. One caveat: we have to clone the class type params and
use the constructor as their owner, otherwise ASF will rewrite
them based on the prefix.
(`PolyType(tpars, res).ASF(pre, clazz)` means references in
`res` to type params owned by `clazz` will be rewritten to use
prefix `pre`, but the resulting poly type's type params will
not be adjusted.)
0 commit comments