Greatest Common SubType Inference + Array Literal #2744
Labels
Area-Language Design
Language-VB
Resolution-Duplicate
The described behavior is tracked in another issue
If you look at the object graph below you can see that
TextRule
inheritsRuleDef
So it would be logical sense the when using on in an array literal with other
RuleDef
's that the inferred type of the array should beRuleDef()
but on examination the declared type isObject()
.WIth
Option Strict On
we get the warning message.Cannot infer an element type, and Option Strict On does not allow 'Object' to be assumed. Specifying the type of the array might correct this error.
The extension method on the type
string
just create instances of theRuleDef
But if I use a the exact same form of the array literal being used as the first argument of the exact same function. Except that in one we use is as as extension method the other not.
The first has an error, the second does not.
My expectation is for both to mean the same.
So this behaviour suggest that type-inference isn't correctly inferring the greatest common subtype for the array literal. In which the exampe would be
RuleDef
, Same behaviour exists with VS2013 version of VB.net. I shouldn't have to specify the type when it could be be inferred.The text was updated successfully, but these errors were encountered: