Fix NDFDE for single underscore named property in primary constructor
NDFDE = NoDescriptorForDeclarationException See the comment in change
This commit is contained in:
@@ -313,7 +313,11 @@ public class DescriptorResolver {
|
||||
Name parameterName;
|
||||
|
||||
if (destructuringDeclaration == null) {
|
||||
parameterName = UnderscoreUtilKt.isSingleUnderscore(valueParameter)
|
||||
// NB: val/var for parameter is only allowed in primary constructors where single underscore names are still prohibited.
|
||||
// The problem with val/var is that when lazy resolve try to find their descriptor, it searches through the member scope
|
||||
// of containing class where, it can not find a descriptor with special name.
|
||||
// Thus, to preserve behavior, we don't use a special name for val/var.
|
||||
parameterName = !valueParameter.hasValOrVar() && UnderscoreUtilKt.isSingleUnderscore(valueParameter)
|
||||
? Name.special("<anonymous parameter " + index + ">")
|
||||
: KtPsiUtil.safeName(valueParameter.getName());
|
||||
}
|
||||
|
||||
@@ -19,9 +19,24 @@ fun <!UNDERSCORE_IS_RESERVED!>__<!>(<!UNDERSCORE_IS_RESERVED!>___<!>: Int, y: _<
|
||||
|
||||
val <!UNDERSCORE_IS_RESERVED!>_<!> = 56
|
||||
|
||||
fun localFun(<!UNDERSCORE_IS_RESERVED!>_<!>: String) = 1
|
||||
|
||||
<!UNDERSCORE_IS_RESERVED!>__<!>@ return if (y != null) __(____, y) else __(`_`, ______)
|
||||
}
|
||||
|
||||
|
||||
class A1(val <!UNDERSCORE_IS_RESERVED, UNDERSCORE_IS_RESERVED!>_<!>: String)
|
||||
class A2(<!UNDERSCORE_IS_RESERVED!>_<!>: String) {
|
||||
class B {
|
||||
typealias <!UNDERSCORE_IS_RESERVED!>_<!> = CharSequence
|
||||
}
|
||||
val <!UNDERSCORE_IS_RESERVED!>_<!>: Int = 1
|
||||
|
||||
fun <!UNDERSCORE_IS_RESERVED!>_<!>() {}
|
||||
|
||||
fun foo(<!UNDERSCORE_IS_RESERVED!>_<!>: Double) {}
|
||||
}
|
||||
|
||||
// one underscore parameters for named function are still prohibited
|
||||
fun oneUnderscore(<!UNDERSCORE_IS_RESERVED!>_<!>: Int) {}
|
||||
|
||||
|
||||
@@ -7,6 +7,32 @@ public fun __(/*0*/ ___: kotlin.Int, /*1*/ y: _<kotlin.Int>?): kotlin.Int
|
||||
public fun doIt(/*0*/ f: (kotlin.Any?) -> kotlin.Any?): kotlin.Any?
|
||||
public fun oneUnderscore(/*0*/ <anonymous parameter 0>: kotlin.Int): kotlin.Unit
|
||||
|
||||
public final class A1 {
|
||||
public constructor A1(/*0*/ _: kotlin.String)
|
||||
public final val _: 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
|
||||
}
|
||||
|
||||
public final class A2 {
|
||||
public constructor A2(/*0*/ <anonymous parameter 0>: kotlin.String)
|
||||
public final val _: kotlin.Int = 1
|
||||
public final fun _(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun foo(/*0*/ <anonymous parameter 0>: kotlin.Double): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
public 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
|
||||
public typealias _ = kotlin.CharSequence
|
||||
}
|
||||
}
|
||||
|
||||
@kotlin.Deprecated(message = "") public final data class Pair {
|
||||
public constructor Pair(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.Int)
|
||||
public final val x: kotlin.Int
|
||||
|
||||
Reference in New Issue
Block a user