You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by al...@apache.org on 2015/03/02 17:33:30 UTC
[2/2] flink git commit: [hotfix] Fix Scala type analysis for classes
that extend Collections
[hotfix] Fix Scala type analysis for classes that extend Collections
Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/9ff94105
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/9ff94105
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/9ff94105
Branch: refs/heads/master
Commit: 9ff941052f6af78ee1a88f86ae5dd21b47e2dbe1
Parents: 84c11e6
Author: Aljoscha Krettek <al...@gmail.com>
Authored: Mon Mar 2 15:29:50 2015 +0100
Committer: Aljoscha Krettek <al...@gmail.com>
Committed: Mon Mar 2 16:07:48 2015 +0100
----------------------------------------------------------------------
.../flink/api/scala/codegen/TypeAnalyzer.scala | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flink/blob/9ff94105/flink-scala/src/main/scala/org/apache/flink/api/scala/codegen/TypeAnalyzer.scala
----------------------------------------------------------------------
diff --git a/flink-scala/src/main/scala/org/apache/flink/api/scala/codegen/TypeAnalyzer.scala b/flink-scala/src/main/scala/org/apache/flink/api/scala/codegen/TypeAnalyzer.scala
index 3121815..541ba20 100644
--- a/flink-scala/src/main/scala/org/apache/flink/api/scala/codegen/TypeAnalyzer.scala
+++ b/flink-scala/src/main/scala/org/apache/flink/api/scala/codegen/TypeAnalyzer.scala
@@ -18,6 +18,7 @@
package org.apache.flink.api.scala.codegen
import scala.collection._
+import scala.collection.generic.CanBuildFrom
import scala.reflect.macros.Context
import scala.util.DynamicVariable
@@ -288,7 +289,22 @@ private[flink] trait TypeAnalyzer[C <: Context] { this: MacroContextHolder[C]
traversable match {
case TypeRef(_, _, elemTpe :: Nil) =>
- Some(elemTpe.asSeenFrom(tpe, tpe.typeSymbol))
+
+ // determine whether we can find an implicit for the CanBuildFrom because
+ // TypeInformationGen requires this. This catches the case where a user
+ // has a custom class that implements Iterable[], for example.
+ val cbfTpe = TypeRef(
+ typeOf[CanBuildFrom[_, _, _]],
+ typeOf[CanBuildFrom[_, _, _]].typeSymbol,
+ tpe :: elemTpe :: tpe :: Nil)
+
+ val cbf = c.inferImplicitValue(cbfTpe, silent = true)
+
+ if (cbf == EmptyTree) {
+ None
+ } else {
+ Some(elemTpe.asSeenFrom(tpe, tpe.typeSymbol))
+ }
case _ => None
}