diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/DoubleColonExpressionResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/DoubleColonExpressionResolver.kt index f4a25008d52..49dd6492f30 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/DoubleColonExpressionResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/DoubleColonExpressionResolver.kt @@ -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) diff --git a/compiler/testData/diagnostics/tests/callableReference/bareType.kt b/compiler/testData/diagnostics/tests/callableReference/bareType.kt new file mode 100644 index 00000000000..669f4f1c27c --- /dev/null +++ b/compiler/testData/diagnostics/tests/callableReference/bareType.kt @@ -0,0 +1,8 @@ +fun f1() = Map::hashCode +fun f2() = Map.Entry::hashCode + +class Outer { + inner class Inner +} + +fun f3() = Outer.Inner::hashCode diff --git a/compiler/testData/diagnostics/tests/callableReference/bareType.txt b/compiler/testData/diagnostics/tests/callableReference/bareType.txt new file mode 100644 index 00000000000..2fd1493e181 --- /dev/null +++ b/compiler/testData/diagnostics/tests/callableReference/bareType.txt @@ -0,0 +1,19 @@ +package + +public fun f1(): kotlin.reflect.KFunction1, kotlin.Int> +public fun f2(): kotlin.reflect.KFunction1, kotlin.Int> +public fun f3(): kotlin.reflect.KFunction1.Inner, kotlin.Int> + +public 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 + + 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 + } +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index f30393785f2..36cb9a0ce11 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -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");