[
https://issues.apache.org/jira/browse/FLINK-2806?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14943126#comment-14943126
]
ASF GitHub Bot commented on FLINK-2806:
---------------------------------------
Github user tillrohrmann commented on a diff in the pull request:
https://github.com/apache/flink/pull/1212#discussion_r41125339
--- Diff:
flink-scala/src/main/scala/org/apache/flink/api/scala/typeutils/ScalaNothingTypeInfo.scala
---
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.flink.api.scala.typeutils
+
+import org.apache.flink.api.common.ExecutionConfig
+import org.apache.flink.api.common.typeinfo.TypeInformation
+import org.apache.flink.api.common.typeutils.TypeSerializer
+
+class ScalaNothingTypeInfo extends TypeInformation[Nothing] {
+
+ override def isBasicType: Boolean = false
+ override def isTupleType: Boolean = false
+ override def getArity: Int = 0
+ override def getTotalFields: Int = 0
+ override def getTypeClass: Class[Nothing] = classOf[Nothing]
+ override def isKeyType: Boolean = false
+
+ override def createSerializer(config: ExecutionConfig):
TypeSerializer[Nothing] =
+ (new NothingSerializer).asInstanceOf[TypeSerializer[Nothing]]
+
+ override def hashCode(): Int = 42
--- End diff --
Could we use `classOf[ScalaNothingTypeInfo].hashCode` here? Otherwise, all
objects we create end up in the bucket with hash code `42`.
> No TypeInfo for Scala's Nothing type
> ------------------------------------
>
> Key: FLINK-2806
> URL: https://issues.apache.org/jira/browse/FLINK-2806
> Project: Flink
> Issue Type: Bug
> Components: Scala API
> Reporter: Gabor Gevay
> Assignee: Gabor Gevay
> Priority: Minor
>
> When writing some generic code, I encountered a situation where I needed a
> TypeInformation[Nothing]. Two problems prevent me from getting it:
> 1. TypeInformationGen.mkTypeInfo doesn't return a real
> TypeInformation[Nothing]. (It actually returns a casted null in that case.)
> 2. The line
> implicit def createTypeInformation[T]: TypeInformation[T] = macro
> TypeUtils.createTypeInfo[T]
> does not fire in some situations when it should, when T = Nothing. (I guess
> this is a compiler bug.)
> I will open a PR shortly.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)