The attached test project (Android library) has issues compiling code using a protocol with associated type. The code compiles fine in Xcode. Using Elements/Fire .2485.
ITypedField
is a protocol with associated type ValueType
.
IStorableField
is a regular protocol.
Both have IFormComponent
and IField
as ancestors.
-
If
IStorableField
extension is defined with constraintSelf: ITypedField
, thenValueType
isn’t recognized in extension. The compiler complains about unknown type. -
If I use any property from
IField
orIFormComponent
in the extension (other thanIField.updating
) compilation fails with System.NullReferenceException. -
If
ValueType
is constrained asEquatable
, theTestBoolField
class doesn’t compile (Generic parameter doesn’t fulfill constraint). I’m not sure if this is even doable in Android as Bool doesn’t implementEquatable
. Usingextension Bool: Equatable {}
doesn’t help. -
If I remove
Equatable
constraint fromValueType
this part goes ok, but then the compiler complains that getters and setters for some properties aren’t implemented.
AssociatedTypeTest.zip (11.2 KB)