public void CS1770ERR_NoConversionForNubDefaultParam()
{
var text = @"using System;
...
...
@@ -15378,12 +15378,22 @@ public enum E { None }
public void Foo1(int? x = default(int)) { }
public void Foo2(E? x = default(E)) { }
public void Foo3(DateTime? x = default(DateTime?)) { }
public void Foo4(DateTime? x = new DateTime?()) { }
// Error:
public void Foo(DateTime? x = default(DateTime)) { }
public void Foo11(DateTime? x = default(DateTime)) { }
public void Foo12(DateTime? x = new DateTime()) { }
}";
var comp = DiagnosticsUtils.VerifyErrorsAndGetCompilationWithMscorlib(text,
new ErrorDescription { Code = 1770, Line = 12, Column = 31 });
var comp = CreateCompilationWithMscorlib(text);
comp.VerifyDiagnostics(
// (13,33): error CS1770: A value of type 'DateTime' cannot be used as default parameter for nullable parameter 'x' because 'DateTime' is not a simple type
// public void Foo11(DateTime? x = default(DateTime)) { }
// (14,33): error CS1770: A value of type 'DateTime' cannot be used as default parameter for nullable parameter 'x' because 'DateTime' is not a simple type
// public void Foo12(DateTime? x = new DateTime()) { }