rename @overloads annotation to @jvmOverloads

This commit is contained in:
Dmitry Jemerov
2015-05-26 19:32:05 +02:00
parent 5c7d13e23c
commit 1188e57597
51 changed files with 66 additions and 66 deletions
@@ -58,7 +58,7 @@ public class DefaultParameterValueSubstitutor(val state: GenerationState) {
} }
/** /**
* If the function is annotated with [kotlin.jvm.overloads], generates Java methods that * If the function is annotated with [kotlin.jvm.jvmOverloads], generates Java methods that
* have the default parameter values substituted. If a method has N parameters and M of which * have the default parameter values substituted. If a method has N parameters and M of which
* have default values, M overloads are generated: the first one takes N-1 parameters (all but * have default values, M overloads are generated: the first one takes N-1 parameters (all but
* the last one that takes a default value), the second takes N-2 parameters, and so on. * the last one that takes a default value), the second takes N-2 parameters, and so on.
@@ -75,7 +75,7 @@ public class DefaultParameterValueSubstitutor(val state: GenerationState) {
delegateFunctionDescriptor: FunctionDescriptor, delegateFunctionDescriptor: FunctionDescriptor,
owner: CodegenContext<*>, owner: CodegenContext<*>,
classBuilder: ClassBuilder): Boolean { classBuilder: ClassBuilder): Boolean {
if (functionDescriptor.getAnnotations().findAnnotation(FqName("kotlin.jvm.overloads")) == null) { if (functionDescriptor.getAnnotations().findAnnotation(FqName("kotlin.jvm.jvmOverloads")) == null) {
return false return false
} }
@@ -120,7 +120,7 @@ public class PlatformStaticAnnotationChecker : DeclarationChecker {
public class OverloadsAnnotationChecker: DeclarationChecker { public class OverloadsAnnotationChecker: DeclarationChecker {
override fun check(declaration: JetDeclaration, descriptor: DeclarationDescriptor, diagnosticHolder: DiagnosticSink) { override fun check(declaration: JetDeclaration, descriptor: DeclarationDescriptor, diagnosticHolder: DiagnosticSink) {
if (descriptor.getAnnotations().findAnnotation(FqName("kotlin.jvm.overloads")) != null) { if (descriptor.getAnnotations().findAnnotation(FqName("kotlin.jvm.jvmOverloads")) != null) {
checkDeclaration(declaration, descriptor, diagnosticHolder) checkDeclaration(declaration, descriptor, diagnosticHolder)
} }
} }
@@ -48,9 +48,9 @@ public class DefaultErrorMessagesJvm implements DefaultErrorMessages.Extension {
MAP.put(ErrorsJvm.PLATFORM_STATIC_NOT_IN_OBJECT, "Only functions in named objects and companion objects of classes can be annotated with 'platformStatic'"); MAP.put(ErrorsJvm.PLATFORM_STATIC_NOT_IN_OBJECT, "Only functions in named objects and companion objects of classes can be annotated with 'platformStatic'");
MAP.put(ErrorsJvm.OVERRIDE_CANNOT_BE_STATIC, "Override member cannot be 'platformStatic' in object"); MAP.put(ErrorsJvm.OVERRIDE_CANNOT_BE_STATIC, "Override member cannot be 'platformStatic' in object");
MAP.put(ErrorsJvm.PLATFORM_STATIC_ILLEGAL_USAGE, "This declaration does not support ''platformStatic''", DescriptorRenderer.SHORT_NAMES_IN_TYPES); MAP.put(ErrorsJvm.PLATFORM_STATIC_ILLEGAL_USAGE, "This declaration does not support ''platformStatic''", DescriptorRenderer.SHORT_NAMES_IN_TYPES);
MAP.put(ErrorsJvm.OVERLOADS_WITHOUT_DEFAULT_ARGUMENTS, "''overloads'' annotation has no effect for methods without default arguments"); MAP.put(ErrorsJvm.OVERLOADS_WITHOUT_DEFAULT_ARGUMENTS, "''jvmOverloads'' annotation has no effect for methods without default arguments");
MAP.put(ErrorsJvm.OVERLOADS_ABSTRACT, "''overloads'' annotation cannot be used on abstract methods"); MAP.put(ErrorsJvm.OVERLOADS_ABSTRACT, "''jvmOverloads'' annotation cannot be used on abstract methods");
MAP.put(ErrorsJvm.OVERLOADS_PRIVATE, "''overloads'' annotation has no effect on private and local declarations"); MAP.put(ErrorsJvm.OVERLOADS_PRIVATE, "''jvmOverloads'' annotation has no effect on private and local declarations");
MAP.put(ErrorsJvm.NATIVE_DECLARATION_CANNOT_BE_ABSTRACT, "Native declaration can not be abstract"); MAP.put(ErrorsJvm.NATIVE_DECLARATION_CANNOT_BE_ABSTRACT, "Native declaration can not be abstract");
MAP.put(ErrorsJvm.NATIVE_DECLARATION_CANNOT_HAVE_BODY, "Native declaration can not have a body"); MAP.put(ErrorsJvm.NATIVE_DECLARATION_CANNOT_HAVE_BODY, "Native declaration can not have a body");
MAP.put(ErrorsJvm.NATIVE_DECLARATION_IN_TRAIT, "Members of interfaces can not be native"); MAP.put(ErrorsJvm.NATIVE_DECLARATION_IN_TRAIT, "Members of interfaces can not be native");
@@ -1,13 +1,13 @@
public final class C { public final class C {
@kotlin.jvm.overloads @kotlin.jvm.jvmOverloads
@org.jetbrains.annotations.NotNull @org.jetbrains.annotations.NotNull
public final java.lang.String foo(@org.jetbrains.annotations.NotNull java.lang.String o, @org.jetbrains.annotations.NotNull java.lang.String s1, @org.jetbrains.annotations.NotNull java.lang.String k, @org.jetbrains.annotations.Nullable java.lang.String s2) { /* compiled code */ } public final java.lang.String foo(@org.jetbrains.annotations.NotNull java.lang.String o, @org.jetbrains.annotations.NotNull java.lang.String s1, @org.jetbrains.annotations.NotNull java.lang.String k, @org.jetbrains.annotations.Nullable java.lang.String s2) { /* compiled code */ }
@kotlin.jvm.overloads @kotlin.jvm.jvmOverloads
@org.jetbrains.annotations.NotNull @org.jetbrains.annotations.NotNull
public java.lang.String foo(@org.jetbrains.annotations.NotNull java.lang.String p, @org.jetbrains.annotations.NotNull java.lang.String p1, @org.jetbrains.annotations.Nullable java.lang.String p2) { /* compiled code */ } public java.lang.String foo(@org.jetbrains.annotations.NotNull java.lang.String p, @org.jetbrains.annotations.NotNull java.lang.String p1, @org.jetbrains.annotations.Nullable java.lang.String p2) { /* compiled code */ }
@kotlin.jvm.overloads @kotlin.jvm.jvmOverloads
@org.jetbrains.annotations.NotNull @org.jetbrains.annotations.NotNull
public java.lang.String foo(@org.jetbrains.annotations.NotNull java.lang.String p, @org.jetbrains.annotations.Nullable java.lang.String p1) { /* compiled code */ } public java.lang.String foo(@org.jetbrains.annotations.NotNull java.lang.String p, @org.jetbrains.annotations.Nullable java.lang.String p1) { /* compiled code */ }
@@ -1,7 +1,7 @@
// C // C
class C { class C {
[kotlin.jvm.overloads] public fun foo(o: String = "O", s1: String, k: String = "K", s2: String?): String { [kotlin.jvm.jvmOverloads] public fun foo(o: String = "O", s1: String, k: String = "K", s2: String?): String {
return o + k return o + k
} }
} }
@@ -1,5 +1,5 @@
class C<T> { class C<T> {
[kotlin.jvm.overloads] public fun foo(o: T, k: String = "K"): String = o.toString() + k [kotlin.jvm.jvmOverloads] public fun foo(o: T, k: String = "K"): String = o.toString() + k
} }
fun box(): String { fun box(): String {
@@ -1,5 +1,5 @@
class C { class C {
[kotlin.jvm.overloads] public fun foo(o: String = "O", k: String = "K"): String = o + k [kotlin.jvm.jvmOverloads] public fun foo(o: String = "O", k: String = "K"): String = o + k
} }
fun box(): String { fun box(): String {
@@ -1,6 +1,6 @@
class C { class C {
companion object { companion object {
[kotlin.platform.platformStatic] [kotlin.jvm.overloads] public fun foo(o: String, k: String = "K"): String { [kotlin.platform.platformStatic] [kotlin.jvm.jvmOverloads] public fun foo(o: String, k: String = "K"): String {
return o + k return o + k
} }
} }
@@ -1,5 +1,5 @@
class C { class C {
[kotlin.jvm.overloads] public fun foo(o: String = "O", i1: Int, k: String = "K", i2: Int): String { [kotlin.jvm.jvmOverloads] public fun foo(o: String = "O", i1: Int, k: String = "K", i2: Int): String {
return o + k return o + k
} }
} }
@@ -1,5 +1,5 @@
class C { class C {
[kotlin.jvm.overloads] public fun foo(d1: Double, d2: Double, status: String = "OK"): String { [kotlin.jvm.jvmOverloads] public fun foo(d1: Double, d2: Double, status: String = "OK"): String {
return if (d1 + d2 == 3.0) status else "fail" return if (d1 + d2 == 3.0) status else "fail"
} }
} }
@@ -1,7 +1,7 @@
class C { class C {
} }
[kotlin.jvm.overloads] fun C.foo(o: String, k: String = "K"): String { [kotlin.jvm.jvmOverloads] fun C.foo(o: String, k: String = "K"): String {
return o + k return o + k
} }
@@ -1,5 +1,5 @@
class C { class C {
[kotlin.jvm.overloads] public fun foo(o: String = "O", k: String = "K"): String { [kotlin.jvm.jvmOverloads] public fun foo(o: String = "O", k: String = "K"): String {
return o + k return o + k
} }
} }
@@ -1,5 +1,5 @@
class C { class C {
[kotlin.jvm.overloads] public fun foo(o: String, k: String = "K"): String { [kotlin.jvm.jvmOverloads] public fun foo(o: String, k: String = "K"): String {
return o + k return o + k
} }
} }
@@ -1,4 +1,4 @@
class C [kotlin.jvm.overloads] (s1: String, s2: String = "K") { class C [kotlin.jvm.jvmOverloads] (s1: String, s2: String = "K") {
public val status: String = s1 + s2 public val status: String = s1 + s2
} }
@@ -1,7 +1,7 @@
class C(val i: Int) { class C(val i: Int) {
var status = "fail" var status = "fail"
[kotlin.jvm.overloads] constructor(o: String, k: String = "K"): this(-1) { [kotlin.jvm.jvmOverloads] constructor(o: String, k: String = "K"): this(-1) {
status = o + k status = o + k
} }
} }
@@ -1,5 +1,5 @@
class C { class C {
[kotlin.jvm.overloads] public fun foo(s: String = "OK"): String { [kotlin.jvm.jvmOverloads] public fun foo(s: String = "OK"): String {
return s return s
} }
} }
@@ -2,7 +2,7 @@ package test
class E1: Exception() class E1: Exception()
throws(E1::class) overloads throws(E1::class) jvmOverloads
fun one(a: Int = 1) {} fun one(a: Int = 1) {}
class One [throws(E1::class)] (a: Int = 1) { class One [throws(E1::class)] (a: Int = 1) {
@@ -1,7 +1,7 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER // !DIAGNOSTICS: -UNUSED_PARAMETER
class C { class C {
<!OVERLOADS_WITHOUT_DEFAULT_ARGUMENTS!>@kotlin.jvm.overloads constructor()<!> { <!OVERLOADS_WITHOUT_DEFAULT_ARGUMENTS!>@kotlin.jvm.jvmOverloads constructor()<!> {
} }
<!OVERLOADS_WITHOUT_DEFAULT_ARGUMENTS!>@kotlin.jvm.overloads fun foo(s: String)<!> {} <!OVERLOADS_WITHOUT_DEFAULT_ARGUMENTS!>@kotlin.jvm.jvmOverloads fun foo(s: String)<!> {}
} }
@@ -1,9 +1,9 @@
package package
internal final class C { internal final class C {
kotlin.jvm.overloads() public constructor C() kotlin.jvm.jvmOverloads() public constructor C()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
kotlin.jvm.overloads() internal final fun foo(/*0*/ s: kotlin.String): kotlin.Unit kotlin.jvm.jvmOverloads() internal final fun foo(/*0*/ s: kotlin.String): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
} }
@@ -1,8 +1,8 @@
interface T { interface T {
<!OVERLOADS_ABSTRACT!>@kotlin.jvm.overloads fun foo(s: String = "OK")<!> <!OVERLOADS_ABSTRACT!>@kotlin.jvm.jvmOverloads fun foo(s: String = "OK")<!>
} }
abstract class C { abstract class C {
<!OVERLOADS_ABSTRACT!>@kotlin.jvm.overloads abstract fun foo(s: String = "OK")<!> <!OVERLOADS_ABSTRACT!>@kotlin.jvm.jvmOverloads abstract fun foo(s: String = "OK")<!>
} }
@@ -3,14 +3,14 @@ package
internal abstract class C { internal abstract class C {
public constructor C() public constructor C()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
kotlin.jvm.overloads() internal abstract fun foo(/*0*/ s: kotlin.String = ...): kotlin.Unit kotlin.jvm.jvmOverloads() internal abstract fun foo(/*0*/ s: kotlin.String = ...): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
} }
internal interface T { internal interface T {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
kotlin.jvm.overloads() internal abstract fun foo(/*0*/ s: kotlin.String = ...): kotlin.Unit kotlin.jvm.jvmOverloads() internal abstract fun foo(/*0*/ s: kotlin.String = ...): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
} }
@@ -1,20 +1,20 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER // !DIAGNOSTICS: -UNUSED_PARAMETER
class C { class C {
<!OVERLOADS_PRIVATE!>@kotlin.jvm.overloads private fun foo(s: String = "OK")<!> { <!OVERLOADS_PRIVATE!>@kotlin.jvm.jvmOverloads private fun foo(s: String = "OK")<!> {
} }
@kotlin.jvm.overloads fun bar(s: String = "OK") { @kotlin.jvm.jvmOverloads fun bar(s: String = "OK") {
} }
} }
fun foo() { fun foo() {
class D { class D {
<!OVERLOADS_PRIVATE!>@kotlin.jvm.overloads fun foo(s: String = "OK")<!> { <!OVERLOADS_PRIVATE!>@kotlin.jvm.jvmOverloads fun foo(s: String = "OK")<!> {
} }
} }
val <!UNUSED_VARIABLE!>x<!> = object { val <!UNUSED_VARIABLE!>x<!> = object {
<!OVERLOADS_PRIVATE!>@kotlin.jvm.overloads fun foo(s: String = "OK")<!> { <!OVERLOADS_PRIVATE!>@kotlin.jvm.jvmOverloads fun foo(s: String = "OK")<!> {
} }
} }
} }
@@ -4,9 +4,9 @@ internal fun foo(): kotlin.Unit
internal final class C { internal final class C {
public constructor C() public constructor C()
kotlin.jvm.overloads() internal final fun bar(/*0*/ s: kotlin.String = ...): kotlin.Unit kotlin.jvm.jvmOverloads() internal final fun bar(/*0*/ s: kotlin.String = ...): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
kotlin.jvm.overloads() private final fun foo(/*0*/ s: kotlin.String = ...): kotlin.Unit kotlin.jvm.jvmOverloads() private final fun foo(/*0*/ s: kotlin.String = ...): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
} }
@@ -1,6 +1,6 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER // !DIAGNOSTICS: -UNUSED_PARAMETER
class A { class A {
<!CONFLICTING_JVM_DECLARATIONS!>@kotlin.jvm.overloads fun foo(s: String = "")<!> { <!CONFLICTING_JVM_DECLARATIONS!>@kotlin.jvm.jvmOverloads fun foo(s: String = "")<!> {
} }
<!CONFLICTING_JVM_DECLARATIONS!>fun foo()<!> { <!CONFLICTING_JVM_DECLARATIONS!>fun foo()<!> {
@@ -4,7 +4,7 @@ internal final class A {
public constructor A() public constructor A()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
internal final fun foo(): kotlin.Unit internal final fun foo(): kotlin.Unit
kotlin.jvm.overloads() internal final fun foo(/*0*/ s: kotlin.String = ...): kotlin.Unit kotlin.jvm.jvmOverloads() internal final fun foo(/*0*/ s: kotlin.String = ...): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
} }
@@ -2,7 +2,7 @@ package test.kotlin
interface A interface A
kotlin.jvm.overloads kotlin.jvm.jvmOverloads
public fun foo<T : A>(k: Class<T>, a: A, b: Boolean = false, s: String="hello"): List<T> { public fun foo<T : A>(k: Class<T>, a: A, b: Boolean = false, s: String="hello"): List<T> {
println("$b $s") println("$b $s")
return listOf() return listOf()
@@ -49,7 +49,7 @@ interface TraitWithImpl {
public class TraitWithDelegatedWithImpl(f: TraitWithImpl) : TraitWithImpl by f public class TraitWithDelegatedWithImpl(f: TraitWithImpl) : TraitWithImpl by f
kotlin.jvm.overloads kotlin.jvm.jvmOverloads
public fun withJvmOverloads(i: Int, b: Boolean = false, s: String="hello") {} public fun withJvmOverloads(i: Int, b: Boolean = false, s: String="hello") {}
@@ -422,7 +422,7 @@ class Converter private(
if (function.parameterList.parameters.any { it.defaultValue != null }) { if (function.parameterList.parameters.any { it.defaultValue != null }) {
function.annotations += Annotations( function.annotations += Annotations(
listOf(Annotation(Identifier("overloads").assignNoPrototype(), listOf(Annotation(Identifier("jvmOverloads").assignNoPrototype(),
listOf(), listOf(),
brackets = function is PrimaryConstructor, brackets = function is PrimaryConstructor,
newLineAfter = false).assignNoPrototype())).assignNoPrototype() newLineAfter = false).assignNoPrototype())).assignNoPrototype()
@@ -1,5 +1,5 @@
class A// this is a primary constructor class A// this is a primary constructor
[overloads] (p: Int = 1) { [jvmOverloads] (p: Int = 1) {
private val v: Int private val v: Int
init { init {
@@ -1,6 +1,6 @@
package pack package pack
class C [overloads] (arg1: Int, arg2: Int = 0, arg3: Int = 0) class C [jvmOverloads] (arg1: Int, arg2: Int = 0, arg3: Int = 0)
public object User { public object User {
public fun main() { public fun main() {
@@ -1 +1 @@
class C [overloads] (private val string: String, a: Int = string.length()) class C [jvmOverloads] (private val string: String, a: Int = string.length())
@@ -1,4 +1,4 @@
class A [overloads] (nested: A.Nested = A.Nested(A.Nested.FIELD)) { class A [jvmOverloads] (nested: A.Nested = A.Nested(A.Nested.FIELD)) {
class Nested(p: Int) { class Nested(p: Int) {
companion object { companion object {
@@ -1,7 +1,7 @@
// ERROR: Property must be initialized or be abstract // ERROR: Property must be initialized or be abstract
import A.Nested import A.Nested
class A [overloads] (nested: Nested = Nested(Nested.FIELD)) { class A [jvmOverloads] (nested: Nested = Nested(Nested.FIELD)) {
class Nested(p: Int) { class Nested(p: Int) {
companion object { companion object {
@@ -3,7 +3,7 @@ package pack
import pack.A.Nested import pack.A.Nested
class A [overloads] (nested: Nested = Nested(Nested.FIELD)) { class A [jvmOverloads] (nested: Nested = Nested(Nested.FIELD)) {
class Nested(p: Int) { class Nested(p: Int) {
companion object { companion object {
@@ -3,7 +3,7 @@ package pack
import pack.A.* import pack.A.*
class A [overloads] (nested: Nested = Nested(Nested.FIELD)) { class A [jvmOverloads] (nested: Nested = Nested(Nested.FIELD)) {
class Nested(p: Int) { class Nested(p: Int) {
companion object { companion object {
@@ -1,6 +1,6 @@
package pack package pack
class C [overloads] (a: Int = 0, b: Int = 0, c: Int = 0, d: Int = 0, e: Int = 0) { class C [jvmOverloads] (a: Int = 0, b: Int = 0, c: Int = 0, d: Int = 0, e: Int = 0) {
constructor(a: Int) : this(a, 0, 0, 0, 1) { constructor(a: Int) : this(a, 0, 0, 0, 1) {
} }
@@ -1,6 +1,6 @@
package pack package pack
class C [overloads] (a: Int = 0, b: Int = 0, c: Int = 0, d: Int = 0, e: Int = 0) { class C [jvmOverloads] (a: Int = 0, b: Int = 0, c: Int = 0, d: Int = 0, e: Int = 0) {
constructor(a1: Int, b1: Int, c1: Int) : this(a1, b1, c1, 0, 0) { constructor(a1: Int, b1: Int, c1: Int) : this(a1, b1, c1, 0, 0) {
} }
@@ -1,6 +1,6 @@
package pack package pack
class C [overloads] (a: Int = 0, b: Int = 0, c: Int = 0, d: Int = 0, e: Int = 0) { class C [jvmOverloads] (a: Int = 0, b: Int = 0, c: Int = 0, d: Int = 0, e: Int = 0) {
constructor(a: Int, b: Int, c: Int) : this(b, a, c, 0, 0) { constructor(a: Int, b: Int, c: Int) : this(b, a, c, 0, 0) {
} }
@@ -1,3 +1,3 @@
package pack package pack
class C [overloads] (a: Int = 1, b: Int = 2, c: Int = 3, d: Int = 4, e: Int = 5) class C [jvmOverloads] (a: Int = 1, b: Int = 2, c: Int = 3, d: Int = 4, e: Int = 5)
@@ -1,3 +1,3 @@
package pack package pack
class C [overloads] (a: Int = 1, b: Int = 2, c: Int = 3, d: Int = 4, e: Int = 5) class C [jvmOverloads] (a: Int = 1, b: Int = 2, c: Int = 3, d: Int = 4, e: Int = 5)
@@ -1,5 +1,5 @@
// ERROR: Overload resolution ambiguity: public constructor C(arg1: kotlin.Int, arg2: kotlin.Int) defined in C kotlin.jvm.overloads public constructor C(arg1: kotlin.Int, arg2: kotlin.Int = ..., arg3: kotlin.Int = ...) defined in C // ERROR: Overload resolution ambiguity: public constructor C(arg1: kotlin.Int, arg2: kotlin.Int) defined in C kotlin.jvm.jvmOverloads public constructor C(arg1: kotlin.Int, arg2: kotlin.Int = ..., arg3: kotlin.Int = ...) defined in C
class C [overloads] (arg1: Int, arg2: Int = 0, arg3: Int = 0) { class C [jvmOverloads] (arg1: Int, arg2: Int = 0, arg3: Int = 0) {
private val field: Int private val field: Int
init { init {
@@ -1,4 +1,4 @@
class C [overloads] private (arg1: Int, arg2: Int, arg3: Int = 0) { class C [jvmOverloads] private (arg1: Int, arg2: Int, arg3: Int = 0) {
public constructor(arg1: Int) : this(arg1, 0, 0) { public constructor(arg1: Int) : this(arg1, 0, 0) {
} }
@@ -7,7 +7,7 @@ class A {
public constructor() { public constructor() {
} }
overloads public constructor(p: Int, s: String, x: Int = 1) { jvmOverloads public constructor(p: Int, s: String, x: Int = 1) {
this.s = s this.s = s
this.x = x this.x = x
} }
@@ -4,7 +4,7 @@ class A() {
private val s = "" private val s = ""
private val x = 0 private val x = 0
overloads public constructor(p: Int, s: String, x: Int = 1) : this() { jvmOverloads public constructor(p: Int, s: String, x: Int = 1) : this() {
this.s = s this.s = s
this.x = x this.x = x
} }
@@ -1 +1 @@
public class C [overloads] (c: C, public val x: Int = c.x) public class C [jvmOverloads] (c: C, public val x: Int = c.x)
@@ -1,7 +1,7 @@
// ERROR: Type mismatch: inferred type is kotlin.Any? but kotlin.Any was expected // ERROR: Type mismatch: inferred type is kotlin.Any? but kotlin.Any was expected
// ERROR: Type mismatch: inferred type is kotlin.Any? but kotlin.Any was expected // ERROR: Type mismatch: inferred type is kotlin.Any? but kotlin.Any was expected
class A { class A {
overloads fun foo(s: String? = null): Any { jvmOverloads fun foo(s: String? = null): Any {
println("s = " + s!!) println("s = " + s!!)
return "" return ""
} }
@@ -1,9 +1,9 @@
class A { class A {
overloads fun foo(i: Int, c: Char = 'a', s: String = "") { jvmOverloads fun foo(i: Int, c: Char = 'a', s: String = "") {
println("foo" + i + c + s) println("foo" + i + c + s)
} }
overloads fun bar(s: String? = null): Int { jvmOverloads fun bar(s: String? = null): Int {
println("s = " + s!!) println("s = " + s!!)
return 0 return 0
} }
@@ -1,6 +1,6 @@
package test package test
kotlin.jvm.overloads kotlin.jvm.jvmOverloads
fun f(a: String, b: Int = 5) { fun f(a: String, b: Int = 5) {
} }
@@ -1,6 +1,6 @@
package test package test
kotlin.jvm.overloads kotlin.jvm.jvmOverloads
fun f(a: String, b: Int = 5) { fun f(a: String, b: Int = 5) {
} }
+1 -1
View File
@@ -17,4 +17,4 @@
package kotlin.jvm package kotlin.jvm
// is used in common generated code in stdlib // is used in common generated code in stdlib
internal annotation class overloads internal annotation class jvmOverloads
@@ -26,4 +26,4 @@ import java.lang.annotation.RetentionPolicy
* takes N-1 parameters (all but the last one that takes a default value), the second takes N-2 parameters, and so on. * takes N-1 parameters (all but the last one that takes a default value), the second takes N-2 parameters, and so on.
*/ */
Retention(RetentionPolicy.CLASS) Retention(RetentionPolicy.CLASS)
public annotation class overloads public annotation class jvmOverloads