From 3345ba1013f80533c4e02f03d6e097066a92f893 Mon Sep 17 00:00:00 2001 From: Anton Vasetenkov Date: Wed, 30 Oct 2024 22:11:13 +1300 Subject: [PATCH] Call isInstantiable recursively to make sure that type parameters (if present) are bound --- .../src/main/java/org/hl7/cql/model/ChoiceType.java | 10 ++++++++++ .../src/main/java/org/hl7/cql/model/TupleType.java | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/Src/java/model/src/main/java/org/hl7/cql/model/ChoiceType.java b/Src/java/model/src/main/java/org/hl7/cql/model/ChoiceType.java index 017a69b9e..5b43a3f0b 100644 --- a/Src/java/model/src/main/java/org/hl7/cql/model/ChoiceType.java +++ b/Src/java/model/src/main/java/org/hl7/cql/model/ChoiceType.java @@ -148,6 +148,16 @@ public boolean isGeneric() { @Override public boolean isInstantiable(DataType callType, InstantiationContext context) { + // Call isInstantiable recursively to make sure that type parameters (if present) are bound + if (callType.equals(DataType.ANY)) { + for (var type : types) { + if (!type.isInstantiable(callType, context)) { + return false; + } + } + return true; + } + return isSuperTypeOf(callType); } diff --git a/Src/java/model/src/main/java/org/hl7/cql/model/TupleType.java b/Src/java/model/src/main/java/org/hl7/cql/model/TupleType.java index 79474bc31..473d6c9d2 100644 --- a/Src/java/model/src/main/java/org/hl7/cql/model/TupleType.java +++ b/Src/java/model/src/main/java/org/hl7/cql/model/TupleType.java @@ -164,7 +164,13 @@ public boolean isGeneric() { @Override public boolean isInstantiable(DataType callType, InstantiationContext context) { + // Call isInstantiable recursively to make sure that type parameters (if present) are bound if (callType.equals(DataType.ANY)) { + for (var element : elements) { + if (!element.getType().isInstantiable(callType, context)) { + return false; + } + } return true; }