From 7db3a58872593526c2cc175df633161f2ce9cccb Mon Sep 17 00:00:00 2001 From: Lukas Rytz Date: Wed, 27 May 2015 17:29:03 +0200 Subject: Fix illegal inlining of instructions accessing protected members There were two issues in the new inliner that would cause a VerifyError and an IllegalAccessError. First, an access to a public member of package protected class C can only be inlined if the destination class can access C. This is tested by t7582b. Second, an access to a protected member requires the receiver object to be a subtype of the class where the instruction is located. So when inlining such an access, we need to know the type of the receiver object - which we don't have. Therefore we don't inline in this case for now. This can be fixed once we have a type propagation analyis. https://github.com/scala-opt/scala/issues/13. This case is tested by t2106. Force kmpSliceSearch test to delambdafy:inline See discussion on https://github.com/scala/scala/pull/4505. The issue will go away when moving to indy-lambda. --- test/files/run/kmpSliceSearch.flags | 1 + test/files/run/t2106.check | 7 +++++++ test/files/run/t2106.flags | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 test/files/run/kmpSliceSearch.flags (limited to 'test/files/run') diff --git a/test/files/run/kmpSliceSearch.flags b/test/files/run/kmpSliceSearch.flags new file mode 100644 index 0000000000..ac96850b69 --- /dev/null +++ b/test/files/run/kmpSliceSearch.flags @@ -0,0 +1 @@ +-Ydelambdafy:inline \ No newline at end of file diff --git a/test/files/run/t2106.check b/test/files/run/t2106.check index f8f625ff46..66a0e707b3 100644 --- a/test/files/run/t2106.check +++ b/test/files/run/t2106.check @@ -1,3 +1,10 @@ +#partest -Ybackend:GenBCode +t2106.scala:7: warning: A::foo()Ljava/lang/Object; is annotated @inline but could not be inlined: +The callee A::foo()Ljava/lang/Object; contains the instruction INVOKEVIRTUAL java/lang/Object.clone ()Ljava/lang/Object; +that would cause an IllegalAccessError when inlined into class Test$. + def main(args: Array[String]): Unit = x.foo + ^ +#partest !-Ybackend:GenBCode t2106.scala:7: warning: Could not inline required method foo because access level required by callee not matched by caller. def main(args: Array[String]): Unit = x.foo ^ diff --git a/test/files/run/t2106.flags b/test/files/run/t2106.flags index 00d3643fd4..a2e413bb22 100644 --- a/test/files/run/t2106.flags +++ b/test/files/run/t2106.flags @@ -1 +1 @@ --optimise -Yinline-warnings +-optimise -Yinline-warnings -Yopt:l:classpath -- cgit v1.2.3