Feature request: Specify unification strategy for generic method types #29780
Labels
area-language
Dart language related items (some items might be better tracked at github.com/dart-lang/language).
closed-stale
Closed as the issue or PR is assumed stale
type-enhancement
A request for a change that isn't a bug
issue #29777 revealed yet another scenario where the lowest-upper-bound unification can work against users intent.
I have talked to @leafpetersen a number of times about better strategies, and the answer seems to be that no single strategy is perfect.
What about a new keyword such as
exact
, that lets the individual API opt into the constraint unification strategy?I think only one new strategy would be needed (exact). But I could also imagine greatest-lower-bound checks to be useful:
arguably the regular inference rules should be usable with a user-specified upper bound.
More likely, I think, there should be one strategy, with a name as simple as
exact
, but with the semantics ofgreatest
.upto X
specifically to me seems presumptuous, though most scenarios that confuse people involving unification are where the inferred type is Object, so maybe a single strategy should be specifyable which has the behavior ofupto Object
.Perhaps a better keyword is
foo<strict T>
so that its meaning can be more flexible.The text was updated successfully, but these errors were encountered: