Reference ID
fcf8c0b6-4e77-a5bd-8819-22b85bd4e4ef
Please select what you are reporting on:
Verse
What Type of Bug are you experiencing?
Verse
Summary
Common Type Deduction Of Operator Or
Expressions Is Incorrect When Result Type Is Class Derived From Interface And A Child Of Class
Steps to Reproduce
See min repro code:
my_interface := interface
{
DoSomething<public>()<transacts>:int
}
item<public> := class(my_interface)
{
DoSomething<override>()<transacts>:int = 1
}
sub_item<public> := class(item)
{
DoSomething<override>()<transacts>:int = 1
}
TestFunction(OptItem:?item):void =
{
Item:item = OptItem? or sub_item{}
}
TestFunction() cannot compile as the assignment to Item:item fails due to the deduced common type being “any” instead of the common base “item”:
This variable expects to be initialized with a value of type item, but this initializer is an incompatible value of type any.(3509)
Expected Result
This code should be compile. It can be worked around by upcasting the child class to the parent class explicitly.
TestFunction(OptItem:?item):void =
{
Item:item = OptItem? or item(sub_item{})
}
Observed Result
This code does not compile.
This variable expects to be initialized with a value of type item, but this initializer is an incompatible value of type any.(3509)
Platform(s)
windows