Let types that implicitly convert to interface pass interface check.

"null" in particular is now considered to pass the interface conformance check.
This commit is contained in:
Sönke Ludwig 2016-11-05 01:42:20 +01:00
parent 9cfb702f0b
commit eb0697d6e4

View file

@ -451,7 +451,9 @@ template checkInterfaceConformance(T, I) {
} else enum string impl = null; } else enum string impl = null;
} }
static if (is(T == struct) || is(T == class) || is(T == interface)) static if (is(T : I))
enum checkInterfaceConformance = null;
else static if (is(T == struct) || is(T == class) || is(T == interface))
enum checkInterfaceConformance = impl!0; enum checkInterfaceConformance = impl!0;
else else
enum checkInterfaceConformance = "Aggregate type expected, not " ~ T.stringof; enum checkInterfaceConformance = "Aggregate type expected, not " ~ T.stringof;