Front end must infer top level types before filling in type inference details for top level initializers #29719
Labels
area-front-end
Use area-front-end for front end / CFE / kernel format related issues.
Projects
Consider the following code:
The following pieces of information must be inferred by type inference, in order:
B.x
isList<num>
A.x
isList<num>
(inherited fromB.x
becauseA
implementsB
)A.constructor
'sx
parameter isList<num>
(determined byA.x
because initializing formals without an explicit type get their type from the field)[1]
inB.x
's initializer is<num>
(determined by the type ofA.constructor
'sx
parameter)Note that
B.x
appears both at the top and the bottom of the above list. This means that we can't do the type inference forB.x
all at once. We have to do top level type inference first. Then at a later pass we can fill in type inference for subexpressions appearing inB.x
's initializer.This is going to require some rework of the front end type inference algorithm, since it currently assumes that it doesn't have to visit any field's initializer more than once.
The text was updated successfully, but these errors were encountered: