- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
constructor not accessible
Fri, 2009-03-27, 17:53
Hi,
I have some weird behavior with the scala compiler making a difference between
typed java public and protected constructors.
Given the following Java class:
----------
package jfiles;
public abstract class DataView { protected DataView(T id) { } }
----------
When trying to extend this class in Scala with
----------
package sfiles
import jfiles.DataView
class myDataView extends DataView( "String" )
----------
I get the following error:
sfiles/myDataView.scala:3: error: constructor DataView cannot be accessed in
package sfiles
class myDataView extends DataView( "String" )
If the Java class has a public constructor, this works without a problem!
To get the above Scala source compiling with the protected version, I need to
give a hint on the type:
----------
package sfiles
import jfiles.DataView
class myDataView extends DataView[String]( "String" )
----------
Can someone give me a hint why? At least the error message is somewhat
irritating. Or should I call this a bug and file it?
Best regards, --- Jan.
2009/3/27 Jan Kriesten <kriesten@mail.footprint.de>