Skip to content

Nested Java interfaces not found in Scala and Java #1409

Closed
@scabug

Description

@scabug

Compiling the following two .java files with javac succeeds as expected,

OuterInterface.java:

public interface OuterInterface {
  public interface InnerInterface {
    public void foo();
  }
}
AbstractImpl.java:

public abstract class AbstractImpl implements OuterInterface {
  public abstract InnerInterface create();
}

However, if the following .scala class is added,

ConcreteImpl.scala:

class ConcreteImpl extends AbstractImpl {
  def create : InnerInterface = null
}

and all three are compiled with scalac 2.7.2.RC2, the following unexpected errors are reported against both the Scala and the Java,

miles@frege:test$$ scalac *
ConcreteImpl.scala:2: error: not found: type InnerInterface
  def create : InnerInterface = null
               ^
AbstractImpl.java:2: error: not found: type InnerInterface
  public abstract InnerInterface create();
                  ^
two errors found

The only workaround is to add redundant qualifiers to both the Java and the Scala sources,

AbstractImpl2.java:

public abstract class AbstractImpl implements OuterInterface {
  public abstract OuterInterface.InnerInterface create();
}
ConcreteImpl2.scala:

class ConcreteImpl extends AbstractImpl {
  def create : OuterInterface.InnerInterface = null
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions