[FIR] Throws by star import wins builtin Throws, ^KT-52407 Fixed, ^KT-52517 Fixed

This commit is contained in:
Ivan Kochurkin
2022-05-24 21:46:37 +03:00
parent 5fdf365ac4
commit 792aa24a04
9 changed files with 71 additions and 3 deletions
@@ -34414,6 +34414,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/throws.kt");
}
@Test
@TestMetadata("throwsByStarWinsBuiltin.kt")
public void testThrowsByStarWinsBuiltin() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/throwsByStarWinsBuiltin.kt");
}
@Test
@TestMetadata("TransientOnDelegate.kt")
public void testTransientOnDelegate() throws Exception {
@@ -34414,6 +34414,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/throws.kt");
}
@Test
@TestMetadata("throwsByStarWinsBuiltin.kt")
public void testThrowsByStarWinsBuiltin() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/throwsByStarWinsBuiltin.kt");
}
@Test
@TestMetadata("TransientOnDelegate.kt")
public void testTransientOnDelegate() throws Exception {
@@ -34414,6 +34414,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/throws.kt");
}
@Test
@TestMetadata("throwsByStarWinsBuiltin.kt")
public void testThrowsByStarWinsBuiltin() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/throwsByStarWinsBuiltin.kt");
}
@Test
@TestMetadata("TransientOnDelegate.kt")
public void testTransientOnDelegate() throws Exception {
@@ -16,7 +16,7 @@ enum class DefaultImportPriority {
languageVersionSettings: LanguageVersionSettings
): List<ImportPath>? =
platformDependentAnalyzerServices?.getDefaultImports(languageVersionSettings, includeLowPriorityImports = false)?.let {
it + ImportPath.fromString("kotlin.Throws")
it
}
},
LOW {
@@ -25,6 +25,14 @@ enum class DefaultImportPriority {
languageVersionSettings: LanguageVersionSettings
): List<ImportPath>? =
platformDependentAnalyzerServices?.defaultLowPriorityImports
},
KOTLIN_THROWS {
override fun getAllDefaultImports(
platformDependentAnalyzerServices: PlatformDependentAnalyzerServices?,
languageVersionSettings: LanguageVersionSettings
): List<ImportPath> {
return listOf(ImportPath.fromString("kotlin.Throws"))
}
};
abstract fun getAllDefaultImports(
@@ -49,6 +49,9 @@ private fun doCreateImportingScopes(
scopeSession.getOrBuild(DefaultStarImportKey(DefaultImportPriority.HIGH, excludedImportNames), DEFAULT_STAR_IMPORT) {
FirDefaultStarImportingScope(session, scopeSession, DefaultImportPriority.HIGH, excludedImportNames)
},
scopeSession.getOrBuild(DefaultImportPriority.KOTLIN_THROWS, DEFAULT_SIMPLE_IMPORT) {
FirDefaultSimpleImportingScope(session, scopeSession, priority = DefaultImportPriority.KOTLIN_THROWS)
},
FirExplicitStarImportingScope(file.imports, session, scopeSession, excludedImportNames),
scopeSession.getOrBuild(DefaultImportPriority.LOW, DEFAULT_SIMPLE_IMPORT) {
@@ -112,7 +112,7 @@ package abc7
import kotlin.*
import kotlin.jvm.*
@Throws(Exception::class)
@<!OVERLOAD_RESOLUTION_AMBIGUITY!>Throws<!>(Exception::class)
fun foo1() {}
@kotlin.Throws(Exception::class)
@@ -121,7 +121,7 @@ fun foo2() {}
@kotlin.jvm.Throws(Exception::class)
fun foo3() {}
fun foo5(x: Throws) {}
fun foo5(x: <!OVERLOAD_RESOLUTION_AMBIGUITY!>Throws<!>) {}
fun foo6(x: kotlin.Throws) {}
fun foo7(x: kotlin.jvm.Throws) {}
@@ -0,0 +1,19 @@
// FIR_IDENTICAL
// WITH_STDLIB
// ISSUE: KT-52407
// FILE: x.kt
package x
class Throws {
fun test() {}
}
// FILE: main.kt
import x.*
fun main() {
Throws().test()
}
@@ -0,0 +1,14 @@
package
public fun main(): kotlin.Unit
package x {
public final class Throws {
public constructor Throws()
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 final fun test(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
}
@@ -34504,6 +34504,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/throws.kt");
}
@Test
@TestMetadata("throwsByStarWinsBuiltin.kt")
public void testThrowsByStarWinsBuiltin() throws Exception {
runTest("compiler/testData/diagnostics/testsWithStdLib/annotations/throwsByStarWinsBuiltin.kt");
}
@Test
@TestMetadata("TransientOnDelegate.kt")
public void testTransientOnDelegate() throws Exception {