Report conflicting overloads for constructors

- It's worked almost fine but diagnostics were filtered out by
  positioning strategy.

- Also a couple of "put" calls to Multimap are replaced by "putValues"
  within OverloadResolver, that is more semantically correct.

- Note that constructors of top-level classes are handled when processing
  package, it helps to figure out if there are clashes with top-level
  functions that have the same name.

- But constructors of different classes are not reported as
  overloads because containing classes has the same name and will be
  reported as redeclaration.
This commit is contained in:
Denis Zharkov
2015-03-04 19:02:09 +03:00
parent 9d2d3c0c7b
commit 5eb4dcd913
7 changed files with 153 additions and 7 deletions
@@ -0,0 +1,28 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
class <!CONFLICTING_OVERLOADS!>A(x: String = "", y: String = "")<!> {
<!CONFLICTING_OVERLOADS!>constructor(x: String, y: String)<!>: <!OVERLOAD_RESOLUTION_AMBIGUITY!>this<!>(x, y) {}
<!CONFLICTING_OVERLOADS!>constructor()<!>: <!OVERLOAD_RESOLUTION_AMBIGUITY!>this<!>("", "") {}
<!CONFLICTING_OVERLOADS!>constructor()<!>: <!OVERLOAD_RESOLUTION_AMBIGUITY!>this<!>("", "") {}
}
class B {
<!CONFLICTING_OVERLOADS!>constructor(x: Int)<!> {}
}
<!CONFLICTING_OVERLOADS!>fun B(x: Int)<!> {}
class Outer {
class <!CONFLICTING_OVERLOADS!>A(x: String = "", y: String = "")<!> {
<!CONFLICTING_OVERLOADS!>constructor(x: String, y: String)<!>: <!OVERLOAD_RESOLUTION_AMBIGUITY!>this<!>(x, y) {}
<!CONFLICTING_OVERLOADS!>constructor()<!>: <!OVERLOAD_RESOLUTION_AMBIGUITY!>this<!>("", "") {}
<!CONFLICTING_OVERLOADS!>constructor()<!>: <!OVERLOAD_RESOLUTION_AMBIGUITY!>this<!>("", "") {}
}
class B {
<!CONFLICTING_OVERLOADS!>constructor(x: Int)<!> {
}
}
<!CONFLICTING_OVERLOADS!>fun B(x: Int)<!> {}
}
@@ -0,0 +1,45 @@
package
internal fun B(/*0*/ x: kotlin.Int): kotlin.Unit
internal final class A {
public constructor A()
public constructor A()
public constructor A(/*0*/ x: kotlin.String = ..., /*1*/ y: kotlin.String = ...)
public constructor A(/*0*/ x: kotlin.String, /*1*/ y: kotlin.String)
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
}
internal final class B {
public constructor B(/*0*/ x: kotlin.Int)
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
}
internal final class Outer {
public constructor Outer()
internal final fun B(/*0*/ x: kotlin.Int): kotlin.Unit
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
internal final class A {
public constructor A()
public constructor A()
public constructor A(/*0*/ x: kotlin.String = ..., /*1*/ y: kotlin.String = ...)
public constructor A(/*0*/ x: kotlin.String, /*1*/ y: kotlin.String)
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
}
internal final class B {
public constructor B(/*0*/ x: kotlin.Int)
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
}
}
@@ -0,0 +1,11 @@
class <!REDECLARATION!>A<!>
class <!REDECLARATION!>A<!> {
constructor() {}
}
class B
class Outer {
class B {
constructor() {}
}
}
@@ -0,0 +1,36 @@
package
internal final class 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 hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
internal final class 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 hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
internal final class B {
public constructor B()
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
}
internal final class Outer {
public constructor Outer()
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
internal final class B {
public constructor B()
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
}
}