Avoid assertion in bridges-generation for light classes
^KT-11656
This commit is contained in:
@@ -56,7 +56,7 @@ fun <Function : FunctionHandle, Signature> generateBridges(
|
||||
// into some of the super-classes and will be inherited in this class
|
||||
if (fake && function.getOverridden().none { it.isAbstract }) return setOf()
|
||||
|
||||
val implementation = findConcreteSuperDeclaration(function)
|
||||
val implementation = findConcreteSuperDeclaration(function) ?: return setOf()
|
||||
|
||||
val bridgesToGenerate = findAllReachableDeclarations(function).mapTo(LinkedHashSet<Signature>(), signature)
|
||||
|
||||
@@ -94,7 +94,7 @@ fun <Function : FunctionHandle> findAllReachableDeclarations(function: Function)
|
||||
* Given a concrete function, finds an implementation (a concrete declaration) of this function in the supertypes.
|
||||
* The implementation is guaranteed to exist because if it wouldn't, the given function would've been abstract
|
||||
*/
|
||||
fun <Function : FunctionHandle> findConcreteSuperDeclaration(function: Function): Function {
|
||||
fun <Function : FunctionHandle> findConcreteSuperDeclaration(function: Function): Function? {
|
||||
require(!function.isAbstract, { "Only concrete functions have implementations: $function" })
|
||||
|
||||
if (function.isDeclaration) return function
|
||||
@@ -118,7 +118,11 @@ fun <Function : FunctionHandle> findConcreteSuperDeclaration(function: Function)
|
||||
|
||||
val concreteRelevantDeclarations = result.filter { !it.isAbstract && it.mayBeUsedAsSuperImplementation }
|
||||
if (concreteRelevantDeclarations.size != 1) {
|
||||
error("Concrete fake override $function should have exactly one concrete super-declaration: $concreteRelevantDeclarations")
|
||||
if (!function.mightBeIncorrectCode) {
|
||||
error("Concrete fake override $function should have exactly one concrete super-declaration: $concreteRelevantDeclarations")
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
return concreteRelevantDeclarations[0]
|
||||
|
||||
Reference in New Issue
Block a user