LanguageFeatures/Private-fields-promotion/not_promotable_A01_t04 has incorrect expectation #2306
Labels
bad-test
Report tests in need of updates. When closed, the tests should be considered good
LanguageFeatures/Private-fields-promotion/not_promotable_A01_t04
looks like this:The test is trying to verify that
C._x
does not type promote.The first expectation (inside
C.test
) works fine, because inside an instance method ofC
, the unpromoted type of_x
isT
, and therefore trying to call_x.foo()
is an effective way of verifying that_x
wasn't promoted toA
.The second expectation (inside
main
) is problematic, becauseC c = C();
gets type inferred asC<dynamic> c = C();
, therefore the unpromoted type ofc._x
isdynamic
, and so the call toc._x.foo()
works regardless of whetherc._x
has been type promoted.One possible fix would be to change the first line of
main
tovar c = C<Object>()
. That would ensure that the unpromoted type ofc._x
isObject
, and so the call toc._x.foo()
would be an effective way of verifying thatc._x
hasn't been type promoted.The text was updated successfully, but these errors were encountered: