Shared Function TypeofIntoNullableT(of T As Structure, U As Structure)(input As T?, ByRef output As U?) As Boolean
output = If(input.HasValue, Microsoft.VisualBasic.CompilerServices.Conversions.ToGenericParameter(Of U?)(input.Value)), NOthing)
Return output.HasValue
End Function
Dim input As Integer? = 123
Dim output As Double? = 0
Dim valid = TypeofIntoNullable(input, output)
Debug.Assert(valid)
Debug.Assert(input.ToString() = output.ToString())
The code works within the language, but I can attempting to write a lowering the does the equalvent transformation.