Silver: Weird verifier failed: bad method exception

IDE: Fire
Version: 9.0.97.2071, 9.1.100.2076
Target: Java
Description:

Run into really weird issue:

  1. I have a realm persistent object defined in Java library. Let’s call it rReport entity, this entity is a subclass of Object class defined in realm library.
  2. This realm persistent rReport class is extended in Silver.
  3. There is a container class Report that hides rReport inside, which has a base superclass BaseEntity.

BaseEntity:

public class BaseEntity {
	
	public enum PersistenceKind {
		#if os(Linux)
		
		//will be implemented in future
		case postgres
		
		#else
		
		case realm
		
		#endif
	}
	
	#if os(Linux)
	
	public private(set) var backingPersistenceKind: PersistenceKind = .postgres
	internal var _persistentEntity: pgresObject
	
	public init(persistentEntity: pgresObject){
		_persistentEntity = persistentEntity
	}
	
	#else
	
	public private(set) var backingPersistenceKind: PersistenceKind = .realm
	internal var _persistentEntity: Object

	public required init(persistentEntity: Object){
		_persistentEntity = persistentEntity
	}
	
	#endif
	
	#if COOPER
	public static func instance(with persistentEntity: Object) -> Self {
		return Self(persistentEntity: persistentEntity)
	}
	#endif
}

now this Report class has a following initializer:

public init(persistentEntityWithIdentifier identifier: String) throws {
		
	let realm = try RealmGate.defaultRealm()
	let thisInstancesInCurrentRealm = realm.objects(rCategory.self).where(field: FieldLiteral.identifier, equalsTo: identifier).all
	if thisInstancesInCurrentRealm.count > 1 {
		print("Unexpectedly found \(thisInstancesInCurrentRealm.count) instance when 1 is expected with identifier: \(identifier)")
	}
		
	guard let thisInstanceInCurrentRealm = thisInstancesInCurrentRealm.first else {
		throw Error.EntityNotFound
	}
		
	//if you don't cast it to Object, the runtime (Verifier failed: bad method) exception will occur in Silver
	super.init(persistentEntity: thisInstanceInCurrentRealm as Object)
}

Notice the last super.init call I need to cast thisInstanceInCurrentRealm to its superclass.
Without this cast on app launch I will get runtime (Verifier failed: bad method) exception

Same as the other one. If I can’t reproduce it here, I can’t fix it.

@ck: Will create a sample project for you guys a bit later. (just found a timeframe today to report all issues encountered in previous several month)