Skip to content

Type unexpectedly inferred as "Object" in "return x ? y : z" #59667

@DanTup

Description

@DanTup

While working in the analyzer, I got this analysis error:

image

For some reason, the inferred type is Object. If I change this to this as Element2 then the error goes away:

image

However, if I rewrite the code using if/else, there is no problem without the cast:

image

As far as I can tell, these are functionally the same?

The class ConstructorElementImpl2 is an Element2 via this chain: ConstructorElementImpl2 extends ExecutableElementImpl2 extends FunctionTypedElementImpl2 extends TypeParameterizedElementImpl2 extends ElementImpl2 implements Element2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions