public void TwoConstructorTypesWithSameConstructorNameAndDifferentInnerTypes_Unify_TypeMismatchReported() { TypeVariableSet typeVariableSet = new TypeVariableSet(); TypeVariableReference constructorType1 = typeVariableSet.CreateReferenceToConstructorType("Vector", typeVariableSet.CreateReferenceToLiteralType(PFTypes.Int32)); TypeVariableReference constructorType2 = typeVariableSet.CreateReferenceToConstructorType("Vector", typeVariableSet.CreateReferenceToLiteralType(PFTypes.Boolean)); var typeUnificationResult = new TestTypeUnificationResult(); typeVariableSet.Unify(constructorType1, constructorType2, typeUnificationResult); Assert.IsTrue(typeUnificationResult.TypeMismatch); }
public void TwoConstructorTypesWithSameConstructorName_Unify_InnerTypesAreUnified() { TypeVariableSet typeVariableSet = new TypeVariableSet(); TypeVariableReference innerTypeVariable = typeVariableSet.CreateReferenceToNewTypeVariable(); TypeVariableReference constructorType1 = typeVariableSet.CreateReferenceToConstructorType("Vector", innerTypeVariable); TypeVariableReference constructorType2 = typeVariableSet.CreateReferenceToConstructorType("Vector", typeVariableSet.CreateReferenceToLiteralType(PFTypes.Int32)); typeVariableSet.Unify(constructorType1, constructorType2, new TestTypeUnificationResult()); Assert.IsTrue(innerTypeVariable.RenderNIType().IsInt32()); }
public override void UnifyWithConnectedWireTypeAsNodeInput(VariableReference wireFacadeVariable, TerminalTypeUnificationResults unificationResults) { TypeVariableSet typeVariableSet = Terminal.GetTypeVariableSet(); ITypeUnificationResult inputUnificationResult = unificationResults.GetTypeUnificationResult(Terminal, TrueVariable.TypeVariableReference, wireFacadeVariable.TypeVariableReference); typeVariableSet.Unify(TrueVariable.TypeVariableReference, wireFacadeVariable.TypeVariableReference, inputUnificationResult); TrueVariable.MergeInto(wireFacadeVariable); string constructorName; TypeVariableReference innerType, optionType; if (typeVariableSet.TryDecomposeConstructorType(TrueVariable.TypeVariableReference, out constructorName, out innerType) && constructorName == "Option") { optionType = TrueVariable.TypeVariableReference; } else { optionType = typeVariableSet.CreateReferenceToConstructorType("Option", TrueVariable.TypeVariableReference); } TypeVariableReference outputTypeReference = _outputTerminalFacade.TrueVariable.TypeVariableReference; ITypeUnificationResult outputUnificationResult = unificationResults.GetTypeUnificationResult(_outputTerminalFacade.Terminal, outputTypeReference, optionType); typeVariableSet.Unify(outputTypeReference, optionType, outputUnificationResult); }
public void LiteralTypeAndConstructorType_Unify_TypeMismatchReported() { TypeVariableSet typeVariableSet = new TypeVariableSet(); TypeVariableReference literalReference = typeVariableSet.CreateReferenceToLiteralType(PFTypes.Int32), constructorReference = typeVariableSet.CreateReferenceToConstructorType("Vector", literalReference); var testTypeUnificationResult = new TestTypeUnificationResult(); typeVariableSet.Unify(constructorReference, literalReference, testTypeUnificationResult); Assert.IsTrue(testTypeUnificationResult.TypeMismatch); }
bool IDfirNodeVisitor <bool> .VisitLockTunnel(LockTunnel lockTunnel) { Terminal lockInput = lockTunnel.InputTerminals.ElementAt(0), referenceOutput = lockTunnel.OutputTerminals.ElementAt(0); LifetimeTypeVariableGroup lifetimeTypeVariableGroup = LifetimeTypeVariableGroup.CreateFromTerminal(lockInput); TypeVariableReference dataVariableType = _typeVariableSet.CreateReferenceToNewTypeVariable(); TypeVariableReference lockType = _typeVariableSet.CreateReferenceToConstructorType("LockingCell", dataVariableType); _nodeFacade .CreateInputLifetimeGroup(InputReferenceMutability.AllowImmutable, lifetimeTypeVariableGroup.LazyNewLifetime, lifetimeTypeVariableGroup.LifetimeType) .AddTerminalFacade(lockInput, lockType, default(TypeVariableReference)); Lifetime innerLifetime = referenceOutput.GetDiagramLifetime(); TypeVariableReference referenceType = _typeVariableSet.CreateReferenceToReferenceType( true, lockType, _typeVariableSet.CreateReferenceToLifetimeType(innerLifetime)); _nodeFacade[referenceOutput] = new SimpleTerminalFacade(referenceOutput, referenceType); return(true); }