static void FixupConstructor(MethodInfo method, KotlinConstructor metadata) { if (method is null) { return; } // Hide constructor if it isn't Public/Protected if (method.IsPubliclyVisible && !metadata.Flags.IsPubliclyVisible()) { Log.Debug($"Kotlin: Hiding internal constructor {method.DeclaringType?.ThisClass.Name.Value} - {metadata.GetSignature ()}"); method.AccessFlags = MethodAccessFlags.Private; } }
static MethodInfo FindJavaConstructor(KotlinClass kotlinClass, KotlinConstructor constructor, ClassFile klass) { var all_constructors = klass.Methods.Where(method => method.Name == "<init>" || method.Name == "<clinit>"); var possible_constructors = all_constructors.Where(method => method.GetFilteredParameters().Length == constructor.ValueParameters.Count); foreach (var method in possible_constructors) { if (ParametersMatch(kotlinClass, method, constructor.ValueParameters)) { return(method); } } return(null); }
internal static KotlinClass FromProtobuf(Class c, JvmNameResolver resolver) { return(new KotlinClass { CompanionObjectName = c.CompanionObjectName > 0 ? resolver.GetString(c.CompanionObjectName) : null, Constructors = c.Constructors?.Select(ctor => KotlinConstructor.FromProtobuf(ctor, resolver)).ToList(), EnumEntries = c.EnumEntries?.Select(e => resolver.GetString(e.Name)).ToList(), Flags = (KotlinClassFlags)c.Flags, FullyQualifiedName = c.FqName > 0 ? resolver.GetString(c.FqName) : null, Functions = c.Functions?.Select(f => KotlinFunction.FromProtobuf(f, resolver)).ToList(), NestedClassNames = c.NestedClassNames?.Select(n => resolver.GetString(n)).ToList(), Properties = c.Properties?.Select(p => KotlinProperty.FromProtobuf(p, resolver)).ToList(), SealedSubclassFullyQualifiedNames = c.SealedSubclassFqNames?.Select(n => resolver.GetString(n)).ToList(), SuperTypeIds = c.SupertypeIds?.Select(n => resolver.GetString(n)).ToList(), SuperTypes = c.Supertypes?.Select(st => KotlinType.FromProtobuf(st, resolver)).ToList(), TypeAliases = c.TypeAlias?.Select(tp => KotlinTypeAlias.FromProtobuf(tp, resolver)).ToList(), TypeParameters = c.TypeParameters?.Select(tp => KotlinTypeParameter.FromProtobuf(tp, resolver)).ToList(), VersionRequirements = c.VersionRequirements, TypeTable = KotlinTypeTable.FromProtobuf(c.TypeTable, resolver), VersionRequirementTable = KotlinVersionRequirementTable.FromProtobuf(c.VersionRequirementTable, resolver) }); }