From 41d461afeab1da2a4e10b726c5f2b14996706dcd Mon Sep 17 00:00:00 2001 From: jsimomaa Date: Mon, 30 Oct 2017 16:14:49 +0200 Subject: [PATCH] Change universal type variables to existential in requested value types refs #7575 Change-Id: If6d1ce540b22b0bb34239427fbfe7579fc0413ae --- .../server/request/ServerSCLHandlerValueRequest.java | 7 ++++++- .../document/server/request/ServerSCLValueRequest.java | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/bundles/org.simantics.document.server/src/org/simantics/document/server/request/ServerSCLHandlerValueRequest.java b/bundles/org.simantics.document.server/src/org/simantics/document/server/request/ServerSCLHandlerValueRequest.java index 286cae272..7283cf26b 100644 --- a/bundles/org.simantics.document.server/src/org/simantics/document/server/request/ServerSCLHandlerValueRequest.java +++ b/bundles/org.simantics.document.server/src/org/simantics/document/server/request/ServerSCLHandlerValueRequest.java @@ -1,5 +1,6 @@ package org.simantics.document.server.request; +import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -27,6 +28,8 @@ import org.simantics.scl.compiler.environment.specification.EnvironmentSpecifica import org.simantics.scl.compiler.runtime.RuntimeEnvironment; import org.simantics.scl.compiler.top.SCLExpressionCompilationException; import org.simantics.scl.compiler.types.TCon; +import org.simantics.scl.compiler.types.TMetaVar; +import org.simantics.scl.compiler.types.TVar; import org.simantics.scl.compiler.types.Type; import org.simantics.scl.compiler.types.Types; import org.simantics.scl.compiler.types.kinds.Kinds; @@ -232,7 +235,9 @@ public class ServerSCLHandlerValueRequest extends AbstractExpressionCompilationR protected Type getExpectedType(ReadGraph graph, CompilationContext context) throws DatabaseException { if(possibleExpectedValueType != null) { try { - return Environments.getType(context.runtimeEnvironment.getEnvironment(), possibleExpectedValueType); + Type type = Environments.getType(context.runtimeEnvironment.getEnvironment(), possibleExpectedValueType); + type = Types.instantiate(Types.forAll(Types.freeVars(type).toArray(new TVar[0]), type), new ArrayList()); + return type; } catch (SCLExpressionCompilationException e) { LOGGER.error("Could not get type for " + String.valueOf(possibleExpectedValueType), e); } diff --git a/bundles/org.simantics.document.server/src/org/simantics/document/server/request/ServerSCLValueRequest.java b/bundles/org.simantics.document.server/src/org/simantics/document/server/request/ServerSCLValueRequest.java index 5013f8814..e6cdf6ff5 100644 --- a/bundles/org.simantics.document.server/src/org/simantics/document/server/request/ServerSCLValueRequest.java +++ b/bundles/org.simantics.document.server/src/org/simantics/document/server/request/ServerSCLValueRequest.java @@ -1,5 +1,6 @@ package org.simantics.document.server.request; +import java.util.ArrayList; import java.util.Map; import org.simantics.databoard.Bindings; @@ -28,6 +29,8 @@ import org.simantics.scl.compiler.environment.Environments; import org.simantics.scl.compiler.environment.specification.EnvironmentSpecification; import org.simantics.scl.compiler.runtime.RuntimeEnvironment; import org.simantics.scl.compiler.top.SCLExpressionCompilationException; +import org.simantics.scl.compiler.types.TMetaVar; +import org.simantics.scl.compiler.types.TVar; import org.simantics.scl.compiler.types.Type; import org.simantics.scl.compiler.types.Types; import org.simantics.scl.compiler.types.kinds.Kinds; @@ -205,7 +208,9 @@ public class ServerSCLValueRequest extends AbstractExpressionCompilationRequest< protected Type getExpectedType(ReadGraph graph, CompilationContext context) throws DatabaseException { if(possibleExpectedValueType != null) { try { - return Environments.getType(context.runtimeEnvironment.getEnvironment(), possibleExpectedValueType); + Type type = Environments.getType(context.runtimeEnvironment.getEnvironment(), possibleExpectedValueType); + type = Types.instantiate(Types.forAll(Types.freeVars(type).toArray(new TVar[0]), type), new ArrayList()); + return type; } catch (SCLExpressionCompilationException e) { LOGGER.error("Could not get type for " + String.valueOf(possibleExpectedValueType), e); } -- 2.47.1