Created
July 6, 2022 23:34
-
-
Save agocke/6556180733079acafa0f980b62b6eb94 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ref struct S<#a> { | |
public int Field; | |
public ref<#a> int RefField; | |
} | |
static int StaticField = 5; | |
public void M1() { | |
S s = default; // S<#global> | |
s = new S() { RefField = ref StaticField }; | |
CC(ref s); | |
} | |
public void CC1<#a, #b>(ref<#a> S<#b> s) { | |
s = new S() { | |
RefField = ref s.Field // error, ref<#b> int <- ref<#a> int, #b and #a are unrelated | |
}; | |
} | |
public void M2() { | |
S s = default; // S<#global> | |
s = new S() { RefField = ref StaticField }; | |
CC(ref s); // error, invalid type parameters, ref s :: ref<#local> S<#global> | |
} | |
public void CC2<#a>(ref<#a> S<#a> s) { | |
s = new S() { | |
RefField = ref s.Field // OK | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment