Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pattern matching using path dependent inner class fails with exception #10067

Closed
scabug opened this issue Nov 17, 2016 · 3 comments
Closed

Pattern matching using path dependent inner class fails with exception #10067

scabug opened this issue Nov 17, 2016 · 3 comments

Comments

@scabug
Copy link

scabug commented Nov 17, 2016

File OuterClass.java

package innerClassPatternMatching;

public class OuterClass {
	public class InnerClass { }
	
	public Object getInnerClassInstance() {
		return new InnerClass();
	}
}

File Bug.scala

package innerClassPatternMatching

class Bug {
	def show() : Unit = {
		//get inner class as some instance of super type
		var oc = new OuterClass();
		var icObj = oc.getInnerClassInstance();
		
		//get a stable identifier on outer class
		val ocStable = oc;
		
		//these will work
		icObj.isInstanceOf[ocStable.InnerClass];
		icObj.asInstanceOf[ocStable.InnerClass];
		
		//this will fail with java.lang.NoSuchMethodError
		icObj match {
			case ic : ocStable.InnerClass =>;
		}
	}
}

Pattern matching will fail at runtime with the following exception:

Exception in thread "main" java.lang.NoSuchMethodError: innerClassPatternMatching.OuterClass$InnerClass.innerClassPatternMatching$OuterClass$InnerClass$$$outer()LinnerClassPatternMatching/OuterClass;
	at innerClassPatternMatching.Bug.show(Bug.scala:18)

Might be related to #4440.

@scabug
Copy link
Author

scabug commented Nov 17, 2016

Imported From: https://issues.scala-lang.org/browse/SI-10067?orig=1
Reporter: Linas (vejobrolis)
Affected Versions: 2.11.8
See #4440, #4400

@scabug
Copy link
Author

scabug commented Nov 18, 2016

@retronym said:
scala/scala#5541

@scabug
Copy link
Author

scabug commented Nov 18, 2016

@retronym said:
Thanks for the report. I think this is distinct from #4400. I've submitted a pull request, which should in in 2.12.2 at the latest.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants