From d06068777503e5e3ab6246a4d006e1edc60a7f9f Mon Sep 17 00:00:00 2001 From: Dmitry Petrov Date: Fri, 30 Oct 2015 14:57:48 +0300 Subject: [PATCH] Package vs class conflict in qualifier resolution: - add test for unresolved 'a.a' after 'import a.a'; - added TODO in copy-paste test for 'a.a' --- .../qualifiedExpression/PackageVsClass2.kt | 20 +++++++++- .../qualifiedExpression/PackageVsClass2.txt | 37 +++++++++++++++++++ .../ClassResolvedToPackage.expected.kt | 11 ++++-- .../imports/ClassResolvedToPackage.kt | 5 ++- 4 files changed, 68 insertions(+), 5 deletions(-) diff --git a/compiler/testData/diagnostics/tests/qualifiedExpression/PackageVsClass2.kt b/compiler/testData/diagnostics/tests/qualifiedExpression/PackageVsClass2.kt index 0b08c173578..6cccc7a53f2 100644 --- a/compiler/testData/diagnostics/tests/qualifiedExpression/PackageVsClass2.kt +++ b/compiler/testData/diagnostics/tests/qualifiedExpression/PackageVsClass2.kt @@ -1,7 +1,12 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER // MODULE: m1 // FILE: a.kt package a +class a { + companion object {} +} + class b { fun a_b() {} } @@ -12,4 +17,17 @@ package test class a -val x = a.b() \ No newline at end of file +val x = a.b() + +// MODULE: m3(m1) +// FILE: c.kt +package test + +import a.a + +fun foo(i: a) { + a + a() + a.a + a.a() +} diff --git a/compiler/testData/diagnostics/tests/qualifiedExpression/PackageVsClass2.txt b/compiler/testData/diagnostics/tests/qualifiedExpression/PackageVsClass2.txt index cb080b2574a..a083bf739bd 100644 --- a/compiler/testData/diagnostics/tests/qualifiedExpression/PackageVsClass2.txt +++ b/compiler/testData/diagnostics/tests/qualifiedExpression/PackageVsClass2.txt @@ -3,6 +3,20 @@ package package a { + public 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 + + public companion object Companion { + private constructor Companion() + 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 b { public constructor b() public final fun a_b(): kotlin.Unit @@ -18,6 +32,10 @@ package package a { + public final class a { + // -- Module: -- + } + public final class b { // -- Module: -- } @@ -35,3 +53,22 @@ package test { } +// -- Module: -- +package + +package a { + + public final class a { + // -- Module: -- + } + + public final class b { + // -- Module: -- + } +} + +package test { + public fun foo(/*0*/ i: a.a): kotlin.Unit +} + + diff --git a/idea/testData/copyPaste/imports/ClassResolvedToPackage.expected.kt b/idea/testData/copyPaste/imports/ClassResolvedToPackage.expected.kt index 9c4e5c5c729..4e7356a5f39 100644 --- a/idea/testData/copyPaste/imports/ClassResolvedToPackage.expected.kt +++ b/idea/testData/copyPaste/imports/ClassResolvedToPackage.expected.kt @@ -1,9 +1,14 @@ // ERROR: Unresolved reference: a +// ERROR: Unresolved reference: a +// ERROR: Unresolved reference: a package to import a.a -fun f(i: a.a) { // todo must be i: a - a - a() +fun f(i: a.a) { + // TODO References shortening doesn't work for package vs class conflicts under the new resolution rules. + // After importing 'a.a', expression 'a.a' is unresolved (since 'a' becomes a class). + // 'package' in expression syntax might be required to fix it properly. + a.a + a.a() } \ No newline at end of file diff --git a/idea/testData/copyPaste/imports/ClassResolvedToPackage.kt b/idea/testData/copyPaste/imports/ClassResolvedToPackage.kt index 5ce2e3cd6ee..5360bec9bf3 100644 --- a/idea/testData/copyPaste/imports/ClassResolvedToPackage.kt +++ b/idea/testData/copyPaste/imports/ClassResolvedToPackage.kt @@ -5,7 +5,10 @@ class a { } } -fun f(i: a) { // todo must be i: a +fun f(i: a) { + // TODO References shortening doesn't work for package vs class conflicts under the new resolution rules. + // After importing 'a.a', expression 'a.a' is unresolved (since 'a' becomes a class). + // 'package' in expression syntax might be required to fix it properly. a a() } \ No newline at end of file