Skip to content

Ignore added/removed and changed anonymous lambdas for Scala 2.12.x #92

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -378,4 +378,8 @@ object ClassfileParser {
(flags & JAVA_ACC_ABSTRACT) != 0
@inline final def isFinal(flags: Int) =
(flags & JAVA_ACC_FINAL) != 0
@inline final def isSynthetic(flags: Int) =
(flags & JAVA_ACC_SYNTHETIC) != 0
@inline final def isBridge(flags: Int) =
(flags & JAVA_ACC_BRIDGE) != 0
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ class MemberInfo(val owner: ClassInfo, val bytecodeName: String, override val fl

def hasSyntheticName: Boolean = decodedName contains '$'

def isAccessible: Boolean = isPublic && !hasSyntheticName
def isAccessible: Boolean = isPublic && !isSynthetic && !hasSyntheticName

def nonAccessible: Boolean = !isAccessible

/** The name of the getter corresponding to this setter */
private def getterName: String = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,14 @@ abstract class PackageInfo(val owner: PackageInfo) {
}

def isAccessible(clazz: ClassInfo, prefix: Set[ClassInfo]) = {
val idx = clazz.decodedName.lastIndexOf("$")
lazy val isReachable =
if (idx < 0) prefix.isEmpty // class name contains no $
else (prefix exists (_.decodedName == clazz.decodedName.substring(0, idx))) // prefix before dollar is an accessible class detected previously
def isReachable = {
if (clazz.isSynthetic) false
else {
val idx = clazz.decodedName.lastIndexOf("$")
if (idx < 0) prefix.isEmpty // class name contains no $
else prefix exists (_.decodedName == clazz.decodedName.substring(0, idx)) // prefix before dollar is an accessible class detected previously
}
}
clazz.isPublic && isReachable
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,10 @@ trait WithLocalModifier extends HasAccessFlags {
def isFinal: Boolean = ClassfileParser.isFinal(flags)

def nonFinal: Boolean = !isFinal
}

def isSynthetic: Boolean = ClassfileParser.isSynthetic(flags)

def isBridge: Boolean = ClassfileParser.isBridge(flags)

def nonBridge: Boolean = !isBridge
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
class A was concrete; is declared abstract in new version
method apply()java.lang.Object in object A does not have a correspondent in new version
method apply()A in object A does not have a correspondent in new version
the type hierarchy of object A has changed in new version. Missing types {scala.runtime.AbstractFunction0}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class A {
private var a = 5
def foo() {
val f1 = () => a.toString
val f2 = (x: Int) => x * a
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class A {
private var a = 5
def foo() {
val f1 = () => a
val f2 = (x: Int) => (x * a).toString
val f3 = (x: Float) => x * a.toFloat
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class A {
private var a = 5
def foo() {
val f1 = () => a.toString
val f2 = (x: Int) => x * a
val f3 = (x: Float) => x * a.toFloat
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class A {
private var a = 5
def foo() {
val f1 = () => a
val f2 = (x: Int) => (x * a).toString
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ private[analyze] abstract class BaseMethodChecker extends Checker[MemberInfo, Cl

private[analyze] class ClassMethodChecker extends BaseMethodChecker {
def check(method: MemberInfo, inclazz: ClassInfo): Option[Problem] = {
if (method.isDeferred)
if (method.nonAccessible)
None
else if (method.isDeferred)
super.check(method, inclazz.lookupMethods(method.bytecodeName))
else
super.check(method, inclazz.lookupClassMethods(method.bytecodeName))
Expand All @@ -46,11 +48,12 @@ private[analyze] class ClassMethodChecker extends BaseMethodChecker {

private[analyze] class TraitMethodChecker extends BaseMethodChecker {
def check(method: MemberInfo, inclazz: ClassInfo): Option[Problem] = {
if (method.owner.hasStaticImpl(method)) {
if (method.nonAccessible)
None
else if (method.owner.hasStaticImpl(method))
checkStaticImplMethod(method, inclazz)
} else {
else
super.check(method, inclazz.lookupMethods(method.bytecodeName))
}
}

private def checkStaticImplMethod(method: MemberInfo, inclazz: ClassInfo) = {
Expand Down