Skip to content

Do not choke on Java's default methods when parsing Java source files #7398

Description

@scabug

Consider the following Java interface that defines default method:

interface TestInterface{
  public void testMe();
   
  default public void aDefaulter() {
    System.out.println("Default from interface");
  }
}

and the following Scala code:

class TestImpl extends TestInterface {
	def testMe() { println("TestImpl.testMe") }
	/*override def aDefaulter() { { println("TestImpl.aDefaulter") } }*/
}

When we try to compile it by passing both source files, Scala's parser for java files chokes on default modifier:

scalac -d classes/ src/TestInterface.java src/TestImpl.scala
src/TestInterface.java:4: error: illegal start of type
  default public void aDefaulter() {
  ^
src/TestInterface.java:7: error: identifier expected but `}' found.
}
^
two errors found

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions