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

Comments

Projects
None yet
2 participants
@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

This comment has been minimized.

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

This comment has been minimized.

Copy link
Author

scabug commented Nov 18, 2016

@scabug

This comment has been minimized.

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.

@scabug scabug closed this Dec 19, 2016

@scabug scabug added this to the 2.12.2 milestone Apr 7, 2017

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