You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nlpcraft.apache.org by se...@apache.org on 2021/02/18 11:27:38 UTC

[incubator-nlpcraft] branch NLPCRAFT-230 created (now 2ecb853)

This is an automated email from the ASF dual-hosted git repository.

sergeykamov pushed a change to branch NLPCRAFT-230
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git.


      at 2ecb853  WIP.

This branch includes the following new commits:

     new 2ecb853  WIP.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[incubator-nlpcraft] 01/01: WIP.

Posted by se...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sergeykamov pushed a commit to branch NLPCRAFT-230
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git

commit 2ecb8530ea3d5221fae1b62f3dbbe76542db18a4
Author: Sergey Kamov <sk...@gmail.com>
AuthorDate: Thu Feb 18 14:27:24 2021 +0300

    WIP.
---
 .../probe/mgrs/deploy/NCDeployManager.scala        | 26 ++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/deploy/NCDeployManager.scala b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/deploy/NCDeployManager.scala
index 58a8c36..1d598f5 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/deploy/NCDeployManager.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/probe/mgrs/deploy/NCDeployManager.scala
@@ -18,12 +18,11 @@
 package org.apache.nlpcraft.probe.mgrs.deploy
 
 import java.io._
-import java.lang.reflect.{InvocationTargetException, Method, ParameterizedType, Type}
+import java.lang.reflect.{InvocationTargetException, Method, ParameterizedType, Type, WildcardType}
 import java.util
 import java.util.function.Function
 import java.util.jar.JarInputStream
 import java.util.regex.{Pattern, PatternSyntaxException}
-
 import io.opencensus.trace.Span
 import org.apache.nlpcraft.model.NCModelView._
 import org.apache.nlpcraft.common._
@@ -1050,6 +1049,13 @@ object NCDeployManager extends NCService with DecorateAsScala {
 
     /**
       *
+      * @param wct
+      * @return
+      */
+    private def wc2Str(wct: WildcardType): String = if (wct == null) "null" else s"'${wct.getTypeName}'"
+
+    /**
+      *
       * @param mtd
       * @return
       */
@@ -1358,6 +1364,7 @@ object NCDeployManager extends NCService with DecorateAsScala {
                         val compType = compTypes.head
 
                         compType match {
+                            // Java, Scala, Groovy.
                             case _: Class[_] ⇒
                                 val genClass = compTypes.head.asInstanceOf[Class[_]]
 
@@ -1367,6 +1374,21 @@ object NCDeployManager extends NCService with DecorateAsScala {
                                         s"type=${class2Str(genClass)}, " +
                                         s"arg=${mkArg()}" +
                                     s"]")
+                            // Kotlin.
+                            case _: WildcardType ⇒
+                                val wildcardType = compTypes.head.asInstanceOf[WildcardType]
+
+                                val lowBounds = wildcardType.getLowerBounds
+                                val upBounds = wildcardType.getUpperBounds
+
+                                if (lowBounds.nonEmpty || upBounds.size != 1 || upBounds(0) != CLS_TOKEN)
+                                    throw new NCE(
+                                        s"Unexpected generic type for @NCIntentTerm annotated argument [" +
+                                        s"mdlId=$mdlId, " +
+                                        s"type=${wc2Str(wildcardType)}, " +
+                                        s"arg=${mkArg()}" +
+                                        s"]"
+                                    )
                             case _ ⇒
                                 throw new NCE(s"Unexpected generic type for @NCIntentTerm annotated argument [" +
                                     s"mdlId=$mdlId, " +