Report error on bare types in LHS of callable reference expressions
This commit is contained in:
+4
@@ -166,6 +166,10 @@ class DoubleColonExpressionResolver(
|
||||
val descriptor = possiblyBareType.bareTypeConstructor.declarationDescriptor as? ClassDescriptor
|
||||
?: error("Only classes can produce bare types: $possiblyBareType")
|
||||
|
||||
if (doubleColonExpression is KtCallableReferenceExpression) {
|
||||
c.trace.report(WRONG_NUMBER_OF_TYPE_ARGUMENTS.on(expression, descriptor.typeConstructor.parameters.size, descriptor))
|
||||
}
|
||||
|
||||
KotlinTypeImpl.create(
|
||||
Annotations.EMPTY, descriptor, possiblyBareType.isNullable || doubleColonExpression.hasQuestionMarks,
|
||||
descriptor.typeConstructor.parameters.map(TypeUtils::makeStarProjection)
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fun f1() = <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>Map<!>::hashCode
|
||||
fun f2() = <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>Map.Entry<!>::hashCode
|
||||
|
||||
class Outer<T> {
|
||||
inner class Inner
|
||||
}
|
||||
|
||||
fun f3() = <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>Outer.Inner<!>::hashCode
|
||||
@@ -0,0 +1,19 @@
|
||||
package
|
||||
|
||||
public fun f1(): kotlin.reflect.KFunction1<kotlin.collections.Map<*, *>, kotlin.Int>
|
||||
public fun f2(): kotlin.reflect.KFunction1<kotlin.collections.Map.Entry<*, *>, kotlin.Int>
|
||||
public fun f3(): kotlin.reflect.KFunction1<Outer<*>.Inner, kotlin.Int>
|
||||
|
||||
public final class Outer</*0*/ T> {
|
||||
public constructor Outer</*0*/ T>()
|
||||
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 inner class Inner /*captured type parameters: /*0*/ T*/ {
|
||||
public constructor Inner()
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -1653,6 +1653,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/callableReference"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("bareType.kt")
|
||||
public void testBareType() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/callableReference/bareType.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("classVsPackage.kt")
|
||||
public void testClassVsPackage() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/callableReference/classVsPackage.kt");
|
||||
|
||||
Reference in New Issue
Block a user