[FIR] add missing Any super type to Cloneable

^KTIJ-24272 Fixed
This commit is contained in:
Dmitrii Gridin
2023-07-03 16:49:57 +02:00
committed by Space Team
parent 85919c4d62
commit 050c66ea81
7 changed files with 71 additions and 4 deletions
@@ -20084,6 +20084,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
runTest("compiler/testData/diagnostics/tests/j+k/kt7523.kt");
}
@Test
@TestMetadata("ktij24272.kt")
public void testKtij24272() throws Exception {
runTest("compiler/testData/diagnostics/tests/j+k/ktij24272.kt");
}
@Test
@TestMetadata("matchers.kt")
public void testMatchers() throws Exception {
@@ -20084,6 +20084,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
runTest("compiler/testData/diagnostics/tests/j+k/kt7523.kt");
}
@Test
@TestMetadata("ktij24272.kt")
public void testKtij24272() throws Exception {
runTest("compiler/testData/diagnostics/tests/j+k/ktij24272.kt");
}
@Test
@TestMetadata("matchers.kt")
public void testMatchers() throws Exception {
@@ -20084,6 +20084,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
runTest("compiler/testData/diagnostics/tests/j+k/kt7523.kt");
}
@Test
@TestMetadata("ktij24272.kt")
public void testKtij24272() throws Exception {
runTest("compiler/testData/diagnostics/tests/j+k/ktij24272.kt");
}
@Test
@TestMetadata("matchers.kt")
public void testMatchers() throws Exception {
@@ -20090,6 +20090,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
runTest("compiler/testData/diagnostics/tests/j+k/kt7523.kt");
}
@Test
@TestMetadata("ktij24272.kt")
public void testKtij24272() throws Exception {
runTest("compiler/testData/diagnostics/tests/j+k/ktij24272.kt");
}
@Test
@TestMetadata("matchers.kt")
public void testMatchers() throws Exception {
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -16,7 +16,6 @@ import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
import org.jetbrains.kotlin.fir.declarations.builder.buildRegularClass
import org.jetbrains.kotlin.fir.declarations.builder.buildSimpleFunction
import org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl
import org.jetbrains.kotlin.fir.resolve.providers.FirSymbolNamesProvider
import org.jetbrains.kotlin.fir.resolve.providers.FirSymbolNamesProviderWithoutCallables
import org.jetbrains.kotlin.fir.declarations.impl.FirResolvedDeclarationStatusImpl
@@ -36,7 +35,7 @@ import org.jetbrains.kotlin.name.StandardClassIds
class FirCloneableSymbolProvider(
session: FirSession,
moduleData: FirModuleData,
scopeProvider: FirScopeProvider
scopeProvider: FirScopeProvider,
) : FirSymbolProvider(session) {
private val klass = buildRegularClass {
resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
@@ -47,9 +46,14 @@ class FirCloneableSymbolProvider(
Modality.ABSTRACT,
EffectiveVisibility.Public
)
classKind = ClassKind.INTERFACE
val classSymbol = FirRegularClassSymbol(StandardClassIds.Cloneable)
symbol = classSymbol
superTypeRefs += buildResolvedTypeRef {
type = session.builtinTypes.anyType.type
}
declarations += buildSimpleFunction {
this.moduleData = moduleData
resolvePhase = FirResolvePhase.ANALYZED_DEPENDENCIES
@@ -57,14 +61,18 @@ class FirCloneableSymbolProvider(
returnTypeRef = buildResolvedTypeRef {
type = session.builtinTypes.anyType.type
}
status = FirResolvedDeclarationStatusImpl(
Visibilities.Protected,
Modality.OPEN,
Visibilities.Protected.toEffectiveVisibility(classSymbol))
Visibilities.Protected.toEffectiveVisibility(classSymbol)
)
name = StandardClassIds.Callables.clone.callableName
symbol = FirNamedFunctionSymbol(StandardClassIds.Callables.clone)
dispatchReceiverType = this@buildRegularClass.symbol.constructType(emptyArray(), isNullable = false)
}
this.scopeProvider = scopeProvider
name = StandardClassIds.Cloneable.shortClassName
+29
View File
@@ -0,0 +1,29 @@
// FIR_IDENTICAL
// FILE: use.kt
package one
fun getStructureElementFor() {
val container: SuperJava = if (true) {
true <!CAST_NEVER_SUCCEEDS!>as<!> Child2
} else {
false <!CAST_NEVER_SUCCEEDS!>as<!> Child1
}
}
// FILE: SuperJava.java
package one;
public class SuperJava {
}
// FILE: Child1.java
package one;
public class Child1 extends SuperJava implements Cloneable {
}
// FILE: Child2.java
package one;
public class Child2 extends SuperJava implements Cloneable {
}
@@ -20090,6 +20090,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
runTest("compiler/testData/diagnostics/tests/j+k/kt7523.kt");
}
@Test
@TestMetadata("ktij24272.kt")
public void testKtij24272() throws Exception {
runTest("compiler/testData/diagnostics/tests/j+k/ktij24272.kt");
}
@Test
@TestMetadata("matchers.kt")
public void testMatchers() throws Exception {