[SLC] SymbolLightClassForEnumEntry: improve implementation
^KT-54051 ^KT-50241
This commit is contained in:
committed by
Space Team
parent
5f20c10185
commit
a7fae5fd99
@@ -0,0 +1,17 @@
|
||||
static final class FirstEntry /* p.KotlinEnum.FirstEntry*/ extends p.KotlinEnum {
|
||||
private final int firstEntryProp = 4 /* initializer type: int */;
|
||||
|
||||
private int variable = 1 /* initializer type: int */;
|
||||
|
||||
FirstEntry();// .ctor()
|
||||
|
||||
@java.lang.Override()
|
||||
public void abstractFun();// abstractFun()
|
||||
|
||||
public final int getFirstEntryProp();// getFirstEntryProp()
|
||||
|
||||
public final int getVariable();// getVariable()
|
||||
|
||||
public final void firstEntryFun();// firstEntryFun()
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
public static final class FirstEntry /* p.KotlinEnum.FirstEntry*/ extends p.KotlinEnum {
|
||||
private final int firstEntryProp;
|
||||
|
||||
private int variable;
|
||||
|
||||
FirstEntry();// .ctor()
|
||||
|
||||
public final int getFirstEntryProp();// getFirstEntryProp()
|
||||
|
||||
public final int getVariable();// getVariable()
|
||||
|
||||
public final void firstEntryFun();// firstEntryFun()
|
||||
|
||||
public void abstractFun();// abstractFun()
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// p.KotlinEnum.FirstEntry
|
||||
|
||||
package p
|
||||
|
||||
enum class KotlinEnum {
|
||||
FirstEntry {
|
||||
fun firstEntryFun() = Unit
|
||||
val firstEntryProp = 4
|
||||
var variable: Int = 1
|
||||
get() = 2
|
||||
private set
|
||||
|
||||
override fun abstractFun() {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
},
|
||||
|
||||
SecondEntry {
|
||||
fun secondEntryFun() = 3
|
||||
val secondEntryProp = 2
|
||||
|
||||
override fun abstractFun() {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
};
|
||||
|
||||
abstract fun abstractFun()
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
static final class FirstEntry /* p.KotlinEnum.FirstEntry*/ extends p.KotlinEnum {
|
||||
private final int firstEntryProp;
|
||||
|
||||
private int variable;
|
||||
|
||||
FirstEntry();// .ctor()
|
||||
|
||||
public final int getFirstEntryProp();// getFirstEntryProp()
|
||||
|
||||
public final int getVariable();// getVariable()
|
||||
|
||||
public final void firstEntryFun();// firstEntryFun()
|
||||
|
||||
public void abstractFun();// abstractFun()
|
||||
|
||||
}
|
||||
+16
-20
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright 2010-2022 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.asJava
|
||||
@@ -22,7 +11,11 @@ import org.jetbrains.kotlin.asJava.finder.JavaElementFinder
|
||||
import org.jetbrains.kotlin.checkers.KotlinMultiFileTestWithJava
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.test.*
|
||||
import org.jetbrains.kotlin.psi.KtEnumEntry
|
||||
import org.jetbrains.kotlin.test.Directives
|
||||
import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
||||
import org.jetbrains.kotlin.test.KotlinBaseTest
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.jetbrains.kotlin.util.KotlinFrontEndException
|
||||
import org.junit.Assert
|
||||
import java.io.File
|
||||
@@ -63,14 +56,17 @@ abstract class AbstractCompilerLightClassTest : KotlinMultiFileTestWithJava<Kotl
|
||||
KotlinTestUtils.resolveAllKotlinFiles(environment)
|
||||
}
|
||||
|
||||
val lightCLassForScript = KotlinAsJavaSupport
|
||||
.getInstance(environment.project)
|
||||
.getScriptClasses(FqName(fqname), GlobalSearchScope.allScope(environment.project))
|
||||
val searchScope = GlobalSearchScope.allScope(environment.project)
|
||||
val kotlinAsJavaSupport = KotlinAsJavaSupport.getInstance(environment.project)
|
||||
val lightClassForScript = kotlinAsJavaSupport
|
||||
.getScriptClasses(FqName(fqname), searchScope)
|
||||
.firstOrNull()
|
||||
|
||||
return lightCLassForScript ?: JavaElementFinder
|
||||
.getInstance(environment.project)
|
||||
.findClass(fqname, GlobalSearchScope.allScope(environment.project))
|
||||
return lightClassForScript
|
||||
?: JavaElementFinder.getInstance(environment.project).findClass(fqname, searchScope)
|
||||
?: kotlinAsJavaSupport.findClassOrObjectDeclarations(FqName(fqname), searchScope).firstOrNull {
|
||||
it is KtEnumEntry // JavaElementFinder will ignore enum entry
|
||||
}?.toLightClass()
|
||||
}
|
||||
|
||||
private fun assertException(shouldOccur: Boolean, klass: Class<out Throwable>, f: () -> Unit) {
|
||||
|
||||
+5
@@ -109,6 +109,11 @@ public class CompilerLightClassTestGenerated extends AbstractCompilerLightClassT
|
||||
runTest("compiler/testData/asJava/lightClasses/DollarsInNameNoPackage.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("EnumEntry.kt")
|
||||
public void testEnumEntry() throws Exception {
|
||||
runTest("compiler/testData/asJava/lightClasses/EnumEntry.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ExtendingInterfaceWithDefaultImpls.kt")
|
||||
public void testExtendingInterfaceWithDefaultImpls() throws Exception {
|
||||
runTest("compiler/testData/asJava/lightClasses/ExtendingInterfaceWithDefaultImpls.kt");
|
||||
|
||||
Reference in New Issue
Block a user