[ https://issues.apache.org/jira/browse/FLINK-1458?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14295010#comment-14295010 ]
Aljoscha Krettek commented on FLINK-1458: ----------------------------------------- Yes, after the fix is merged it will indeed work. If you later on add fields to SimpleClass, you have to make sure that they are public or have getters/setters and that the class has a zero-argument-constructor, like so: {code} class SimpleClass(var a: Double) extends SimpleTrait { def this() = this(0.0) def contains(x: String) = true override def toString: String = "Simple Class " + a } {code} > Interfaces and abstract classes are not valid types > --------------------------------------------------- > > Key: FLINK-1458 > URL: https://issues.apache.org/jira/browse/FLINK-1458 > Project: Flink > Issue Type: Bug > Reporter: John Sandiford > > I don't know whether this is by design or is a bug, but I am having trouble > working with DataSet and traits in scala which is a major limitation. A > simple example is shown below. > Compile time warning is 'Type Main.SimpleTrait has no fields that are visible > from Scala Type analysis. Falling back to Java Type Analysis...' > Run time error is 'Interfaces and abstract classes are not valid types: > interface Main$SimpleTrait' > Regards, John > val env = ExecutionEnvironment.getExecutionEnvironment > trait SimpleTrait { > def contains(x: String): Boolean > } > class SimpleClass extends SimpleTrait { > def contains(x: String) = true > } > val data: DataSet[Double] = env.fromElements(1.0, 2.0, 3.0, 4.0) > def f(data: DataSet[Double]): DataSet[SimpleTrait] = { > data.mapPartition(iterator => { > Iterator(new SimpleClass) > }) > } > val g = f(data) > g.print() > env.execute("Simple example") -- This message was sent by Atlassian JIRA (v6.3.4#6332)