Inner union compile with error `Cannot implicitly convert type 'X' to 'Y`
See original GitHub issueHi. First of all, I’d like to thank you for this excellent library! It is very useful in many contexts! That is great and impressive work! 😃
It would be nice if the inner union classes worked. Below is the example that doesn’t compile
using Dunet;
Console.WriteLine("Hello, World!");
public class Foo
{
[Union]
public partial record R
{
public partial record O1();
}
public R Bar()
{
return new R.O1();
}
}
The error says: Error CS0029 Cannot implicitly convert type 'Foo.R.O1' to 'Foo.R'
Although below code works just fine:
using Dunet;
Console.WriteLine("Hello, World!");
[Union]
public partial record R
{
public partial record O1();
}
public class Foo
{
public R Bar()
{
return new R.O1();
}
}
I would expect that both variants of code compile. The first version could be useful because the result type can be hidden inside the class. Is it possible to fix that?
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:6 (4 by maintainers)
Top Results From Across the Web
c# - Cannot implicitly convert type 'customtype' to ' ...
Everything works fine except that I now get this error message on the "return person" in the if statement. Cannot implicitly convert type...
Read more >Something that confused me a bit when I started doing C# ...
Something that confused me a bit when I started doing C#, "What do you mean 'Cannot implicitly convert type 'x' to 'y', do...
Read more >Compiler Error CS0266
This error occurs when your code tries to convert between two types that cannot be implicitly converted, but where an explicit conversion is ......
Read more >Conversion and Promotion - Julia Documentation
In this section, we explain how this promotion system works, as well as how to extend it to new types and apply it...
Read more >Cannot implicitly convert type 'float' to 'UnityEngine.Vector3 ...
So I am following a Brackeys tutorial about fp movement in unity ([MEDIA]) and as far as I can tell, all of my...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That’s my pleasure 😃 Thank you so much for implementing that feature in such a rapid time period! 😃 🥇 If I find some other reasonable ideas for improvements I’ll come back here if you don’t mind 😉 Take care! 🍻
@KarolBajkowski v1.2.0 now includes support for this use case. Thanks again for filing this issue and helping review it. Cheers!