Skip to content
This repository was archived by the owner on Dec 12, 2024. It is now read-only.

[SoM] Code generation failure with struct with Equatable protocol #87

Open
chamons opened this issue Dec 31, 2018 · 0 comments
Open

[SoM] Code generation failure with struct with Equatable protocol #87

chamons opened this issue Dec 31, 2018 · 0 comments
Milestone

Comments

@chamons
Copy link
Contributor

chamons commented Dec 31, 2018

		[Test]
		public void FunctionReturnsStructWithProtocol ()
		{
			string swiftCode = @"public struct FunctionStruct : Equatable {
	public var X:Int32 = 0;
	public init(x:Int32) {
		X = x;
	}
	
	public static func == (lhs: FunctionStruct, rhs: FunctionStruct) -> Bool {
		return lhs.X == rhs.X;
	}
}

public func RetunsStruct (s: String, x: Int32) -> FunctionStruct { return FunctionStruct (x: x); }";

			CSSimpleType structType = (CSSimpleType)"FunctionStruct";
			CSLine structDecl = CSVariableDeclaration.VarLine (structType, "foo", CSFunctionCall.Ctor (structType.ToString (), CSConstant.Val (42)));
			CSLine printer = CSFunctionCall.ConsoleWriteLine ((CSIdentifier)"foo.X");

			TestRunning.TestAndExecute (swiftCode, CSCodeBlock.Create (structDecl, printer), "42\n");
		}
System.Exception : Failed to execute (exit code 1): /Library/Frameworks/Mono.framework/Versions/Current/bin/mcs -unsafe -define:_MAC_TS_TEST_ -nowarn:CS0169 -out:NameNotImportant.exe  /Users/donblas/Programming/maccore/tools/tom-swifty/tests/tom-swifty-test/bin/Debug/swift-o-matic-tests/3/FunctionStructSwiftMethodWrapTests.cs /Users/donblas/Programming/maccore/tools/tom-swifty/tests/tom-swifty-test/bin/Debug/swift-o-matic-tests/3/NameNotImportant.cs /Users/donblas/Programming/maccore/tools/tom-swifty/tests/tom-swifty-test/bin/Debug/swift-o-matic-tests/3/TopLevelEntitiesSwiftMethodWrapTests.cs -lib:/Users/donblas/Programming/maccore/tools/tom-swifty/tests/tom-swifty-test/bin/Debug/../../../../SwiftRuntimeLibrary/bin/Debug -r:SwiftRuntimeLibrary 
/Users/donblas/Programming/maccore/tools/tom-swifty/tests/tom-swifty-test/bin/Debug/swift-o-matic-tests/3/FunctionStructSwiftMethodWrapTests.cs(13,18): error CS0535: `SwiftMethodWrapTests.FunctionStruct' does not implement interface member `SwiftRuntimeLibrary.ISwiftEquatable.OpEquals(SwiftRuntimeLibrary.ISwiftEquatable)'
/Users/donblas/Programming/maccore/tools/tom-swifty/tests/tom-swifty-test/bin/Debug/../../../../SwiftRuntimeLibrary/bin/Debug/SwiftRuntimeLibrary.dll (Location of the symbol related to previous error)
Compilation failed: 1 error(s), 0 warnings

Output: https://gist.github.com/chamons/d296e8cca4bd20c4857e3fc7f83dcb92

@stephen-hawley stephen-hawley transferred this issue from another repository Oct 29, 2019
@chamons chamons added this to the Future milestone Nov 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant