diff options
Diffstat (limited to 'gnu')
| -rw-r--r-- | gnu/local.mk | 1 | ||||
| -rw-r--r-- | gnu/packages/dotnet.scm | 81 | ||||
| -rw-r--r-- | gnu/packages/patches/mono-mcs-patches-from-5.10.0.patch | 4218 |
3 files changed, 4294 insertions, 6 deletions
diff --git a/gnu/local.mk b/gnu/local.mk index faec0d72495..57f2bf6177d 100644 --- a/gnu/local.mk +++ b/gnu/local.mk | |||
| @@ -1838,6 +1838,7 @@ dist_patch_DATA = \ | |||
| 1838 | %D%/packages/patches/mono-4.9.0-fix-runtimemetadataversion.patch \ | 1838 | %D%/packages/patches/mono-4.9.0-fix-runtimemetadataversion.patch \ |
| 1839 | %D%/packages/patches/mono-5.4.0-patches.patch \ | 1839 | %D%/packages/patches/mono-5.4.0-patches.patch \ |
| 1840 | %D%/packages/patches/mono-5.8.0-patches.patch \ | 1840 | %D%/packages/patches/mono-5.8.0-patches.patch \ |
| 1841 | %D%/packages/patches/mono-mcs-patches-from-5.10.0.patch \ | ||
| 1841 | %D%/packages/patches/mosaicatcher-unbundle-htslib.patch \ | 1842 | %D%/packages/patches/mosaicatcher-unbundle-htslib.patch \ |
| 1842 | %D%/packages/patches/mrrescue-support-love-11.patch \ | 1843 | %D%/packages/patches/mrrescue-support-love-11.patch \ |
| 1843 | %D%/packages/patches/mtools-mformat-uninitialized.patch \ | 1844 | %D%/packages/patches/mtools-mformat-uninitialized.patch \ |
diff --git a/gnu/packages/dotnet.scm b/gnu/packages/dotnet.scm index 238d630b88b..901e653d27d 100644 --- a/gnu/packages/dotnet.scm +++ b/gnu/packages/dotnet.scm | |||
| @@ -1279,10 +1279,9 @@ unused0:"))))) | |||
| 1279 | (name "mono") | 1279 | (name "mono") |
| 1280 | (source (origin | 1280 | (source (origin |
| 1281 | (method git-fetch) | 1281 | (method git-fetch) |
| 1282 | (uri | 1282 | (uri (git-reference |
| 1283 | (git-reference | 1283 | (url "https://gitlab.winehq.org/mono/mono.git") |
| 1284 | (url "https://gitlab.winehq.org/mono/mono.git") | 1284 | (commit commit))) |
| 1285 | (commit commit))) | ||
| 1286 | (file-name (git-file-name name version)) | 1285 | (file-name (git-file-name name version)) |
| 1287 | (sha256 | 1286 | (sha256 |
| 1288 | (base32 | 1287 | (base32 |
| @@ -1293,8 +1292,7 @@ unused0:"))))) | |||
| 1293 | #$(add-external-repos | 1292 | #$(add-external-repos |
| 1294 | mono-pre-5.8.0-external-repo-specs) | 1293 | mono-pre-5.8.0-external-repo-specs) |
| 1295 | #$@prepare-mono-source-0)) | 1294 | #$@prepare-mono-source-0)) |
| 1296 | (patches | 1295 | (patches (search-patches "mono-5.4.0-patches.patch")))) |
| 1297 | (search-patches "mono-5.4.0-patches.patch")))) | ||
| 1298 | (native-inputs (modify-inputs (package-native-inputs mono-5.4.0) | 1296 | (native-inputs (modify-inputs (package-native-inputs mono-5.4.0) |
| 1299 | (replace "mono" mono-5.4.0))) | 1297 | (replace "mono" mono-5.4.0))) |
| 1300 | (arguments | 1298 | (arguments |
| @@ -1430,3 +1428,74 @@ unused0:"))))) | |||
| 1430 | " " | 1428 | " " |
| 1431 | top "/mcs/class/lib/build/mcs.exe") | 1429 | top "/mcs/class/lib/build/mcs.exe") |
| 1432 | ,@make-flags)))))))))))) | 1430 | ,@make-flags)))))))))))) |
| 1431 | |||
| 1432 | (define mono-pre-5.10.0-external-repo-specs | ||
| 1433 | '(("api-doc-tools" "d03e819838c6241f92f90655cb448cc47c9e8791" | ||
| 1434 | "1riki79f3ig3cxigviss81dz601hn92a1gifglm0mzjbs76sf3fj" | ||
| 1435 | #:recursive? #t) | ||
| 1436 | ("api-snapshot" "627333cae84f02a36ee9ca605c96dac4557d9f35" | ||
| 1437 | "0p9c6brxiwx38yvaf55jd0l1mxfj3b5ah0xas2hv6frkz80yrqdl") | ||
| 1438 | ("aspnetwebstack" "e77b12e6cc5ed260a98447f609e887337e44e299" | ||
| 1439 | "0rks344qr4fmp3fs1264d2qkmm348m8d1kjd7z4l94iiirwn1fq1") | ||
| 1440 | (("reference-assemblies" "binary-reference-assemblies") | ||
| 1441 | "9c5cc7f051a0bba2e41341a5baebfc4d2c2133ef" | ||
| 1442 | "14bfn1qvni8gyfxjwmvykyjjy3j5ng4fnbljdadi9dm4b9al0wg1") | ||
| 1443 | ("bockbuild" "29022af5d8a94651b2eece93f910559b254ec3f0" | ||
| 1444 | "0lclc1smmrj6xw32dll073mxw4ddiixv9arv02yw3w5h135ay7w4") | ||
| 1445 | ("boringssl" "3e0770e18835714708860ba9fe1af04a932971ff" | ||
| 1446 | "139a0gl91a52k2r6na6ialzkqykaj1rk88zjrkaz3sdxx7nmmg6y") | ||
| 1447 | ("cecil" "bc11f472954694ebd92ae4956f110c1036a7c2e0" | ||
| 1448 | "122nnp5pcnw18pj6amnqkqxlrmapd4vy9xs65hd0bqyqjh56bwnd") | ||
| 1449 | (("cecil" "cecil-legacy") "33d50b874fd527118bc361d83de3d494e8bb55e1" | ||
| 1450 | "1p4hl1796ib26ykyf5snl6cj0lx0v7mjh0xqhjw6qdh753nsjyhb") | ||
| 1451 | ("corefx" "cb1b049c95227465c1791b857cb5ba86385d9f29" | ||
| 1452 | "1pr0qjlgxf63zs1g80gqd6x3qhlgb0wlcc8zm8z8am5aywrvgb53") | ||
| 1453 | ("corert" "48dba73801e804e89f00311da99d873f9c550278" | ||
| 1454 | "1zw47jf4cwqmaixylisxi73xf6cap41bwf9vlmpxanzxaqklzsvk") | ||
| 1455 | ("ikdasm" "465c0815558fd43c0110f8d00fc186ac0044ac6a" | ||
| 1456 | "0xir7pcgq04hb7s8g9wsqdrypb6l29raj3iz5rcqzdm0056k75w2") | ||
| 1457 | (("ikvm-fork" "ikvm") "847e05fced5c9a41ff0f24f1f9d40d5a8a5772c1" | ||
| 1458 | "1fl9bm3lmzf8iqv3x4iqkz9fc54mwdvrxisxg2nvwwcsi4saffpi") | ||
| 1459 | ("linker" "99354bf5c13b8055209cb082cddc50c8047ab088" | ||
| 1460 | "05zlajnqf83xfvn2whh9nql6j85sq12aw26sqmyqz7zcpml171mj") | ||
| 1461 | ("Newtonsoft.Json" "471c3e0803a9f40a0acc8aeceb31de6ff93a52c4" | ||
| 1462 | "0dgngd5hqk6yhlg40kabn6qdnknm32zcx9q6bm2w31csnsk5978s") | ||
| 1463 | (("NuGet.BuildTasks" "nuget-buildtasks") | ||
| 1464 | "b58ba4282377bcefd48abdc2d62ce6330e079abe" | ||
| 1465 | "1say03fnqkjsx97zacany3sa5j4mhfk827hkwp23ib02q18f7lvp") | ||
| 1466 | (("NUnitLite" "nunit-lite") "764656cdafdb3acd25df8cb52a4e0ea14760fccd" | ||
| 1467 | "0pc7lk3p916is8cn4ngaqvjlmlzv3vvjpyksy4pvb3qb5iiaw0vq") | ||
| 1468 | ;; ("roslyn-binaries" "1904c7d0682a878e2d25b4d49f3475d12fbb9cc6" | ||
| 1469 | ;; "") | ||
| 1470 | ("rx" "b29a4b0fda609e0af33ff54ed13652b6ccf0e05e" | ||
| 1471 | "1n1jwhmsbkcv2d806immcpzkb72rz04xy98myw355a8w5ah25yiv") | ||
| 1472 | ;; ("xunit-binaries" "d4433b0972f40cb3efaa3fbba52869bde5df8fa8" | ||
| 1473 | ;; "") | ||
| 1474 | )) | ||
| 1475 | |||
| 1476 | (define-public mono-pre-5.10.0 | ||
| 1477 | (let ((commit "3e9d7d6e9cf8dc33eb29c497c350a1cd7df3a057") | ||
| 1478 | (version "5.8.0.129") | ||
| 1479 | (revision "0")) | ||
| 1480 | (package | ||
| 1481 | (inherit mono-5.8.0) | ||
| 1482 | (version (git-version version revision commit)) | ||
| 1483 | (name "mono") | ||
| 1484 | (source (origin | ||
| 1485 | (method git-fetch) | ||
| 1486 | (uri (git-reference | ||
| 1487 | (url "https://gitlab.winehq.org/mono/mono.git") | ||
| 1488 | (commit commit))) | ||
| 1489 | (file-name (git-file-name name version)) | ||
| 1490 | (sha256 | ||
| 1491 | (base32 | ||
| 1492 | "0m8i0zgzh0fgb3ssy95v9czk1c0rl76q0jj7834s5fjnkdj8l4jb")) | ||
| 1493 | (modules '((guix build utils) | ||
| 1494 | (ice-9 string-fun))) | ||
| 1495 | (snippet #~(begin | ||
| 1496 | #$(add-external-repos | ||
| 1497 | mono-pre-5.10.0-external-repo-specs) | ||
| 1498 | #$@prepare-mono-source-0)) | ||
| 1499 | (patches (search-patches "mono-mcs-patches-from-5.10.0.patch")))) | ||
| 1500 | (native-inputs (modify-inputs (package-native-inputs mono-5.8.0) | ||
| 1501 | (replace "mono" mono-5.8.0)))))) | ||
diff --git a/gnu/packages/patches/mono-mcs-patches-from-5.10.0.patch b/gnu/packages/patches/mono-mcs-patches-from-5.10.0.patch new file mode 100644 index 00000000000..41dfed7df7f --- /dev/null +++ b/gnu/packages/patches/mono-mcs-patches-from-5.10.0.patch | |||
| @@ -0,0 +1,4218 @@ | |||
| 1 | Includes the following commits: | ||
| 2 | 6f5bfe5cf5a | ||
| 3 | 3812d1c13fc | ||
| 4 | a80f3d0d87c | ||
| 5 | b2f051f0b19 | ||
| 6 | 2a202a8478b | ||
| 7 | 4d7d1606d73 | ||
| 8 | d9970305731 | ||
| 9 | 94e80fc8d7f | ||
| 10 | 0b9280083a9 | ||
| 11 | 07d1e5f36a5 | ||
| 12 | 5f279f14aa2 | ||
| 13 | 889421f3bef | ||
| 14 | f4c0fd3dc11 | ||
| 15 | 71df5c63b46 | ||
| 16 | d6e5bf16782 | ||
| 17 | 207f5c2cd6d | ||
| 18 | c512752a416 | ||
| 19 | 9aca8d5fe4b | ||
| 20 | diff --git a/mcs/class/Mono.CSharp/Test/Evaluator/TypesTest.cs b/mcs/class/Mono.CSharp/Test/Evaluator/TypesTest.cs | ||
| 21 | index 97f9e047e6d..f8bf63455de 100644 | ||
| 22 | --- a/mcs/class/Mono.CSharp/Test/Evaluator/TypesTest.cs | ||
| 23 | +++ b/mcs/class/Mono.CSharp/Test/Evaluator/TypesTest.cs | ||
| 24 | @@ -131,5 +131,17 @@ namespace MonoTests.EvaluatorTest | ||
| 25 | { | ||
| 26 | Evaluator.Run ("public class TestClass { private TestEnum _te; public string Get() { return _te.ToString(); } } public enum TestEnum { First, Second }"); | ||
| 27 | } | ||
| 28 | + | ||
| 29 | + [Test] | ||
| 30 | + public void EnumTypeWithOrderDependency () | ||
| 31 | + { | ||
| 32 | + Evaluator.Run ("public class TestClass { public enum TestEnum { Val1, Val2, Val3 } public TestEnum test; public TestClass() { test = TestEnum.Val3; } }"); | ||
| 33 | + object res = Evaluator.Evaluate ("new TestClass()"); | ||
| 34 | + | ||
| 35 | + var fields = res.GetType ().GetFields (); | ||
| 36 | + foreach (var field in fields) { | ||
| 37 | + Console.WriteLine ($"{field.Name} = {field.MemberType}"); | ||
| 38 | + } | ||
| 39 | + } | ||
| 40 | } | ||
| 41 | } | ||
| 42 | \ No newline at end of file | ||
| 43 | diff --git a/mcs/errors/cs0023-30.cs b/mcs/errors/cs0023-30.cs | ||
| 44 | new file mode 100644 | ||
| 45 | index 00000000000..fc19cc24e3e | ||
| 46 | --- /dev/null | ||
| 47 | +++ b/mcs/errors/cs0023-30.cs | ||
| 48 | @@ -0,0 +1,11 @@ | ||
| 49 | +// CS0023: The `is' operator cannot be applied to operand of type `default' | ||
| 50 | +// Line: 9 | ||
| 51 | +// Compiler options: -langversion:latest | ||
| 52 | + | ||
| 53 | +class C | ||
| 54 | +{ | ||
| 55 | + static void Main () | ||
| 56 | + { | ||
| 57 | + bool d = default is C; | ||
| 58 | + } | ||
| 59 | +} | ||
| 60 | \ No newline at end of file | ||
| 61 | diff --git a/mcs/errors/cs0029-39.cs b/mcs/errors/cs0029-39.cs | ||
| 62 | new file mode 100644 | ||
| 63 | index 00000000000..0ed200036dc | ||
| 64 | --- /dev/null | ||
| 65 | +++ b/mcs/errors/cs0029-39.cs | ||
| 66 | @@ -0,0 +1,15 @@ | ||
| 67 | +// CS0029: Cannot implicitly convert type `S' to `object' | ||
| 68 | +// Line: 13 | ||
| 69 | +// Compiler options: -langversion:latest | ||
| 70 | + | ||
| 71 | +public ref struct S | ||
| 72 | +{ | ||
| 73 | +} | ||
| 74 | + | ||
| 75 | +class Test | ||
| 76 | +{ | ||
| 77 | + public static void Main () | ||
| 78 | + { | ||
| 79 | + object o = new S (); | ||
| 80 | + } | ||
| 81 | +} | ||
| 82 | \ No newline at end of file | ||
| 83 | diff --git a/mcs/errors/cs0029-40.cs b/mcs/errors/cs0029-40.cs | ||
| 84 | new file mode 100644 | ||
| 85 | index 00000000000..6d9167c31fa | ||
| 86 | --- /dev/null | ||
| 87 | +++ b/mcs/errors/cs0029-40.cs | ||
| 88 | @@ -0,0 +1,19 @@ | ||
| 89 | +// CS0029: Cannot implicitly convert type `S' to `System.ValueType' | ||
| 90 | +// Line: 16 | ||
| 91 | +// Compiler options: -langversion:latest | ||
| 92 | + | ||
| 93 | +using System; | ||
| 94 | + | ||
| 95 | +public ref struct S | ||
| 96 | +{ | ||
| 97 | +} | ||
| 98 | + | ||
| 99 | +class Test | ||
| 100 | +{ | ||
| 101 | + public static void Main () | ||
| 102 | + { | ||
| 103 | + var s = default (S); | ||
| 104 | + ValueType s2 = s; | ||
| 105 | + var res = default (S).ToString (); | ||
| 106 | + } | ||
| 107 | +} | ||
| 108 | \ No newline at end of file | ||
| 109 | diff --git a/mcs/errors/cs0029-41.cs b/mcs/errors/cs0029-41.cs | ||
| 110 | new file mode 100644 | ||
| 111 | index 00000000000..1a65f52f737 | ||
| 112 | --- /dev/null | ||
| 113 | +++ b/mcs/errors/cs0029-41.cs | ||
| 114 | @@ -0,0 +1,12 @@ | ||
| 115 | +// CS0029: Cannot implicitly convert type `System.TypedReference' to `object' | ||
| 116 | +// Line: 10 | ||
| 117 | + | ||
| 118 | +using System; | ||
| 119 | + | ||
| 120 | +class Test | ||
| 121 | +{ | ||
| 122 | + public static void Main () | ||
| 123 | + { | ||
| 124 | + var res = default (TypedReference).ToString (); | ||
| 125 | + } | ||
| 126 | +} | ||
| 127 | \ No newline at end of file | ||
| 128 | diff --git a/mcs/errors/cs0029-42.cs b/mcs/errors/cs0029-42.cs | ||
| 129 | new file mode 100644 | ||
| 130 | index 00000000000..c7671000c76 | ||
| 131 | --- /dev/null | ||
| 132 | +++ b/mcs/errors/cs0029-42.cs | ||
| 133 | @@ -0,0 +1,10 @@ | ||
| 134 | +// CS0029: Cannot implicitly convert type `string' to `int' | ||
| 135 | +// Line: 8 | ||
| 136 | + | ||
| 137 | +class C | ||
| 138 | +{ | ||
| 139 | + void Exists (int _) | ||
| 140 | + { | ||
| 141 | + _ = "2"; | ||
| 142 | + } | ||
| 143 | +} | ||
| 144 | \ No newline at end of file | ||
| 145 | diff --git a/mcs/errors/cs0030-17.cs b/mcs/errors/cs0030-17.cs | ||
| 146 | new file mode 100644 | ||
| 147 | index 00000000000..b72b8bf71e5 | ||
| 148 | --- /dev/null | ||
| 149 | +++ b/mcs/errors/cs0030-17.cs | ||
| 150 | @@ -0,0 +1,15 @@ | ||
| 151 | +// CS0030: Cannot convert type `object' to `S' | ||
| 152 | +// Line: 13 | ||
| 153 | +// Compiler options: -langversion:latest | ||
| 154 | + | ||
| 155 | +ref struct S | ||
| 156 | +{ | ||
| 157 | +} | ||
| 158 | + | ||
| 159 | +class X | ||
| 160 | +{ | ||
| 161 | + public static void Foo (object o) | ||
| 162 | + { | ||
| 163 | + var res = (S) o; | ||
| 164 | + } | ||
| 165 | +} | ||
| 166 | \ No newline at end of file | ||
| 167 | diff --git a/mcs/errors/cs0103-18.cs b/mcs/errors/cs0103-18.cs | ||
| 168 | new file mode 100644 | ||
| 169 | index 00000000000..8cec755d23d | ||
| 170 | --- /dev/null | ||
| 171 | +++ b/mcs/errors/cs0103-18.cs | ||
| 172 | @@ -0,0 +1,10 @@ | ||
| 173 | +// CS0103: The name `_' does not exist in the current context | ||
| 174 | +// Line: 8 | ||
| 175 | + | ||
| 176 | +class C | ||
| 177 | +{ | ||
| 178 | + void Test () | ||
| 179 | + { | ||
| 180 | + _.ToString (); | ||
| 181 | + } | ||
| 182 | +} | ||
| 183 | \ No newline at end of file | ||
| 184 | diff --git a/mcs/errors/cs0123-10.cs b/mcs/errors/cs0123-10.cs | ||
| 185 | new file mode 100644 | ||
| 186 | index 00000000000..43d5e5d6368 | ||
| 187 | --- /dev/null | ||
| 188 | +++ b/mcs/errors/cs0123-10.cs | ||
| 189 | @@ -0,0 +1,18 @@ | ||
| 190 | +// CS0123: A method or delegate `object.ToString()' parameters do not match delegate `System.Func<string>()' parameters | ||
| 191 | +// Line: 16 | ||
| 192 | +// Compiler options: -langversion:latest | ||
| 193 | + | ||
| 194 | +using System; | ||
| 195 | + | ||
| 196 | +public ref struct S | ||
| 197 | +{ | ||
| 198 | +} | ||
| 199 | + | ||
| 200 | +class Test | ||
| 201 | +{ | ||
| 202 | + public static void Main () | ||
| 203 | + { | ||
| 204 | + var s = new S (); | ||
| 205 | + Func<string> f = s.ToString; | ||
| 206 | + } | ||
| 207 | +} | ||
| 208 | \ No newline at end of file | ||
| 209 | diff --git a/mcs/errors/cs0123-11.cs b/mcs/errors/cs0123-11.cs | ||
| 210 | new file mode 100644 | ||
| 211 | index 00000000000..427b628c159 | ||
| 212 | --- /dev/null | ||
| 213 | +++ b/mcs/errors/cs0123-11.cs | ||
| 214 | @@ -0,0 +1,12 @@ | ||
| 215 | +// CS0123: A method or delegate `object.ToString()' parameters do not match delegate `System.Func<string>()' parameters | ||
| 216 | +// Line: 16 | ||
| 217 | + | ||
| 218 | +using System; | ||
| 219 | + | ||
| 220 | +class Test | ||
| 221 | +{ | ||
| 222 | + public static void Main () | ||
| 223 | + { | ||
| 224 | + Func<string> f = default (TypedReference).ToString; | ||
| 225 | + } | ||
| 226 | +} | ||
| 227 | \ No newline at end of file | ||
| 228 | diff --git a/mcs/errors/cs0133-2.cs b/mcs/errors/cs0133-2.cs | ||
| 229 | index b7a37182d73..48488876f7e 100644 | ||
| 230 | --- a/mcs/errors/cs0133-2.cs | ||
| 231 | +++ b/mcs/errors/cs0133-2.cs | ||
| 232 | @@ -1,4 +1,4 @@ | ||
| 233 | -// CS0133: The expression being assigned to `c' must be constant | ||
| 234 | +// CS0133: The expression being assigned to `c' must be a constant or default value | ||
| 235 | // Line: 10 | ||
| 236 | |||
| 237 | class C | ||
| 238 | diff --git a/mcs/errors/cs0133-3.cs b/mcs/errors/cs0133-3.cs | ||
| 239 | index caae3bde68c..2f7dac6880d 100644 | ||
| 240 | --- a/mcs/errors/cs0133-3.cs | ||
| 241 | +++ b/mcs/errors/cs0133-3.cs | ||
| 242 | @@ -1,5 +1,5 @@ | ||
| 243 | -// CS0133: The expression being assigned to `Foo' must be constant | ||
| 244 | -// Line: 12 | ||
| 245 | +// CS0133: The expression being assigned to `Foo' must be a constant or default value | ||
| 246 | +// Line: 8 | ||
| 247 | |||
| 248 | class T | ||
| 249 | { | ||
| 250 | diff --git a/mcs/errors/cs0133-4.cs b/mcs/errors/cs0133-4.cs | ||
| 251 | index 41fe639b446..54162d544ca 100644 | ||
| 252 | --- a/mcs/errors/cs0133-4.cs | ||
| 253 | +++ b/mcs/errors/cs0133-4.cs | ||
| 254 | @@ -1,4 +1,4 @@ | ||
| 255 | -// CS0133: The expression being assigned to `S.pathName' must be constant | ||
| 256 | +// CS0133: The expression being assigned to `S.pathName' must be a constant or default value | ||
| 257 | // Line: 12 | ||
| 258 | // Compiler options: -unsafe | ||
| 259 | |||
| 260 | diff --git a/mcs/errors/cs0133-5.cs b/mcs/errors/cs0133-5.cs | ||
| 261 | index a49f265c690..32e6bfdf416 100644 | ||
| 262 | --- a/mcs/errors/cs0133-5.cs | ||
| 263 | +++ b/mcs/errors/cs0133-5.cs | ||
| 264 | @@ -1,4 +1,4 @@ | ||
| 265 | -// CS0133: The expression being assigned to `b' must be constant | ||
| 266 | +// CS0133: The expression being assigned to `b' must be a constant or default value | ||
| 267 | // Line: 8 | ||
| 268 | |||
| 269 | class X | ||
| 270 | diff --git a/mcs/errors/cs0133-6.cs b/mcs/errors/cs0133-6.cs | ||
| 271 | index a523169cdbd..28448dd6de8 100644 | ||
| 272 | --- a/mcs/errors/cs0133-6.cs | ||
| 273 | +++ b/mcs/errors/cs0133-6.cs | ||
| 274 | @@ -1,4 +1,4 @@ | ||
| 275 | -// CS0133: The expression being assigned to `o' must be constant | ||
| 276 | +// CS0133: The expression being assigned to `o' must be a constant or default value | ||
| 277 | // Line: 8 | ||
| 278 | |||
| 279 | class X | ||
| 280 | diff --git a/mcs/errors/cs0133-7.cs b/mcs/errors/cs0133-7.cs | ||
| 281 | index 10d82d9fe5e..024bc148229 100644 | ||
| 282 | --- a/mcs/errors/cs0133-7.cs | ||
| 283 | +++ b/mcs/errors/cs0133-7.cs | ||
| 284 | @@ -1,4 +1,4 @@ | ||
| 285 | -// CS0133: The expression being assigned to `o' must be constant | ||
| 286 | +// CS0133: The expression being assigned to `o' must be a constant or default value | ||
| 287 | // Line: 8 | ||
| 288 | |||
| 289 | class X | ||
| 290 | diff --git a/mcs/errors/cs0133.cs b/mcs/errors/cs0133.cs | ||
| 291 | index 094194deabb..f0dda9ee3cb 100644 | ||
| 292 | --- a/mcs/errors/cs0133.cs | ||
| 293 | +++ b/mcs/errors/cs0133.cs | ||
| 294 | @@ -1,5 +1,6 @@ | ||
| 295 | -// CS0133: The expression being assigned to `x' must be constant | ||
| 296 | -// Line: 6 | ||
| 297 | +// CS0133: The expression being assigned to `x' must be a constant or default value | ||
| 298 | +// Line: 7 | ||
| 299 | + | ||
| 300 | class X { | ||
| 301 | X (int arg) | ||
| 302 | { | ||
| 303 | diff --git a/mcs/errors/cs0306-4.cs b/mcs/errors/cs0306-4.cs | ||
| 304 | new file mode 100644 | ||
| 305 | index 00000000000..4653512e55b | ||
| 306 | --- /dev/null | ||
| 307 | +++ b/mcs/errors/cs0306-4.cs | ||
| 308 | @@ -0,0 +1,15 @@ | ||
| 309 | +// CS0306: The type `S' may not be used as a type argument | ||
| 310 | +// Line: 13 | ||
| 311 | +// Compiler options: -langversion:latest | ||
| 312 | + | ||
| 313 | +public ref struct S | ||
| 314 | +{ | ||
| 315 | +} | ||
| 316 | + | ||
| 317 | +class Test<T> | ||
| 318 | +{ | ||
| 319 | + public static void Foo () | ||
| 320 | + { | ||
| 321 | + Test<S> local; | ||
| 322 | + } | ||
| 323 | +} | ||
| 324 | \ No newline at end of file | ||
| 325 | diff --git a/mcs/errors/cs0611-3.cs b/mcs/errors/cs0611-3.cs | ||
| 326 | new file mode 100644 | ||
| 327 | index 00000000000..6eda773dd24 | ||
| 328 | --- /dev/null | ||
| 329 | +++ b/mcs/errors/cs0611-3.cs | ||
| 330 | @@ -0,0 +1,15 @@ | ||
| 331 | +// CS0611: Array elements cannot be of type `S' | ||
| 332 | +// Line: 13 | ||
| 333 | +// Compiler options: -langversion:latest | ||
| 334 | + | ||
| 335 | +public ref struct S | ||
| 336 | +{ | ||
| 337 | +} | ||
| 338 | + | ||
| 339 | +class Test | ||
| 340 | +{ | ||
| 341 | + public static void Main () | ||
| 342 | + { | ||
| 343 | + var x = new S[0]; | ||
| 344 | + } | ||
| 345 | +} | ||
| 346 | \ No newline at end of file | ||
| 347 | diff --git a/mcs/errors/cs0815-9.cs b/mcs/errors/cs0815-9.cs | ||
| 348 | new file mode 100644 | ||
| 349 | index 00000000000..f54703349be | ||
| 350 | --- /dev/null | ||
| 351 | +++ b/mcs/errors/cs0815-9.cs | ||
| 352 | @@ -0,0 +1,11 @@ | ||
| 353 | +// CS0815: An implicitly typed local variable declaration cannot be initialized with `default' | ||
| 354 | +// Line: 9 | ||
| 355 | +// Compiler options: -langversion:latest | ||
| 356 | + | ||
| 357 | +static class X | ||
| 358 | +{ | ||
| 359 | + public static void Main () | ||
| 360 | + { | ||
| 361 | + var x = default; | ||
| 362 | + } | ||
| 363 | +} | ||
| 364 | \ No newline at end of file | ||
| 365 | diff --git a/mcs/errors/cs1502-11.cs b/mcs/errors/cs1502-11.cs | ||
| 366 | deleted file mode 100644 | ||
| 367 | index 82dcb3a2c17..00000000000 | ||
| 368 | --- a/mcs/errors/cs1502-11.cs | ||
| 369 | +++ /dev/null | ||
| 370 | @@ -1,11 +0,0 @@ | ||
| 371 | -// CS1502: The best overloaded method match for `string.String(char*)' has some invalid arguments | ||
| 372 | -// Line: 8 | ||
| 373 | - | ||
| 374 | -class C | ||
| 375 | -{ | ||
| 376 | - static string Prop { | ||
| 377 | - get { | ||
| 378 | - return new string ("s"); | ||
| 379 | - } | ||
| 380 | - } | ||
| 381 | -} | ||
| 382 | diff --git a/mcs/errors/cs1599-2.cs b/mcs/errors/cs1599-2.cs | ||
| 383 | index 941ff6bb0d6..28aa05b2ed3 100644 | ||
| 384 | --- a/mcs/errors/cs1599-2.cs | ||
| 385 | +++ b/mcs/errors/cs1599-2.cs | ||
| 386 | @@ -1,4 +1,4 @@ | ||
| 387 | -// CS1599: Method or delegate cannot return type `System.ArgIterator' | ||
| 388 | +// CS1599: The return type of `System.ArgIterator' is not allowed | ||
| 389 | // Line: 8 | ||
| 390 | |||
| 391 | using System; | ||
| 392 | diff --git a/mcs/errors/cs1599-3.cs b/mcs/errors/cs1599-3.cs | ||
| 393 | index e4869dcaf70..9d378099d82 100644 | ||
| 394 | --- a/mcs/errors/cs1599-3.cs | ||
| 395 | +++ b/mcs/errors/cs1599-3.cs | ||
| 396 | @@ -1,4 +1,4 @@ | ||
| 397 | -// CS1599: Method or delegate cannot return type `System.ArgIterator' | ||
| 398 | +// CS1599: The return type of `System.ArgIterator' is not allowed | ||
| 399 | // Line: 8 | ||
| 400 | |||
| 401 | using System; | ||
| 402 | diff --git a/mcs/errors/cs1599-4.cs b/mcs/errors/cs1599-4.cs | ||
| 403 | new file mode 100644 | ||
| 404 | index 00000000000..358eee59a13 | ||
| 405 | --- /dev/null | ||
| 406 | +++ b/mcs/errors/cs1599-4.cs | ||
| 407 | @@ -0,0 +1,12 @@ | ||
| 408 | +// CS1599: The return type of `System.TypedReference' is not allowed | ||
| 409 | +// Line: 8 | ||
| 410 | + | ||
| 411 | +using System; | ||
| 412 | + | ||
| 413 | +public class Program | ||
| 414 | +{ | ||
| 415 | + public static TypedReference operator + (int a, Program b) | ||
| 416 | + { | ||
| 417 | + throw new ApplicationException (); | ||
| 418 | + } | ||
| 419 | +} | ||
| 420 | \ No newline at end of file | ||
| 421 | diff --git a/mcs/errors/cs1599.cs b/mcs/errors/cs1599.cs | ||
| 422 | index 5cef32d7f97..871d9fb3e7a 100644 | ||
| 423 | --- a/mcs/errors/cs1599.cs | ||
| 424 | +++ b/mcs/errors/cs1599.cs | ||
| 425 | @@ -1,4 +1,4 @@ | ||
| 426 | -// CS1599: Method or delegate cannot return type `System.TypedReference' | ||
| 427 | +// CS1599: The return type of `System.TypedReference' is not allowed | ||
| 428 | // Line: 8 | ||
| 429 | |||
| 430 | using System; | ||
| 431 | diff --git a/mcs/errors/cs1644-57.cs b/mcs/errors/cs1644-57.cs | ||
| 432 | new file mode 100644 | ||
| 433 | index 00000000000..7ee98373080 | ||
| 434 | --- /dev/null | ||
| 435 | +++ b/mcs/errors/cs1644-57.cs | ||
| 436 | @@ -0,0 +1,7 @@ | ||
| 437 | +// CS1644: Feature `ref structs' cannot be used because it is not part of the C# 7.0 language specification | ||
| 438 | +// Line: 5 | ||
| 439 | +// Compiler options: -langversion:7 | ||
| 440 | + | ||
| 441 | +ref struct S | ||
| 442 | +{ | ||
| 443 | +} | ||
| 444 | \ No newline at end of file | ||
| 445 | diff --git a/mcs/errors/cs1644-58.cs b/mcs/errors/cs1644-58.cs | ||
| 446 | new file mode 100644 | ||
| 447 | index 00000000000..e994cf338bd | ||
| 448 | --- /dev/null | ||
| 449 | +++ b/mcs/errors/cs1644-58.cs | ||
| 450 | @@ -0,0 +1,8 @@ | ||
| 451 | +// CS1644: Feature `default literal' cannot be used because it is not part of the C# 7.0 language specification | ||
| 452 | +// Line: 7 | ||
| 453 | +// Compiler options: -langversion:7 | ||
| 454 | + | ||
| 455 | +class X | ||
| 456 | +{ | ||
| 457 | + int i = default; | ||
| 458 | +} | ||
| 459 | diff --git a/mcs/errors/cs1644-59.cs b/mcs/errors/cs1644-59.cs | ||
| 460 | new file mode 100644 | ||
| 461 | index 00000000000..2f8aed6b958 | ||
| 462 | --- /dev/null | ||
| 463 | +++ b/mcs/errors/cs1644-59.cs | ||
| 464 | @@ -0,0 +1,13 @@ | ||
| 465 | +// CS1644: Feature `readonly references' cannot be used because it is not part of the C# 7.0 language specification | ||
| 466 | +// Line: 9 | ||
| 467 | +// Compiler options: -langversion:7 | ||
| 468 | + | ||
| 469 | +class X | ||
| 470 | +{ | ||
| 471 | + int i; | ||
| 472 | + | ||
| 473 | + ref readonly int Test () | ||
| 474 | + { | ||
| 475 | + return ref i; | ||
| 476 | + } | ||
| 477 | +} | ||
| 478 | diff --git a/mcs/errors/cs1644-60.cs b/mcs/errors/cs1644-60.cs | ||
| 479 | new file mode 100644 | ||
| 480 | index 00000000000..ca9547bc561 | ||
| 481 | --- /dev/null | ||
| 482 | +++ b/mcs/errors/cs1644-60.cs | ||
| 483 | @@ -0,0 +1,11 @@ | ||
| 484 | +// CS1644: Feature `discards' cannot be used because it is not part of the C# 6.0 language specification | ||
| 485 | +// Line: 9 | ||
| 486 | +// Compiler options: -langversion:6 | ||
| 487 | + | ||
| 488 | +class X | ||
| 489 | +{ | ||
| 490 | + int Test () | ||
| 491 | + { | ||
| 492 | + _ = 2; | ||
| 493 | + } | ||
| 494 | +} | ||
| 495 | diff --git a/mcs/errors/cs1738-2.cs b/mcs/errors/cs1738-2.cs | ||
| 496 | index f59221f4c7a..44b3f6d1b14 100644 | ||
| 497 | --- a/mcs/errors/cs1738-2.cs | ||
| 498 | +++ b/mcs/errors/cs1738-2.cs | ||
| 499 | @@ -1,4 +1,4 @@ | ||
| 500 | -// CS1738: Named arguments must appear after the positional arguments | ||
| 501 | +// CS1738: Named arguments must appear after the positional arguments when using language version older than 7.2 | ||
| 502 | // Line: 13 | ||
| 503 | |||
| 504 | using System; | ||
| 505 | diff --git a/mcs/errors/cs1738-3.cs b/mcs/errors/cs1738-3.cs | ||
| 506 | index 53c4efc3553..901ac0e5d59 100644 | ||
| 507 | --- a/mcs/errors/cs1738-3.cs | ||
| 508 | +++ b/mcs/errors/cs1738-3.cs | ||
| 509 | @@ -1,4 +1,4 @@ | ||
| 510 | -// CS1738: Named arguments must appear after the positional arguments | ||
| 511 | +// CS1738: Named arguments must appear after the positional arguments when using language version older than 7.2 | ||
| 512 | // Line: 14 | ||
| 513 | |||
| 514 | class C | ||
| 515 | diff --git a/mcs/errors/cs1738.cs b/mcs/errors/cs1738.cs | ||
| 516 | index dab9a61160b..537bc17b917 100644 | ||
| 517 | --- a/mcs/errors/cs1738.cs | ||
| 518 | +++ b/mcs/errors/cs1738.cs | ||
| 519 | @@ -1,4 +1,4 @@ | ||
| 520 | -// CS1738: Named arguments must appear after the positional arguments | ||
| 521 | +// CS1738: Named arguments must appear after the positional arguments when using language version older than 7.2 | ||
| 522 | // Line: 12 | ||
| 523 | |||
| 524 | class C | ||
| 525 | diff --git a/mcs/errors/cs1983.cs b/mcs/errors/cs1983.cs | ||
| 526 | index a2ef6c150d6..76d2db4e677 100644 | ||
| 527 | --- a/mcs/errors/cs1983.cs | ||
| 528 | +++ b/mcs/errors/cs1983.cs | ||
| 529 | @@ -1,4 +1,4 @@ | ||
| 530 | -// CS1983: The return type of an async method must be void, Task, or Task<T> | ||
| 531 | +// CS1983: The return type of an async method must be void or task type | ||
| 532 | // Line: 6 | ||
| 533 | |||
| 534 | class C | ||
| 535 | diff --git a/mcs/errors/cs4012-3.cs b/mcs/errors/cs4012-3.cs | ||
| 536 | new file mode 100644 | ||
| 537 | index 00000000000..fb3d1dc276f | ||
| 538 | --- /dev/null | ||
| 539 | +++ b/mcs/errors/cs4012-3.cs | ||
| 540 | @@ -0,0 +1,19 @@ | ||
| 541 | +// CS4012: Parameters or local variables of type `S' cannot be declared in async methods or iterators | ||
| 542 | +// Line: 16 | ||
| 543 | +// Compiler options: -langversion:latest | ||
| 544 | + | ||
| 545 | +using System; | ||
| 546 | +using System.Threading.Tasks; | ||
| 547 | + | ||
| 548 | +public ref struct S | ||
| 549 | +{ | ||
| 550 | +} | ||
| 551 | + | ||
| 552 | +class C | ||
| 553 | +{ | ||
| 554 | + public async void Test () | ||
| 555 | + { | ||
| 556 | + var tr = new S (); | ||
| 557 | + await Task.Factory.StartNew (() => 6); | ||
| 558 | + } | ||
| 559 | +} | ||
| 560 | \ No newline at end of file | ||
| 561 | diff --git a/mcs/errors/cs8175-2.cs b/mcs/errors/cs8175-2.cs | ||
| 562 | new file mode 100644 | ||
| 563 | index 00000000000..27c4babf8bf | ||
| 564 | --- /dev/null | ||
| 565 | +++ b/mcs/errors/cs8175-2.cs | ||
| 566 | @@ -0,0 +1,19 @@ | ||
| 567 | +// CS8175: Cannot use by-reference variable `s' inside an anonymous method, lambda expression, or query expression | ||
| 568 | +// Line: 17 | ||
| 569 | +// Compiler options: -langversion:latest | ||
| 570 | + | ||
| 571 | +using System; | ||
| 572 | + | ||
| 573 | +public ref struct S | ||
| 574 | +{ | ||
| 575 | +} | ||
| 576 | + | ||
| 577 | +class Test | ||
| 578 | +{ | ||
| 579 | + public static void Main () | ||
| 580 | + { | ||
| 581 | + var s = new S (); | ||
| 582 | + | ||
| 583 | + Action a = () => Console.WriteLine (s); | ||
| 584 | + } | ||
| 585 | +} | ||
| 586 | \ No newline at end of file | ||
| 587 | diff --git a/mcs/errors/cs8183.cs b/mcs/errors/cs8183.cs | ||
| 588 | new file mode 100644 | ||
| 589 | index 00000000000..f9e9004b737 | ||
| 590 | --- /dev/null | ||
| 591 | +++ b/mcs/errors/cs8183.cs | ||
| 592 | @@ -0,0 +1,11 @@ | ||
| 593 | +// CS8183: Cannot infer the type of implicitly-typed discard | ||
| 594 | +// Line: 9 | ||
| 595 | +// Compiler options: -langversion:7.2 | ||
| 596 | + | ||
| 597 | +class X | ||
| 598 | +{ | ||
| 599 | + public static void Main () | ||
| 600 | + { | ||
| 601 | + _ = default; | ||
| 602 | + } | ||
| 603 | +} | ||
| 604 | \ No newline at end of file | ||
| 605 | diff --git a/mcs/errors/cs8184.cs b/mcs/errors/cs8184.cs | ||
| 606 | new file mode 100644 | ||
| 607 | index 00000000000..19a4685d7bd | ||
| 608 | --- /dev/null | ||
| 609 | +++ b/mcs/errors/cs8184.cs | ||
| 610 | @@ -0,0 +1,10 @@ | ||
| 611 | +// CS8184: A deconstruction cannot mix declarations and expressions on the left-hand-side | ||
| 612 | +// Line: 8 | ||
| 613 | + | ||
| 614 | +class X | ||
| 615 | +{ | ||
| 616 | + public static void Main () | ||
| 617 | + { | ||
| 618 | + (int a, b) = (1, 2); | ||
| 619 | + } | ||
| 620 | +} | ||
| 621 | \ No newline at end of file | ||
| 622 | diff --git a/mcs/errors/cs8207.cs b/mcs/errors/cs8207.cs | ||
| 623 | new file mode 100644 | ||
| 624 | index 00000000000..31090948b45 | ||
| 625 | --- /dev/null | ||
| 626 | +++ b/mcs/errors/cs8207.cs | ||
| 627 | @@ -0,0 +1,19 @@ | ||
| 628 | +// CS8207: An expression tree cannot contain a discard | ||
| 629 | +// Line: 11 | ||
| 630 | + | ||
| 631 | +using System; | ||
| 632 | +using System.Linq.Expressions; | ||
| 633 | + | ||
| 634 | +class X | ||
| 635 | +{ | ||
| 636 | + void Test () | ||
| 637 | + { | ||
| 638 | + Expression<Func<bool>> e = () => TryGetValue (out _); | ||
| 639 | + } | ||
| 640 | + | ||
| 641 | + bool TryGetValue (out int arg) | ||
| 642 | + { | ||
| 643 | + arg = 3; | ||
| 644 | + return true; | ||
| 645 | + } | ||
| 646 | +} | ||
| 647 | diff --git a/mcs/errors/cs8209.cs b/mcs/errors/cs8209.cs | ||
| 648 | new file mode 100644 | ||
| 649 | index 00000000000..3a46a206c8e | ||
| 650 | --- /dev/null | ||
| 651 | +++ b/mcs/errors/cs8209.cs | ||
| 652 | @@ -0,0 +1,10 @@ | ||
| 653 | +// CS8209: Cannot assign void to a discard | ||
| 654 | +// Line: 8 | ||
| 655 | + | ||
| 656 | +class C | ||
| 657 | +{ | ||
| 658 | + public static void Main () | ||
| 659 | + { | ||
| 660 | + _ = Main (); | ||
| 661 | + } | ||
| 662 | +} | ||
| 663 | \ No newline at end of file | ||
| 664 | diff --git a/mcs/errors/cs8310.cs b/mcs/errors/cs8310.cs | ||
| 665 | new file mode 100644 | ||
| 666 | index 00000000000..134624c03b7 | ||
| 667 | --- /dev/null | ||
| 668 | +++ b/mcs/errors/cs8310.cs | ||
| 669 | @@ -0,0 +1,11 @@ | ||
| 670 | +// CS8310: Operator `+' cannot be applied to operand `default' | ||
| 671 | +// Line: 9 | ||
| 672 | +// Compiler options: -langversion:latest | ||
| 673 | + | ||
| 674 | +class C | ||
| 675 | +{ | ||
| 676 | + static void Main () | ||
| 677 | + { | ||
| 678 | + int h = 1 + default; | ||
| 679 | + } | ||
| 680 | +} | ||
| 681 | \ No newline at end of file | ||
| 682 | diff --git a/mcs/errors/cs8311.cs b/mcs/errors/cs8311.cs | ||
| 683 | new file mode 100644 | ||
| 684 | index 00000000000..5b35229442d | ||
| 685 | --- /dev/null | ||
| 686 | +++ b/mcs/errors/cs8311.cs | ||
| 687 | @@ -0,0 +1,12 @@ | ||
| 688 | +// CS8311: Cannot use a default literal as an argument to a dynamically dispatched operation | ||
| 689 | +// Line: 10 | ||
| 690 | +// Compiler options: -langversion:latest | ||
| 691 | + | ||
| 692 | +class C | ||
| 693 | +{ | ||
| 694 | + static void Main () | ||
| 695 | + { | ||
| 696 | + dynamic d = null; | ||
| 697 | + d.M2 (default); | ||
| 698 | + } | ||
| 699 | +} | ||
| 700 | \ No newline at end of file | ||
| 701 | diff --git a/mcs/errors/cs8312.cs b/mcs/errors/cs8312.cs | ||
| 702 | new file mode 100644 | ||
| 703 | index 00000000000..d2ad3f52f02 | ||
| 704 | --- /dev/null | ||
| 705 | +++ b/mcs/errors/cs8312.cs | ||
| 706 | @@ -0,0 +1,12 @@ | ||
| 707 | +// CS8312: Use of default literal is not valid in this context | ||
| 708 | +// Line: 9 | ||
| 709 | +// Compiler options: -langversion:latest | ||
| 710 | + | ||
| 711 | +class C | ||
| 712 | +{ | ||
| 713 | + static void Main () | ||
| 714 | + { | ||
| 715 | + foreach (var x in default) { | ||
| 716 | + } | ||
| 717 | + } | ||
| 718 | +} | ||
| 719 | \ No newline at end of file | ||
| 720 | diff --git a/mcs/errors/cs8315.cs b/mcs/errors/cs8315.cs | ||
| 721 | new file mode 100644 | ||
| 722 | index 00000000000..c40bf8613b4 | ||
| 723 | --- /dev/null | ||
| 724 | +++ b/mcs/errors/cs8315.cs | ||
| 725 | @@ -0,0 +1,11 @@ | ||
| 726 | +// CS8315: Operator `==' is ambiguous on operands `default' and `default' | ||
| 727 | +// Line: 9 | ||
| 728 | +// Compiler options: -langversion:latest | ||
| 729 | + | ||
| 730 | +class C | ||
| 731 | +{ | ||
| 732 | + static void Main () | ||
| 733 | + { | ||
| 734 | + bool d = default == default; | ||
| 735 | + } | ||
| 736 | +} | ||
| 737 | \ No newline at end of file | ||
| 738 | diff --git a/mcs/errors/cs8323.cs b/mcs/errors/cs8323.cs | ||
| 739 | new file mode 100644 | ||
| 740 | index 00000000000..c6c9309ec0d | ||
| 741 | --- /dev/null | ||
| 742 | +++ b/mcs/errors/cs8323.cs | ||
| 743 | @@ -0,0 +1,15 @@ | ||
| 744 | +// CS8323: Named argument `str' is used out of position but is followed by positional argument | ||
| 745 | +// Line: 9 | ||
| 746 | +// Compiler options: -langversion:7.2 | ||
| 747 | + | ||
| 748 | +class X | ||
| 749 | +{ | ||
| 750 | + public static void Main () | ||
| 751 | + { | ||
| 752 | + Test (str: "", ""); | ||
| 753 | + } | ||
| 754 | + | ||
| 755 | + static void Test (int arg, string str) | ||
| 756 | + { | ||
| 757 | + } | ||
| 758 | +} | ||
| 759 | \ No newline at end of file | ||
| 760 | diff --git a/mcs/errors/cs8324.cs b/mcs/errors/cs8324.cs | ||
| 761 | new file mode 100644 | ||
| 762 | index 00000000000..8a0be1aefb9 | ||
| 763 | --- /dev/null | ||
| 764 | +++ b/mcs/errors/cs8324.cs | ||
| 765 | @@ -0,0 +1,12 @@ | ||
| 766 | +// CS8324: Named argument specifications must appear after all fixed arguments have been specified in a dynamic invocation | ||
| 767 | +// Line: 10 | ||
| 768 | +// Compiler options: -langversion:7.2 | ||
| 769 | + | ||
| 770 | +class C | ||
| 771 | +{ | ||
| 772 | + void M () | ||
| 773 | + { | ||
| 774 | + dynamic d = new object (); | ||
| 775 | + d.M (arg: 1, ""); | ||
| 776 | + } | ||
| 777 | +} | ||
| 778 | \ No newline at end of file | ||
| 779 | diff --git a/mcs/errors/cs8343.cs b/mcs/errors/cs8343.cs | ||
| 780 | new file mode 100644 | ||
| 781 | index 00000000000..b6aa8e83a09 | ||
| 782 | --- /dev/null | ||
| 783 | +++ b/mcs/errors/cs8343.cs | ||
| 784 | @@ -0,0 +1,12 @@ | ||
| 785 | +// CS8343: `S': ref structs cannot implement interfaces | ||
| 786 | +// Line: 7 | ||
| 787 | +// Compiler options: -langversion:latest | ||
| 788 | + | ||
| 789 | +using System; | ||
| 790 | + | ||
| 791 | +public ref struct S : IDisposable | ||
| 792 | +{ | ||
| 793 | + public void Dispose () | ||
| 794 | + { | ||
| 795 | + } | ||
| 796 | +} | ||
| 797 | diff --git a/mcs/errors/cs8345-2.cs b/mcs/errors/cs8345-2.cs | ||
| 798 | new file mode 100644 | ||
| 799 | index 00000000000..3f6137b1b56 | ||
| 800 | --- /dev/null | ||
| 801 | +++ b/mcs/errors/cs8345-2.cs | ||
| 802 | @@ -0,0 +1,12 @@ | ||
| 803 | +// CS8345: Field or auto-implemented property cannot be of type `S' unless it is an instance member of a ref struct | ||
| 804 | +// Line: 11 | ||
| 805 | +// Compiler options: -langversion:latest | ||
| 806 | + | ||
| 807 | +public ref struct S | ||
| 808 | +{ | ||
| 809 | +} | ||
| 810 | + | ||
| 811 | +ref struct Test | ||
| 812 | +{ | ||
| 813 | + static S field; | ||
| 814 | +} | ||
| 815 | \ No newline at end of file | ||
| 816 | diff --git a/mcs/errors/cs8345.cs b/mcs/errors/cs8345.cs | ||
| 817 | new file mode 100644 | ||
| 818 | index 00000000000..0b5bd05518f | ||
| 819 | --- /dev/null | ||
| 820 | +++ b/mcs/errors/cs8345.cs | ||
| 821 | @@ -0,0 +1,12 @@ | ||
| 822 | +// CS8345: Field or auto-implemented property cannot be of type `S' unless it is an instance member of a ref struct | ||
| 823 | +// Line: 11 | ||
| 824 | +// Compiler options: -langversion:latest | ||
| 825 | + | ||
| 826 | +public ref struct S | ||
| 827 | +{ | ||
| 828 | +} | ||
| 829 | + | ||
| 830 | +struct Test | ||
| 831 | +{ | ||
| 832 | + S field; | ||
| 833 | +} | ||
| 834 | \ No newline at end of file | ||
| 835 | diff --git a/mcs/errors/cs8346.cs b/mcs/errors/cs8346.cs | ||
| 836 | new file mode 100644 | ||
| 837 | index 00000000000..58e22a2ae7f | ||
| 838 | --- /dev/null | ||
| 839 | +++ b/mcs/errors/cs8346.cs | ||
| 840 | @@ -0,0 +1,13 @@ | ||
| 841 | +// CS8346: Cannot convert a stackalloc expression of type `byte' to type `System.Span<int>' | ||
| 842 | +// Line: 11 | ||
| 843 | +// Compiler options: -langversion:7.2 | ||
| 844 | + | ||
| 845 | +using System; | ||
| 846 | + | ||
| 847 | +class X | ||
| 848 | +{ | ||
| 849 | + public static void Main () | ||
| 850 | + { | ||
| 851 | + Span<int> stackSpan = stackalloc byte[1]; | ||
| 852 | + } | ||
| 853 | +} | ||
| 854 | \ No newline at end of file | ||
| 855 | diff --git a/mcs/mcs/argument.cs b/mcs/mcs/argument.cs | ||
| 856 | index 8421b4dfbfc..5b1003dbadf 100644 | ||
| 857 | --- a/mcs/mcs/argument.cs | ||
| 858 | +++ b/mcs/mcs/argument.cs | ||
| 859 | @@ -106,11 +106,6 @@ namespace Mono.CSharp | ||
| 860 | |||
| 861 | public virtual Expression CreateExpressionTree (ResolveContext rc) | ||
| 862 | { | ||
| 863 | - if (Type.Kind == MemberKind.ByRef) { | ||
| 864 | - rc.Report.Error (8153, Expr.Location, "An expression tree lambda cannot contain a call to a method, property, or indexer that returns by reference"); | ||
| 865 | - return null; | ||
| 866 | - } | ||
| 867 | - | ||
| 868 | if (ArgType == AType.Default) | ||
| 869 | rc.Report.Error (854, Expr.Location, "An expression tree cannot contain an invocation which uses optional parameter"); | ||
| 870 | |||
| 871 | diff --git a/mcs/mcs/assign.cs b/mcs/mcs/assign.cs | ||
| 872 | index a07c8c0ef39..596623feae4 100644 | ||
| 873 | --- a/mcs/mcs/assign.cs | ||
| 874 | +++ b/mcs/mcs/assign.cs | ||
| 875 | @@ -391,9 +391,21 @@ namespace Mono.CSharp { | ||
| 876 | return System.Linq.Expressions.Expression.Assign (target_object, source_object); | ||
| 877 | } | ||
| 878 | |||
| 879 | - protected virtual Expression ResolveConversions (ResolveContext ec) | ||
| 880 | + protected virtual Expression ResolveConversions (ResolveContext rc) | ||
| 881 | { | ||
| 882 | - source = Convert.ImplicitConversionRequired (ec, source, target.Type, source.Location); | ||
| 883 | + var ttype = target.Type; | ||
| 884 | + var stackAlloc = source as StackAlloc; | ||
| 885 | + if (stackAlloc != null && ttype.Arity == 1 && ttype.GetDefinition () == rc.Module.PredefinedTypes.SpanGeneric.TypeSpec && | ||
| 886 | + rc.Module.Compiler.Settings.Version >= LanguageVersion.V_7_2) { | ||
| 887 | + | ||
| 888 | + var etype = ttype.TypeArguments [0]; | ||
| 889 | + var stype = ((PointerContainer)source.Type).Element; | ||
| 890 | + if (etype == stype && stackAlloc.ResolveSpanConversion (rc, ttype)) { | ||
| 891 | + return this; | ||
| 892 | + } | ||
| 893 | + } | ||
| 894 | + | ||
| 895 | + source = Convert.ImplicitConversionRequired (rc, source, ttype, source.Location); | ||
| 896 | if (source == null) | ||
| 897 | return null; | ||
| 898 | |||
| 899 | diff --git a/mcs/mcs/async.cs b/mcs/mcs/async.cs | ||
| 900 | index fd6499346e8..643aed5e568 100644 | ||
| 901 | --- a/mcs/mcs/async.cs | ||
| 902 | +++ b/mcs/mcs/async.cs | ||
| 903 | @@ -628,58 +628,112 @@ namespace Mono.CSharp | ||
| 904 | |||
| 905 | protected override bool DoDefineMembers () | ||
| 906 | { | ||
| 907 | - PredefinedType builder_type; | ||
| 908 | - PredefinedMember<MethodSpec> bf; | ||
| 909 | - PredefinedMember<MethodSpec> bs; | ||
| 910 | - PredefinedMember<MethodSpec> sr; | ||
| 911 | - PredefinedMember<MethodSpec> se; | ||
| 912 | - PredefinedMember<MethodSpec> sm; | ||
| 913 | + TypeSpec bt; | ||
| 914 | bool has_task_return_type = false; | ||
| 915 | - var pred_members = Module.PredefinedMembers; | ||
| 916 | + var istate_machine = Module.PredefinedTypes.IAsyncStateMachine; | ||
| 917 | + MethodSpec set_statemachine; | ||
| 918 | |||
| 919 | - if (return_type.Kind == MemberKind.Void) { | ||
| 920 | - builder_type = Module.PredefinedTypes.AsyncVoidMethodBuilder; | ||
| 921 | - bf = pred_members.AsyncVoidMethodBuilderCreate; | ||
| 922 | - bs = pred_members.AsyncVoidMethodBuilderStart; | ||
| 923 | - sr = pred_members.AsyncVoidMethodBuilderSetResult; | ||
| 924 | - se = pred_members.AsyncVoidMethodBuilderSetException; | ||
| 925 | - sm = pred_members.AsyncVoidMethodBuilderSetStateMachine; | ||
| 926 | - } else if (return_type == Module.PredefinedTypes.Task.TypeSpec) { | ||
| 927 | - builder_type = Module.PredefinedTypes.AsyncTaskMethodBuilder; | ||
| 928 | - bf = pred_members.AsyncTaskMethodBuilderCreate; | ||
| 929 | - bs = pred_members.AsyncTaskMethodBuilderStart; | ||
| 930 | - sr = pred_members.AsyncTaskMethodBuilderSetResult; | ||
| 931 | - se = pred_members.AsyncTaskMethodBuilderSetException; | ||
| 932 | - sm = pred_members.AsyncTaskMethodBuilderSetStateMachine; | ||
| 933 | - task = pred_members.AsyncTaskMethodBuilderTask.Get (); | ||
| 934 | + if (return_type.IsCustomTaskType ()) { | ||
| 935 | + // | ||
| 936 | + // TODO: Would be nice to cache all this on per-type basis | ||
| 937 | + // | ||
| 938 | + var btypes = Compiler.BuiltinTypes; | ||
| 939 | + bt = return_type.MemberDefinition.GetAsyncMethodBuilder (); | ||
| 940 | + TypeSpec bt_inflated; | ||
| 941 | + if (return_type.IsGeneric) { | ||
| 942 | + bt_inflated = bt.MakeGenericType (Module, bt.MemberDefinition.TypeParameters); | ||
| 943 | + } else { | ||
| 944 | + bt_inflated = bt; | ||
| 945 | + } | ||
| 946 | + | ||
| 947 | + var set_result_sign = MemberFilter.Method ("SetResult", 0, ParametersCompiled.CreateFullyResolved (bt.MemberDefinition.TypeParameters), btypes.Void); | ||
| 948 | + set_result = new PredefinedMember<MethodSpec> (Module, bt, set_result_sign).Resolve (Location); | ||
| 949 | + | ||
| 950 | + var set_exception_sign = MemberFilter.Method ("SetException", 0, ParametersCompiled.CreateFullyResolved (btypes.Exception), btypes.Void); | ||
| 951 | + set_exception = new PredefinedMember<MethodSpec> (Module, bt, set_exception_sign).Resolve (Location); | ||
| 952 | + | ||
| 953 | + var builder_factory_sign = MemberFilter.Method ("Create", 0, ParametersCompiled.EmptyReadOnlyParameters, bt_inflated); | ||
| 954 | + builder_factory = new PredefinedMember<MethodSpec> (Module, bt, builder_factory_sign).Resolve (Location); | ||
| 955 | + if (builder_factory?.IsStatic == false) | ||
| 956 | + throw new NotImplementedException ("report better error message"); | ||
| 957 | + | ||
| 958 | + var builder_start_sign = MemberFilter.Method ("Start", 1, new ParametersImported ( | ||
| 959 | + new [] { | ||
| 960 | + new ParameterData (null, Parameter.Modifier.REF), | ||
| 961 | + }, | ||
| 962 | + new [] { | ||
| 963 | + new TypeParameterSpec (0, null, SpecialConstraint.None, Variance.None, null), | ||
| 964 | + }, false), | ||
| 965 | + btypes.Void); | ||
| 966 | + builder_start = new PredefinedMember<MethodSpec> (Module, bt, builder_start_sign).Resolve (Location); | ||
| 967 | + | ||
| 968 | + if (!istate_machine.Define ()) | ||
| 969 | + return false; | ||
| 970 | + | ||
| 971 | + var set_statemachine_sign = MemberFilter.Method ("SetStateMachine", 0, ParametersCompiled.CreateFullyResolved (istate_machine.TypeSpec), btypes.Void); | ||
| 972 | + set_statemachine = new PredefinedMember<MethodSpec> (Module, bt, set_statemachine_sign).Resolve (Location); ; | ||
| 973 | + | ||
| 974 | + var task_sign = MemberFilter.Property ("Task", return_type.MemberDefinition as TypeSpec); | ||
| 975 | + task = new PredefinedMember<PropertySpec> (Module, bt, task_sign).Resolve (Location); | ||
| 976 | + | ||
| 977 | + if (set_result == null || set_exception == null || builder_factory == null || builder_start == null || set_statemachine == null || task == null || | ||
| 978 | + !Module.PredefinedTypes.INotifyCompletion.Define ()) { | ||
| 979 | + return false; | ||
| 980 | + } | ||
| 981 | + | ||
| 982 | + has_task_return_type = return_type.IsGeneric; | ||
| 983 | } else { | ||
| 984 | - builder_type = Module.PredefinedTypes.AsyncTaskMethodBuilderGeneric; | ||
| 985 | - bf = pred_members.AsyncTaskMethodBuilderGenericCreate; | ||
| 986 | - bs = pred_members.AsyncTaskMethodBuilderGenericStart; | ||
| 987 | - sr = pred_members.AsyncTaskMethodBuilderGenericSetResult; | ||
| 988 | - se = pred_members.AsyncTaskMethodBuilderGenericSetException; | ||
| 989 | - sm = pred_members.AsyncTaskMethodBuilderGenericSetStateMachine; | ||
| 990 | - task = pred_members.AsyncTaskMethodBuilderGenericTask.Get (); | ||
| 991 | - has_task_return_type = true; | ||
| 992 | - } | ||
| 993 | + PredefinedType builder_type; | ||
| 994 | + PredefinedMember<MethodSpec> bf; | ||
| 995 | + PredefinedMember<MethodSpec> bs; | ||
| 996 | + PredefinedMember<MethodSpec> sr; | ||
| 997 | + PredefinedMember<MethodSpec> se; | ||
| 998 | + PredefinedMember<MethodSpec> sm; | ||
| 999 | + var pred_members = Module.PredefinedMembers; | ||
| 1000 | + | ||
| 1001 | + if (return_type.Kind == MemberKind.Void) { | ||
| 1002 | + builder_type = Module.PredefinedTypes.AsyncVoidMethodBuilder; | ||
| 1003 | + bf = pred_members.AsyncVoidMethodBuilderCreate; | ||
| 1004 | + bs = pred_members.AsyncVoidMethodBuilderStart; | ||
| 1005 | + sr = pred_members.AsyncVoidMethodBuilderSetResult; | ||
| 1006 | + se = pred_members.AsyncVoidMethodBuilderSetException; | ||
| 1007 | + sm = pred_members.AsyncVoidMethodBuilderSetStateMachine; | ||
| 1008 | + } else if (return_type == Module.PredefinedTypes.Task.TypeSpec) { | ||
| 1009 | + builder_type = Module.PredefinedTypes.AsyncTaskMethodBuilder; | ||
| 1010 | + bf = pred_members.AsyncTaskMethodBuilderCreate; | ||
| 1011 | + bs = pred_members.AsyncTaskMethodBuilderStart; | ||
| 1012 | + sr = pred_members.AsyncTaskMethodBuilderSetResult; | ||
| 1013 | + se = pred_members.AsyncTaskMethodBuilderSetException; | ||
| 1014 | + sm = pred_members.AsyncTaskMethodBuilderSetStateMachine; | ||
| 1015 | + task = pred_members.AsyncTaskMethodBuilderTask.Get (); | ||
| 1016 | + } else { | ||
| 1017 | + builder_type = Module.PredefinedTypes.AsyncTaskMethodBuilderGeneric; | ||
| 1018 | + bf = pred_members.AsyncTaskMethodBuilderGenericCreate; | ||
| 1019 | + bs = pred_members.AsyncTaskMethodBuilderGenericStart; | ||
| 1020 | + sr = pred_members.AsyncTaskMethodBuilderGenericSetResult; | ||
| 1021 | + se = pred_members.AsyncTaskMethodBuilderGenericSetException; | ||
| 1022 | + sm = pred_members.AsyncTaskMethodBuilderGenericSetStateMachine; | ||
| 1023 | + task = pred_members.AsyncTaskMethodBuilderGenericTask.Get (); | ||
| 1024 | + has_task_return_type = true; | ||
| 1025 | + } | ||
| 1026 | |||
| 1027 | - set_result = sr.Get (); | ||
| 1028 | - set_exception = se.Get (); | ||
| 1029 | - builder_factory = bf.Get (); | ||
| 1030 | - builder_start = bs.Get (); | ||
| 1031 | + set_result = sr.Get (); | ||
| 1032 | + set_exception = se.Get (); | ||
| 1033 | + builder_factory = bf.Get (); | ||
| 1034 | + builder_start = bs.Get (); | ||
| 1035 | |||
| 1036 | - var istate_machine = Module.PredefinedTypes.IAsyncStateMachine; | ||
| 1037 | - var set_statemachine = sm.Get (); | ||
| 1038 | - | ||
| 1039 | - if (!builder_type.Define () || !istate_machine.Define () || set_result == null || builder_factory == null || | ||
| 1040 | - set_exception == null || set_statemachine == null || builder_start == null || | ||
| 1041 | - !Module.PredefinedTypes.INotifyCompletion.Define ()) { | ||
| 1042 | - Report.Error (1993, Location, | ||
| 1043 | - "Cannot find compiler required types for asynchronous functions support. Are you targeting the wrong framework version?"); | ||
| 1044 | - return base.DoDefineMembers (); | ||
| 1045 | - } | ||
| 1046 | + set_statemachine = sm.Get (); | ||
| 1047 | + | ||
| 1048 | + if (!builder_type.Define () || !istate_machine.Define () || set_result == null || builder_factory == null || | ||
| 1049 | + set_exception == null || set_statemachine == null || builder_start == null || | ||
| 1050 | + !Module.PredefinedTypes.INotifyCompletion.Define ()) { | ||
| 1051 | + Report.Error (1993, Location, | ||
| 1052 | + "Cannot find compiler required types for asynchronous functions support. Are you targeting the wrong framework version?"); | ||
| 1053 | + return base.DoDefineMembers (); | ||
| 1054 | + } | ||
| 1055 | |||
| 1056 | - var bt = builder_type.TypeSpec; | ||
| 1057 | + bt = builder_type.TypeSpec; | ||
| 1058 | + } | ||
| 1059 | |||
| 1060 | // | ||
| 1061 | // Inflate generic Task types | ||
| 1062 | @@ -825,9 +879,26 @@ namespace Mono.CSharp | ||
| 1063 | predefined = unsafeVersion ? pm.AsyncVoidMethodBuilderOnCompletedUnsafe : pm.AsyncVoidMethodBuilderOnCompleted; | ||
| 1064 | } else if (return_type == Module.PredefinedTypes.Task.TypeSpec) { | ||
| 1065 | predefined = unsafeVersion ? pm.AsyncTaskMethodBuilderOnCompletedUnsafe : pm.AsyncTaskMethodBuilderOnCompleted; | ||
| 1066 | - } else { | ||
| 1067 | + } else if (return_type.IsGenericTask) { | ||
| 1068 | predefined = unsafeVersion ? pm.AsyncTaskMethodBuilderGenericOnCompletedUnsafe : pm.AsyncTaskMethodBuilderGenericOnCompleted; | ||
| 1069 | has_task_return_type = true; | ||
| 1070 | + } else { | ||
| 1071 | + var parameters = new ParametersImported ( | ||
| 1072 | + new [] { | ||
| 1073 | + new ParameterData (null, Parameter.Modifier.REF), | ||
| 1074 | + new ParameterData (null, Parameter.Modifier.REF) | ||
| 1075 | + }, | ||
| 1076 | + new [] { | ||
| 1077 | + new TypeParameterSpec (0, null, SpecialConstraint.None, Variance.None, null), | ||
| 1078 | + new TypeParameterSpec (1, null, SpecialConstraint.None, Variance.None, null) | ||
| 1079 | + }, false); | ||
| 1080 | + | ||
| 1081 | + var on_completed_sign = unsafeVersion ? | ||
| 1082 | + MemberFilter.Method ("AwaitUnsafeOnCompleted", 2, parameters, Compiler.BuiltinTypes.Void) : | ||
| 1083 | + MemberFilter.Method ("AwaitOnCompleted", 2, parameters, Compiler.BuiltinTypes.Void); | ||
| 1084 | + | ||
| 1085 | + predefined = new PredefinedMember<MethodSpec> (Module, return_type.MemberDefinition.GetAsyncMethodBuilder (), on_completed_sign); | ||
| 1086 | + has_task_return_type = return_type.IsGeneric; | ||
| 1087 | } | ||
| 1088 | |||
| 1089 | var on_completed = predefined.Resolve (Location); | ||
| 1090 | @@ -887,11 +958,14 @@ namespace Mono.CSharp | ||
| 1091 | // stateMachine.$builder.Start<{storey-type}>(ref stateMachine); | ||
| 1092 | // | ||
| 1093 | instance.AddressOf (ec, AddressOp.Store); | ||
| 1094 | - ec.Emit (OpCodes.Ldflda, builder_field); | ||
| 1095 | + | ||
| 1096 | + bool struct_builder = builder.MemberType.IsStruct; | ||
| 1097 | + | ||
| 1098 | + ec.Emit (struct_builder ? OpCodes.Ldflda : OpCodes.Ldfld, builder_field); | ||
| 1099 | if (Task != null) | ||
| 1100 | ec.Emit (OpCodes.Dup); | ||
| 1101 | instance.AddressOf (ec, AddressOp.Store); | ||
| 1102 | - ec.Emit (OpCodes.Call, builder_start.MakeGenericMethod (Module, instance.Type)); | ||
| 1103 | + ec.Emit (struct_builder ? OpCodes.Call : OpCodes.Callvirt, builder_start.MakeGenericMethod (Module, instance.Type)); | ||
| 1104 | |||
| 1105 | // | ||
| 1106 | // Emits return stateMachine.$builder.Task; | ||
| 1107 | @@ -1029,4 +1103,20 @@ namespace Mono.CSharp | ||
| 1108 | EmitAssign (ec, new NullConstant (type, loc), false, false); | ||
| 1109 | } | ||
| 1110 | } | ||
| 1111 | + | ||
| 1112 | + static class TypeSpecAsyncExtensions | ||
| 1113 | + { | ||
| 1114 | + public static bool IsCustomTaskType (this TypeSpec type) | ||
| 1115 | + { | ||
| 1116 | + // LAMESPEC: Arity is not mentioned | ||
| 1117 | + if (type.Arity > 1) | ||
| 1118 | + return false; | ||
| 1119 | + | ||
| 1120 | + var amb = type.MemberDefinition.GetAsyncMethodBuilder (); | ||
| 1121 | + if (amb == null) | ||
| 1122 | + return false; | ||
| 1123 | + | ||
| 1124 | + return amb.Arity == type.Arity; | ||
| 1125 | + } | ||
| 1126 | + } | ||
| 1127 | } | ||
| 1128 | diff --git a/mcs/mcs/attribute.cs b/mcs/mcs/attribute.cs | ||
| 1129 | index 3ff2d68ccb5..83d403118ad 100644 | ||
| 1130 | --- a/mcs/mcs/attribute.cs | ||
| 1131 | +++ b/mcs/mcs/attribute.cs | ||
| 1132 | @@ -789,6 +789,17 @@ namespace Mono.CSharp { | ||
| 1133 | return ((BoolConstant) pos_args[0].Expr).Value; | ||
| 1134 | } | ||
| 1135 | |||
| 1136 | + public TypeSpec GetAsyncMethodBuilderValue () | ||
| 1137 | + { | ||
| 1138 | + if (!arg_resolved) | ||
| 1139 | + Resolve (); | ||
| 1140 | + | ||
| 1141 | + if (resolve_error) | ||
| 1142 | + return null; | ||
| 1143 | + | ||
| 1144 | + return GetArgumentType (); | ||
| 1145 | + } | ||
| 1146 | + | ||
| 1147 | public TypeSpec GetCoClassAttributeValue () | ||
| 1148 | { | ||
| 1149 | if (!arg_resolved) | ||
| 1150 | @@ -1754,9 +1765,11 @@ namespace Mono.CSharp { | ||
| 1151 | |||
| 1152 | // New in .NET 4.7 | ||
| 1153 | public readonly PredefinedTupleElementNamesAttribute TupleElementNames; | ||
| 1154 | + public readonly PredefinedAttribute AsyncMethodBuilder; | ||
| 1155 | |||
| 1156 | // New in .NET 4.7.1 | ||
| 1157 | public readonly PredefinedAttribute IsReadOnly; | ||
| 1158 | + public readonly PredefinedAttribute IsByRefLike; | ||
| 1159 | |||
| 1160 | // | ||
| 1161 | // Optional types which are used as types and for member lookup | ||
| 1162 | @@ -1837,8 +1850,10 @@ namespace Mono.CSharp { | ||
| 1163 | CallerLineNumberAttribute = new PredefinedAttribute (module, "System.Runtime.CompilerServices", "CallerLineNumberAttribute"); | ||
| 1164 | CallerFilePathAttribute = new PredefinedAttribute (module, "System.Runtime.CompilerServices", "CallerFilePathAttribute"); | ||
| 1165 | |||
| 1166 | + AsyncMethodBuilder = new PredefinedAttribute (module, "System.Runtime.CompilerServices", "AsyncMethodBuilderAttribute"); | ||
| 1167 | TupleElementNames = new PredefinedTupleElementNamesAttribute (module, "System.Runtime.CompilerServices", "TupleElementNamesAttribute"); | ||
| 1168 | IsReadOnly = new PredefinedAttribute (module, "System.Runtime.CompilerServices", "IsReadOnlyAttribute"); | ||
| 1169 | + IsByRefLike = new PredefinedAttribute (module, "System.Runtime.CompilerServices", "IsByRefLikeAttribute"); | ||
| 1170 | |||
| 1171 | // TODO: Should define only attributes which are used for comparison | ||
| 1172 | const System.Reflection.BindingFlags all_fields = System.Reflection.BindingFlags.Public | | ||
| 1173 | diff --git a/mcs/mcs/class.cs b/mcs/mcs/class.cs | ||
| 1174 | index 9afb32c6fe5..6b1adc297a3 100644 | ||
| 1175 | --- a/mcs/mcs/class.cs | ||
| 1176 | +++ b/mcs/mcs/class.cs | ||
| 1177 | @@ -224,6 +224,24 @@ namespace Mono.CSharp | ||
| 1178 | } | ||
| 1179 | } | ||
| 1180 | |||
| 1181 | + public void CloseContainerEarlyForReflectionEmit () | ||
| 1182 | + { | ||
| 1183 | + if (containers != null) { | ||
| 1184 | + foreach (TypeContainer tc in containers) { | ||
| 1185 | + // | ||
| 1186 | + // SRE requires due to internal checks that any field of enum type is | ||
| 1187 | + // baked. We close all enum types before closing any other types to | ||
| 1188 | + // workaround this limitation | ||
| 1189 | + // | ||
| 1190 | + if (tc.Kind == MemberKind.Enum) { | ||
| 1191 | + tc.CloseContainer (); | ||
| 1192 | + } else { | ||
| 1193 | + tc.CloseContainerEarlyForReflectionEmit (); | ||
| 1194 | + } | ||
| 1195 | + } | ||
| 1196 | + } | ||
| 1197 | + } | ||
| 1198 | + | ||
| 1199 | public virtual void CreateMetadataName (StringBuilder sb) | ||
| 1200 | { | ||
| 1201 | if (Parent != null && Parent.MemberName != null) | ||
| 1202 | @@ -1102,6 +1120,18 @@ namespace Mono.CSharp | ||
| 1203 | member.GenerateDocComment (builder); | ||
| 1204 | } | ||
| 1205 | |||
| 1206 | + public TypeSpec GetAsyncMethodBuilder () | ||
| 1207 | + { | ||
| 1208 | + if (OptAttributes == null) | ||
| 1209 | + return null; | ||
| 1210 | + | ||
| 1211 | + Attribute a = OptAttributes.Search (Module.PredefinedAttributes.AsyncMethodBuilder); | ||
| 1212 | + if (a == null) | ||
| 1213 | + return null; | ||
| 1214 | + | ||
| 1215 | + return a.GetAsyncMethodBuilderValue (); | ||
| 1216 | + } | ||
| 1217 | + | ||
| 1218 | public TypeSpec GetAttributeCoClass () | ||
| 1219 | { | ||
| 1220 | if (OptAttributes == null) | ||
| 1221 | @@ -2171,7 +2201,7 @@ namespace Mono.CSharp | ||
| 1222 | |||
| 1223 | public override void Emit () | ||
| 1224 | { | ||
| 1225 | - if (Interfaces != null) { | ||
| 1226 | + if (Interfaces != null && (ModFlags & Modifiers.PRIVATE) == 0) { | ||
| 1227 | foreach (var iface in Interfaces) { | ||
| 1228 | if (iface.HasNamedTupleElement) { | ||
| 1229 | throw new NotImplementedException ("named tuples for .interfaceimpl"); | ||
| 1230 | @@ -3023,7 +3053,8 @@ namespace Mono.CSharp | ||
| 1231 | Modifiers.INTERNAL | | ||
| 1232 | Modifiers.UNSAFE | | ||
| 1233 | Modifiers.PRIVATE | | ||
| 1234 | - Modifiers.READONLY; | ||
| 1235 | + Modifiers.READONLY | | ||
| 1236 | + Modifiers.REF; | ||
| 1237 | |||
| 1238 | public Struct (TypeContainer parent, MemberName name, Modifiers mod, Attributes attrs) | ||
| 1239 | : base (parent, name, attrs, MemberKind.Struct) | ||
| 1240 | @@ -3139,6 +3170,9 @@ namespace Mono.CSharp | ||
| 1241 | if ((ModFlags & Modifiers.READONLY) != 0) | ||
| 1242 | Module.PredefinedAttributes.IsReadOnly.EmitAttribute (TypeBuilder); | ||
| 1243 | |||
| 1244 | + if ((ModFlags & Modifiers.REF) != 0) | ||
| 1245 | + Module.PredefinedAttributes.IsByRefLike.EmitAttribute (TypeBuilder); | ||
| 1246 | + | ||
| 1247 | CheckStructCycles (); | ||
| 1248 | |||
| 1249 | base.Emit (); | ||
| 1250 | @@ -3213,6 +3247,10 @@ namespace Mono.CSharp | ||
| 1251 | protected override TypeSpec[] ResolveBaseTypes (out FullNamedExpression base_class) | ||
| 1252 | { | ||
| 1253 | var ifaces = base.ResolveBaseTypes (out base_class); | ||
| 1254 | + if (ifaces != null && (ModFlags & Modifiers.REF) != 0) { | ||
| 1255 | + Report.Error (8343, Location, "`{0}': ref structs cannot implement interfaces", GetSignatureForError ()); | ||
| 1256 | + } | ||
| 1257 | + | ||
| 1258 | base_type = Compiler.BuiltinTypes.ValueType; | ||
| 1259 | return ifaces; | ||
| 1260 | } | ||
| 1261 | @@ -3915,7 +3953,7 @@ namespace Mono.CSharp | ||
| 1262 | |||
| 1263 | protected void IsTypePermitted () | ||
| 1264 | { | ||
| 1265 | - if (MemberType.IsSpecialRuntimeType) { | ||
| 1266 | + if (MemberType.IsSpecialRuntimeType || MemberType.IsByRefLike) { | ||
| 1267 | if (Parent is StateMachine) { | ||
| 1268 | Report.Error (4012, Location, | ||
| 1269 | "Parameters or local variables of type `{0}' cannot be declared in async methods or iterators", | ||
| 1270 | @@ -3924,6 +3962,19 @@ namespace Mono.CSharp | ||
| 1271 | Report.Error (4013, Location, | ||
| 1272 | "Local variables of type `{0}' cannot be used inside anonymous methods, lambda expressions or query expressions", | ||
| 1273 | MemberType.GetSignatureForError ()); | ||
| 1274 | + } else if (MemberType.IsByRefLike) { | ||
| 1275 | + if ((ModFlags & (Modifiers.ABSTRACT | Modifiers.EXTERN)) != 0) | ||
| 1276 | + return; | ||
| 1277 | + | ||
| 1278 | + if ((ModFlags & Modifiers.AutoProperty) == 0 && this is Property) | ||
| 1279 | + return; | ||
| 1280 | + | ||
| 1281 | + if ((ModFlags & Modifiers.STATIC) == 0 && (Parent.ModFlags & Modifiers.REF) != 0) | ||
| 1282 | + return; | ||
| 1283 | + | ||
| 1284 | + Report.Error (8345, Location, | ||
| 1285 | + "Field or auto-implemented property cannot be of type `{0}' unless it is an instance member of a ref struct", | ||
| 1286 | + MemberType.GetSignatureForError ()); | ||
| 1287 | } else { | ||
| 1288 | Report.Error (610, Location, | ||
| 1289 | "Field or property cannot be of type `{0}'", MemberType.GetSignatureForError ()); | ||
| 1290 | diff --git a/mcs/mcs/const.cs b/mcs/mcs/const.cs | ||
| 1291 | index 046aec24c1b..658f15ec57a 100644 | ||
| 1292 | --- a/mcs/mcs/const.cs | ||
| 1293 | +++ b/mcs/mcs/const.cs | ||
| 1294 | @@ -206,7 +206,9 @@ namespace Mono.CSharp { | ||
| 1295 | c = field.ConvertInitializer (rc, c); | ||
| 1296 | |||
| 1297 | if (c == null) { | ||
| 1298 | - if (TypeSpec.IsReferenceType (field.MemberType)) | ||
| 1299 | + if (expr is DefaultLiteralExpression) { | ||
| 1300 | + // It's handled bellow in New.Constantify | ||
| 1301 | + } else if (TypeSpec.IsReferenceType (field.MemberType)) | ||
| 1302 | Error_ConstantCanBeInitializedWithNullOnly (rc, field.MemberType, expr.Location, GetSignatureForError ()); | ||
| 1303 | else if (!(expr is Constant)) | ||
| 1304 | Error_ExpressionMustBeConstant (rc, expr.Location, GetSignatureForError ()); | ||
| 1305 | diff --git a/mcs/mcs/convert.cs b/mcs/mcs/convert.cs | ||
| 1306 | index b11477c1043..ae153fc49e8 100644 | ||
| 1307 | --- a/mcs/mcs/convert.cs | ||
| 1308 | +++ b/mcs/mcs/convert.cs | ||
| 1309 | @@ -392,6 +392,9 @@ namespace Mono.CSharp { | ||
| 1310 | if (!TypeSpec.IsValueType (expr_type)) | ||
| 1311 | return null; | ||
| 1312 | |||
| 1313 | + if (expr_type.IsByRefLike) | ||
| 1314 | + return null; | ||
| 1315 | + | ||
| 1316 | return expr == null ? EmptyExpression.Null : new BoxedCast (expr, target_type); | ||
| 1317 | |||
| 1318 | case BuiltinTypeSpec.Type.Enum: | ||
| 1319 | @@ -816,7 +819,7 @@ namespace Mono.CSharp { | ||
| 1320 | if (expr_type == target_type) | ||
| 1321 | return true; | ||
| 1322 | |||
| 1323 | - if (expr_type == InternalType.ThrowExpr) | ||
| 1324 | + if (expr_type == InternalType.ThrowExpr || expr_type == InternalType.DefaultType) | ||
| 1325 | return target_type.Kind != MemberKind.InternalCompilerType; | ||
| 1326 | |||
| 1327 | if (target_type.IsNullableType) | ||
| 1328 | @@ -1478,6 +1481,10 @@ namespace Mono.CSharp { | ||
| 1329 | return target_type.Kind == MemberKind.InternalCompilerType ? null : EmptyCast.Create (expr, target_type); | ||
| 1330 | } | ||
| 1331 | |||
| 1332 | + if (expr_type == InternalType.DefaultType) { | ||
| 1333 | + return new DefaultValueExpression (new TypeExpression (target_type, expr.Location), expr.Location).Resolve (ec); | ||
| 1334 | + } | ||
| 1335 | + | ||
| 1336 | if (target_type.IsNullableType) | ||
| 1337 | return ImplicitNulableConversion (ec, expr, target_type); | ||
| 1338 | |||
| 1339 | @@ -1967,7 +1974,7 @@ namespace Mono.CSharp { | ||
| 1340 | // From object or dynamic to any reference type or value type (unboxing) | ||
| 1341 | // | ||
| 1342 | if (source_type.BuiltinType == BuiltinTypeSpec.Type.Object || source_type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) { | ||
| 1343 | - if (target_type.IsPointer) | ||
| 1344 | + if (target_type.IsPointer || target_type.IsByRefLike) | ||
| 1345 | return null; | ||
| 1346 | |||
| 1347 | return | ||
| 1348 | diff --git a/mcs/mcs/cs-parser.jay b/mcs/mcs/cs-parser.jay | ||
| 1349 | index 2868d2fd8f6..4d6fcb44c0d 100644 | ||
| 1350 | --- a/mcs/mcs/cs-parser.jay | ||
| 1351 | +++ b/mcs/mcs/cs-parser.jay | ||
| 1352 | @@ -169,7 +169,8 @@ namespace Mono.CSharp | ||
| 1353 | %token CONST | ||
| 1354 | %token CONTINUE | ||
| 1355 | %token DECIMAL | ||
| 1356 | -%token DEFAULT | ||
| 1357 | +%token DEFAULT | ||
| 1358 | +%token DEFAULT_VALUE | ||
| 1359 | %token DELEGATE | ||
| 1360 | %token DO | ||
| 1361 | %token DOUBLE | ||
| 1362 | @@ -336,6 +337,7 @@ namespace Mono.CSharp | ||
| 1363 | %token DEFAULT_COLON | ||
| 1364 | %token OPEN_BRACKET_EXPR | ||
| 1365 | %token OPEN_PARENS_DECONSTRUCT | ||
| 1366 | +%token REF_STRUCT | ||
| 1367 | |||
| 1368 | // Make the parser go into eval mode parsing (statements and compilation units). | ||
| 1369 | %token EVAL_STATEMENT_PARSER | ||
| 1370 | @@ -863,7 +865,7 @@ attribute_arguments | ||
| 1371 | } | ||
| 1372 | |||
| 1373 | Arguments args = ((Arguments) o [0]); | ||
| 1374 | - if (args.Count > 0 && !($3 is NamedArgument) && args [args.Count - 1] is NamedArgument) | ||
| 1375 | + if (lang_version < LanguageVersion.V_7_2 && args.Count > 0 && !($3 is NamedArgument) && args [args.Count - 1] is NamedArgument) | ||
| 1376 | Error_NamedArgumentExpected ((NamedArgument) args [args.Count - 1]); | ||
| 1377 | |||
| 1378 | args.Add ((Argument) $3); | ||
| 1379 | @@ -1015,17 +1017,34 @@ primary_constructor_body | ||
| 1380 | } | ||
| 1381 | ; | ||
| 1382 | |||
| 1383 | +struct_keyword | ||
| 1384 | + : STRUCT | ||
| 1385 | + { | ||
| 1386 | + $$ = null; | ||
| 1387 | + } | ||
| 1388 | + | REF_STRUCT | ||
| 1389 | + { | ||
| 1390 | + if (lang_version < LanguageVersion.V_7_2) { | ||
| 1391 | + FeatureIsNotAvailable (GetLocation ($1), "ref structs"); | ||
| 1392 | + } | ||
| 1393 | + | ||
| 1394 | + $$ = this; | ||
| 1395 | + } | ||
| 1396 | + ; | ||
| 1397 | + | ||
| 1398 | struct_declaration | ||
| 1399 | : opt_attributes | ||
| 1400 | opt_modifiers | ||
| 1401 | opt_partial | ||
| 1402 | - STRUCT | ||
| 1403 | + struct_keyword | ||
| 1404 | type_declaration_name | ||
| 1405 | { | ||
| 1406 | var mods = (Modifiers) $2; | ||
| 1407 | if ((mods & Modifiers.READONLY) != 0 && lang_version < LanguageVersion.V_7_2) { | ||
| 1408 | FeatureIsNotAvailable (GetLocation ($4), "readonly structs"); | ||
| 1409 | } | ||
| 1410 | + if ($4 != null) | ||
| 1411 | + mods |= Modifiers.REF; | ||
| 1412 | |||
| 1413 | lexer.ConstraintsParsing = true; | ||
| 1414 | valid_param_mod = ParameterModifierType.PrimaryConstructor; | ||
| 1415 | @@ -1071,7 +1090,7 @@ struct_declaration | ||
| 1416 | } | ||
| 1417 | $$ = pop_current_class (); | ||
| 1418 | } | ||
| 1419 | - | opt_attributes opt_modifiers opt_partial STRUCT error | ||
| 1420 | + | opt_attributes opt_modifiers opt_partial struct_keyword error | ||
| 1421 | { | ||
| 1422 | Error_SyntaxError (yyToken); | ||
| 1423 | } | ||
| 1424 | @@ -1384,6 +1403,18 @@ ref_member_type | ||
| 1425 | |||
| 1426 | $$ = new ReferenceTypeExpr ((FullNamedExpression) $3, GetLocation ($1)); | ||
| 1427 | } | ||
| 1428 | + | REF READONLY | ||
| 1429 | + { | ||
| 1430 | + lexer.parsing_generic_declaration = true; | ||
| 1431 | + } | ||
| 1432 | + type | ||
| 1433 | + { | ||
| 1434 | + if (lang_version < LanguageVersion.V_7_2) { | ||
| 1435 | + FeatureIsNotAvailable (GetLocation ($2), "readonly references"); | ||
| 1436 | + } | ||
| 1437 | + | ||
| 1438 | + $$ = new ReferenceTypeExpr ((FullNamedExpression) $4, true, GetLocation ($1)); | ||
| 1439 | + } | ||
| 1440 | ; | ||
| 1441 | |||
| 1442 | method_header | ||
| 1443 | @@ -3448,6 +3479,7 @@ primary_expression | ||
| 1444 | | anonymous_method_expression | ||
| 1445 | | undocumented_expressions | ||
| 1446 | | interpolated_string | ||
| 1447 | + | default_literal | ||
| 1448 | ; | ||
| 1449 | |||
| 1450 | type_name_expression | ||
| 1451 | @@ -3824,7 +3856,7 @@ argument_list | ||
| 1452 | | argument_list COMMA argument | ||
| 1453 | { | ||
| 1454 | Arguments list = (Arguments) $1; | ||
| 1455 | - if (list [list.Count - 1] is NamedArgument) | ||
| 1456 | + if (lang_version < LanguageVersion.V_7_2 && list [list.Count - 1] is NamedArgument) | ||
| 1457 | Error_NamedArgumentExpected ((NamedArgument) list [list.Count - 1]); | ||
| 1458 | |||
| 1459 | list.Add ((Argument) $3); | ||
| 1460 | @@ -3969,7 +4001,7 @@ expression_list_arguments | ||
| 1461 | | expression_list_arguments COMMA expression_list_argument | ||
| 1462 | { | ||
| 1463 | Arguments args = (Arguments) $1; | ||
| 1464 | - if (args [args.Count - 1] is NamedArgument && !($3 is NamedArgument)) | ||
| 1465 | + if (lang_version < LanguageVersion.V_7_2 && args [args.Count - 1] is NamedArgument && !($3 is NamedArgument)) | ||
| 1466 | Error_NamedArgumentExpected ((NamedArgument) args [args.Count - 1]); | ||
| 1467 | |||
| 1468 | args.Add ((Argument) $3); | ||
| 1469 | @@ -4386,7 +4418,7 @@ anonymous_method_signature | ||
| 1470 | ; | ||
| 1471 | |||
| 1472 | default_value_expression | ||
| 1473 | - : DEFAULT open_parens_any type CLOSE_PARENS | ||
| 1474 | + : DEFAULT_VALUE open_parens_any type CLOSE_PARENS | ||
| 1475 | { | ||
| 1476 | if (lang_version < LanguageVersion.ISO_2) | ||
| 1477 | FeatureIsNotAvailable (GetLocation ($1), "default value expression"); | ||
| 1478 | @@ -4396,6 +4428,16 @@ default_value_expression | ||
| 1479 | } | ||
| 1480 | ; | ||
| 1481 | |||
| 1482 | +default_literal | ||
| 1483 | + : DEFAULT | ||
| 1484 | + { | ||
| 1485 | + if (lang_version < LanguageVersion.V_7_1) | ||
| 1486 | + FeatureIsNotAvailable (GetLocation ($1), "default literal"); | ||
| 1487 | + | ||
| 1488 | + $$ = new DefaultLiteralExpression (GetLocation ($1)); | ||
| 1489 | + } | ||
| 1490 | + ; | ||
| 1491 | + | ||
| 1492 | unary_expression | ||
| 1493 | : primary_expression | ||
| 1494 | | BANG prefixed_unary_expression | ||
| 1495 | @@ -4750,7 +4792,7 @@ pattern_list | ||
| 1496 | | pattern_list COMMA pattern_argument | ||
| 1497 | { | ||
| 1498 | Arguments args = (Arguments) $1; | ||
| 1499 | - if (args [args.Count - 1] is NamedArgument && !($3 is NamedArgument)) | ||
| 1500 | + if (lang_version < LanguageVersion.V_7_2 && args [args.Count - 1] is NamedArgument && !($3 is NamedArgument)) | ||
| 1501 | Error_NamedArgumentExpected ((NamedArgument) args [args.Count - 1]); | ||
| 1502 | |||
| 1503 | args.Add ((Argument) $3); | ||
| 1504 | @@ -5067,17 +5109,25 @@ assignment_expression | ||
| 1505 | $$ = new CompoundAssign (Binary.Operator.ExclusiveOr, (Expression) $1, (Expression) $3); | ||
| 1506 | lbag.AddLocation ($$, GetLocation ($2)); | ||
| 1507 | } | ||
| 1508 | - | OPEN_PARENS_DECONSTRUCT deconstruct_exprs CLOSE_PARENS ASSIGN expression | ||
| 1509 | + | OPEN_PARENS_DECONSTRUCT deconstruct_assignment CLOSE_PARENS ASSIGN expression | ||
| 1510 | { | ||
| 1511 | if (lang_version < LanguageVersion.V_7) | ||
| 1512 | FeatureIsNotAvailable (GetLocation ($1), "tuples"); | ||
| 1513 | |||
| 1514 | - var exprs = (List<Expression>) $2; | ||
| 1515 | + var exprs = (List<Expression>) $2; | ||
| 1516 | + $$ = new TupleDeconstruct (exprs, (Expression) $5, GetLocation ($4)); | ||
| 1517 | + } | ||
| 1518 | + | OPEN_PARENS_DECONSTRUCT deconstruct_declaration CLOSE_PARENS ASSIGN expression | ||
| 1519 | + { | ||
| 1520 | + if (lang_version < LanguageVersion.V_7) | ||
| 1521 | + FeatureIsNotAvailable (GetLocation ($1), "tuples"); | ||
| 1522 | + | ||
| 1523 | + var exprs = (List<BlockVariable>) $2; | ||
| 1524 | $$ = new TupleDeconstruct (exprs, (Expression) $5, GetLocation ($4)); | ||
| 1525 | } | ||
| 1526 | ; | ||
| 1527 | |||
| 1528 | -deconstruct_exprs | ||
| 1529 | +deconstruct_assignment | ||
| 1530 | : expression COMMA expression | ||
| 1531 | { | ||
| 1532 | $$ = new List<Expression> () { | ||
| 1533 | @@ -5085,7 +5135,7 @@ deconstruct_exprs | ||
| 1534 | (Expression) $3 | ||
| 1535 | }; | ||
| 1536 | } | ||
| 1537 | - | deconstruct_exprs COMMA expression | ||
| 1538 | + | deconstruct_assignment COMMA expression | ||
| 1539 | { | ||
| 1540 | var src = (List<Expression>) $1; | ||
| 1541 | src.Add ((Expression) $3); | ||
| 1542 | @@ -5093,6 +5143,43 @@ deconstruct_exprs | ||
| 1543 | } | ||
| 1544 | ; | ||
| 1545 | |||
| 1546 | +deconstruct_declaration | ||
| 1547 | + : variable_type identifier_inside_body | ||
| 1548 | + { | ||
| 1549 | + var lt = (LocatedToken) $2; | ||
| 1550 | + var li = new LocalVariable (current_block, lt.Value, lt.Location); | ||
| 1551 | + current_block.AddLocalName (li); | ||
| 1552 | + $$ = new List<BlockVariable> (2) { | ||
| 1553 | + new BlockVariable ((FullNamedExpression) $1, li) | ||
| 1554 | + }; | ||
| 1555 | + } | ||
| 1556 | + | deconstruct_declaration COMMA variable_type identifier_inside_body | ||
| 1557 | + { | ||
| 1558 | + var lt = (LocatedToken) $4; | ||
| 1559 | + var li = new LocalVariable (current_block, lt.Value, lt.Location); | ||
| 1560 | + current_block.AddLocalName (li); | ||
| 1561 | + | ||
| 1562 | + var src = (List<BlockVariable>) $1; | ||
| 1563 | + src.Add (new BlockVariable ((FullNamedExpression) $3, li)); | ||
| 1564 | + $$ = src; | ||
| 1565 | + } | ||
| 1566 | + | deconstruct_declaration COMMA identifier_inside_body | ||
| 1567 | + { | ||
| 1568 | + var lt = (LocatedToken) $3; | ||
| 1569 | + var li = new LocalVariable (current_block, lt.Value, lt.Location); | ||
| 1570 | + | ||
| 1571 | + if (lt.Value != "_") { | ||
| 1572 | + report.Error (8184, lt.Location, "A deconstruction cannot mix declarations and expressions on the left-hand-side"); | ||
| 1573 | + } else { | ||
| 1574 | + li.Type = InternalType.Discard; | ||
| 1575 | + } | ||
| 1576 | + | ||
| 1577 | + var src = (List<BlockVariable>) $1; | ||
| 1578 | + src.Add (new BlockVariable (new TypeExpression (li.Type, lt.Location), li)); | ||
| 1579 | + $$ = src; | ||
| 1580 | + } | ||
| 1581 | + ; | ||
| 1582 | + | ||
| 1583 | lambda_parameter_list | ||
| 1584 | : lambda_parameter | ||
| 1585 | { | ||
| 1586 | @@ -6008,6 +6095,28 @@ block_variable_declaration | ||
| 1587 | lbag.AddLocation ($$, GetLocation ($7)); | ||
| 1588 | } | ||
| 1589 | } | ||
| 1590 | + | REF READONLY variable_type identifier_inside_body | ||
| 1591 | + { | ||
| 1592 | + if (lang_version < LanguageVersion.V_7_2) { | ||
| 1593 | + FeatureIsNotAvailable (GetLocation ($2), "readonly references"); | ||
| 1594 | + } | ||
| 1595 | + | ||
| 1596 | + var lt = (LocatedToken) $4; | ||
| 1597 | + var li = new LocalVariable (current_block, lt.Value, LocalVariable.Flags.ByRef | LocalVariable.Flags.ReadonlyMask, lt.Location); | ||
| 1598 | + current_block.AddLocalName (li); | ||
| 1599 | + current_variable = new BlockVariable ((FullNamedExpression) $3, li); | ||
| 1600 | + } | ||
| 1601 | + opt_local_variable_initializer opt_variable_declarators SEMICOLON | ||
| 1602 | + { | ||
| 1603 | + $$ = current_variable; | ||
| 1604 | + current_variable = null; | ||
| 1605 | + if ($6 != null) { | ||
| 1606 | + lbag.AddLocation ($$, PopLocation (), GetLocation ($8)); | ||
| 1607 | + } else { | ||
| 1608 | + report.Error (8174, GetLocation ($3), "A declaration of a by-reference variable must have an initializer"); | ||
| 1609 | + lbag.AddLocation ($$, GetLocation ($8)); | ||
| 1610 | + } | ||
| 1611 | + } | ||
| 1612 | ; | ||
| 1613 | |||
| 1614 | opt_local_variable_initializer | ||
| 1615 | @@ -7731,7 +7840,7 @@ void Warning_EmptyStatement (Location loc) | ||
| 1616 | |||
| 1617 | void Error_NamedArgumentExpected (NamedArgument a) | ||
| 1618 | { | ||
| 1619 | - report.Error (1738, a.Location, "Named arguments must appear after the positional arguments"); | ||
| 1620 | + report.Error (1738, a.Location, "Named arguments must appear after the positional arguments when using language version older than 7.2"); | ||
| 1621 | } | ||
| 1622 | |||
| 1623 | void Error_MissingInitializer (Location loc) | ||
| 1624 | @@ -8255,6 +8364,7 @@ static string GetTokenName (int token) | ||
| 1625 | case Token.CONTINUE: | ||
| 1626 | return "continue"; | ||
| 1627 | case Token.DEFAULT: | ||
| 1628 | + case Token.DEFAULT_VALUE: | ||
| 1629 | return "default"; | ||
| 1630 | case Token.DELEGATE: | ||
| 1631 | return "delegate"; | ||
| 1632 | @@ -8334,6 +8444,7 @@ static string GetTokenName (int token) | ||
| 1633 | case Token.STATIC: | ||
| 1634 | return "static"; | ||
| 1635 | case Token.STRUCT: | ||
| 1636 | + case Token.REF_STRUCT: | ||
| 1637 | return "struct"; | ||
| 1638 | case Token.SWITCH: | ||
| 1639 | return "switch"; | ||
| 1640 | diff --git a/mcs/mcs/cs-tokenizer.cs b/mcs/mcs/cs-tokenizer.cs | ||
| 1641 | index d6d00d31400..37edb5c1224 100644 | ||
| 1642 | --- a/mcs/mcs/cs-tokenizer.cs | ||
| 1643 | +++ b/mcs/mcs/cs-tokenizer.cs | ||
| 1644 | @@ -716,9 +716,18 @@ namespace Mono.CSharp | ||
| 1645 | res = Token.EXTERN_ALIAS; | ||
| 1646 | break; | ||
| 1647 | case Token.DEFAULT: | ||
| 1648 | - if (peek_token () == Token.COLON) { | ||
| 1649 | - token (); | ||
| 1650 | - res = Token.DEFAULT_COLON; | ||
| 1651 | + switch (peek_token ()) { | ||
| 1652 | + case Token.COLON: | ||
| 1653 | + // Special case: foo == null ? default : 1; | ||
| 1654 | + if (current_token != Token.INTERR) { | ||
| 1655 | + token (); | ||
| 1656 | + res = Token.DEFAULT_COLON; | ||
| 1657 | + } | ||
| 1658 | + break; | ||
| 1659 | + case Token.OPEN_PARENS: | ||
| 1660 | + case Token.OPEN_PARENS_CAST: | ||
| 1661 | + res = Token.DEFAULT_VALUE; | ||
| 1662 | + break; | ||
| 1663 | } | ||
| 1664 | break; | ||
| 1665 | case Token.WHEN: | ||
| 1666 | @@ -812,10 +821,12 @@ namespace Mono.CSharp | ||
| 1667 | PushPosition (); | ||
| 1668 | |||
| 1669 | next_token = token (); | ||
| 1670 | - bool ok = (next_token == Token.CLASS) || | ||
| 1671 | - (next_token == Token.STRUCT) || | ||
| 1672 | - (next_token == Token.INTERFACE) || | ||
| 1673 | - (next_token == Token.VOID); | ||
| 1674 | + bool ok = | ||
| 1675 | + next_token == Token.CLASS || | ||
| 1676 | + next_token == Token.STRUCT || | ||
| 1677 | + next_token == Token.INTERFACE || | ||
| 1678 | + next_token == Token.VOID || | ||
| 1679 | + next_token == Token.REF_STRUCT; | ||
| 1680 | |||
| 1681 | PopPosition (); | ||
| 1682 | |||
| 1683 | @@ -903,6 +914,12 @@ namespace Mono.CSharp | ||
| 1684 | break; | ||
| 1685 | } | ||
| 1686 | |||
| 1687 | + break; | ||
| 1688 | + case Token.REF: | ||
| 1689 | + if (peek_token () == Token.STRUCT) { | ||
| 1690 | + token (); | ||
| 1691 | + res = Token.REF_STRUCT; | ||
| 1692 | + } | ||
| 1693 | break; | ||
| 1694 | } | ||
| 1695 | |||
| 1696 | @@ -1094,6 +1111,7 @@ namespace Mono.CSharp | ||
| 1697 | case Token.UNCHECKED: | ||
| 1698 | case Token.UNSAFE: | ||
| 1699 | case Token.DEFAULT: | ||
| 1700 | + case Token.DEFAULT_VALUE: | ||
| 1701 | case Token.AWAIT: | ||
| 1702 | |||
| 1703 | // | ||
| 1704 | @@ -1273,14 +1291,21 @@ namespace Mono.CSharp | ||
| 1705 | |||
| 1706 | return false; | ||
| 1707 | case Token.OPEN_PARENS: | ||
| 1708 | - if (!parsing_generic_declaration) | ||
| 1709 | - return false; | ||
| 1710 | - | ||
| 1711 | + int parens_count = 1; | ||
| 1712 | while (true) { | ||
| 1713 | switch (token ()) { | ||
| 1714 | case Token.COMMA: | ||
| 1715 | // tuple declaration after < | ||
| 1716 | - return true; | ||
| 1717 | + if (parens_count == 1) | ||
| 1718 | + return true; | ||
| 1719 | + continue; | ||
| 1720 | + case Token.OPEN_PARENS: | ||
| 1721 | + ++parens_count; | ||
| 1722 | + continue; | ||
| 1723 | + case Token.CLOSE_PARENS: | ||
| 1724 | + if (--parens_count <= 0) | ||
| 1725 | + return false; | ||
| 1726 | + continue; | ||
| 1727 | case Token.OP_GENERICS_GT: | ||
| 1728 | case Token.EOF: | ||
| 1729 | return false; | ||
| 1730 | @@ -1380,6 +1405,7 @@ namespace Mono.CSharp | ||
| 1731 | case Token.NEW: | ||
| 1732 | case Token.INTERPOLATED_STRING: | ||
| 1733 | case Token.THROW: | ||
| 1734 | + case Token.DEFAULT_COLON: | ||
| 1735 | next_token = Token.INTERR; | ||
| 1736 | break; | ||
| 1737 | |||
| 1738 | @@ -3502,6 +3528,7 @@ namespace Mono.CSharp | ||
| 1739 | case Token.SWITCH: | ||
| 1740 | case Token.USING: | ||
| 1741 | case Token.DEFAULT: | ||
| 1742 | + case Token.DEFAULT_VALUE: | ||
| 1743 | case Token.DELEGATE: | ||
| 1744 | case Token.OP_GENERICS_GT: | ||
| 1745 | case Token.REFVALUE: | ||
| 1746 | @@ -3963,26 +3990,29 @@ namespace Mono.CSharp | ||
| 1747 | { | ||
| 1748 | int d; | ||
| 1749 | |||
| 1750 | - // Save current position and parse next token. | ||
| 1751 | - PushPosition (); | ||
| 1752 | - int generic_dimension = 0; | ||
| 1753 | - if (parse_less_than (ref generic_dimension)) { | ||
| 1754 | - if (parsing_generic_declaration && (parsing_generic_declaration_doc || token () != Token.DOT)) { | ||
| 1755 | - d = Token.OP_GENERICS_LT_DECL; | ||
| 1756 | - } else { | ||
| 1757 | - if (generic_dimension > 0) { | ||
| 1758 | - val = generic_dimension; | ||
| 1759 | - DiscardPosition (); | ||
| 1760 | - return Token.GENERIC_DIMENSION; | ||
| 1761 | - } | ||
| 1762 | + if (current_token != Token.OPERATOR) { | ||
| 1763 | + // Save current position and parse next token. | ||
| 1764 | + PushPosition (); | ||
| 1765 | + int generic_dimension = 0; | ||
| 1766 | + if (parse_less_than (ref generic_dimension)) { | ||
| 1767 | + if (parsing_generic_declaration && (parsing_generic_declaration_doc || token () != Token.DOT)) { | ||
| 1768 | + d = Token.OP_GENERICS_LT_DECL; | ||
| 1769 | + } else { | ||
| 1770 | + if (generic_dimension > 0) { | ||
| 1771 | + val = generic_dimension; | ||
| 1772 | + DiscardPosition (); | ||
| 1773 | + return Token.GENERIC_DIMENSION; | ||
| 1774 | + } | ||
| 1775 | |||
| 1776 | - d = Token.OP_GENERICS_LT; | ||
| 1777 | + d = Token.OP_GENERICS_LT; | ||
| 1778 | + } | ||
| 1779 | + PopPosition (); | ||
| 1780 | + return d; | ||
| 1781 | } | ||
| 1782 | + | ||
| 1783 | PopPosition (); | ||
| 1784 | - return d; | ||
| 1785 | } | ||
| 1786 | |||
| 1787 | - PopPosition (); | ||
| 1788 | parsing_generic_less_than = 0; | ||
| 1789 | |||
| 1790 | d = peek_char (); | ||
| 1791 | diff --git a/mcs/mcs/delegate.cs b/mcs/mcs/delegate.cs | ||
| 1792 | index 80eb7e265f1..52cee8f3455 100644 | ||
| 1793 | --- a/mcs/mcs/delegate.cs | ||
| 1794 | +++ b/mcs/mcs/delegate.cs | ||
| 1795 | @@ -188,8 +188,8 @@ namespace Mono.CSharp { | ||
| 1796 | |||
| 1797 | CheckProtectedModifier (); | ||
| 1798 | |||
| 1799 | - if (Compiler.Settings.StdLib && ret_type.IsSpecialRuntimeType) { | ||
| 1800 | - Method.Error1599 (Location, ret_type, Report); | ||
| 1801 | + if (ret_type.IsSpecialRuntimeType && Compiler.Settings.StdLib) { | ||
| 1802 | + Method.Error_ReturnTypeCantBeRefAny (Location, ret_type, Report); | ||
| 1803 | return false; | ||
| 1804 | } | ||
| 1805 | |||
| 1806 | @@ -338,6 +338,8 @@ namespace Mono.CSharp { | ||
| 1807 | Module.PredefinedAttributes.Dynamic.EmitAttribute (CreateReturnBuilder ().Builder); | ||
| 1808 | } else if (rtype.HasDynamicElement) { | ||
| 1809 | Module.PredefinedAttributes.Dynamic.EmitAttribute (CreateReturnBuilder ().Builder, rtype, Location); | ||
| 1810 | + } else if (rtype is ReadOnlyReferenceContainer) { | ||
| 1811 | + Module.PredefinedAttributes.IsReadOnly.EmitAttribute (CreateReturnBuilder ().Builder); | ||
| 1812 | } | ||
| 1813 | |||
| 1814 | if (rtype.HasNamedTupleElement) { | ||
| 1815 | @@ -603,8 +605,14 @@ namespace Mono.CSharp { | ||
| 1816 | } | ||
| 1817 | |||
| 1818 | var expr = method_group.InstanceExpression; | ||
| 1819 | - if (expr != null && (expr.Type.IsGenericParameter || !TypeSpec.IsReferenceType (expr.Type))) | ||
| 1820 | + if (expr != null && (expr.Type.IsGenericParameter || !TypeSpec.IsReferenceType (expr.Type))) { | ||
| 1821 | + if (expr.Type.IsByRefLike || expr.Type.IsSpecialRuntimeType) { | ||
| 1822 | + // CSC: Should be better error code | ||
| 1823 | + Error_ConversionFailed (ec, delegate_method, null); | ||
| 1824 | + } | ||
| 1825 | + | ||
| 1826 | method_group.InstanceExpression = new BoxedCast (expr, ec.BuiltinTypes.Object); | ||
| 1827 | + } | ||
| 1828 | |||
| 1829 | eclass = ExprClass.Value; | ||
| 1830 | return this; | ||
| 1831 | diff --git a/mcs/mcs/dynamic.cs b/mcs/mcs/dynamic.cs | ||
| 1832 | index fd4662b2fed..f8314b2f3cd 100644 | ||
| 1833 | --- a/mcs/mcs/dynamic.cs | ||
| 1834 | +++ b/mcs/mcs/dynamic.cs | ||
| 1835 | @@ -279,11 +279,19 @@ namespace Mono.CSharp | ||
| 1836 | |||
| 1837 | protected bool DoResolveCore (ResolveContext rc) | ||
| 1838 | { | ||
| 1839 | + int i = 0; | ||
| 1840 | foreach (var arg in arguments) { | ||
| 1841 | if (arg.Type == InternalType.VarOutType) { | ||
| 1842 | // Should be special error message about dynamic dispatch | ||
| 1843 | rc.Report.Error (8197, arg.Expr.Location, "Cannot infer the type of implicitly-typed out variable `{0}'", ((DeclarationExpression) arg.Expr).Variable.Name); | ||
| 1844 | + } else if (arg.Type == InternalType.DefaultType) { | ||
| 1845 | + rc.Report.Error (8311, arg.Expr.Location, "Cannot use a default literal as an argument to a dynamically dispatched operation"); | ||
| 1846 | } | ||
| 1847 | + | ||
| 1848 | + // Forced limitation because Microsoft.CSharp needs to catch up | ||
| 1849 | + if (i > 0 && arguments [i - 1] is NamedArgument && !(arguments [i] is NamedArgument)) | ||
| 1850 | + rc.Report.Error (8324, loc, "Named argument specifications must appear after all fixed arguments have been specified in a dynamic invocation"); | ||
| 1851 | + ++i; | ||
| 1852 | } | ||
| 1853 | |||
| 1854 | if (rc.CurrentTypeParameters != null && rc.CurrentTypeParameters[0].IsMethodTypeParameter) | ||
| 1855 | diff --git a/mcs/mcs/ecore.cs b/mcs/mcs/ecore.cs | ||
| 1856 | index 34ff9a30dab..20ee9e73b19 100644 | ||
| 1857 | --- a/mcs/mcs/ecore.cs | ||
| 1858 | +++ b/mcs/mcs/ecore.cs | ||
| 1859 | @@ -255,7 +255,7 @@ namespace Mono.CSharp { | ||
| 1860 | |||
| 1861 | public void Error_ExpressionMustBeConstant (ResolveContext rc, Location loc, string e_name) | ||
| 1862 | { | ||
| 1863 | - rc.Report.Error (133, loc, "The expression being assigned to `{0}' must be constant", e_name); | ||
| 1864 | + rc.Report.Error (133, loc, "The expression being assigned to `{0}' must be a constant or default value", e_name); | ||
| 1865 | } | ||
| 1866 | |||
| 1867 | public void Error_ConstantCanBeInitializedWithNullOnly (ResolveContext rc, TypeSpec type, Location loc, string name) | ||
| 1868 | @@ -2957,6 +2957,13 @@ namespace Mono.CSharp { | ||
| 1869 | if ((restrictions & MemberLookupRestrictions.NameOfExcluded) == 0 && Name == "nameof") | ||
| 1870 | return new NameOf (this); | ||
| 1871 | |||
| 1872 | + if ((restrictions & MemberLookupRestrictions.ReadAccess) == 0 && Name == "_") { | ||
| 1873 | + if (rc.Module.Compiler.Settings.Version < LanguageVersion.V_7) | ||
| 1874 | + rc.Report.FeatureIsNotAvailable (rc.Module.Compiler, loc, "discards"); | ||
| 1875 | + | ||
| 1876 | + return new Discard (loc).Resolve (rc); | ||
| 1877 | + } | ||
| 1878 | + | ||
| 1879 | if (errorMode) { | ||
| 1880 | if (variable_found) { | ||
| 1881 | rc.Report.Error (841, loc, "A local variable `{0}' cannot be used before it is declared", Name); | ||
| 1882 | @@ -4029,6 +4036,13 @@ namespace Mono.CSharp { | ||
| 1883 | return Methods.First ().GetSignatureForError (); | ||
| 1884 | } | ||
| 1885 | |||
| 1886 | + static MethodSpec CandidateDevirtualization (TypeSpec type, MethodSpec method) | ||
| 1887 | + { | ||
| 1888 | + // Assumes no generics get involved | ||
| 1889 | + var filter = new MemberFilter (method.Name, method.Arity, MemberKind.Method, method.Parameters, null); | ||
| 1890 | + return MemberCache.FindMember (type, filter, BindingRestriction.InstanceOnly | BindingRestriction.OverrideOnly | BindingRestriction.DeclaredOnly) as MethodSpec; | ||
| 1891 | + } | ||
| 1892 | + | ||
| 1893 | public override Expression CreateExpressionTree (ResolveContext ec) | ||
| 1894 | { | ||
| 1895 | if (best_candidate == null) { | ||
| 1896 | @@ -4177,6 +4191,22 @@ namespace Mono.CSharp { | ||
| 1897 | } | ||
| 1898 | |||
| 1899 | InstanceExpression.Resolve (ec, ResolveFlags.VariableOrValue | ResolveFlags.MethodGroup | ResolveFlags.Type); | ||
| 1900 | + | ||
| 1901 | + var expr_type = InstanceExpression.Type; | ||
| 1902 | + if ((expr_type.IsByRefLike || expr_type.IsSpecialRuntimeType) && best_candidate.DeclaringType != expr_type) { | ||
| 1903 | + MethodSpec devirt = null; | ||
| 1904 | + if ((best_candidate.Modifiers & (Modifiers.VIRTUAL | Modifiers.ABSTRACT | Modifiers.OVERRIDE)) != 0) { | ||
| 1905 | + devirt = CandidateDevirtualization (expr_type, best_candidate); | ||
| 1906 | + } | ||
| 1907 | + | ||
| 1908 | + if (devirt == null) { | ||
| 1909 | + // CSC: Should be better error message | ||
| 1910 | + ec.Report.Error (29, InstanceExpression.Location, "Cannot implicitly convert type `{0}' to `{1}'", | ||
| 1911 | + InstanceExpression.Type.GetSignatureForError (), best_candidate.DeclaringType.GetSignatureForError ()); | ||
| 1912 | + } else { | ||
| 1913 | + best_candidate = devirt; | ||
| 1914 | + } | ||
| 1915 | + } | ||
| 1916 | } | ||
| 1917 | } | ||
| 1918 | |||
| 1919 | @@ -5419,7 +5449,7 @@ namespace Mono.CSharp { | ||
| 1920 | } | ||
| 1921 | |||
| 1922 | if (arg_type != parameter) { | ||
| 1923 | - if (arg_type == InternalType.VarOutType) | ||
| 1924 | + if (arg_type == InternalType.VarOutType || arg_type == InternalType.Discard) | ||
| 1925 | return 0; | ||
| 1926 | |||
| 1927 | var ref_arg_type = arg_type as ReferenceContainer; | ||
| 1928 | @@ -6028,6 +6058,11 @@ namespace Mono.CSharp { | ||
| 1929 | continue; | ||
| 1930 | } | ||
| 1931 | |||
| 1932 | + if (arg_type == InternalType.Discard) { | ||
| 1933 | + a.Expr.Type = pt; | ||
| 1934 | + continue; | ||
| 1935 | + } | ||
| 1936 | + | ||
| 1937 | var ref_arg_type = arg_type as ReferenceContainer; | ||
| 1938 | if (ref_arg_type != null) { | ||
| 1939 | if (ref_arg_type.Element != pt) | ||
| 1940 | @@ -6061,9 +6096,15 @@ namespace Mono.CSharp { | ||
| 1941 | else | ||
| 1942 | ec.Report.SymbolRelatedToPreviousError (member); | ||
| 1943 | |||
| 1944 | - ec.Report.Error (1744, na.Location, | ||
| 1945 | - "Named argument `{0}' cannot be used for a parameter which has positional argument specified", | ||
| 1946 | - na.Name); | ||
| 1947 | + if (name_index > a_idx) { | ||
| 1948 | + ec.Report.Error (8323, na.Location, | ||
| 1949 | + "Named argument `{0}' is used out of position but is followed by positional argument", | ||
| 1950 | + na.Name); | ||
| 1951 | + } else { | ||
| 1952 | + ec.Report.Error (1744, na.Location, | ||
| 1953 | + "Named argument `{0}' cannot be used for a parameter which has positional argument specified", | ||
| 1954 | + na.Name); | ||
| 1955 | + } | ||
| 1956 | } | ||
| 1957 | } | ||
| 1958 | |||
| 1959 | @@ -7350,6 +7391,9 @@ namespace Mono.CSharp { | ||
| 1960 | if (!ResolveGetter (ec)) | ||
| 1961 | return null; | ||
| 1962 | |||
| 1963 | + if (type.Kind == MemberKind.ByRef) | ||
| 1964 | + return ByRefDereference.Create (this).Resolve (ec); | ||
| 1965 | + | ||
| 1966 | return this; | ||
| 1967 | } | ||
| 1968 | |||
| 1969 | @@ -7359,12 +7403,11 @@ namespace Mono.CSharp { | ||
| 1970 | Error_NullPropagatingLValue (rc); | ||
| 1971 | |||
| 1972 | if (right_side == EmptyExpression.OutAccess) { | ||
| 1973 | - if (best_candidate?.MemberType.Kind == MemberKind.ByRef) { | ||
| 1974 | - if (Arguments?.ContainsEmitWithAwait () == true) { | ||
| 1975 | - rc.Report.Error (8178, loc, "`await' cannot be used in an expression containing a call to `{0}' because it returns by reference", | ||
| 1976 | - GetSignatureForError ()); | ||
| 1977 | - } | ||
| 1978 | + if (OverloadResolve (rc, null) == null) | ||
| 1979 | + return null; | ||
| 1980 | |||
| 1981 | + if (best_candidate?.MemberType.Kind == MemberKind.ByRef) { | ||
| 1982 | + getter = CandidateToBaseOverride (rc, best_candidate.Get); | ||
| 1983 | return this; | ||
| 1984 | } | ||
| 1985 | |||
| 1986 | @@ -7396,7 +7439,7 @@ namespace Mono.CSharp { | ||
| 1987 | |||
| 1988 | if (best_candidate.MemberType.Kind == MemberKind.ByRef) { | ||
| 1989 | getter = CandidateToBaseOverride (rc, best_candidate.Get); | ||
| 1990 | - return ByRefDereference.Create(this).Resolve(rc); | ||
| 1991 | + return ByRefDereference.Create (this).Resolve (rc); | ||
| 1992 | } | ||
| 1993 | |||
| 1994 | rc.Report.Error (200, loc, "Property or indexer `{0}' cannot be assigned to (it is read-only)", | ||
| 1995 | diff --git a/mcs/mcs/eval.cs b/mcs/mcs/eval.cs | ||
| 1996 | index 60e0c6d64a0..075697bb1df 100644 | ||
| 1997 | --- a/mcs/mcs/eval.cs | ||
| 1998 | +++ b/mcs/mcs/eval.cs | ||
| 1999 | @@ -788,6 +788,7 @@ namespace Mono.CSharp | ||
| 2000 | return null; | ||
| 2001 | } | ||
| 2002 | |||
| 2003 | + module.CloseContainerEarlyForReflectionEmit (); | ||
| 2004 | module.CloseContainer (); | ||
| 2005 | if (host != null) | ||
| 2006 | host.CloseContainer (); | ||
| 2007 | diff --git a/mcs/mcs/expression.cs b/mcs/mcs/expression.cs | ||
| 2008 | index 732ee3ee934..518ccc8ef43 100644 | ||
| 2009 | --- a/mcs/mcs/expression.cs | ||
| 2010 | +++ b/mcs/mcs/expression.cs | ||
| 2011 | @@ -1220,6 +1220,7 @@ namespace Mono.CSharp | ||
| 2012 | expr = expr.ResolveLValue (ec, expr); | ||
| 2013 | } else { | ||
| 2014 | ec.Report.Error (1059, loc, "The operand of an increment or decrement operator must be a variable, property or indexer"); | ||
| 2015 | + return null; | ||
| 2016 | } | ||
| 2017 | |||
| 2018 | // | ||
| 2019 | @@ -1477,6 +1478,11 @@ namespace Mono.CSharp | ||
| 2020 | return null; | ||
| 2021 | } | ||
| 2022 | |||
| 2023 | + if (expr.Type == InternalType.DefaultType) { | ||
| 2024 | + Error_OperatorCannotBeApplied (rc, loc, OperatorName, expr.Type); | ||
| 2025 | + return null; | ||
| 2026 | + } | ||
| 2027 | + | ||
| 2028 | return this; | ||
| 2029 | } | ||
| 2030 | |||
| 2031 | @@ -4304,9 +4310,32 @@ namespace Mono.CSharp | ||
| 2032 | CheckOutOfRangeComparison (ec, rc, left.Type); | ||
| 2033 | } | ||
| 2034 | |||
| 2035 | - if (left.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic || right.Type.BuiltinType == BuiltinTypeSpec.Type.Dynamic) | ||
| 2036 | + var ltype = left.Type; | ||
| 2037 | + var rtype = right.Type; | ||
| 2038 | + if (ltype.BuiltinType == BuiltinTypeSpec.Type.Dynamic || rtype.BuiltinType == BuiltinTypeSpec.Type.Dynamic) | ||
| 2039 | return DoResolveDynamic (ec); | ||
| 2040 | |||
| 2041 | + // | ||
| 2042 | + // Only default with == and != is explicitly allowed | ||
| 2043 | + // | ||
| 2044 | + if (ltype == InternalType.DefaultType || rtype == InternalType.DefaultType) { | ||
| 2045 | + if ((Oper & Operator.EqualityMask) == 0) { | ||
| 2046 | + ec.Report.Error (8310, loc, "Operator `{0}' cannot be applied to operand `default'", OperName (Oper)); | ||
| 2047 | + return null; | ||
| 2048 | + } | ||
| 2049 | + | ||
| 2050 | + if (ltype == rtype) { | ||
| 2051 | + ec.Report.Error (8315, loc, "Operator `{0}' is ambiguous on operands `default' and `default'", OperName (Oper)); | ||
| 2052 | + return null; | ||
| 2053 | + } | ||
| 2054 | + | ||
| 2055 | + if (rtype == InternalType.DefaultType) { | ||
| 2056 | + right = new DefaultValueExpression (new TypeExpression (ltype, right.Location), right.Location).Resolve (ec); | ||
| 2057 | + } else { | ||
| 2058 | + left = new DefaultValueExpression (new TypeExpression (rtype, left.Location), left.Location).Resolve (ec); | ||
| 2059 | + } | ||
| 2060 | + } | ||
| 2061 | + | ||
| 2062 | return DoResolveCore (ec, left, right); | ||
| 2063 | } | ||
| 2064 | |||
| 2065 | @@ -6744,10 +6773,14 @@ namespace Mono.CSharp | ||
| 2066 | ec.Report.Error (1764, loc, | ||
| 2067 | "Cannot use fixed variable `{0}' inside an anonymous method, lambda expression or query expression", | ||
| 2068 | GetSignatureForError ()); | ||
| 2069 | - } else if (local_info.IsByRef) { | ||
| 2070 | - ec.Report.Error (8175, loc, | ||
| 2071 | - "Cannot use by-reference variable `{0}' inside an anonymous method, lambda expression, or query expression", | ||
| 2072 | - GetSignatureForError ()); | ||
| 2073 | + } else if (local_info.IsByRef || local_info.Type.IsByRefLike) { | ||
| 2074 | + if (ec.CurrentAnonymousMethod is StateMachineInitializer) { | ||
| 2075 | + // It's reported later as 4012/4013 | ||
| 2076 | + } else { | ||
| 2077 | + ec.Report.Error (8175, loc, | ||
| 2078 | + "Cannot use by-reference variable `{0}' inside an anonymous method, lambda expression, or query expression", | ||
| 2079 | + GetSignatureForError ()); | ||
| 2080 | + } | ||
| 2081 | } | ||
| 2082 | |||
| 2083 | if (ec.IsVariableCapturingRequired) { | ||
| 2084 | @@ -6783,7 +6816,9 @@ namespace Mono.CSharp | ||
| 2085 | local_info.SetIsUsed (); | ||
| 2086 | |||
| 2087 | if (local_info.IsReadonly && !ec.HasAny (ResolveContext.Options.FieldInitializerScope | ResolveContext.Options.UsingInitializerScope)) { | ||
| 2088 | - if (rhs == EmptyExpression.LValueMemberAccess) { | ||
| 2089 | + if (local_info.IsByRef) { | ||
| 2090 | + // OK because it cannot be reassigned | ||
| 2091 | + } else if (rhs == EmptyExpression.LValueMemberAccess) { | ||
| 2092 | // CS1654 already reported | ||
| 2093 | } else { | ||
| 2094 | int code; | ||
| 2095 | @@ -7175,8 +7210,7 @@ namespace Mono.CSharp | ||
| 2096 | { | ||
| 2097 | var sn = expr as SimpleName; | ||
| 2098 | if (sn != null && sn.Name == "var" && sn.Arity == 0 && arguments?.Count > 1) { | ||
| 2099 | - var targets = new List<Expression> (arguments.Count); | ||
| 2100 | - var variables = new List<LocalVariable> (arguments.Count); | ||
| 2101 | + var variables = new List<BlockVariable> (arguments.Count); | ||
| 2102 | foreach (var arg in arguments) { | ||
| 2103 | var arg_sn = arg.Expr as SimpleName; | ||
| 2104 | if (arg_sn == null || arg_sn.Arity != 0) { | ||
| 2105 | @@ -7186,12 +7220,10 @@ namespace Mono.CSharp | ||
| 2106 | |||
| 2107 | var lv = new LocalVariable (rc.CurrentBlock, arg_sn.Name, arg.Expr.Location); | ||
| 2108 | rc.CurrentBlock.AddLocalName (lv); | ||
| 2109 | - variables.Add (lv); | ||
| 2110 | - | ||
| 2111 | - targets.Add (new LocalVariableReference (lv, arg_sn.Location)); | ||
| 2112 | + variables.Add (new BlockVariable (new VarExpr (lv.Location), lv)); | ||
| 2113 | } | ||
| 2114 | |||
| 2115 | - var res = new TupleDeconstruct (targets, variables, right_side, loc); | ||
| 2116 | + var res = new TupleDeconstruct (variables, right_side, loc); | ||
| 2117 | return res.Resolve (rc); | ||
| 2118 | } | ||
| 2119 | |||
| 2120 | @@ -7306,15 +7338,8 @@ namespace Mono.CSharp | ||
| 2121 | |||
| 2122 | eclass = ExprClass.Value; | ||
| 2123 | |||
| 2124 | - if (type.Kind == MemberKind.ByRef) { | ||
| 2125 | - if (rhs == null && arguments?.ContainsEmitWithAwait () == true) { | ||
| 2126 | - ec.Report.Error (8178, loc, "`await' cannot be used in an expression containing a call to `{0}' because it returns by reference", | ||
| 2127 | - GetSignatureForError ()); | ||
| 2128 | - } | ||
| 2129 | - | ||
| 2130 | - if (rhs != EmptyExpression.OutAccess) | ||
| 2131 | - return ByRefDereference.Create (this).Resolve (ec); | ||
| 2132 | - } | ||
| 2133 | + if (type.Kind == MemberKind.ByRef && rhs != EmptyExpression.OutAccess) | ||
| 2134 | + return ByRefDereference.Create (this).Resolve (ec); | ||
| 2135 | |||
| 2136 | return this; | ||
| 2137 | } | ||
| 2138 | @@ -9034,7 +9059,7 @@ namespace Mono.CSharp | ||
| 2139 | if (eclass == ExprClass.Unresolved) | ||
| 2140 | ResolveBase (ec); | ||
| 2141 | |||
| 2142 | - if (type.IsClass || type.IsReadOnly) { | ||
| 2143 | + if (type.IsClass || (type.IsReadOnly && !ec.HasSet (ResolveContext.Options.ConstructorScope))) { | ||
| 2144 | if (right_side == EmptyExpression.UnaryAddress) | ||
| 2145 | ec.Report.Error (459, loc, "Cannot take the address of `this' because it is read-only"); | ||
| 2146 | else if (right_side == EmptyExpression.OutAccess) | ||
| 2147 | @@ -9908,7 +9933,7 @@ namespace Mono.CSharp | ||
| 2148 | public static bool IsValidDotExpression (TypeSpec type) | ||
| 2149 | { | ||
| 2150 | const MemberKind dot_kinds = MemberKind.Class | MemberKind.Struct | MemberKind.Delegate | MemberKind.Enum | | ||
| 2151 | - MemberKind.Interface | MemberKind.TypeParameter | MemberKind.ArrayType; | ||
| 2152 | + MemberKind.Interface | MemberKind.TypeParameter | MemberKind.ArrayType | MemberKind.ByRef; | ||
| 2153 | |||
| 2154 | return (type.Kind & dot_kinds) != 0 || type.BuiltinType == BuiltinTypeSpec.Type.Dynamic; | ||
| 2155 | } | ||
| 2156 | @@ -11614,7 +11639,7 @@ namespace Mono.CSharp | ||
| 2157 | } | ||
| 2158 | |||
| 2159 | if (single_spec != null && single_spec.Dimension > 0) { | ||
| 2160 | - if (type.IsSpecialRuntimeType) { | ||
| 2161 | + if (type.IsSpecialRuntimeType || type.IsByRefLike) { | ||
| 2162 | ec.Module.Compiler.Report.Error (611, loc, "Array elements cannot be of type `{0}'", type.GetSignatureForError ()); | ||
| 2163 | } else if (type.IsStatic) { | ||
| 2164 | ec.Module.Compiler.Report.SymbolRelatedToPreviousError (type); | ||
| 2165 | @@ -11650,6 +11675,13 @@ namespace Mono.CSharp | ||
| 2166 | class ReferenceTypeExpr : TypeExpr | ||
| 2167 | { | ||
| 2168 | FullNamedExpression element; | ||
| 2169 | + readonly bool readOnly; | ||
| 2170 | + | ||
| 2171 | + public ReferenceTypeExpr (FullNamedExpression element, bool readOnly, Location loc) | ||
| 2172 | + : this (element, loc) | ||
| 2173 | + { | ||
| 2174 | + this.readOnly = readOnly; | ||
| 2175 | + } | ||
| 2176 | |||
| 2177 | public ReferenceTypeExpr (FullNamedExpression element, Location loc) | ||
| 2178 | { | ||
| 2179 | @@ -11664,14 +11696,17 @@ namespace Mono.CSharp | ||
| 2180 | return null; | ||
| 2181 | |||
| 2182 | eclass = ExprClass.Type; | ||
| 2183 | - type = ReferenceContainer.MakeType (mc.Module, type); | ||
| 2184 | + type = readOnly ? | ||
| 2185 | + ReadOnlyReferenceContainer.MakeType (mc.Module, type) : | ||
| 2186 | + ReferenceContainer.MakeType (mc.Module, type); | ||
| 2187 | |||
| 2188 | return type; | ||
| 2189 | } | ||
| 2190 | |||
| 2191 | public override string GetSignatureForError () | ||
| 2192 | { | ||
| 2193 | - return "ref " + element.GetSignatureForError (); | ||
| 2194 | + var prefix = readOnly ? "ref " : "ref readonly "; | ||
| 2195 | + return prefix + element.GetSignatureForError (); | ||
| 2196 | } | ||
| 2197 | |||
| 2198 | public override object Accept (StructuralVisitor visitor) | ||
| 2199 | @@ -11783,6 +11818,7 @@ namespace Mono.CSharp | ||
| 2200 | TypeSpec otype; | ||
| 2201 | Expression texpr; | ||
| 2202 | Expression count; | ||
| 2203 | + MethodSpec ctor; | ||
| 2204 | |||
| 2205 | public StackAlloc (Expression type, Expression count, Location l) | ||
| 2206 | { | ||
| 2207 | @@ -11852,6 +11888,11 @@ namespace Mono.CSharp | ||
| 2208 | int size = BuiltinTypeSpec.GetSize (otype); | ||
| 2209 | |||
| 2210 | count.Emit (ec); | ||
| 2211 | + bool count_on_stack = false; | ||
| 2212 | + if (ctor != null && !ExpressionAnalyzer.IsInexpensiveLoad (count)) { | ||
| 2213 | + ec.Emit (OpCodes.Dup); | ||
| 2214 | + count_on_stack = true; | ||
| 2215 | + } | ||
| 2216 | |||
| 2217 | if (size == 0) | ||
| 2218 | ec.Emit (OpCodes.Sizeof, otype); | ||
| 2219 | @@ -11860,6 +11901,19 @@ namespace Mono.CSharp | ||
| 2220 | |||
| 2221 | ec.Emit (OpCodes.Mul_Ovf_Un); | ||
| 2222 | ec.Emit (OpCodes.Localloc); | ||
| 2223 | + | ||
| 2224 | + if (ctor != null) { | ||
| 2225 | + if (!count_on_stack) | ||
| 2226 | + count.Emit (ec); | ||
| 2227 | + ec.Emit (OpCodes.Newobj, ctor); | ||
| 2228 | + } | ||
| 2229 | + } | ||
| 2230 | + | ||
| 2231 | + public override void Error_ValueCannotBeConverted (ResolveContext rc, TypeSpec target, bool expl) | ||
| 2232 | + { | ||
| 2233 | + var etype = ((PointerContainer)type).Element; | ||
| 2234 | + rc.Report.Error (8346, loc, "Cannot convert a stackalloc expression of type `{0}' to type `{1}'", | ||
| 2235 | + etype.GetSignatureForError (), target.GetSignatureForError ()); | ||
| 2236 | } | ||
| 2237 | |||
| 2238 | protected override void CloneTo (CloneContext clonectx, Expression t) | ||
| 2239 | @@ -11873,6 +11927,16 @@ namespace Mono.CSharp | ||
| 2240 | { | ||
| 2241 | return visitor.Visit (this); | ||
| 2242 | } | ||
| 2243 | + | ||
| 2244 | + public bool ResolveSpanConversion (ResolveContext rc, TypeSpec spanType) | ||
| 2245 | + { | ||
| 2246 | + ctor = MemberCache.FindMember (spanType, MemberFilter.Constructor (ParametersCompiled.CreateFullyResolved (PointerContainer.MakeType (rc.Module, rc.Module.Compiler.BuiltinTypes.Void), rc.Module.Compiler.BuiltinTypes.Int)), BindingRestriction.DeclaredOnly) as MethodSpec; | ||
| 2247 | + if (ctor == null) | ||
| 2248 | + return false; | ||
| 2249 | + | ||
| 2250 | + this.type = spanType; | ||
| 2251 | + return true; | ||
| 2252 | + } | ||
| 2253 | } | ||
| 2254 | |||
| 2255 | // | ||
| 2256 | @@ -13093,6 +13157,12 @@ namespace Mono.CSharp | ||
| 2257 | expr.Emit (ec); | ||
| 2258 | } | ||
| 2259 | |||
| 2260 | + public override Expression CreateExpressionTree (ResolveContext rc) | ||
| 2261 | + { | ||
| 2262 | + rc.Report.Error (8153, Location, "An expression tree lambda cannot contain a call to a method, property, or indexer that returns by reference"); | ||
| 2263 | + return null; | ||
| 2264 | + } | ||
| 2265 | + | ||
| 2266 | public void Emit (EmitContext ec, bool leave_copy) | ||
| 2267 | { | ||
| 2268 | Emit (ec); | ||
| 2269 | @@ -13133,6 +13203,11 @@ namespace Mono.CSharp | ||
| 2270 | |||
| 2271 | public override Expression DoResolveLValue (ResolveContext rc, Expression right_side) | ||
| 2272 | { | ||
| 2273 | + if (expr.ContainsEmitWithAwait ()) { | ||
| 2274 | + rc.Report.Error (8178, loc, "`await' cannot be used in an expression containing a call to `{0}' because it returns by reference", | ||
| 2275 | + expr.GetSignatureForError ()); | ||
| 2276 | + } | ||
| 2277 | + | ||
| 2278 | return DoResolve (rc); | ||
| 2279 | } | ||
| 2280 | |||
| 2281 | @@ -13149,4 +13224,98 @@ namespace Mono.CSharp | ||
| 2282 | return visitor.Visit (this); | ||
| 2283 | } | ||
| 2284 | } | ||
| 2285 | + | ||
| 2286 | + class DefaultLiteralExpression : Expression | ||
| 2287 | + { | ||
| 2288 | + public DefaultLiteralExpression (Location loc) | ||
| 2289 | + { | ||
| 2290 | + this.loc = loc; | ||
| 2291 | + } | ||
| 2292 | + | ||
| 2293 | + public override Expression CreateExpressionTree (ResolveContext ec) | ||
| 2294 | + { | ||
| 2295 | + throw new NotImplementedException (); | ||
| 2296 | + } | ||
| 2297 | + | ||
| 2298 | + protected override Expression DoResolve (ResolveContext rc) | ||
| 2299 | + { | ||
| 2300 | + type = InternalType.DefaultType; | ||
| 2301 | + eclass = ExprClass.Value; | ||
| 2302 | + return this; | ||
| 2303 | + } | ||
| 2304 | + | ||
| 2305 | + public override void Emit (EmitContext ec) | ||
| 2306 | + { | ||
| 2307 | + throw new NotSupportedException (); | ||
| 2308 | + } | ||
| 2309 | + } | ||
| 2310 | + | ||
| 2311 | + class Discard : Expression, IAssignMethod, IMemoryLocation | ||
| 2312 | + { | ||
| 2313 | + public Discard (Location loc) | ||
| 2314 | + { | ||
| 2315 | + this.loc = loc; | ||
| 2316 | + } | ||
| 2317 | + | ||
| 2318 | + public override Expression CreateExpressionTree (ResolveContext rc) | ||
| 2319 | + { | ||
| 2320 | + rc.Report.Error (8207, loc, "An expression tree cannot contain a discard"); | ||
| 2321 | + return null; | ||
| 2322 | + } | ||
| 2323 | + | ||
| 2324 | + protected override Expression DoResolve (ResolveContext rc) | ||
| 2325 | + { | ||
| 2326 | + type = InternalType.Discard; | ||
| 2327 | + eclass = ExprClass.Variable; | ||
| 2328 | + return this; | ||
| 2329 | + } | ||
| 2330 | + | ||
| 2331 | + public override Expression DoResolveLValue (ResolveContext rc, Expression right_side) | ||
| 2332 | + { | ||
| 2333 | + if (right_side.Type == InternalType.DefaultType) { | ||
| 2334 | + rc.Report.Error (8183, loc, "Cannot infer the type of implicitly-typed discard"); | ||
| 2335 | + type = InternalType.ErrorType; | ||
| 2336 | + return this; | ||
| 2337 | + } | ||
| 2338 | + | ||
| 2339 | + if (right_side.Type.Kind == MemberKind.Void) { | ||
| 2340 | + rc.Report.Error (8209, loc, "Cannot assign void to a discard"); | ||
| 2341 | + type = InternalType.ErrorType; | ||
| 2342 | + return this; | ||
| 2343 | + } | ||
| 2344 | + | ||
| 2345 | + if (right_side != EmptyExpression.OutAccess) { | ||
| 2346 | + type = right_side.Type; | ||
| 2347 | + } | ||
| 2348 | + | ||
| 2349 | + return this; | ||
| 2350 | + } | ||
| 2351 | + | ||
| 2352 | + public override void Emit (EmitContext ec) | ||
| 2353 | + { | ||
| 2354 | + throw new NotImplementedException (); | ||
| 2355 | + } | ||
| 2356 | + | ||
| 2357 | + public void Emit (EmitContext ec, bool leave_copy) | ||
| 2358 | + { | ||
| 2359 | + throw new NotImplementedException (); | ||
| 2360 | + } | ||
| 2361 | + | ||
| 2362 | + public void EmitAssign (EmitContext ec, Expression source, bool leave_copy, bool isCompound) | ||
| 2363 | + { | ||
| 2364 | + if (leave_copy) | ||
| 2365 | + source.Emit (ec); | ||
| 2366 | + else | ||
| 2367 | + source.EmitSideEffect (ec); | ||
| 2368 | + } | ||
| 2369 | + | ||
| 2370 | + public void AddressOf (EmitContext ec, AddressOp mode) | ||
| 2371 | + { | ||
| 2372 | + var temp = ec.GetTemporaryLocal (type); | ||
| 2373 | + ec.Emit (OpCodes.Ldloca, temp); | ||
| 2374 | + | ||
| 2375 | + // TODO: Should free it on next statement but don't have mechanism for that yet | ||
| 2376 | + // ec.FreeTemporaryLocal (temp, type); | ||
| 2377 | + } | ||
| 2378 | + } | ||
| 2379 | } | ||
| 2380 | diff --git a/mcs/mcs/generic.cs b/mcs/mcs/generic.cs | ||
| 2381 | index 625cd0c773f..ec2965df63b 100644 | ||
| 2382 | --- a/mcs/mcs/generic.cs | ||
| 2383 | +++ b/mcs/mcs/generic.cs | ||
| 2384 | @@ -693,6 +693,11 @@ namespace Mono.CSharp { | ||
| 2385 | GetSignatureForError (), mc.GetSignatureForError (), input_variance, gtype_variance, parameters); | ||
| 2386 | } | ||
| 2387 | |||
| 2388 | + public TypeSpec GetAsyncMethodBuilder () | ||
| 2389 | + { | ||
| 2390 | + return null; | ||
| 2391 | + } | ||
| 2392 | + | ||
| 2393 | public TypeSpec GetAttributeCoClass () | ||
| 2394 | { | ||
| 2395 | return null; | ||
| 2396 | @@ -2292,7 +2297,7 @@ namespace Mono.CSharp { | ||
| 2397 | ok = false; | ||
| 2398 | } | ||
| 2399 | |||
| 2400 | - if (te.IsPointer || te.IsSpecialRuntimeType) { | ||
| 2401 | + if (te.IsPointer || te.IsSpecialRuntimeType || te.IsByRefLike) { | ||
| 2402 | ec.Module.Compiler.Report.Error (306, args[i].Location, | ||
| 2403 | "The type `{0}' may not be used as a type argument", | ||
| 2404 | te.GetSignatureForError ()); | ||
| 2405 | @@ -3102,7 +3107,7 @@ namespace Mono.CSharp { | ||
| 2406 | // | ||
| 2407 | // Some types cannot be used as type arguments | ||
| 2408 | // | ||
| 2409 | - if ((bound.Type.Kind == MemberKind.Void && !voidAllowed) || bound.Type.IsPointer || bound.Type.IsSpecialRuntimeType || | ||
| 2410 | + if ((bound.Type.Kind == MemberKind.Void && !voidAllowed) || bound.Type.IsPointer || bound.Type.IsSpecialRuntimeType || bound.Type.IsByRefLike || | ||
| 2411 | bound.Type == InternalType.MethodGroup || bound.Type == InternalType.AnonymousMethod || bound.Type == InternalType.VarOutType || | ||
| 2412 | bound.Type == InternalType.ThrowExpr) | ||
| 2413 | return; | ||
| 2414 | @@ -3110,6 +3115,9 @@ namespace Mono.CSharp { | ||
| 2415 | if (bound.Type.IsTupleType && TupleLiteral.ContainsNoTypeElement (bound.Type)) | ||
| 2416 | return; | ||
| 2417 | |||
| 2418 | + if (bound.Type == InternalType.DefaultType) | ||
| 2419 | + return; | ||
| 2420 | + | ||
| 2421 | var a = bounds [index]; | ||
| 2422 | if (a == null) { | ||
| 2423 | a = new List<BoundInfo> (2); | ||
| 2424 | diff --git a/mcs/mcs/import.cs b/mcs/mcs/import.cs | ||
| 2425 | index 1cddf7c01f4..f7c4fd74b08 100644 | ||
| 2426 | --- a/mcs/mcs/import.cs | ||
| 2427 | +++ b/mcs/mcs/import.cs | ||
| 2428 | @@ -975,6 +975,10 @@ namespace Mono.CSharp | ||
| 2429 | mod |= Modifiers.READONLY; | ||
| 2430 | } | ||
| 2431 | |||
| 2432 | + if (HasAttribute (CustomAttributeData.GetCustomAttributes (type), "IsByRefLikeAttribute", CompilerServicesNamespace)) { | ||
| 2433 | + mod |= Modifiers.REF; | ||
| 2434 | + } | ||
| 2435 | + | ||
| 2436 | break; | ||
| 2437 | } | ||
| 2438 | } | ||
| 2439 | @@ -1401,6 +1405,7 @@ namespace Mono.CSharp | ||
| 2440 | public string DefaultIndexerName; | ||
| 2441 | public bool? CLSAttributeValue; | ||
| 2442 | public TypeSpec CoClass; | ||
| 2443 | + public TypeSpec AsyncMethodBuilder; | ||
| 2444 | |||
| 2445 | static bool HasMissingType (ConstructorInfo ctor) | ||
| 2446 | { | ||
| 2447 | @@ -1522,6 +1527,20 @@ namespace Mono.CSharp | ||
| 2448 | bag.CoClass = importer.ImportType ((MetaType) a.ConstructorArguments[0].Value); | ||
| 2449 | continue; | ||
| 2450 | } | ||
| 2451 | + | ||
| 2452 | + if (name == "AsyncMethodBuilderAttribute") { | ||
| 2453 | + if (dt.Namespace != "System.Runtime.CompilerServices") | ||
| 2454 | + continue; | ||
| 2455 | + | ||
| 2456 | + if (HasMissingType (a.Constructor)) | ||
| 2457 | + continue; | ||
| 2458 | + | ||
| 2459 | + if (bag == null) | ||
| 2460 | + bag = new AttributesBag (); | ||
| 2461 | + | ||
| 2462 | + bag.AsyncMethodBuilder = importer.ImportType ((MetaType)a.ConstructorArguments [0].Value); | ||
| 2463 | + continue; | ||
| 2464 | + } | ||
| 2465 | } | ||
| 2466 | } | ||
| 2467 | |||
| 2468 | @@ -2129,6 +2148,14 @@ namespace Mono.CSharp | ||
| 2469 | } | ||
| 2470 | } | ||
| 2471 | |||
| 2472 | + public TypeSpec GetAsyncMethodBuilder () | ||
| 2473 | + { | ||
| 2474 | + if (cattrs == null) | ||
| 2475 | + ReadAttributes (); | ||
| 2476 | + | ||
| 2477 | + return cattrs.AsyncMethodBuilder; | ||
| 2478 | + } | ||
| 2479 | + | ||
| 2480 | public TypeSpec GetAttributeCoClass () | ||
| 2481 | { | ||
| 2482 | if (cattrs == null) | ||
| 2483 | @@ -2445,6 +2472,11 @@ namespace Mono.CSharp | ||
| 2484 | |||
| 2485 | #endregion | ||
| 2486 | |||
| 2487 | + public TypeSpec GetAsyncMethodBuilder () | ||
| 2488 | + { | ||
| 2489 | + return null; | ||
| 2490 | + } | ||
| 2491 | + | ||
| 2492 | public TypeSpec GetAttributeCoClass () | ||
| 2493 | { | ||
| 2494 | return null; | ||
| 2495 | diff --git a/mcs/mcs/membercache.cs b/mcs/mcs/membercache.cs | ||
| 2496 | index eebf71b844b..ca05d2d7afc 100644 | ||
| 2497 | --- a/mcs/mcs/membercache.cs | ||
| 2498 | +++ b/mcs/mcs/membercache.cs | ||
| 2499 | @@ -309,7 +309,6 @@ namespace Mono.CSharp { | ||
| 2500 | // | ||
| 2501 | if (!BuiltinTypeSpec.IsPrimitiveType (dt) || dt.BuiltinType == BuiltinTypeSpec.Type.Char) { | ||
| 2502 | switch (dt.BuiltinType) { | ||
| 2503 | - case BuiltinTypeSpec.Type.String: | ||
| 2504 | case BuiltinTypeSpec.Type.Delegate: | ||
| 2505 | case BuiltinTypeSpec.Type.MulticastDelegate: | ||
| 2506 | break; | ||
| 2507 | @@ -317,6 +316,9 @@ namespace Mono.CSharp { | ||
| 2508 | if (name == Operator.GetMetadataName (Operator.OpType.Implicit) || name == Operator.GetMetadataName (Operator.OpType.Explicit)) { | ||
| 2509 | state |= StateFlags.HasConversionOperator; | ||
| 2510 | } else { | ||
| 2511 | + if (dt.BuiltinType == BuiltinTypeSpec.Type.String) | ||
| 2512 | + break; | ||
| 2513 | + | ||
| 2514 | state |= StateFlags.HasUserOperator; | ||
| 2515 | } | ||
| 2516 | |||
| 2517 | diff --git a/mcs/mcs/method.cs b/mcs/mcs/method.cs | ||
| 2518 | index ccd4898e91c..1fca10dd6d0 100644 | ||
| 2519 | --- a/mcs/mcs/method.cs | ||
| 2520 | +++ b/mcs/mcs/method.cs | ||
| 2521 | @@ -701,6 +701,10 @@ namespace Mono.CSharp { | ||
| 2522 | if (MemberType.IsStatic) { | ||
| 2523 | Error_StaticReturnType (); | ||
| 2524 | } | ||
| 2525 | + | ||
| 2526 | + if (MemberType.IsSpecialRuntimeType && Compiler.Settings.StdLib) { | ||
| 2527 | + Error_ReturnTypeCantBeRefAny (Location, ReturnType, Report); | ||
| 2528 | + } | ||
| 2529 | } | ||
| 2530 | |||
| 2531 | public override void Emit () | ||
| 2532 | @@ -716,6 +720,8 @@ namespace Mono.CSharp { | ||
| 2533 | Module.PredefinedAttributes.Dynamic.EmitAttribute (CreateReturnBuilder ().Builder); | ||
| 2534 | } else if (ReturnType.HasDynamicElement) { | ||
| 2535 | Module.PredefinedAttributes.Dynamic.EmitAttribute (CreateReturnBuilder ().Builder, ReturnType, Location); | ||
| 2536 | + } else if (ReturnType is ReadOnlyReferenceContainer) { | ||
| 2537 | + Module.PredefinedAttributes.IsReadOnly.EmitAttribute (CreateReturnBuilder ().Builder); | ||
| 2538 | } | ||
| 2539 | |||
| 2540 | if (ReturnType.HasNamedTupleElement) { | ||
| 2541 | @@ -764,6 +770,11 @@ namespace Mono.CSharp { | ||
| 2542 | GetSignatureForError ()); | ||
| 2543 | } | ||
| 2544 | |||
| 2545 | + public static void Error_ReturnTypeCantBeRefAny (Location loc, TypeSpec t, Report Report) | ||
| 2546 | + { | ||
| 2547 | + Report.Error (1599, loc, "The return type of `{0}' is not allowed", t.GetSignatureForError ()); | ||
| 2548 | + } | ||
| 2549 | + | ||
| 2550 | public bool IsPartialDefinition { | ||
| 2551 | get { | ||
| 2552 | return (ModFlags & Modifiers.PARTIAL) != 0 && Block == null; | ||
| 2553 | @@ -1231,11 +1242,6 @@ namespace Mono.CSharp { | ||
| 2554 | "Introducing `Finalize' method can interfere with destructor invocation. Did you intend to declare a destructor?"); | ||
| 2555 | } | ||
| 2556 | |||
| 2557 | - if (Compiler.Settings.StdLib && ReturnType.IsSpecialRuntimeType) { | ||
| 2558 | - Error1599 (Location, ReturnType, Report); | ||
| 2559 | - return false; | ||
| 2560 | - } | ||
| 2561 | - | ||
| 2562 | if (CurrentTypeParameters == null) { | ||
| 2563 | if (base_method != null && !IsExplicitImpl) { | ||
| 2564 | if (parameters.Count == 1 && ParameterTypes[0].BuiltinType == BuiltinTypeSpec.Type.Object && MemberName.Name == "Equals") | ||
| 2565 | @@ -1261,8 +1267,9 @@ namespace Mono.CSharp { | ||
| 2566 | if ((ModFlags & Modifiers.ASYNC) != 0) { | ||
| 2567 | if (ReturnType.Kind != MemberKind.Void && | ||
| 2568 | ReturnType != Module.PredefinedTypes.Task.TypeSpec && | ||
| 2569 | - !ReturnType.IsGenericTask) { | ||
| 2570 | - Report.Error (1983, Location, "The return type of an async method must be void, Task, or Task<T>"); | ||
| 2571 | + !ReturnType.IsGenericTask && | ||
| 2572 | + !ReturnType.IsCustomTaskType ()) { | ||
| 2573 | + Report.Error (1983, Location, "The return type of an async method must be void or task type"); | ||
| 2574 | } | ||
| 2575 | |||
| 2576 | block = (ToplevelBlock) block.ConvertToAsyncTask (this, Parent.PartialContainer, parameters, ReturnType, null, Location); | ||
| 2577 | @@ -1396,11 +1403,6 @@ namespace Mono.CSharp { | ||
| 2578 | return base.EnableOverloadChecks (overload); | ||
| 2579 | } | ||
| 2580 | |||
| 2581 | - public static void Error1599 (Location loc, TypeSpec t, Report Report) | ||
| 2582 | - { | ||
| 2583 | - Report.Error (1599, loc, "Method or delegate cannot return type `{0}'", t.GetSignatureForError ()); | ||
| 2584 | - } | ||
| 2585 | - | ||
| 2586 | protected override bool ResolveMemberType () | ||
| 2587 | { | ||
| 2588 | if (CurrentTypeParameters != null) { | ||
| 2589 | @@ -2467,6 +2469,8 @@ namespace Mono.CSharp { | ||
| 2590 | Module.PredefinedAttributes.Dynamic.EmitAttribute (CreateReturnBuilder ().Builder); | ||
| 2591 | } else if (ReturnType.HasDynamicElement) { | ||
| 2592 | Module.PredefinedAttributes.Dynamic.EmitAttribute (CreateReturnBuilder ().Builder, ReturnType, Location); | ||
| 2593 | + } else if (ReturnType is ReadOnlyReferenceContainer) { | ||
| 2594 | + Module.PredefinedAttributes.IsReadOnly.EmitAttribute (CreateReturnBuilder ().Builder); | ||
| 2595 | } | ||
| 2596 | |||
| 2597 | if (ReturnType.HasNamedTupleElement) { | ||
| 2598 | diff --git a/mcs/mcs/modifiers.cs b/mcs/mcs/modifiers.cs | ||
| 2599 | index bfae5985a03..926ab5d1848 100644 | ||
| 2600 | --- a/mcs/mcs/modifiers.cs | ||
| 2601 | +++ b/mcs/mcs/modifiers.cs | ||
| 2602 | @@ -53,6 +53,7 @@ namespace Mono.CSharp | ||
| 2603 | DEBUGGER_HIDDEN = 0x400000, | ||
| 2604 | DEBUGGER_STEP_THROUGH = 0x800000, | ||
| 2605 | AutoProperty = 0x1000000, | ||
| 2606 | + REF = 0x2000000, | ||
| 2607 | |||
| 2608 | AccessibilityMask = PUBLIC | PROTECTED | INTERNAL | PRIVATE, | ||
| 2609 | AllowedExplicitImplFlags = UNSAFE | EXTERN, | ||
| 2610 | diff --git a/mcs/mcs/module.cs b/mcs/mcs/module.cs | ||
| 2611 | index 00afac6c604..2293d825b36 100644 | ||
| 2612 | --- a/mcs/mcs/module.cs | ||
| 2613 | +++ b/mcs/mcs/module.cs | ||
| 2614 | @@ -265,6 +265,7 @@ namespace Mono.CSharp | ||
| 2615 | readonly Dictionary<ArrayContainer.TypeRankPair, ArrayContainer> array_types; | ||
| 2616 | readonly Dictionary<TypeSpec, PointerContainer> pointer_types; | ||
| 2617 | readonly Dictionary<TypeSpec, ReferenceContainer> reference_types; | ||
| 2618 | + readonly Dictionary<TypeSpec, ReadOnlyReferenceContainer> readonly_reference_types; | ||
| 2619 | readonly Dictionary<TypeSpec, MethodSpec> attrs_cache; | ||
| 2620 | readonly Dictionary<TypeSpec, AwaiterDefinition> awaiters; | ||
| 2621 | readonly Dictionary<TypeSpec, TypeInfo> type_info_cache; | ||
| 2622 | @@ -301,6 +302,7 @@ namespace Mono.CSharp | ||
| 2623 | array_types = new Dictionary<ArrayContainer.TypeRankPair, ArrayContainer> (); | ||
| 2624 | pointer_types = new Dictionary<TypeSpec, PointerContainer> (); | ||
| 2625 | reference_types = new Dictionary<TypeSpec, ReferenceContainer> (); | ||
| 2626 | + readonly_reference_types = new Dictionary<TypeSpec, ReadOnlyReferenceContainer> (); | ||
| 2627 | attrs_cache = new Dictionary<TypeSpec, MethodSpec> (); | ||
| 2628 | awaiters = new Dictionary<TypeSpec, AwaiterDefinition> (); | ||
| 2629 | type_info_cache = new Dictionary<TypeSpec, TypeInfo> (); | ||
| 2630 | @@ -427,6 +429,12 @@ namespace Mono.CSharp | ||
| 2631 | } | ||
| 2632 | } | ||
| 2633 | |||
| 2634 | + internal Dictionary<TypeSpec, ReadOnlyReferenceContainer> ReadonlyReferenceTypesCache { | ||
| 2635 | + get { | ||
| 2636 | + return readonly_reference_types; | ||
| 2637 | + } | ||
| 2638 | + } | ||
| 2639 | + | ||
| 2640 | internal Dictionary<TypeSpec, TypeInfo> TypeInfoCache { | ||
| 2641 | get { | ||
| 2642 | return type_info_cache; | ||
| 2643 | diff --git a/mcs/mcs/parameter.cs b/mcs/mcs/parameter.cs | ||
| 2644 | index 2bd2a498a91..cc10eee162b 100644 | ||
| 2645 | --- a/mcs/mcs/parameter.cs | ||
| 2646 | +++ b/mcs/mcs/parameter.cs | ||
| 2647 | @@ -1447,7 +1447,7 @@ namespace Mono.CSharp { | ||
| 2648 | |||
| 2649 | expr = Child; | ||
| 2650 | |||
| 2651 | - if (!(expr is Constant || expr is DefaultValueExpression || (expr is New && ((New) expr).IsGeneratedStructConstructor))) { | ||
| 2652 | + if (!(expr is Constant || expr is DefaultValueExpression || expr is DefaultLiteralExpression || (expr is New && ((New) expr).IsGeneratedStructConstructor))) { | ||
| 2653 | if (!(expr is ErrorExpression)) { | ||
| 2654 | rc.Report.Error (1736, Location, | ||
| 2655 | "The expression being assigned to optional parameter `{0}' must be a constant or default value", | ||
| 2656 | diff --git a/mcs/mcs/statement.cs b/mcs/mcs/statement.cs | ||
| 2657 | index 58ba2795e4b..9c51128548f 100644 | ||
| 2658 | --- a/mcs/mcs/statement.cs | ||
| 2659 | +++ b/mcs/mcs/statement.cs | ||
| 2660 | @@ -1160,7 +1160,8 @@ namespace Mono.CSharp { | ||
| 2661 | // | ||
| 2662 | if (ec.CurrentAnonymousMethod is AsyncInitializer) { | ||
| 2663 | var storey = (AsyncTaskStorey) ec.CurrentAnonymousMethod.Storey; | ||
| 2664 | - if (storey.ReturnType == ec.Module.PredefinedTypes.Task.TypeSpec) { | ||
| 2665 | + var s_return_type = storey.ReturnType; | ||
| 2666 | + if (s_return_type == ec.Module.PredefinedTypes.Task.TypeSpec) { | ||
| 2667 | // | ||
| 2668 | // Extra trick not to emit ret/leave inside awaiter body | ||
| 2669 | // | ||
| 2670 | @@ -1168,8 +1169,8 @@ namespace Mono.CSharp { | ||
| 2671 | return true; | ||
| 2672 | } | ||
| 2673 | |||
| 2674 | - if (storey.ReturnType.IsGenericTask) | ||
| 2675 | - block_return_type = storey.ReturnType.TypeArguments[0]; | ||
| 2676 | + if (s_return_type.IsGenericTask || (s_return_type.Arity == 1 && s_return_type.IsCustomTaskType ())) | ||
| 2677 | + block_return_type = s_return_type.TypeArguments[0]; | ||
| 2678 | } | ||
| 2679 | |||
| 2680 | if (ec.CurrentIterator != null) { | ||
| 2681 | @@ -1220,7 +1221,7 @@ namespace Mono.CSharp { | ||
| 2682 | return false; | ||
| 2683 | } | ||
| 2684 | |||
| 2685 | - if (!async_type.IsGenericTask) { | ||
| 2686 | + if (!async_type.IsGeneric) { | ||
| 2687 | if (this is ContextualReturn) | ||
| 2688 | return true; | ||
| 2689 | |||
| 2690 | @@ -2368,7 +2369,12 @@ namespace Mono.CSharp { | ||
| 2691 | if (initializer == null) | ||
| 2692 | return null; | ||
| 2693 | |||
| 2694 | - var c = initializer as Constant; | ||
| 2695 | + Constant c; | ||
| 2696 | + if (initializer.Type == InternalType.DefaultType) | ||
| 2697 | + c = New.Constantify (li.Type, initializer.Location); | ||
| 2698 | + else | ||
| 2699 | + c = initializer as Constant; | ||
| 2700 | + | ||
| 2701 | if (c == null) { | ||
| 2702 | initializer.Error_ExpressionMustBeConstant (bc, initializer.Location, li.Name); | ||
| 2703 | return null; | ||
| 2704 | @@ -2407,14 +2413,14 @@ namespace Mono.CSharp { | ||
| 2705 | AddressTaken = 1 << 2, | ||
| 2706 | CompilerGenerated = 1 << 3, | ||
| 2707 | Constant = 1 << 4, | ||
| 2708 | - ForeachVariable = 1 << 5, | ||
| 2709 | - FixedVariable = 1 << 6, | ||
| 2710 | - UsingVariable = 1 << 7, | ||
| 2711 | + ForeachVariable = 1 << 5 | ReadonlyMask, | ||
| 2712 | + FixedVariable = 1 << 6 | ReadonlyMask, | ||
| 2713 | + UsingVariable = 1 << 7 | ReadonlyMask, | ||
| 2714 | IsLocked = 1 << 8, | ||
| 2715 | SymbolFileHidden = 1 << 9, | ||
| 2716 | ByRef = 1 << 10, | ||
| 2717 | |||
| 2718 | - ReadonlyMask = ForeachVariable | FixedVariable | UsingVariable | ||
| 2719 | + ReadonlyMask = 1 << 20 | ||
| 2720 | } | ||
| 2721 | |||
| 2722 | TypeSpec type; | ||
| 2723 | @@ -2534,7 +2540,7 @@ namespace Mono.CSharp { | ||
| 2724 | |||
| 2725 | public bool IsFixed { | ||
| 2726 | get { | ||
| 2727 | - return (flags & Flags.FixedVariable) != 0; | ||
| 2728 | + return (flags & Flags.FixedVariable) == Flags.FixedVariable; | ||
| 2729 | } | ||
| 2730 | set { | ||
| 2731 | flags = value ? flags | Flags.FixedVariable : flags & ~Flags.FixedVariable; | ||
| 2732 | @@ -2672,7 +2678,7 @@ namespace Mono.CSharp { | ||
| 2733 | |||
| 2734 | public string GetReadOnlyContext () | ||
| 2735 | { | ||
| 2736 | - switch (flags & Flags.ReadonlyMask) { | ||
| 2737 | + switch (flags & (Flags.ForeachVariable | Flags.FixedVariable | Flags.UsingVariable)) { | ||
| 2738 | case Flags.FixedVariable: | ||
| 2739 | return "fixed variable"; | ||
| 2740 | case Flags.ForeachVariable: | ||
| 2741 | @@ -8191,7 +8197,9 @@ namespace Mono.CSharp { | ||
| 2742 | } | ||
| 2743 | |||
| 2744 | if (iface_candidate == null) { | ||
| 2745 | - if (expr.Type != InternalType.ErrorType) { | ||
| 2746 | + if (expr.Type == InternalType.DefaultType) { | ||
| 2747 | + rc.Report.Error (8312, loc, "Use of default literal is not valid in this context"); | ||
| 2748 | + } else if (expr.Type != InternalType.ErrorType) { | ||
| 2749 | rc.Report.Error (1579, loc, | ||
| 2750 | "foreach statement cannot operate on variables of type `{0}' because it does not contain a definition for `{1}' or is inaccessible", | ||
| 2751 | expr.Type.GetSignatureForError (), "GetEnumerator"); | ||
| 2752 | diff --git a/mcs/mcs/tuples.cs b/mcs/mcs/tuples.cs | ||
| 2753 | index bb7faf734df..901efdc9541 100644 | ||
| 2754 | --- a/mcs/mcs/tuples.cs | ||
| 2755 | +++ b/mcs/mcs/tuples.cs | ||
| 2756 | @@ -432,7 +432,7 @@ namespace Mono.CSharp | ||
| 2757 | { | ||
| 2758 | Expression source; | ||
| 2759 | List<Expression> targetExprs; | ||
| 2760 | - List<LocalVariable> variablesToInfer; | ||
| 2761 | + List<BlockVariable> variables; | ||
| 2762 | Expression instance; | ||
| 2763 | |||
| 2764 | public TupleDeconstruct (List<Expression> targetExprs, Expression source, Location loc) | ||
| 2765 | @@ -442,10 +442,11 @@ namespace Mono.CSharp | ||
| 2766 | this.loc = loc; | ||
| 2767 | } | ||
| 2768 | |||
| 2769 | - public TupleDeconstruct (List<Expression> targetExprs, List<LocalVariable> variables, Expression source, Location loc) | ||
| 2770 | - : this (targetExprs, source, loc) | ||
| 2771 | + public TupleDeconstruct (List<BlockVariable> variables, Expression source, Location loc) | ||
| 2772 | { | ||
| 2773 | - this.variablesToInfer = variables; | ||
| 2774 | + this.source = source; | ||
| 2775 | + this.variables = variables; | ||
| 2776 | + this.loc = loc; | ||
| 2777 | } | ||
| 2778 | |||
| 2779 | public override Expression CreateExpressionTree (ResolveContext ec) | ||
| 2780 | @@ -469,9 +470,18 @@ namespace Mono.CSharp | ||
| 2781 | var src_type = src.Type; | ||
| 2782 | |||
| 2783 | if (src_type.IsTupleType) { | ||
| 2784 | - if (src_type.Arity != targetExprs.Count) { | ||
| 2785 | + int target_count; | ||
| 2786 | + | ||
| 2787 | + if (targetExprs == null) { | ||
| 2788 | + target_count = variables.Count; | ||
| 2789 | + targetExprs = new List<Expression> (target_count); | ||
| 2790 | + } else { | ||
| 2791 | + target_count = targetExprs.Count; | ||
| 2792 | + } | ||
| 2793 | + | ||
| 2794 | + if (src_type.Arity != target_count) { | ||
| 2795 | rc.Report.Error (8132, loc, "Cannot deconstruct a tuple of `{0}' elements into `{1}' variables", | ||
| 2796 | - src_type.Arity.ToString (), targetExprs.Count.ToString ()); | ||
| 2797 | + src_type.Arity.ToString (CultureInfo.InvariantCulture), target_count.ToString (CultureInfo.InvariantCulture)); | ||
| 2798 | return null; | ||
| 2799 | } | ||
| 2800 | |||
| 2801 | @@ -482,27 +492,44 @@ namespace Mono.CSharp | ||
| 2802 | instance = expr_variable.CreateReferenceExpression (rc, loc); | ||
| 2803 | } | ||
| 2804 | |||
| 2805 | - for (int i = 0; i < targetExprs.Count; ++i) { | ||
| 2806 | + for (int i = 0; i < target_count; ++i) { | ||
| 2807 | var tle = src_type.TypeArguments [i]; | ||
| 2808 | |||
| 2809 | - var lv = variablesToInfer? [i]; | ||
| 2810 | - if (lv != null) { | ||
| 2811 | - if (InternalType.HasNoType (tle)) { | ||
| 2812 | - rc.Report.Error (8130, Location, "Cannot infer the type of implicitly-typed deconstruction variable `{0}'", lv.Name); | ||
| 2813 | - lv.Type = InternalType.ErrorType; | ||
| 2814 | + if (variables != null) { | ||
| 2815 | + var variable = variables [i].Variable; | ||
| 2816 | + | ||
| 2817 | + if (variable.Type == InternalType.Discard) { | ||
| 2818 | + variables [i] = null; | ||
| 2819 | + targetExprs.Add (EmptyExpressionStatement.Instance); | ||
| 2820 | continue; | ||
| 2821 | } | ||
| 2822 | |||
| 2823 | - lv.Type = tle; | ||
| 2824 | - lv.PrepareAssignmentAnalysis ((BlockContext) rc); | ||
| 2825 | - } | ||
| 2826 | + var variable_type = variables [i].TypeExpression; | ||
| 2827 | + | ||
| 2828 | + targetExprs.Add (new LocalVariableReference (variable, variable.Location)); | ||
| 2829 | + | ||
| 2830 | + if (variable_type is VarExpr) { | ||
| 2831 | + if (InternalType.HasNoType (tle)) { | ||
| 2832 | + rc.Report.Error (8130, Location, "Cannot infer the type of implicitly-typed deconstruction variable `{0}'", variable.Name); | ||
| 2833 | + tle = InternalType.ErrorType; | ||
| 2834 | + } | ||
| 2835 | |||
| 2836 | + variable.Type = tle; | ||
| 2837 | + } else { | ||
| 2838 | + variable.Type = variable_type.ResolveAsType (rc); | ||
| 2839 | + } | ||
| 2840 | + | ||
| 2841 | + variable.PrepareAssignmentAnalysis ((BlockContext)rc); | ||
| 2842 | + } | ||
| 2843 | |||
| 2844 | var element_src = tupleLiteral == null ? new MemberAccess (instance, NamedTupleSpec.GetElementPropertyName (i)) : tupleLiteral.Elements [i].Expr; | ||
| 2845 | targetExprs [i] = new SimpleAssign (targetExprs [i], element_src).Resolve (rc); | ||
| 2846 | } | ||
| 2847 | |||
| 2848 | eclass = ExprClass.Value; | ||
| 2849 | + | ||
| 2850 | + // TODO: The type is same only if there is no target element conversion | ||
| 2851 | + // var res = (/*byte*/ b, /*short*/ s) = (2, 4); | ||
| 2852 | type = src.Type; | ||
| 2853 | return this; | ||
| 2854 | } | ||
| 2855 | @@ -527,11 +554,24 @@ namespace Mono.CSharp | ||
| 2856 | |||
| 2857 | public override void Emit (EmitContext ec) | ||
| 2858 | { | ||
| 2859 | - throw new NotImplementedException (); | ||
| 2860 | + if (instance != null) | ||
| 2861 | + ((ExpressionStatement)source).EmitStatement (ec); | ||
| 2862 | + | ||
| 2863 | + foreach (ExpressionStatement expr in targetExprs) | ||
| 2864 | + expr.Emit (ec); | ||
| 2865 | + | ||
| 2866 | + var ctor = MemberCache.FindMember (type, MemberFilter.Constructor (null), BindingRestriction.DeclaredOnly | BindingRestriction.InstanceOnly) as MethodSpec; | ||
| 2867 | + ec.Emit (OpCodes.Newobj, ctor); | ||
| 2868 | } | ||
| 2869 | |||
| 2870 | public override void EmitStatement (EmitContext ec) | ||
| 2871 | { | ||
| 2872 | + if (variables != null) { | ||
| 2873 | + foreach (var lv in variables) { | ||
| 2874 | + lv?.Variable.CreateBuilder (ec); | ||
| 2875 | + } | ||
| 2876 | + } | ||
| 2877 | + | ||
| 2878 | if (instance != null) | ||
| 2879 | ((ExpressionStatement) source).EmitStatement (ec); | ||
| 2880 | |||
| 2881 | @@ -549,9 +589,6 @@ namespace Mono.CSharp | ||
| 2882 | if (leave_copy) | ||
| 2883 | throw new NotImplementedException (); | ||
| 2884 | |||
| 2885 | - foreach (var lv in variablesToInfer) | ||
| 2886 | - lv.CreateBuilder (ec); | ||
| 2887 | - | ||
| 2888 | EmitStatement (ec); | ||
| 2889 | } | ||
| 2890 | |||
| 2891 | @@ -563,11 +600,11 @@ namespace Mono.CSharp | ||
| 2892 | |||
| 2893 | public void SetGeneratedFieldAssigned (FlowAnalysisContext fc) | ||
| 2894 | { | ||
| 2895 | - if (variablesToInfer == null) | ||
| 2896 | + if (variables == null) | ||
| 2897 | return; | ||
| 2898 | |||
| 2899 | - foreach (var lv in variablesToInfer) | ||
| 2900 | - fc.SetVariableAssigned (lv.VariableInfo); | ||
| 2901 | + foreach (var lv in variables) | ||
| 2902 | + fc.SetVariableAssigned (lv.Variable.VariableInfo); | ||
| 2903 | } | ||
| 2904 | } | ||
| 2905 | } | ||
| 2906 | \ No newline at end of file | ||
| 2907 | diff --git a/mcs/mcs/typemanager.cs b/mcs/mcs/typemanager.cs | ||
| 2908 | index b6aff14e1c0..7a16cda2774 100644 | ||
| 2909 | --- a/mcs/mcs/typemanager.cs | ||
| 2910 | +++ b/mcs/mcs/typemanager.cs | ||
| 2911 | @@ -242,6 +242,7 @@ namespace Mono.CSharp | ||
| 2912 | |||
| 2913 | // C# 7.0 | ||
| 2914 | public readonly PredefinedType[] Tuples; | ||
| 2915 | + public readonly PredefinedType SpanGeneric; | ||
| 2916 | |||
| 2917 | public PredefinedTypes (ModuleContainer module) | ||
| 2918 | { | ||
| 2919 | @@ -301,6 +302,8 @@ namespace Mono.CSharp | ||
| 2920 | FormattableString = new PredefinedType (module, MemberKind.Class, "System", "FormattableString"); | ||
| 2921 | FormattableStringFactory = new PredefinedType (module, MemberKind.Class, "System.Runtime.CompilerServices", "FormattableStringFactory"); | ||
| 2922 | |||
| 2923 | + SpanGeneric = new PredefinedType (module, MemberKind.Struct, "System", "Span", 1); | ||
| 2924 | + | ||
| 2925 | // | ||
| 2926 | // Define types which are used for comparison. It does not matter | ||
| 2927 | // if they don't exist as no error report is needed | ||
| 2928 | @@ -348,6 +351,8 @@ namespace Mono.CSharp | ||
| 2929 | if (pt.Define ()) | ||
| 2930 | pt.TypeSpec.IsTupleType = true; | ||
| 2931 | } | ||
| 2932 | + | ||
| 2933 | + SpanGeneric.Define (); | ||
| 2934 | } | ||
| 2935 | } | ||
| 2936 | |||
| 2937 | @@ -430,6 +435,7 @@ namespace Mono.CSharp | ||
| 2938 | ArrayEmpty = new PredefinedMember<MethodSpec> (module, types.Array, | ||
| 2939 | MemberFilter.Method ("Empty", 1, ParametersCompiled.EmptyReadOnlyParameters, null)); | ||
| 2940 | |||
| 2941 | + // TODO: Must me static | ||
| 2942 | AsyncTaskMethodBuilderCreate = new PredefinedMember<MethodSpec> (module, types.AsyncTaskMethodBuilder, | ||
| 2943 | MemberFilter.Method ("Create", 0, ParametersCompiled.EmptyReadOnlyParameters, types.AsyncTaskMethodBuilder.TypeSpec)); | ||
| 2944 | |||
| 2945 | @@ -485,6 +491,7 @@ namespace Mono.CSharp | ||
| 2946 | AsyncTaskMethodBuilderTask = new PredefinedMember<PropertySpec> (module, types.AsyncTaskMethodBuilder, | ||
| 2947 | MemberFilter.Property ("Task", null)); | ||
| 2948 | |||
| 2949 | + // TODO: Must me static | ||
| 2950 | AsyncTaskMethodBuilderGenericCreate = new PredefinedMember<MethodSpec> (module, types.AsyncTaskMethodBuilderGeneric, | ||
| 2951 | MemberFilter.Method ("Create", 0, ParametersCompiled.EmptyReadOnlyParameters, types.AsyncVoidMethodBuilder.TypeSpec)); | ||
| 2952 | |||
| 2953 | @@ -542,6 +549,7 @@ namespace Mono.CSharp | ||
| 2954 | AsyncTaskMethodBuilderGenericTask = new PredefinedMember<PropertySpec> (module, types.AsyncTaskMethodBuilderGeneric, | ||
| 2955 | MemberFilter.Property ("Task", null)); | ||
| 2956 | |||
| 2957 | + // TODO: Must me static | ||
| 2958 | AsyncVoidMethodBuilderCreate = new PredefinedMember<MethodSpec> (module, types.AsyncVoidMethodBuilder, | ||
| 2959 | MemberFilter.Method ("Create", 0, ParametersCompiled.EmptyReadOnlyParameters, types.AsyncVoidMethodBuilder.TypeSpec)); | ||
| 2960 | |||
| 2961 | @@ -1006,9 +1014,6 @@ namespace Mono.CSharp | ||
| 2962 | |||
| 2963 | public T Resolve (Location loc) | ||
| 2964 | { | ||
| 2965 | - if (member != null) | ||
| 2966 | - return member; | ||
| 2967 | - | ||
| 2968 | if (Get () != null) | ||
| 2969 | return member; | ||
| 2970 | |||
| 2971 | diff --git a/mcs/mcs/typespec.cs b/mcs/mcs/typespec.cs | ||
| 2972 | index d14e1ead3e3..a58a0fe5178 100644 | ||
| 2973 | --- a/mcs/mcs/typespec.cs | ||
| 2974 | +++ b/mcs/mcs/typespec.cs | ||
| 2975 | @@ -225,6 +225,8 @@ namespace Mono.CSharp | ||
| 2976 | } | ||
| 2977 | } | ||
| 2978 | |||
| 2979 | + public bool IsByRefLike => (modifiers & Modifiers.REF) != 0; | ||
| 2980 | + | ||
| 2981 | // | ||
| 2982 | // Returns true for instances of System.Threading.Tasks.Task<T> | ||
| 2983 | // | ||
| 2984 | @@ -1452,6 +1454,7 @@ namespace Mono.CSharp | ||
| 2985 | int TypeParametersCount { get; } | ||
| 2986 | TypeParameterSpec[] TypeParameters { get; } | ||
| 2987 | |||
| 2988 | + TypeSpec GetAsyncMethodBuilder (); | ||
| 2989 | TypeSpec GetAttributeCoClass (); | ||
| 2990 | string GetAttributeDefaultMember (); | ||
| 2991 | AttributeUsageAttribute GetAttributeUsage (PredefinedAttribute pa); | ||
| 2992 | @@ -1461,6 +1464,29 @@ namespace Mono.CSharp | ||
| 2993 | |||
| 2994 | class InternalType : TypeSpec, ITypeDefinition | ||
| 2995 | { | ||
| 2996 | + sealed class InternalTypeAssembly : IAssemblyDefinition | ||
| 2997 | + { | ||
| 2998 | + public static readonly InternalTypeAssembly Instance = new InternalTypeAssembly (); | ||
| 2999 | + | ||
| 3000 | + public string FullName => throw new NotImplementedException (); | ||
| 3001 | + | ||
| 3002 | + public bool IsCLSCompliant => false; | ||
| 3003 | + | ||
| 3004 | + public bool IsMissing => false; | ||
| 3005 | + | ||
| 3006 | + public string Name => throw new NotImplementedException (); | ||
| 3007 | + | ||
| 3008 | + public byte [] GetPublicKeyToken () | ||
| 3009 | + { | ||
| 3010 | + throw new NotImplementedException (); | ||
| 3011 | + } | ||
| 3012 | + | ||
| 3013 | + public bool IsFriendAssemblyTo (IAssemblyDefinition assembly) | ||
| 3014 | + { | ||
| 3015 | + return false; | ||
| 3016 | + } | ||
| 3017 | + } | ||
| 3018 | + | ||
| 3019 | public static readonly InternalType AnonymousMethod = new InternalType ("anonymous method"); | ||
| 3020 | public static readonly InternalType Arglist = new InternalType ("__arglist"); | ||
| 3021 | public static readonly InternalType MethodGroup = new InternalType ("method group"); | ||
| 3022 | @@ -1470,6 +1496,8 @@ namespace Mono.CSharp | ||
| 3023 | public static readonly InternalType ErrorType = new InternalType ("<error>"); | ||
| 3024 | public static readonly InternalType VarOutType = new InternalType ("var out"); | ||
| 3025 | public static readonly InternalType ThrowExpr = new InternalType ("throw expression"); | ||
| 3026 | + public static readonly InternalType DefaultType = new InternalType ("default"); | ||
| 3027 | + public static readonly InternalType Discard = new InternalType ("discard"); | ||
| 3028 | |||
| 3029 | readonly string name; | ||
| 3030 | |||
| 3031 | @@ -1494,7 +1522,7 @@ namespace Mono.CSharp | ||
| 3032 | |||
| 3033 | IAssemblyDefinition ITypeDefinition.DeclaringAssembly { | ||
| 3034 | get { | ||
| 3035 | - throw new NotImplementedException (); | ||
| 3036 | + return InternalTypeAssembly.Instance; | ||
| 3037 | } | ||
| 3038 | } | ||
| 3039 | |||
| 3040 | @@ -1561,6 +1589,11 @@ namespace Mono.CSharp | ||
| 3041 | |||
| 3042 | #region ITypeDefinition Members | ||
| 3043 | |||
| 3044 | + TypeSpec ITypeDefinition.GetAsyncMethodBuilder () | ||
| 3045 | + { | ||
| 3046 | + return null; | ||
| 3047 | + } | ||
| 3048 | + | ||
| 3049 | TypeSpec ITypeDefinition.GetAttributeCoClass () | ||
| 3050 | { | ||
| 3051 | return null; | ||
| 3052 | @@ -1614,7 +1647,7 @@ namespace Mono.CSharp | ||
| 3053 | |||
| 3054 | public static bool HasNoType (TypeSpec type) | ||
| 3055 | { | ||
| 3056 | - return type == AnonymousMethod || type == MethodGroup || type == NullLiteral || type == ThrowExpr; | ||
| 3057 | + return type == AnonymousMethod || type == MethodGroup || type == NullLiteral || type == ThrowExpr || type == DefaultType; | ||
| 3058 | } | ||
| 3059 | } | ||
| 3060 | |||
| 3061 | @@ -1749,6 +1782,11 @@ namespace Mono.CSharp | ||
| 3062 | } | ||
| 3063 | } | ||
| 3064 | |||
| 3065 | + public TypeSpec GetAsyncMethodBuilder () | ||
| 3066 | + { | ||
| 3067 | + return null; | ||
| 3068 | + } | ||
| 3069 | + | ||
| 3070 | public TypeSpec GetAttributeCoClass () | ||
| 3071 | { | ||
| 3072 | return Element.MemberDefinition.GetAttributeCoClass (); | ||
| 3073 | @@ -1996,9 +2034,10 @@ namespace Mono.CSharp | ||
| 3074 | [System.Diagnostics.DebuggerDisplay("{DisplayDebugInfo()}")] | ||
| 3075 | class ReferenceContainer : ElementTypeSpec | ||
| 3076 | { | ||
| 3077 | - ReferenceContainer (TypeSpec element) | ||
| 3078 | + protected ReferenceContainer (TypeSpec element) | ||
| 3079 | : base (MemberKind.ByRef, element, null) | ||
| 3080 | { | ||
| 3081 | + cache = null; | ||
| 3082 | } | ||
| 3083 | |||
| 3084 | public override IList<TypeSpec> Interfaces { | ||
| 3085 | @@ -2039,6 +2078,39 @@ namespace Mono.CSharp | ||
| 3086 | |||
| 3087 | return pc; | ||
| 3088 | } | ||
| 3089 | + | ||
| 3090 | + protected override void InitializeMemberCache(bool onlyTypes) | ||
| 3091 | + { | ||
| 3092 | + cache = Element.MemberCache; | ||
| 3093 | + } | ||
| 3094 | + } | ||
| 3095 | + | ||
| 3096 | + [System.Diagnostics.DebuggerDisplay ("{DisplayDebugInfo()}")] | ||
| 3097 | + class ReadOnlyReferenceContainer : ReferenceContainer | ||
| 3098 | + { | ||
| 3099 | + public ReadOnlyReferenceContainer (TypeSpec element) | ||
| 3100 | + : base (element) | ||
| 3101 | + { | ||
| 3102 | + } | ||
| 3103 | + | ||
| 3104 | + string DisplayDebugInfo () | ||
| 3105 | + { | ||
| 3106 | + return "ref readonly " + GetSignatureForError (); | ||
| 3107 | + } | ||
| 3108 | + | ||
| 3109 | + public new static ReferenceContainer MakeType (ModuleContainer module, TypeSpec element) | ||
| 3110 | + { | ||
| 3111 | + if (element.Kind == MemberKind.ByRef) | ||
| 3112 | + throw new ArgumentException (); | ||
| 3113 | + | ||
| 3114 | + ReadOnlyReferenceContainer pc; | ||
| 3115 | + if (!module.ReadonlyReferenceTypesCache.TryGetValue (element, out pc)) { | ||
| 3116 | + pc = new ReadOnlyReferenceContainer (element); | ||
| 3117 | + module.ReadonlyReferenceTypesCache.Add (element, pc); | ||
| 3118 | + } | ||
| 3119 | + | ||
| 3120 | + return pc; | ||
| 3121 | + } | ||
| 3122 | } | ||
| 3123 | |||
| 3124 | class PointerContainer : ElementTypeSpec | ||
| 3125 | diff --git a/mcs/tests/gtest-409.cs b/mcs/tests/gtest-409.cs | ||
| 3126 | index 8db59d7e48d..606ae3685d1 100644 | ||
| 3127 | --- a/mcs/tests/gtest-409.cs | ||
| 3128 | +++ b/mcs/tests/gtest-409.cs | ||
| 3129 | @@ -1,3 +1,4 @@ | ||
| 3130 | +// Compiler options: -langversion:latest | ||
| 3131 | using System; | ||
| 3132 | |||
| 3133 | // | ||
| 3134 | @@ -175,6 +176,11 @@ public class ConditionalParsing | ||
| 3135 | var x = args ?.2f : -.2f; | ||
| 3136 | } | ||
| 3137 | |||
| 3138 | + void Test_23 (string args) | ||
| 3139 | + { | ||
| 3140 | + var x = args == null ? default : 1; | ||
| 3141 | + } | ||
| 3142 | + | ||
| 3143 | static void Helper<T> (T arg) | ||
| 3144 | { | ||
| 3145 | } | ||
| 3146 | diff --git a/mcs/tests/test-948.cs b/mcs/tests/test-948.cs | ||
| 3147 | new file mode 100644 | ||
| 3148 | index 00000000000..34b3ab9a0c4 | ||
| 3149 | --- /dev/null | ||
| 3150 | +++ b/mcs/tests/test-948.cs | ||
| 3151 | @@ -0,0 +1,16 @@ | ||
| 3152 | +// Compiler options: -langversion:7.2 -unsafe | ||
| 3153 | + | ||
| 3154 | +using System; | ||
| 3155 | + | ||
| 3156 | +class X | ||
| 3157 | +{ | ||
| 3158 | + public static void Main () | ||
| 3159 | + { | ||
| 3160 | + Span<int> stackSpan = stackalloc int[100]; | ||
| 3161 | + } | ||
| 3162 | + | ||
| 3163 | + unsafe void Foo () | ||
| 3164 | + { | ||
| 3165 | + | ||
| 3166 | + } | ||
| 3167 | +} | ||
| 3168 | \ No newline at end of file | ||
| 3169 | diff --git a/mcs/tests/test-async-94.cs b/mcs/tests/test-async-94.cs | ||
| 3170 | new file mode 100644 | ||
| 3171 | index 00000000000..ce9a30409bb | ||
| 3172 | --- /dev/null | ||
| 3173 | +++ b/mcs/tests/test-async-94.cs | ||
| 3174 | @@ -0,0 +1,127 @@ | ||
| 3175 | +using System; | ||
| 3176 | +using System.Threading.Tasks; | ||
| 3177 | +using System.Runtime.CompilerServices; | ||
| 3178 | + | ||
| 3179 | +[AsyncMethodBuilder (typeof(MyTaskMethodBuilder<>))] | ||
| 3180 | +class MyTask<T> | ||
| 3181 | +{ | ||
| 3182 | +} | ||
| 3183 | + | ||
| 3184 | +[AsyncMethodBuilder (typeof(MyTaskMethodBuilder))] | ||
| 3185 | +class MyTask | ||
| 3186 | +{ | ||
| 3187 | +} | ||
| 3188 | + | ||
| 3189 | +class MyTaskMethodBuilder | ||
| 3190 | +{ | ||
| 3191 | + public static MyTaskMethodBuilder Create() | ||
| 3192 | + { | ||
| 3193 | + return null; | ||
| 3194 | + } | ||
| 3195 | + | ||
| 3196 | + public MyTask Task { | ||
| 3197 | + get { | ||
| 3198 | + return null; | ||
| 3199 | + } | ||
| 3200 | + } | ||
| 3201 | + | ||
| 3202 | + public void SetException (Exception exception) | ||
| 3203 | + { | ||
| 3204 | + | ||
| 3205 | + } | ||
| 3206 | + | ||
| 3207 | + public void SetResult () | ||
| 3208 | + { | ||
| 3209 | + | ||
| 3210 | + } | ||
| 3211 | + | ||
| 3212 | + public void AwaitOnCompleted<TAwaiter, TStateMachine> (ref TAwaiter awaiter, ref TStateMachine stateMachine) where TAwaiter : INotifyCompletion where TStateMachine : IAsyncStateMachine | ||
| 3213 | + { | ||
| 3214 | + | ||
| 3215 | + } | ||
| 3216 | + | ||
| 3217 | + public void AwaitUnsafeOnCompleted<TAwaiter, TStateMachine> (ref TAwaiter awaiter, ref TStateMachine stateMachine) where TAwaiter : ICriticalNotifyCompletion where TStateMachine : IAsyncStateMachine | ||
| 3218 | + { | ||
| 3219 | + | ||
| 3220 | + } | ||
| 3221 | + | ||
| 3222 | + public void Start<TStateMachine> (ref TStateMachine stateMachine) where TStateMachine : IAsyncStateMachine | ||
| 3223 | + { | ||
| 3224 | + | ||
| 3225 | + } | ||
| 3226 | + | ||
| 3227 | + public void SetStateMachine (IAsyncStateMachine stateMachine) | ||
| 3228 | + { | ||
| 3229 | + | ||
| 3230 | + } | ||
| 3231 | +} | ||
| 3232 | + | ||
| 3233 | +class MyTaskMethodBuilder<T> | ||
| 3234 | +{ | ||
| 3235 | + public static MyTaskMethodBuilder<T> Create() | ||
| 3236 | + { | ||
| 3237 | + return null; | ||
| 3238 | + } | ||
| 3239 | + | ||
| 3240 | + public MyTask<T> Task { | ||
| 3241 | + get { | ||
| 3242 | + return null; | ||
| 3243 | + } | ||
| 3244 | + } | ||
| 3245 | + | ||
| 3246 | + public void SetException (Exception exception) | ||
| 3247 | + { | ||
| 3248 | + | ||
| 3249 | + } | ||
| 3250 | + | ||
| 3251 | + public void SetResult (T result) | ||
| 3252 | + { | ||
| 3253 | + | ||
| 3254 | + } | ||
| 3255 | + | ||
| 3256 | + public void AwaitOnCompleted<TAwaiter, TStateMachine> (ref TAwaiter awaiter, ref TStateMachine stateMachine) where TAwaiter : INotifyCompletion where TStateMachine : IAsyncStateMachine | ||
| 3257 | + { | ||
| 3258 | + | ||
| 3259 | + } | ||
| 3260 | + | ||
| 3261 | + public void AwaitUnsafeOnCompleted<TAwaiter, TStateMachine> (ref TAwaiter awaiter, ref TStateMachine stateMachine) where TAwaiter : ICriticalNotifyCompletion where TStateMachine : IAsyncStateMachine | ||
| 3262 | + { | ||
| 3263 | + | ||
| 3264 | + } | ||
| 3265 | + | ||
| 3266 | + public void Start<TStateMachine> (ref TStateMachine stateMachine) where TStateMachine : IAsyncStateMachine | ||
| 3267 | + { | ||
| 3268 | + | ||
| 3269 | + } | ||
| 3270 | + | ||
| 3271 | + public void SetStateMachine (IAsyncStateMachine stateMachine) | ||
| 3272 | + { | ||
| 3273 | + | ||
| 3274 | + } | ||
| 3275 | +} | ||
| 3276 | + | ||
| 3277 | +class X | ||
| 3278 | +{ | ||
| 3279 | + public async MyTask Test () | ||
| 3280 | + { | ||
| 3281 | + await Task.Delay (1); | ||
| 3282 | + } | ||
| 3283 | + | ||
| 3284 | + public async MyTask<int> Test2 () | ||
| 3285 | + { | ||
| 3286 | + await Task.Delay (1); | ||
| 3287 | + return 2; | ||
| 3288 | + } | ||
| 3289 | + | ||
| 3290 | + public async ValueTask<string> Test3 () | ||
| 3291 | + { | ||
| 3292 | + await Task.Delay (1); | ||
| 3293 | + return "as"; | ||
| 3294 | + } | ||
| 3295 | + | ||
| 3296 | + public static void Main () | ||
| 3297 | + { | ||
| 3298 | + var x = new X (); | ||
| 3299 | + var r1 = x.Test3 ().Result; | ||
| 3300 | + } | ||
| 3301 | +} | ||
| 3302 | \ No newline at end of file | ||
| 3303 | diff --git a/mcs/tests/test-default-01.cs b/mcs/tests/test-default-01.cs | ||
| 3304 | new file mode 100644 | ||
| 3305 | index 00000000000..823e33c451b | ||
| 3306 | --- /dev/null | ||
| 3307 | +++ b/mcs/tests/test-default-01.cs | ||
| 3308 | @@ -0,0 +1,52 @@ | ||
| 3309 | +// Compiler options: -langversion:latest | ||
| 3310 | + | ||
| 3311 | +static class X | ||
| 3312 | +{ | ||
| 3313 | + const int c1 = default; | ||
| 3314 | + const int c2 = default (int); | ||
| 3315 | + | ||
| 3316 | + public static void Main () | ||
| 3317 | + { | ||
| 3318 | + int a = default; | ||
| 3319 | + var b = (int) default; | ||
| 3320 | + const int c = default; | ||
| 3321 | + var d = new[] { 1, default }; | ||
| 3322 | + dynamic e = default; | ||
| 3323 | + int f = checked (default); | ||
| 3324 | + (int a, int b) g = (1, default); | ||
| 3325 | + var h = 1 != default; | ||
| 3326 | + var i = default == M4 (); | ||
| 3327 | + } | ||
| 3328 | + | ||
| 3329 | + static int M1 () | ||
| 3330 | + { | ||
| 3331 | + return default; | ||
| 3332 | + } | ||
| 3333 | + | ||
| 3334 | + static void M2 () | ||
| 3335 | + { | ||
| 3336 | + try { | ||
| 3337 | + throw new System.Exception (); | ||
| 3338 | + } catch (System.Exception) when (default) { | ||
| 3339 | + } | ||
| 3340 | + | ||
| 3341 | + if (default) { | ||
| 3342 | + } | ||
| 3343 | + } | ||
| 3344 | + | ||
| 3345 | + static void M3 (int x = default) | ||
| 3346 | + { | ||
| 3347 | + } | ||
| 3348 | + | ||
| 3349 | + static System.Func<int> M4 () | ||
| 3350 | + { | ||
| 3351 | + return () => default; | ||
| 3352 | + } | ||
| 3353 | +} | ||
| 3354 | +/* | ||
| 3355 | +enum E | ||
| 3356 | +{ | ||
| 3357 | + A = default, | ||
| 3358 | + B = default + 1 | ||
| 3359 | +} | ||
| 3360 | +*/ | ||
| 3361 | \ No newline at end of file | ||
| 3362 | diff --git a/mcs/tests/test-default-02.cs b/mcs/tests/test-default-02.cs | ||
| 3363 | new file mode 100644 | ||
| 3364 | index 00000000000..0039782e5f2 | ||
| 3365 | --- /dev/null | ||
| 3366 | +++ b/mcs/tests/test-default-02.cs | ||
| 3367 | @@ -0,0 +1,33 @@ | ||
| 3368 | +// Compiler options: -langversion:latest | ||
| 3369 | + | ||
| 3370 | +class C | ||
| 3371 | +{ | ||
| 3372 | + static void Main() | ||
| 3373 | + { | ||
| 3374 | + M (default, 1); | ||
| 3375 | + | ||
| 3376 | + M2 (default); | ||
| 3377 | + M2 (null); | ||
| 3378 | + | ||
| 3379 | + var res = Test (default); | ||
| 3380 | + } | ||
| 3381 | + | ||
| 3382 | + | ||
| 3383 | + static void M<T> (T x, T y) | ||
| 3384 | + { | ||
| 3385 | + } | ||
| 3386 | + | ||
| 3387 | + static void M2 (params object[] x) | ||
| 3388 | + { | ||
| 3389 | + } | ||
| 3390 | + | ||
| 3391 | + static byte[] Test (S<byte> x) | ||
| 3392 | + { | ||
| 3393 | + return null; | ||
| 3394 | + } | ||
| 3395 | +} | ||
| 3396 | + | ||
| 3397 | +struct S<T> | ||
| 3398 | +{ | ||
| 3399 | + | ||
| 3400 | +} | ||
| 3401 | \ No newline at end of file | ||
| 3402 | diff --git a/mcs/tests/test-discards-01.cs b/mcs/tests/test-discards-01.cs | ||
| 3403 | new file mode 100644 | ||
| 3404 | index 00000000000..54cf29779c6 | ||
| 3405 | --- /dev/null | ||
| 3406 | +++ b/mcs/tests/test-discards-01.cs | ||
| 3407 | @@ -0,0 +1,36 @@ | ||
| 3408 | +using System; | ||
| 3409 | + | ||
| 3410 | +class X | ||
| 3411 | +{ | ||
| 3412 | + public static void Main () | ||
| 3413 | + { | ||
| 3414 | + string s = null; | ||
| 3415 | + | ||
| 3416 | + _ = 1; | ||
| 3417 | + { | ||
| 3418 | + char _ = '4'; | ||
| 3419 | + } | ||
| 3420 | + | ||
| 3421 | + _ = TestValue (); | ||
| 3422 | + | ||
| 3423 | + _ = _ = s; | ||
| 3424 | + | ||
| 3425 | + byte k1; | ||
| 3426 | + var s1 = (k1, _) = (1, s); | ||
| 3427 | + | ||
| 3428 | + Func<object> l1 = () => _ = (_, _) = (1, s); | ||
| 3429 | + | ||
| 3430 | + TryGetValue (out _); | ||
| 3431 | + } | ||
| 3432 | + | ||
| 3433 | + static bool TryGetValue (out int arg) | ||
| 3434 | + { | ||
| 3435 | + arg = 3; | ||
| 3436 | + return true; | ||
| 3437 | + } | ||
| 3438 | + | ||
| 3439 | + static int TestValue () | ||
| 3440 | + { | ||
| 3441 | + return 4; | ||
| 3442 | + } | ||
| 3443 | +} | ||
| 3444 | \ No newline at end of file | ||
| 3445 | diff --git a/mcs/tests/test-named-11.cs b/mcs/tests/test-named-11.cs | ||
| 3446 | new file mode 100644 | ||
| 3447 | index 00000000000..a01d2883b9c | ||
| 3448 | --- /dev/null | ||
| 3449 | +++ b/mcs/tests/test-named-11.cs | ||
| 3450 | @@ -0,0 +1,13 @@ | ||
| 3451 | +// Compiler options: -langversion:7.2 | ||
| 3452 | + | ||
| 3453 | +class X | ||
| 3454 | +{ | ||
| 3455 | + public static void Main () | ||
| 3456 | + { | ||
| 3457 | + Test (arg: 1, ""); | ||
| 3458 | + } | ||
| 3459 | + | ||
| 3460 | + static void Test (int arg, string str) | ||
| 3461 | + { | ||
| 3462 | + } | ||
| 3463 | +} | ||
| 3464 | \ No newline at end of file | ||
| 3465 | diff --git a/mcs/tests/test-readonly-02.cs b/mcs/tests/test-readonly-02.cs | ||
| 3466 | new file mode 100644 | ||
| 3467 | index 00000000000..231b8cd8fda | ||
| 3468 | --- /dev/null | ||
| 3469 | +++ b/mcs/tests/test-readonly-02.cs | ||
| 3470 | @@ -0,0 +1,27 @@ | ||
| 3471 | +// Compiler options: -langversion:latest | ||
| 3472 | +using System; | ||
| 3473 | + | ||
| 3474 | +public delegate ref readonly int D (int x); | ||
| 3475 | + | ||
| 3476 | +class X | ||
| 3477 | +{ | ||
| 3478 | + public static void Main () | ||
| 3479 | + { | ||
| 3480 | + | ||
| 3481 | + } | ||
| 3482 | + | ||
| 3483 | + Guid g; | ||
| 3484 | + | ||
| 3485 | + ref readonly Guid TestMethod () | ||
| 3486 | + { | ||
| 3487 | + return ref g; | ||
| 3488 | + } | ||
| 3489 | + | ||
| 3490 | + ref readonly Guid TestProp { | ||
| 3491 | + get { | ||
| 3492 | + ref readonly var rg = ref g; | ||
| 3493 | + return ref rg; | ||
| 3494 | + } | ||
| 3495 | + } | ||
| 3496 | + | ||
| 3497 | +} | ||
| 3498 | \ No newline at end of file | ||
| 3499 | diff --git a/mcs/tests/test-readonly-03.cs b/mcs/tests/test-readonly-03.cs | ||
| 3500 | new file mode 100644 | ||
| 3501 | index 00000000000..14cb958b41a | ||
| 3502 | --- /dev/null | ||
| 3503 | +++ b/mcs/tests/test-readonly-03.cs | ||
| 3504 | @@ -0,0 +1,16 @@ | ||
| 3505 | +// Compiler options: -langversion:latest | ||
| 3506 | +using System; | ||
| 3507 | + | ||
| 3508 | +readonly struct S | ||
| 3509 | +{ | ||
| 3510 | + static S shared = new S (); | ||
| 3511 | + | ||
| 3512 | + public S (int arg) | ||
| 3513 | + { | ||
| 3514 | + this = shared; | ||
| 3515 | + } | ||
| 3516 | + | ||
| 3517 | + public static void Main () | ||
| 3518 | + { | ||
| 3519 | + } | ||
| 3520 | +} | ||
| 3521 | \ No newline at end of file | ||
| 3522 | diff --git a/mcs/tests/test-ref-07.cs b/mcs/tests/test-ref-07.cs | ||
| 3523 | new file mode 100644 | ||
| 3524 | index 00000000000..4aa16579752 | ||
| 3525 | --- /dev/null | ||
| 3526 | +++ b/mcs/tests/test-ref-07.cs | ||
| 3527 | @@ -0,0 +1,30 @@ | ||
| 3528 | +// Compiler options: -langversion:latest | ||
| 3529 | + | ||
| 3530 | +public readonly partial ref struct Test | ||
| 3531 | +{ | ||
| 3532 | + public static void Main () | ||
| 3533 | + { | ||
| 3534 | + var m = new Test (); | ||
| 3535 | + m.Method (); | ||
| 3536 | + } | ||
| 3537 | + | ||
| 3538 | + Test Method () | ||
| 3539 | + { | ||
| 3540 | + return new Test (); | ||
| 3541 | + } | ||
| 3542 | +} | ||
| 3543 | + | ||
| 3544 | +ref struct Second | ||
| 3545 | +{ | ||
| 3546 | + Test field; | ||
| 3547 | +} | ||
| 3548 | + | ||
| 3549 | +public abstract class P | ||
| 3550 | +{ | ||
| 3551 | + public abstract Test Span { get; } | ||
| 3552 | +} | ||
| 3553 | + | ||
| 3554 | +public interface II | ||
| 3555 | +{ | ||
| 3556 | + Test Span { get; } | ||
| 3557 | +} | ||
| 3558 | diff --git a/mcs/tests/test-ref-08.cs b/mcs/tests/test-ref-08.cs | ||
| 3559 | new file mode 100644 | ||
| 3560 | index 00000000000..f4ff50f4c5c | ||
| 3561 | --- /dev/null | ||
| 3562 | +++ b/mcs/tests/test-ref-08.cs | ||
| 3563 | @@ -0,0 +1,101 @@ | ||
| 3564 | +using System; | ||
| 3565 | + | ||
| 3566 | +namespace ClassLibrary1 | ||
| 3567 | +{ | ||
| 3568 | + public class C | ||
| 3569 | + { | ||
| 3570 | + | ||
| 3571 | + class B | ||
| 3572 | + { | ||
| 3573 | + int v; | ||
| 3574 | + public ref int this[int index] | ||
| 3575 | + { | ||
| 3576 | + get | ||
| 3577 | + { | ||
| 3578 | + return ref v; | ||
| 3579 | + } | ||
| 3580 | + } | ||
| 3581 | + } | ||
| 3582 | + | ||
| 3583 | + | ||
| 3584 | + class Gen<T> where T : struct | ||
| 3585 | + { | ||
| 3586 | + T v; | ||
| 3587 | + public ref T this[int index] | ||
| 3588 | + { | ||
| 3589 | + get | ||
| 3590 | + { | ||
| 3591 | + return ref v; | ||
| 3592 | + } | ||
| 3593 | + } | ||
| 3594 | + } | ||
| 3595 | + | ||
| 3596 | + struct Val | ||
| 3597 | + { | ||
| 3598 | + } | ||
| 3599 | + | ||
| 3600 | + class BB | ||
| 3601 | + { | ||
| 3602 | + Val v; | ||
| 3603 | + public ref Val this[int index] | ||
| 3604 | + { | ||
| 3605 | + get | ||
| 3606 | + { | ||
| 3607 | + return ref v; | ||
| 3608 | + } | ||
| 3609 | + } | ||
| 3610 | + } | ||
| 3611 | + | ||
| 3612 | + void MM () | ||
| 3613 | + { | ||
| 3614 | + var bbb = new BB(); | ||
| 3615 | + Val v1 = bbb[0]; | ||
| 3616 | + bbb[1] = v1; | ||
| 3617 | + | ||
| 3618 | + ref Val v2 = ref bbb[2]; | ||
| 3619 | + bbb[2] = v2; | ||
| 3620 | + } | ||
| 3621 | + | ||
| 3622 | + static int[] a = new int[1]; | ||
| 3623 | + public static void Main() | ||
| 3624 | + { | ||
| 3625 | + var bb = new B(); | ||
| 3626 | + int b = 1; | ||
| 3627 | + bb[0] = b; | ||
| 3628 | + a[0] = Add2(ref b, 2); | ||
| 3629 | + | ||
| 3630 | + var bbb = new BB(); | ||
| 3631 | + bbb[0] = new Val(); | ||
| 3632 | + | ||
| 3633 | + var v = new Val(); | ||
| 3634 | + bbb[1] = v; | ||
| 3635 | + | ||
| 3636 | + var v2 = bbb[2]; | ||
| 3637 | + | ||
| 3638 | + bbb[3] = v2; | ||
| 3639 | + | ||
| 3640 | + | ||
| 3641 | + bbb[3] = bbb[2]; | ||
| 3642 | + | ||
| 3643 | + | ||
| 3644 | + | ||
| 3645 | + var ggg = new Gen<Val>(); | ||
| 3646 | + ggg[0] = new Val(); | ||
| 3647 | + | ||
| 3648 | + var g = new Val(); | ||
| 3649 | + ggg[1] = v; | ||
| 3650 | + | ||
| 3651 | + var g2 = ggg[2]; | ||
| 3652 | + | ||
| 3653 | + ggg[3] = v2; | ||
| 3654 | + | ||
| 3655 | + | ||
| 3656 | + ggg[3] = ggg[2]; | ||
| 3657 | + } | ||
| 3658 | + | ||
| 3659 | + public static ref int Add2(ref int a, int b) | ||
| 3660 | + { | ||
| 3661 | + return ref a; | ||
| 3662 | + } | ||
| 3663 | + } | ||
| 3664 | +} | ||
| 3665 | \ No newline at end of file | ||
| 3666 | diff --git a/mcs/tests/test-ref-09.cs b/mcs/tests/test-ref-09.cs | ||
| 3667 | new file mode 100644 | ||
| 3668 | index 00000000000..5d0e89e5c1a | ||
| 3669 | --- /dev/null | ||
| 3670 | +++ b/mcs/tests/test-ref-09.cs | ||
| 3671 | @@ -0,0 +1,12 @@ | ||
| 3672 | +struct rigidbody { public float x; } | ||
| 3673 | + | ||
| 3674 | +class Program | ||
| 3675 | +{ | ||
| 3676 | + static rigidbody a; | ||
| 3677 | + static ref rigidbody property_returning_struct_by_ref => ref a; | ||
| 3678 | + | ||
| 3679 | + static void Main() | ||
| 3680 | + { | ||
| 3681 | + System.Console.WriteLine (property_returning_struct_by_ref.x); | ||
| 3682 | + } | ||
| 3683 | +} | ||
| 3684 | \ No newline at end of file | ||
| 3685 | diff --git a/mcs/tests/test-ref-10.cs b/mcs/tests/test-ref-10.cs | ||
| 3686 | new file mode 100644 | ||
| 3687 | index 00000000000..88e201d3174 | ||
| 3688 | --- /dev/null | ||
| 3689 | +++ b/mcs/tests/test-ref-10.cs | ||
| 3690 | @@ -0,0 +1,24 @@ | ||
| 3691 | +// Compiler options: -langversion:latest | ||
| 3692 | + | ||
| 3693 | +using System; | ||
| 3694 | + | ||
| 3695 | +ref struct ValueStringBuilder | ||
| 3696 | +{ | ||
| 3697 | + public override string ToString () | ||
| 3698 | + { | ||
| 3699 | + return "aaa"; | ||
| 3700 | + } | ||
| 3701 | +} | ||
| 3702 | + | ||
| 3703 | + | ||
| 3704 | +class X | ||
| 3705 | +{ | ||
| 3706 | + public static int Main () | ||
| 3707 | + { | ||
| 3708 | + var s = new ValueStringBuilder (); | ||
| 3709 | + if (s.ToString () != "aaa") | ||
| 3710 | + return 1; | ||
| 3711 | + | ||
| 3712 | + return 0; | ||
| 3713 | + } | ||
| 3714 | +} | ||
| 3715 | \ No newline at end of file | ||
| 3716 | diff --git a/mcs/tests/test-tuple-07.cs b/mcs/tests/test-tuple-07.cs | ||
| 3717 | new file mode 100644 | ||
| 3718 | index 00000000000..cc7ce5837ce | ||
| 3719 | --- /dev/null | ||
| 3720 | +++ b/mcs/tests/test-tuple-07.cs | ||
| 3721 | @@ -0,0 +1,16 @@ | ||
| 3722 | +using System; | ||
| 3723 | +using System.Collections.Generic; | ||
| 3724 | + | ||
| 3725 | +// Parser tests | ||
| 3726 | + | ||
| 3727 | +class ParserTest | ||
| 3728 | +{ | ||
| 3729 | + IEnumerable<(Object vertex, int distance)> Test () | ||
| 3730 | + { | ||
| 3731 | + return null; | ||
| 3732 | + } | ||
| 3733 | + | ||
| 3734 | + public static void Main () | ||
| 3735 | + { | ||
| 3736 | + } | ||
| 3737 | +} | ||
| 3738 | \ No newline at end of file | ||
| 3739 | diff --git a/mcs/tests/test-tuple-09.cs b/mcs/tests/test-tuple-09.cs | ||
| 3740 | new file mode 100644 | ||
| 3741 | index 00000000000..3f15cae6cf1 | ||
| 3742 | --- /dev/null | ||
| 3743 | +++ b/mcs/tests/test-tuple-09.cs | ||
| 3744 | @@ -0,0 +1,19 @@ | ||
| 3745 | +using System; | ||
| 3746 | + | ||
| 3747 | +class TupleDeconstructionDeclaration | ||
| 3748 | +{ | ||
| 3749 | + public static int Main () | ||
| 3750 | + { | ||
| 3751 | + (string s, long l) = GetValues (); | ||
| 3752 | + (var vs, var vl) = GetValues (); | ||
| 3753 | + (object o, var vl2) = GetValues (); | ||
| 3754 | + (string ds, _) = GetValues (); | ||
| 3755 | + | ||
| 3756 | + return 0; | ||
| 3757 | + } | ||
| 3758 | + | ||
| 3759 | + static (string, long) GetValues () | ||
| 3760 | + { | ||
| 3761 | + return ("a", 3); | ||
| 3762 | + } | ||
| 3763 | +} | ||
| 3764 | \ No newline at end of file | ||
| 3765 | diff --git a/mcs/tests/ver-il-net_4_x.xml b/mcs/tests/ver-il-net_4_x.xml | ||
| 3766 | index c2c98123305..4dbc7042a8a 100644 | ||
| 3767 | --- a/mcs/tests/ver-il-net_4_x.xml | ||
| 3768 | +++ b/mcs/tests/ver-il-net_4_x.xml | ||
| 3769 | @@ -14659,6 +14659,9 @@ | ||
| 3770 | <method name="Void Test_22(Boolean)" attrs="129"> | ||
| 3771 | <size>24</size> | ||
| 3772 | </method> | ||
| 3773 | + <method name="Void Test_23(System.String)" attrs="129"> | ||
| 3774 | + <size>16</size> | ||
| 3775 | + </method> | ||
| 3776 | </type> | ||
| 3777 | </test> | ||
| 3778 | <test name="gtest-410.cs"> | ||
| 3779 | @@ -52808,6 +52811,19 @@ | ||
| 3780 | </method> | ||
| 3781 | </type> | ||
| 3782 | </test> | ||
| 3783 | + <test name="test-948.cs"> | ||
| 3784 | + <type name="X"> | ||
| 3785 | + <method name="Void Main()" attrs="150"> | ||
| 3786 | + <size>16</size> | ||
| 3787 | + </method> | ||
| 3788 | + <method name="Void Foo()" attrs="129"> | ||
| 3789 | + <size>2</size> | ||
| 3790 | + </method> | ||
| 3791 | + <method name="Void .ctor()" attrs="6278"> | ||
| 3792 | + <size>7</size> | ||
| 3793 | + </method> | ||
| 3794 | + </type> | ||
| 3795 | + </test> | ||
| 3796 | <test name="test-95.cs"> | ||
| 3797 | <type name="X"> | ||
| 3798 | <method name="Int32 Main()" attrs="150"> | ||
| 3799 | @@ -66893,6 +66909,117 @@ | ||
| 3800 | </method> | ||
| 3801 | </type> | ||
| 3802 | </test> | ||
| 3803 | + <test name="test-async-94.cs"> | ||
| 3804 | + <type name="MyTask`1[T]"> | ||
| 3805 | + <method name="Void .ctor()" attrs="6278"> | ||
| 3806 | + <size>7</size> | ||
| 3807 | + </method> | ||
| 3808 | + </type> | ||
| 3809 | + <type name="MyTask"> | ||
| 3810 | + <method name="Void .ctor()" attrs="6278"> | ||
| 3811 | + <size>7</size> | ||
| 3812 | + </method> | ||
| 3813 | + </type> | ||
| 3814 | + <type name="MyTaskMethodBuilder"> | ||
| 3815 | + <method name="MyTaskMethodBuilder Create()" attrs="150"> | ||
| 3816 | + <size>10</size> | ||
| 3817 | + </method> | ||
| 3818 | + <method name="MyTask get_Task()" attrs="2182"> | ||
| 3819 | + <size>10</size> | ||
| 3820 | + </method> | ||
| 3821 | + <method name="Void SetException(System.Exception)" attrs="134"> | ||
| 3822 | + <size>2</size> | ||
| 3823 | + </method> | ||
| 3824 | + <method name="Void SetResult()" attrs="134"> | ||
| 3825 | + <size>2</size> | ||
| 3826 | + </method> | ||
| 3827 | + <method name="Void AwaitOnCompleted[TAwaiter,TStateMachine](TAwaiter ByRef, TStateMachine ByRef)" attrs="134"> | ||
| 3828 | + <size>2</size> | ||
| 3829 | + </method> | ||
| 3830 | + <method name="Void AwaitUnsafeOnCompleted[TAwaiter,TStateMachine](TAwaiter ByRef, TStateMachine ByRef)" attrs="134"> | ||
| 3831 | + <size>2</size> | ||
| 3832 | + </method> | ||
| 3833 | + <method name="Void Start[TStateMachine](TStateMachine ByRef)" attrs="134"> | ||
| 3834 | + <size>2</size> | ||
| 3835 | + </method> | ||
| 3836 | + <method name="Void SetStateMachine(System.Runtime.CompilerServices.IAsyncStateMachine)" attrs="134"> | ||
| 3837 | + <size>2</size> | ||
| 3838 | + </method> | ||
| 3839 | + <method name="Void .ctor()" attrs="6278"> | ||
| 3840 | + <size>7</size> | ||
| 3841 | + </method> | ||
| 3842 | + </type> | ||
| 3843 | + <type name="MyTaskMethodBuilder`1[T]"> | ||
| 3844 | + <method name="MyTaskMethodBuilder`1[T] Create()" attrs="150"> | ||
| 3845 | + <size>10</size> | ||
| 3846 | + </method> | ||
| 3847 | + <method name="MyTask`1[T] get_Task()" attrs="2182"> | ||
| 3848 | + <size>10</size> | ||
| 3849 | + </method> | ||
| 3850 | + <method name="Void SetException(System.Exception)" attrs="134"> | ||
| 3851 | + <size>2</size> | ||
| 3852 | + </method> | ||
| 3853 | + <method name="Void SetResult(T)" attrs="134"> | ||
| 3854 | + <size>2</size> | ||
| 3855 | + </method> | ||
| 3856 | + <method name="Void AwaitOnCompleted[TAwaiter,TStateMachine](TAwaiter ByRef, TStateMachine ByRef)" attrs="134"> | ||
| 3857 | + <size>2</size> | ||
| 3858 | + </method> | ||
| 3859 | + <method name="Void AwaitUnsafeOnCompleted[TAwaiter,TStateMachine](TAwaiter ByRef, TStateMachine ByRef)" attrs="134"> | ||
| 3860 | + <size>2</size> | ||
| 3861 | + </method> | ||
| 3862 | + <method name="Void Start[TStateMachine](TStateMachine ByRef)" attrs="134"> | ||
| 3863 | + <size>2</size> | ||
| 3864 | + </method> | ||
| 3865 | + <method name="Void SetStateMachine(System.Runtime.CompilerServices.IAsyncStateMachine)" attrs="134"> | ||
| 3866 | + <size>2</size> | ||
| 3867 | + </method> | ||
| 3868 | + <method name="Void .ctor()" attrs="6278"> | ||
| 3869 | + <size>7</size> | ||
| 3870 | + </method> | ||
| 3871 | + </type> | ||
| 3872 | + <type name="X"> | ||
| 3873 | + <method name="MyTask Test()" attrs="134"> | ||
| 3874 | + <size>33</size> | ||
| 3875 | + </method> | ||
| 3876 | + <method name="MyTask`1[System.Int32] Test2()" attrs="134"> | ||
| 3877 | + <size>33</size> | ||
| 3878 | + </method> | ||
| 3879 | + <method name="System.Threading.Tasks.ValueTask`1[System.String] Test3()" attrs="134"> | ||
| 3880 | + <size>33</size> | ||
| 3881 | + </method> | ||
| 3882 | + <method name="Void Main()" attrs="150"> | ||
| 3883 | + <size>23</size> | ||
| 3884 | + </method> | ||
| 3885 | + <method name="Void .ctor()" attrs="6278"> | ||
| 3886 | + <size>7</size> | ||
| 3887 | + </method> | ||
| 3888 | + </type> | ||
| 3889 | + <type name="X+<Test>c__async0"> | ||
| 3890 | + <method name="Void MoveNext()" attrs="486"> | ||
| 3891 | + <size>157</size> | ||
| 3892 | + </method> | ||
| 3893 | + <method name="Void SetStateMachine(System.Runtime.CompilerServices.IAsyncStateMachine)" attrs="486"> | ||
| 3894 | + <size>13</size> | ||
| 3895 | + </method> | ||
| 3896 | + </type> | ||
| 3897 | + <type name="X+<Test2>c__async1"> | ||
| 3898 | + <method name="Void MoveNext()" attrs="486"> | ||
| 3899 | + <size>165</size> | ||
| 3900 | + </method> | ||
| 3901 | + <method name="Void SetStateMachine(System.Runtime.CompilerServices.IAsyncStateMachine)" attrs="486"> | ||
| 3902 | + <size>13</size> | ||
| 3903 | + </method> | ||
| 3904 | + </type> | ||
| 3905 | + <type name="X+<Test3>c__async2"> | ||
| 3906 | + <method name="Void MoveNext()" attrs="486"> | ||
| 3907 | + <size>169</size> | ||
| 3908 | + </method> | ||
| 3909 | + <method name="Void SetStateMachine(System.Runtime.CompilerServices.IAsyncStateMachine)" attrs="486"> | ||
| 3910 | + <size>13</size> | ||
| 3911 | + </method> | ||
| 3912 | + </type> | ||
| 3913 | + </test> | ||
| 3914 | <test name="test-cls-00.cs"> | ||
| 3915 | <type name="CLSCLass_6"> | ||
| 3916 | <method name="Void add_Disposed(Delegate)" attrs="2182"> | ||
| 3917 | @@ -68527,6 +68654,47 @@ | ||
| 3918 | </method> | ||
| 3919 | </type> | ||
| 3920 | </test> | ||
| 3921 | + <test name="test-default-01.cs"> | ||
| 3922 | + <type name="X"> | ||
| 3923 | + <method name="Void Main()" attrs="150"> | ||
| 3924 | + <size>53</size> | ||
| 3925 | + </method> | ||
| 3926 | + <method name="Int32 M1()" attrs="145"> | ||
| 3927 | + <size>10</size> | ||
| 3928 | + </method> | ||
| 3929 | + <method name="Void M2()" attrs="145"> | ||
| 3930 | + <size>31</size> | ||
| 3931 | + </method> | ||
| 3932 | + <method name="Void M3(Int32)" attrs="145"> | ||
| 3933 | + <size>2</size> | ||
| 3934 | + </method> | ||
| 3935 | + <method name="System.Func`1[System.Int32] M4()" attrs="145"> | ||
| 3936 | + <size>38</size> | ||
| 3937 | + </method> | ||
| 3938 | + <method name="Int32 <M4>m__0()" attrs="145"> | ||
| 3939 | + <size>9</size> | ||
| 3940 | + </method> | ||
| 3941 | + </type> | ||
| 3942 | + </test> | ||
| 3943 | + <test name="test-default-02.cs"> | ||
| 3944 | + <type name="C"> | ||
| 3945 | + <method name="Void Main()" attrs="145"> | ||
| 3946 | + <size>36</size> | ||
| 3947 | + </method> | ||
| 3948 | + <method name="Void M[T](T, T)" attrs="145"> | ||
| 3949 | + <size>2</size> | ||
| 3950 | + </method> | ||
| 3951 | + <method name="Void M2(System.Object[])" attrs="145"> | ||
| 3952 | + <size>2</size> | ||
| 3953 | + </method> | ||
| 3954 | + <method name="Void .ctor()" attrs="6278"> | ||
| 3955 | + <size>7</size> | ||
| 3956 | + </method> | ||
| 3957 | + <method name="Byte[] Test(S`1[System.Byte])" attrs="145"> | ||
| 3958 | + <size>10</size> | ||
| 3959 | + </method> | ||
| 3960 | + </type> | ||
| 3961 | + </test> | ||
| 3962 | <test name="test-dictinit-01.cs"> | ||
| 3963 | <type name="Program"> | ||
| 3964 | <method name="Int32 Main()" attrs="145"> | ||
| 3965 | @@ -68610,6 +68778,30 @@ | ||
| 3966 | </method> | ||
| 3967 | </type> | ||
| 3968 | </test> | ||
| 3969 | + <test name="test-discards-01.cs"> | ||
| 3970 | + <type name="X"> | ||
| 3971 | + <method name="Void Main()" attrs="150"> | ||
| 3972 | + <size>63</size> | ||
| 3973 | + </method> | ||
| 3974 | + <method name="Boolean TryGetValue(Int32 ByRef)" attrs="145"> | ||
| 3975 | + <size>13</size> | ||
| 3976 | + </method> | ||
| 3977 | + <method name="Int32 TestValue()" attrs="145"> | ||
| 3978 | + <size>10</size> | ||
| 3979 | + </method> | ||
| 3980 | + <method name="Void .ctor()" attrs="6278"> | ||
| 3981 | + <size>7</size> | ||
| 3982 | + </method> | ||
| 3983 | + </type> | ||
| 3984 | + <type name="X+<Main>c__AnonStorey0"> | ||
| 3985 | + <method name="System.Object <>m__0()" attrs="131"> | ||
| 3986 | + <size>25</size> | ||
| 3987 | + </method> | ||
| 3988 | + <method name="Void .ctor()" attrs="6278"> | ||
| 3989 | + <size>7</size> | ||
| 3990 | + </method> | ||
| 3991 | + </type> | ||
| 3992 | + </test> | ||
| 3993 | <test name="test-ex-filter-01.cs"> | ||
| 3994 | <type name="X"> | ||
| 3995 | <method name="Int32 Main()" attrs="150"> | ||
| 3996 | @@ -70689,6 +70881,19 @@ | ||
| 3997 | </method> | ||
| 3998 | </type> | ||
| 3999 | </test> | ||
| 4000 | + <test name="test-named-11.cs"> | ||
| 4001 | + <type name="X"> | ||
| 4002 | + <method name="Void Main()" attrs="150"> | ||
| 4003 | + <size>13</size> | ||
| 4004 | + </method> | ||
| 4005 | + <method name="Void Test(Int32, System.String)" attrs="145"> | ||
| 4006 | + <size>2</size> | ||
| 4007 | + </method> | ||
| 4008 | + <method name="Void .ctor()" attrs="6278"> | ||
| 4009 | + <size>7</size> | ||
| 4010 | + </method> | ||
| 4011 | + </type> | ||
| 4012 | + </test> | ||
| 4013 | <test name="test-nameof-01.cs"> | ||
| 4014 | <type name="X"> | ||
| 4015 | <method name="Int32 Main()" attrs="150"> | ||
| 4016 | @@ -72778,6 +72983,49 @@ | ||
| 4017 | </method> | ||
| 4018 | </type> | ||
| 4019 | </test> | ||
| 4020 | + <test name="test-readonly-02.cs"> | ||
| 4021 | + <type name="D"> | ||
| 4022 | + <method name="Int32& Invoke(Int32)" attrs="454"> | ||
| 4023 | + <size>0</size> | ||
| 4024 | + </method> | ||
| 4025 | + <method name="System.IAsyncResult BeginInvoke(Int32, System.AsyncCallback, System.Object)" attrs="454"> | ||
| 4026 | + <size>0</size> | ||
| 4027 | + </method> | ||
| 4028 | + <method name="Int32& EndInvoke(System.IAsyncResult)" attrs="454"> | ||
| 4029 | + <size>0</size> | ||
| 4030 | + </method> | ||
| 4031 | + <method name="Void .ctor(Object, IntPtr)" attrs="6278"> | ||
| 4032 | + <size>0</size> | ||
| 4033 | + </method> | ||
| 4034 | + </type> | ||
| 4035 | + <type name="X"> | ||
| 4036 | + <method name="Void Main()" attrs="150"> | ||
| 4037 | + <size>2</size> | ||
| 4038 | + </method> | ||
| 4039 | + <method name="System.Guid& TestMethod()" attrs="129"> | ||
| 4040 | + <size>15</size> | ||
| 4041 | + </method> | ||
| 4042 | + <method name="System.Guid& get_TestProp()" attrs="2177"> | ||
| 4043 | + <size>17</size> | ||
| 4044 | + </method> | ||
| 4045 | + <method name="Void .ctor()" attrs="6278"> | ||
| 4046 | + <size>7</size> | ||
| 4047 | + </method> | ||
| 4048 | + </type> | ||
| 4049 | + </test> | ||
| 4050 | + <test name="test-readonly-03.cs"> | ||
| 4051 | + <type name="S"> | ||
| 4052 | + <method name="Void Main()" attrs="150"> | ||
| 4053 | + <size>2</size> | ||
| 4054 | + </method> | ||
| 4055 | + <method name="Void .ctor(Int32)" attrs="6278"> | ||
| 4056 | + <size>13</size> | ||
| 4057 | + </method> | ||
| 4058 | + <method name="Void .cctor()" attrs="6289"> | ||
| 4059 | + <size>15</size> | ||
| 4060 | + </method> | ||
| 4061 | + </type> | ||
| 4062 | + </test> | ||
| 4063 | <test name="test-ref-01.cs"> | ||
| 4064 | <type name="X"> | ||
| 4065 | <method name="Void Main()" attrs="150"> | ||
| 4066 | @@ -72906,6 +73154,95 @@ | ||
| 4067 | </method> | ||
| 4068 | </type> | ||
| 4069 | </test> | ||
| 4070 | + <test name="test-ref-07.cs"> | ||
| 4071 | + <type name="Test"> | ||
| 4072 | + <method name="Void Main()" attrs="150"> | ||
| 4073 | + <size>18</size> | ||
| 4074 | + </method> | ||
| 4075 | + <method name="Test Method()" attrs="129"> | ||
| 4076 | + <size>18</size> | ||
| 4077 | + </method> | ||
| 4078 | + </type> | ||
| 4079 | + <type name="P"> | ||
| 4080 | + <method name="Test get_Span()" attrs="3526"> | ||
| 4081 | + <size>0</size> | ||
| 4082 | + </method> | ||
| 4083 | + <method name="Void .ctor()" attrs="6276"> | ||
| 4084 | + <size>7</size> | ||
| 4085 | + </method> | ||
| 4086 | + </type> | ||
| 4087 | + </test> | ||
| 4088 | + <test name="test-ref-08.cs"> | ||
| 4089 | + <type name="ClassLibrary1.C"> | ||
| 4090 | + <method name="Void MM()" attrs="129"> | ||
| 4091 | + <size>60</size> | ||
| 4092 | + </method> | ||
| 4093 | + <method name="Void Main()" attrs="150"> | ||
| 4094 | + <size>245</size> | ||
| 4095 | + </method> | ||
| 4096 | + <method name="Int32& Add2(Int32 ByRef, Int32)" attrs="150"> | ||
| 4097 | + <size>10</size> | ||
| 4098 | + </method> | ||
| 4099 | + <method name="Void .ctor()" attrs="6278"> | ||
| 4100 | + <size>7</size> | ||
| 4101 | + </method> | ||
| 4102 | + <method name="Void .cctor()" attrs="6289"> | ||
| 4103 | + <size>12</size> | ||
| 4104 | + </method> | ||
| 4105 | + </type> | ||
| 4106 | + <type name="ClassLibrary1.C+B"> | ||
| 4107 | + <method name="Int32& get_Item(Int32)" attrs="2182"> | ||
| 4108 | + <size>15</size> | ||
| 4109 | + </method> | ||
| 4110 | + <method name="Void .ctor()" attrs="6278"> | ||
| 4111 | + <size>7</size> | ||
| 4112 | + </method> | ||
| 4113 | + </type> | ||
| 4114 | + <type name="ClassLibrary1.C+Gen`1[T]"> | ||
| 4115 | + <method name="T& get_Item(Int32)" attrs="2182"> | ||
| 4116 | + <size>15</size> | ||
| 4117 | + </method> | ||
| 4118 | + <method name="Void .ctor()" attrs="6278"> | ||
| 4119 | + <size>7</size> | ||
| 4120 | + </method> | ||
| 4121 | + </type> | ||
| 4122 | + <type name="ClassLibrary1.C+BB"> | ||
| 4123 | + <method name="Val& get_Item(Int32)" attrs="2182"> | ||
| 4124 | + <size>15</size> | ||
| 4125 | + </method> | ||
| 4126 | + <method name="Void .ctor()" attrs="6278"> | ||
| 4127 | + <size>7</size> | ||
| 4128 | + </method> | ||
| 4129 | + </type> | ||
| 4130 | + </test> | ||
| 4131 | + <test name="test-ref-09.cs"> | ||
| 4132 | + <type name="Program"> | ||
| 4133 | + <method name="rigidbody& get_property_returning_struct_by_ref()" attrs="2193"> | ||
| 4134 | + <size>13</size> | ||
| 4135 | + </method> | ||
| 4136 | + <method name="Void Main()" attrs="145"> | ||
| 4137 | + <size>17</size> | ||
| 4138 | + </method> | ||
| 4139 | + <method name="Void .ctor()" attrs="6278"> | ||
| 4140 | + <size>7</size> | ||
| 4141 | + </method> | ||
| 4142 | + </type> | ||
| 4143 | + </test> | ||
| 4144 | + <test name="test-ref-10.cs"> | ||
| 4145 | + <type name="ValueStringBuilder"> | ||
| 4146 | + <method name="System.String ToString()" attrs="198"> | ||
| 4147 | + <size>14</size> | ||
| 4148 | + </method> | ||
| 4149 | + </type> | ||
| 4150 | + <type name="X"> | ||
| 4151 | + <method name="Int32 Main()" attrs="150"> | ||
| 4152 | + <size>47</size> | ||
| 4153 | + </method> | ||
| 4154 | + <method name="Void .ctor()" attrs="6278"> | ||
| 4155 | + <size>7</size> | ||
| 4156 | + </method> | ||
| 4157 | + </type> | ||
| 4158 | + </test> | ||
| 4159 | <test name="test-static-using-01.cs"> | ||
| 4160 | <type name="A.B.X"> | ||
| 4161 | <method name="Int32 Test()" attrs="150"> | ||
| 4162 | @@ -73374,6 +73711,56 @@ | ||
| 4163 | </method> | ||
| 4164 | </type> | ||
| 4165 | </test> | ||
| 4166 | + <test name="test-tuple-07.cs"> | ||
| 4167 | + <type name="ParserTest"> | ||
| 4168 | + <method name="System.Collections.Generic.IEnumerable`1[System.ValueTuple`2[System.Object,System.Int32]] Test()" attrs="129"> | ||
| 4169 | + <size>10</size> | ||
| 4170 | + </method> | ||
| 4171 | + <method name="Void Main()" attrs="150"> | ||
| 4172 | + <size>2</size> | ||
| 4173 | + </method> | ||
| 4174 | + <method name="Void .ctor()" attrs="6278"> | ||
| 4175 | + <size>7</size> | ||
| 4176 | + </method> | ||
| 4177 | + </type> | ||
| 4178 | + </test> | ||
| 4179 | + <test name="test-tuple-08.cs"> | ||
| 4180 | + <type name="X"> | ||
| 4181 | + <method name="Void Main()" attrs="150"> | ||
| 4182 | + <size>19</size> | ||
| 4183 | + </method> | ||
| 4184 | + <method name="System.Threading.Tasks.Task Test()" attrs="129"> | ||
| 4185 | + <size>41</size> | ||
| 4186 | + </method> | ||
| 4187 | + <method name="System.Threading.Tasks.Task`1[System.ValueTuple`2[System.Int32,System.Int32]] Waiting()" attrs="129"> | ||
| 4188 | + <size>21</size> | ||
| 4189 | + </method> | ||
| 4190 | + <method name="Void .ctor()" attrs="6278"> | ||
| 4191 | + <size>7</size> | ||
| 4192 | + </method> | ||
| 4193 | + </type> | ||
| 4194 | + <type name="X+<Test>c__async0"> | ||
| 4195 | + <method name="Void MoveNext()" attrs="486"> | ||
| 4196 | + <size>212</size> | ||
| 4197 | + </method> | ||
| 4198 | + <method name="Void SetStateMachine(System.Runtime.CompilerServices.IAsyncStateMachine)" attrs="486"> | ||
| 4199 | + <size>13</size> | ||
| 4200 | + </method> | ||
| 4201 | + </type> | ||
| 4202 | + </test> | ||
| 4203 | + <test name="test-tuple-09.cs"> | ||
| 4204 | + <type name="TupleDeconstructionDeclaration"> | ||
| 4205 | + <method name="Int32 Main()" attrs="150"> | ||
| 4206 | + <size>99</size> | ||
| 4207 | + </method> | ||
| 4208 | + <method name="System.ValueTuple`2[System.String,System.Int64] GetValues()" attrs="145"> | ||
| 4209 | + <size>21</size> | ||
| 4210 | + </method> | ||
| 4211 | + <method name="Void .ctor()" attrs="6278"> | ||
| 4212 | + <size>7</size> | ||
| 4213 | + </method> | ||
| 4214 | + </type> | ||
| 4215 | + </test> | ||
| 4216 | <test name="test-var-01.cs"> | ||
| 4217 | <type name="Test"> | ||
| 4218 | <method name="Int32 Main()" attrs="150"> | ||
