Mangle function names with inline class parameters

Avoid name clashes in cases such as

  inline class Login(val login: String)
  inline class Password(val password: String)

  fun validate(login: Login) { ... }
  fun validate(password: Password) { ... }
This commit is contained in:
Dmitry Petrov
2018-08-15 10:25:49 +03:00
committed by Ilya Gorbunov
parent ff9ba97d66
commit a56d1d3ce8
45 changed files with 1273 additions and 30 deletions
@@ -0,0 +1,37 @@
// !LANGUAGE: +InlineClasses
// !DIAGNOSTICS: -UNUSED_PARAMETER
inline class X(val x: Int)
inline class Z(val x: Int)
inline class Str(val str: String)
inline class Name(val name: String)
inline class NStr(val str: String?)
fun testSimple(x: X) {}
fun testSimple(z: Z) {}
fun testMixed(x: Int, y: Int) {}
fun testMixed(x: X, y: Int) {}
fun testMixed(x: Int, y: X) {}
fun testMixed(x: X, y: X) {}
fun testNewType(s: Str) {}
fun testNewType(name: Name) {}
fun testNullableVsNonNull1(s: Str) {}
fun testNullableVsNonNull1(s: Str?) {}
fun testNullableVsNonNull2(ns: NStr) {}
fun testNullableVsNonNull2(ns: NStr?) {}
<!CONFLICTING_JVM_DECLARATIONS!>fun testFunVsExt(x: X)<!> {}
<!CONFLICTING_JVM_DECLARATIONS!>fun X.testFunVsExt()<!> {}
<!CONFLICTING_JVM_DECLARATIONS!>fun testNonGenericVsGeneric(x: X, y: Number)<!> {}
<!CONFLICTING_JVM_DECLARATIONS!>fun <T : Number> testNonGenericVsGeneric(x: X, y: T)<!> {}
class C<TC : Number> {
<!CONFLICTING_JVM_DECLARATIONS!>fun testNonGenericVsGeneric(x: X, y: Number)<!> {}
<!CONFLICTING_JVM_DECLARATIONS!>fun <T : Number> testNonGenericVsGeneric(x: X, y: T)<!> {}
<!CONFLICTING_JVM_DECLARATIONS!>fun testNonGenericVsGeneric(x: X, y: TC)<!> {}
}
@@ -0,0 +1,68 @@
package
public fun testFunVsExt(/*0*/ x: X): kotlin.Unit
public fun testMixed(/*0*/ x: X, /*1*/ y: X): kotlin.Unit
public fun testMixed(/*0*/ x: X, /*1*/ y: kotlin.Int): kotlin.Unit
public fun testMixed(/*0*/ x: kotlin.Int, /*1*/ y: X): kotlin.Unit
public fun testMixed(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.Int): kotlin.Unit
public fun testNewType(/*0*/ name: Name): kotlin.Unit
public fun testNewType(/*0*/ s: Str): kotlin.Unit
public fun </*0*/ T : kotlin.Number> testNonGenericVsGeneric(/*0*/ x: X, /*1*/ y: T): kotlin.Unit
public fun testNonGenericVsGeneric(/*0*/ x: X, /*1*/ y: kotlin.Number): kotlin.Unit
public fun testNullableVsNonNull1(/*0*/ s: Str): kotlin.Unit
public fun testNullableVsNonNull1(/*0*/ s: Str?): kotlin.Unit
public fun testNullableVsNonNull2(/*0*/ ns: NStr): kotlin.Unit
public fun testNullableVsNonNull2(/*0*/ ns: NStr?): kotlin.Unit
public fun testSimple(/*0*/ x: X): kotlin.Unit
public fun testSimple(/*0*/ z: Z): kotlin.Unit
public fun X.testFunVsExt(): kotlin.Unit
public final class C</*0*/ TC : kotlin.Number> {
public constructor C</*0*/ TC : kotlin.Number>()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final fun </*0*/ T : kotlin.Number> testNonGenericVsGeneric(/*0*/ x: X, /*1*/ y: T): kotlin.Unit
public final fun testNonGenericVsGeneric(/*0*/ x: X, /*1*/ y: TC): kotlin.Unit
public final fun testNonGenericVsGeneric(/*0*/ x: X, /*1*/ y: kotlin.Number): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final inline class NStr {
public constructor NStr(/*0*/ str: kotlin.String?)
public final val str: kotlin.String?
public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String
}
public final inline class Name {
public constructor Name(/*0*/ name: kotlin.String)
public final val name: kotlin.String
public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String
}
public final inline class Str {
public constructor Str(/*0*/ str: kotlin.String)
public final val str: kotlin.String
public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String
}
public final inline class X {
public constructor X(/*0*/ x: kotlin.Int)
public final val x: kotlin.Int
public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String
}
public final inline class Z {
public constructor Z(/*0*/ x: kotlin.Int)
public final val x: kotlin.Int
public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String
}
@@ -0,0 +1,14 @@
// !LANGUAGE: +InlineClasses
inline class Name(val name: String)
inline class Password(val password: String)
interface NameVerifier {
fun verify(name: Name)
}
interface PasswordVerifier {
fun verify(password: Password)
}
interface NameAndPasswordVerifier : NameVerifier, PasswordVerifier
@@ -0,0 +1,39 @@
package
public final inline class Name {
public constructor Name(/*0*/ name: kotlin.String)
public final val name: kotlin.String
public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String
}
public interface NameAndPasswordVerifier : NameVerifier, PasswordVerifier {
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
public abstract override /*1*/ /*fake_override*/ fun verify(/*0*/ name: Name): kotlin.Unit
public abstract override /*1*/ /*fake_override*/ fun verify(/*0*/ password: Password): kotlin.Unit
}
public interface NameVerifier {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
public abstract fun verify(/*0*/ name: Name): kotlin.Unit
}
public final inline class Password {
public constructor Password(/*0*/ password: kotlin.String)
public final val password: kotlin.String
public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String
}
public interface PasswordVerifier {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
public abstract fun verify(/*0*/ password: Password): kotlin.Unit
}