Kapt: Add DUMP_DEFAULT_PARAMETER_VALUES flag (KT-29355)
Put initializers on fields when corresponding primary constructor parameters have a default value specified. The new behavior is available under the new 'DUMP_DEFAULT_PARAMETER_VALUES' flag. Note that this doesn't affect regular functions with default parameter values, as well as primary constructor parameters without a 'val' or 'var' keyword.
This commit is contained in:
+18
-16
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.resolve.*
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.isAnnotationConstructor
|
||||
import org.jetbrains.kotlin.resolve.lazy.DeclarationScopeProvider
|
||||
import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil
|
||||
import org.jetbrains.kotlin.resolve.lazy.ResolveSession
|
||||
@@ -35,6 +36,9 @@ open class PartialAnalysisHandlerExtension : AnalysisHandlerExtension {
|
||||
open val analyzePartially: Boolean
|
||||
get() = true
|
||||
|
||||
open val analyzeDefaultParameterValues: Boolean
|
||||
get() = false
|
||||
|
||||
override fun doAnalysis(
|
||||
project: Project,
|
||||
module: ModuleDescriptor,
|
||||
@@ -83,20 +87,17 @@ open class PartialAnalysisHandlerExtension : AnalysisHandlerExtension {
|
||||
* val a: Runnable = object : Runnable { ... } */
|
||||
bodyResolver.resolveProperty(topDownAnalysisContext, declaration, descriptor)
|
||||
}
|
||||
else if (declaration is KtParameter) { // Annotation parameter
|
||||
val ownerElement = declaration.ownerFunction
|
||||
val ownerDescriptor = bindingTrace[BindingContext.VALUE_PARAMETER, declaration]?.containingDeclaration
|
||||
val containingScope = ownerDescriptor?.containingScope
|
||||
|
||||
if (ownerElement is KtPrimaryConstructor && ownerDescriptor is ConstructorDescriptor && containingScope != null) {
|
||||
bodyResolver.resolveConstructorParameterDefaultValues(
|
||||
topDownAnalysisContext.outerDataFlowInfo, bindingTrace, ownerElement, ownerDescriptor, containingScope)
|
||||
}
|
||||
}
|
||||
}
|
||||
is FunctionDescriptor -> {
|
||||
// is body expression (not unit)
|
||||
if (declaration is KtFunction && !declaration.hasDeclaredReturnType() && !declaration.hasBlockBody()) {
|
||||
if (declaration is KtPrimaryConstructor && (analyzeDefaultParameterValues || descriptor.isAnnotationConstructor())) {
|
||||
val containingScope = descriptor.containingScope
|
||||
if (containingScope != null) {
|
||||
bodyResolver.resolveConstructorParameterDefaultValues(
|
||||
topDownAnalysisContext.outerDataFlowInfo, bindingTrace,
|
||||
declaration, descriptor as ConstructorDescriptor, containingScope
|
||||
)
|
||||
}
|
||||
} else if (declaration is KtFunction && !declaration.hasDeclaredReturnType() && !declaration.hasBlockBody()) {
|
||||
ForceResolveUtil.forceResolveAllContents(descriptor)
|
||||
}
|
||||
}
|
||||
@@ -122,11 +123,12 @@ open class PartialAnalysisHandlerExtension : AnalysisHandlerExtension {
|
||||
}
|
||||
|
||||
if (declaration is KtClassOrObject) {
|
||||
declaration.declarations.forEach { doForEachDeclaration(it, f) }
|
||||
}
|
||||
val primaryConstructor = declaration.primaryConstructor
|
||||
if (primaryConstructor != null) {
|
||||
f(primaryConstructor)
|
||||
}
|
||||
|
||||
if (declaration is KtClass && declaration.isAnnotation()) {
|
||||
declaration.primaryConstructorParameters.forEach { doForEachDeclaration(it, f) }
|
||||
declaration.declarations.forEach { doForEachDeclaration(it, f) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -366,6 +366,7 @@ class Kapt3KotlinGradleSubplugin : KotlinGradleSubplugin<KotlinCompile> {
|
||||
|
||||
pluginOptions += SubpluginOption("useLightAnalysis", "${kaptExtension.useLightAnalysis}")
|
||||
pluginOptions += SubpluginOption("correctErrorTypes", "${kaptExtension.correctErrorTypes}")
|
||||
pluginOptions += SubpluginOption("dumpDefaultParameterValues", "${kaptExtension.dumpDefaultParameterValues}")
|
||||
pluginOptions += SubpluginOption("mapDiagnosticLocations", "${kaptExtension.mapDiagnosticLocations}")
|
||||
pluginOptions += SubpluginOption("strictMode", "${kaptExtension.strictMode}")
|
||||
pluginOptions += SubpluginOption("showProcessorTimings", "${kaptExtension.showProcessorTimings}")
|
||||
|
||||
+2
@@ -29,6 +29,8 @@ open class KaptExtension {
|
||||
|
||||
open var correctErrorTypes: Boolean = false
|
||||
|
||||
open var dumpDefaultParameterValues: Boolean = false
|
||||
|
||||
open var mapDiagnosticLocations: Boolean = false
|
||||
|
||||
open var strictMode: Boolean = false
|
||||
|
||||
@@ -109,6 +109,7 @@ enum class KaptFlag(val description: String) {
|
||||
INFO_AS_WARNINGS("Info as warnings"),
|
||||
USE_LIGHT_ANALYSIS("Use light analysis"),
|
||||
CORRECT_ERROR_TYPES("Correct error types"),
|
||||
DUMP_DEFAULT_PARAMETER_VALUES("Dump default parameter values"),
|
||||
MAP_DIAGNOSTIC_LOCATIONS("Map diagnostic locations"),
|
||||
STRICT("Strict mode"),
|
||||
INCLUDE_COMPILE_CLASSPATH("Detect annotation processors in compile classpath"),
|
||||
|
||||
@@ -153,6 +153,13 @@ enum class KaptCliOption(
|
||||
cliToolOption = CliToolOption("-Kapt-correct-error-types", FLAG)
|
||||
),
|
||||
|
||||
DUMP_DEFAULT_PARAMETER_VALUES(
|
||||
"dumpDefaultParameterValues",
|
||||
"true | false",
|
||||
"Put initializers on fields when corresponding primary constructor parameters have a default value specified",
|
||||
cliToolOption = CliToolOption("-Kapt-dump-default-parameter-values", FLAG)
|
||||
),
|
||||
|
||||
MAP_DIAGNOSTIC_LOCATIONS_OPTION(
|
||||
"mapDiagnosticLocations",
|
||||
"true | false",
|
||||
|
||||
@@ -132,6 +132,9 @@ abstract class AbstractKapt3Extension(
|
||||
override val analyzePartially: Boolean
|
||||
get() = !annotationProcessingComplete
|
||||
|
||||
override val analyzeDefaultParameterValues: Boolean
|
||||
get() = options[KaptFlag.DUMP_DEFAULT_PARAMETER_VALUES]
|
||||
|
||||
override fun doAnalysis(
|
||||
project: Project,
|
||||
module: ModuleDescriptor,
|
||||
|
||||
@@ -112,6 +112,7 @@ class Kapt3CommandLineProcessor : CommandLineProcessor {
|
||||
VERBOSE_MODE_OPTION -> setFlag(KaptFlag.VERBOSE, value)
|
||||
USE_LIGHT_ANALYSIS_OPTION -> setFlag(KaptFlag.USE_LIGHT_ANALYSIS, value)
|
||||
CORRECT_ERROR_TYPES_OPTION -> setFlag(KaptFlag.CORRECT_ERROR_TYPES, value)
|
||||
DUMP_DEFAULT_PARAMETER_VALUES -> setFlag(KaptFlag.DUMP_DEFAULT_PARAMETER_VALUES, value)
|
||||
MAP_DIAGNOSTIC_LOCATIONS_OPTION -> setFlag(KaptFlag.MAP_DIAGNOSTIC_LOCATIONS, value)
|
||||
INFO_AS_WARNINGS_OPTION -> setFlag(KaptFlag.INFO_AS_WARNINGS, value)
|
||||
STRICT_MODE_OPTION -> setFlag(KaptFlag.STRICT, value)
|
||||
|
||||
+21
-8
@@ -29,7 +29,6 @@ import org.jetbrains.kotlin.codegen.AsmUtil
|
||||
import org.jetbrains.kotlin.codegen.coroutines.CONTINUATION_PARAMETER_NAME
|
||||
import org.jetbrains.kotlin.codegen.needsExperimentalCoroutinesWrapper
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettingsImpl
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
@@ -650,7 +649,12 @@ class ClassFileToSourceStubConverter(val kaptContext: KaptContextForStubGenerati
|
||||
val value = field.value
|
||||
|
||||
val origin = kaptContext.origins[field]
|
||||
val propertyInitializer = (origin?.element as? KtProperty)?.initializer
|
||||
|
||||
val propertyInitializer = when (val declaration = origin?.element) {
|
||||
is KtProperty -> declaration.initializer
|
||||
is KtParameter -> if (kaptContext.options[KaptFlag.DUMP_DEFAULT_PARAMETER_VALUES]) declaration.defaultValue else null
|
||||
else -> null
|
||||
}
|
||||
|
||||
if (value != null) {
|
||||
if (propertyInitializer != null) {
|
||||
@@ -662,12 +666,9 @@ class ClassFileToSourceStubConverter(val kaptContext: KaptContextForStubGenerati
|
||||
|
||||
val propertyType = (origin?.descriptor as? PropertyDescriptor)?.returnType
|
||||
if (propertyInitializer != null && propertyType != null) {
|
||||
val moduleDescriptor = kaptContext.generationState.module
|
||||
val evaluator = ConstantExpressionEvaluator(moduleDescriptor, LanguageVersionSettingsImpl.DEFAULT, kaptContext.project)
|
||||
val trace = DelegatingBindingTrace(kaptContext.bindingContext, "Kapt")
|
||||
val const = evaluator.evaluateExpression(propertyInitializer, trace, propertyType)
|
||||
if (const != null && !const.isError && const.canBeUsedInAnnotations && !const.usesNonConstValAsConstant) {
|
||||
val asmValue = mapConstantValueToAsmRepresentation(const.toConstantValue(propertyType))
|
||||
val constValue = getConstantValue(propertyInitializer, propertyType)
|
||||
if (constValue != null) {
|
||||
val asmValue = mapConstantValueToAsmRepresentation(constValue)
|
||||
if (asmValue !== UnknownConstantValue) {
|
||||
return convertConstantValueArguments(asmValue, listOf(propertyInitializer))
|
||||
}
|
||||
@@ -684,6 +685,18 @@ class ClassFileToSourceStubConverter(val kaptContext: KaptContextForStubGenerati
|
||||
|
||||
private object UnknownConstantValue
|
||||
|
||||
private fun getConstantValue(expression: KtExpression, expectedType: KotlinType): ConstantValue<*>? {
|
||||
val moduleDescriptor = kaptContext.generationState.module
|
||||
val languageVersionSettings = kaptContext.generationState.languageVersionSettings
|
||||
val evaluator = ConstantExpressionEvaluator(moduleDescriptor, languageVersionSettings, kaptContext.project)
|
||||
val trace = DelegatingBindingTrace(kaptContext.bindingContext, "Kapt")
|
||||
val const = evaluator.evaluateExpression(expression, trace, expectedType)
|
||||
if (const == null || const.isError || !const.canBeUsedInAnnotations || const.usesNonConstValAsConstant) {
|
||||
return null
|
||||
}
|
||||
return const.toConstantValue(expectedType)
|
||||
}
|
||||
|
||||
private fun mapConstantValueToAsmRepresentation(value: ConstantValue<*>): Any? {
|
||||
return when (value) {
|
||||
is ByteValue -> value.value
|
||||
|
||||
+2
-4
@@ -21,10 +21,8 @@ import org.jetbrains.kotlin.base.kapt3.DetectMemoryLeaksMode
|
||||
import org.jetbrains.kotlin.base.kapt3.KaptOptions
|
||||
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
|
||||
import org.jetbrains.kotlin.codegen.ClassBuilderMode
|
||||
import org.jetbrains.kotlin.codegen.CodegenTestCase
|
||||
import org.jetbrains.kotlin.codegen.GenerationUtils
|
||||
import org.jetbrains.kotlin.codegen.OriginCollectingClassBuilderFactory
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.kapt3.AbstractKapt3Extension
|
||||
import org.jetbrains.kotlin.kapt3.KaptContextForStubGeneration
|
||||
import org.jetbrains.kotlin.kapt3.base.KaptContext
|
||||
@@ -52,9 +50,8 @@ import javax.lang.model.element.AnnotationMirror
|
||||
import javax.lang.model.element.Element
|
||||
import javax.lang.model.element.ExecutableElement
|
||||
import javax.lang.model.element.TypeElement
|
||||
import com.sun.tools.javac.util.List as JavacList
|
||||
|
||||
abstract class AbstractKotlinKapt3IntegrationTest : CodegenTestCase() {
|
||||
abstract class AbstractKotlinKapt3IntegrationTest : KotlinKapt3TestBase() {
|
||||
private companion object {
|
||||
val TEST_DATA_DIR = File("plugins/kapt3/kapt3-compiler/testData/kotlinRunner")
|
||||
}
|
||||
@@ -144,6 +141,7 @@ abstract class AbstractKotlinKapt3IntegrationTest : CodegenTestCase() {
|
||||
incrementalDataOutputDir = Files.createTempDirectory("kaptIncrementalData").toFile()
|
||||
|
||||
mutableOptions?.let { processingOptions.putAll(it) }
|
||||
flags.addAll(kaptFlags)
|
||||
detectMemoryLeaks = DetectMemoryLeaksMode.NONE
|
||||
}.build()
|
||||
|
||||
|
||||
+27
-23
@@ -104,9 +104,34 @@ abstract class AbstractKotlinKapt3Test : KotlinKapt3TestBase() {
|
||||
createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.ALL, *listOfNotNull(writeJavaFiles(files)).toTypedArray())
|
||||
addAnnotationProcessingRuntimeLibrary(myEnvironment)
|
||||
|
||||
// Use light analysis mode in tests
|
||||
val project = myEnvironment.project
|
||||
val analysisExtension = PartialAnalysisHandlerExtension()
|
||||
|
||||
val javacOptions = wholeFile.getOptionValues("JAVAC_OPTION")
|
||||
.map { opt ->
|
||||
val (key, value) = opt.split('=').map { it.trim() }.also { assert(it.size == 2) }
|
||||
key to value
|
||||
}.toMap()
|
||||
|
||||
val options = KaptOptions.Builder().apply {
|
||||
projectBaseDir = project.basePath?.let { File(it) }
|
||||
compileClasspath.addAll(PathUtil.getJdkClassesRootsFromCurrentJre() + PathUtil.kotlinPathsForIdeaPlugin.stdlibPath)
|
||||
|
||||
sourcesOutputDir = KotlinTestUtils.tmpDir("kaptRunner")
|
||||
classesOutputDir = sourcesOutputDir
|
||||
stubsOutputDir = sourcesOutputDir
|
||||
incrementalDataOutputDir = sourcesOutputDir
|
||||
|
||||
this.javacOptions.putAll(javacOptions)
|
||||
flags.addAll(kaptFlags)
|
||||
|
||||
detectMemoryLeaks = DetectMemoryLeaksMode.NONE
|
||||
}.build()
|
||||
|
||||
val analysisExtension = object : PartialAnalysisHandlerExtension() {
|
||||
override val analyzeDefaultParameterValues: Boolean
|
||||
get() = options[KaptFlag.DUMP_DEFAULT_PARAMETER_VALUES]
|
||||
}
|
||||
|
||||
AnalysisHandlerExtension.registerExtension(project, analysisExtension)
|
||||
StorageComponentContainerContributor.registerExtension(project, KaptComponentContributor(analysisExtension))
|
||||
|
||||
@@ -118,30 +143,9 @@ abstract class AbstractKotlinKapt3Test : KotlinKapt3TestBase() {
|
||||
|
||||
val logger = MessageCollectorBackedKaptLogger(isVerbose = true, isInfoAsWarnings = false, messageCollector = messageCollector)
|
||||
|
||||
val javacOptions = wholeFile.getOptionValues("JAVAC_OPTION")
|
||||
.map { opt ->
|
||||
val (key, value) = opt.split('=').map { it.trim() }.also { assert(it.size == 2) }
|
||||
key to value
|
||||
}.toMap()
|
||||
|
||||
var kaptContext: KaptContext? = null
|
||||
|
||||
try {
|
||||
val options = KaptOptions.Builder().apply {
|
||||
projectBaseDir = generationState.project.basePath?.let(::File)
|
||||
compileClasspath.addAll(PathUtil.getJdkClassesRootsFromCurrentJre() + PathUtil.kotlinPathsForIdeaPlugin.stdlibPath)
|
||||
|
||||
sourcesOutputDir = KotlinTestUtils.tmpDir("kaptRunner")
|
||||
classesOutputDir = sourcesOutputDir
|
||||
stubsOutputDir = sourcesOutputDir
|
||||
incrementalDataOutputDir = sourcesOutputDir
|
||||
|
||||
this.javacOptions.putAll(javacOptions)
|
||||
flags.addAll(kaptFlags)
|
||||
|
||||
detectMemoryLeaks = DetectMemoryLeaksMode.NONE
|
||||
}.build()
|
||||
|
||||
kaptContext = KaptContextForStubGeneration(
|
||||
options, true, logger,
|
||||
generationState.project, generationState.bindingContext, classBuilderFactory.compiledClasses,
|
||||
|
||||
+10
@@ -88,6 +88,16 @@ public class ClassFileToSourceStubConverterTestGenerated extends AbstractClassFi
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/defaultImpls.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultParameterValueOff.kt")
|
||||
public void testDefaultParameterValueOff() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/defaultParameterValueOff.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultParameterValueOn.kt")
|
||||
public void testDefaultParameterValueOn() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/defaultParameterValueOn.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("deprecated.kt")
|
||||
public void testDeprecated() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/deprecated.kt");
|
||||
|
||||
+10
@@ -89,6 +89,16 @@ public class IrClassFileToSourceStubConverterTestGenerated extends AbstractIrCla
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/defaultImpls.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultParameterValueOff.kt")
|
||||
public void testDefaultParameterValueOff() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/defaultParameterValueOff.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultParameterValueOn.kt")
|
||||
public void testDefaultParameterValueOn() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/defaultParameterValueOn.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("deprecated.kt")
|
||||
public void testDeprecated() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/converter/deprecated.kt");
|
||||
|
||||
+5
@@ -29,6 +29,11 @@ public class IrKotlinKaptContextTestGenerated extends AbstractIrKotlinKaptContex
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/kapt3/kapt3-compiler/testData/kotlinRunner"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true);
|
||||
}
|
||||
|
||||
@TestMetadata("DefaultParameterValues.kt")
|
||||
public void testDefaultParameterValues() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/kotlinRunner/DefaultParameterValues.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("NestedClasses.kt")
|
||||
public void testNestedClasses() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/kotlinRunner/NestedClasses.kt");
|
||||
|
||||
+10
@@ -28,6 +28,7 @@ import javax.annotation.processing.RoundEnvironment
|
||||
import javax.lang.model.element.ElementKind
|
||||
import javax.lang.model.element.ExecutableElement
|
||||
import javax.lang.model.element.TypeElement
|
||||
import javax.lang.model.element.VariableElement
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
class KotlinKapt3IntegrationTests : AbstractKotlinKapt3IntegrationTest(), CustomJdkTestLauncher {
|
||||
@@ -62,6 +63,15 @@ class KotlinKapt3IntegrationTests : AbstractKotlinKapt3IntegrationTest(), Custom
|
||||
assert(commentOf("test.MyAnnotation") == null) // multiline comment - not saved
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testParameterNames() {
|
||||
test("DefaultParameterValues", "test.Anno") { set, roundEnv, env ->
|
||||
val user = roundEnv.getElementsAnnotatedWith(set.single()).single() as TypeElement
|
||||
val nameField = user.enclosedElements.filterIsInstance<VariableElement>().single()
|
||||
assertEquals("John", nameField.constantValue)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testSimpleStubsAndIncrementalData() = bindingsTest("Simple") { stubsOutputDir, incrementalDataOutputDir, bindings ->
|
||||
assert(File(stubsOutputDir, "error/NonExistentClass.java").exists())
|
||||
|
||||
+5
@@ -28,6 +28,11 @@ public class KotlinKaptContextTestGenerated extends AbstractKotlinKaptContextTes
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/kapt3/kapt3-compiler/testData/kotlinRunner"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@TestMetadata("DefaultParameterValues.kt")
|
||||
public void testDefaultParameterValues() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/kotlinRunner/DefaultParameterValues.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("NestedClasses.kt")
|
||||
public void testNestedClasses() throws Exception {
|
||||
runTest("plugins/kapt3/kapt3-compiler/testData/kotlinRunner/NestedClasses.kt");
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
class Foo(
|
||||
val z: Boolean = true,
|
||||
val b: Byte = 0.toByte(),
|
||||
val c: Char = 'c',
|
||||
val c2: Char = '\n',
|
||||
val sh: Short = 10.toShort(),
|
||||
val i: Int = 10,
|
||||
val l: Long = -10L,
|
||||
val f: Float = 1.0f,
|
||||
val d: Double = -1.0,
|
||||
val s: String = "foo",
|
||||
val iarr: IntArray = intArrayOf(1, 2, 3),
|
||||
val larr: LongArray = longArrayOf(-1L, 0L, 1L),
|
||||
val darr: DoubleArray = doubleArrayOf(7.3),
|
||||
val sarr: Array<String> = arrayOf("a", "bc"),
|
||||
|
||||
// Sic! Unresolved reference not being reported because of partial resolve
|
||||
val cl: Class<*> = User::class.java,
|
||||
val clarr: Array<Class<*>> = arrayOf(User::class.java),
|
||||
|
||||
val em: Em = Em.BAR,
|
||||
val emarr: Array<Em> = arrayOf(Em.FOO, Em.BAR)
|
||||
) {
|
||||
fun foo(a: Int = 5) {}
|
||||
}
|
||||
|
||||
enum class Em {
|
||||
FOO, BAR
|
||||
}
|
||||
+147
@@ -0,0 +1,147 @@
|
||||
import java.lang.System;
|
||||
|
||||
@kotlin.Metadata()
|
||||
public enum Em {
|
||||
/*public static final*/ FOO /* = new Em() */,
|
||||
/*public static final*/ BAR /* = new Em() */;
|
||||
|
||||
Em() {
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////
|
||||
|
||||
|
||||
import java.lang.System;
|
||||
|
||||
@kotlin.Metadata()
|
||||
public final class Foo {
|
||||
private final boolean z = false;
|
||||
private final byte b = 0;
|
||||
private final char c = '\u0000';
|
||||
private final char c2 = '\u0000';
|
||||
private final short sh = 0;
|
||||
private final int i = 0;
|
||||
private final long l = 0L;
|
||||
private final float f = 0.0F;
|
||||
private final double d = 0.0;
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
private final java.lang.String s = null;
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
private final int[] iarr = null;
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
private final long[] larr = null;
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
private final double[] darr = null;
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
private final java.lang.String[] sarr = null;
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
private final java.lang.Class<?> cl = null;
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
private final java.lang.Class<?>[] clarr = null;
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
private final Em em = null;
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
private final Em[] emarr = null;
|
||||
|
||||
public final void foo(int a) {
|
||||
}
|
||||
|
||||
public final boolean getZ() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public final byte getB() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public final char getC() {
|
||||
return '\u0000';
|
||||
}
|
||||
|
||||
public final char getC2() {
|
||||
return '\u0000';
|
||||
}
|
||||
|
||||
public final short getSh() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public final int getI() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public final long getL() {
|
||||
return 0L;
|
||||
}
|
||||
|
||||
public final float getF() {
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
public final double getD() {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public final java.lang.String getS() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public final int[] getIarr() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public final long[] getLarr() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public final double[] getDarr() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public final java.lang.String[] getSarr() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public final java.lang.Class<?> getCl() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public final java.lang.Class<?>[] getClarr() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public final Em getEm() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public final Em[] getEmarr() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Foo(boolean z, byte b, char c, char c2, short sh, int i, long l, float f, double d, @org.jetbrains.annotations.NotNull()
|
||||
java.lang.String s, @org.jetbrains.annotations.NotNull()
|
||||
int[] iarr, @org.jetbrains.annotations.NotNull()
|
||||
long[] larr, @org.jetbrains.annotations.NotNull()
|
||||
double[] darr, @org.jetbrains.annotations.NotNull()
|
||||
java.lang.String[] sarr, @org.jetbrains.annotations.NotNull()
|
||||
java.lang.Class<?> cl, @org.jetbrains.annotations.NotNull()
|
||||
java.lang.Class<?>[] clarr, @org.jetbrains.annotations.NotNull()
|
||||
Em em, @org.jetbrains.annotations.NotNull()
|
||||
Em[] emarr) {
|
||||
super();
|
||||
}
|
||||
|
||||
public Foo() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// DUMP_DEFAULT_PARAMETER_VALUES
|
||||
|
||||
class Foo(
|
||||
val z: Boolean = true,
|
||||
val b: Byte = 0.toByte(),
|
||||
val c: Char = 'c',
|
||||
val c2: Char = '\n',
|
||||
val sh: Short = 10.toShort(),
|
||||
val i: Int = 10,
|
||||
val l: Long = -10L,
|
||||
val f: Float = 1.0f,
|
||||
val d: Double = -1.0,
|
||||
val s: String = "foo",
|
||||
val iarr: IntArray = intArrayOf(1, 2, 3),
|
||||
val larr: LongArray = longArrayOf(-1L, 0L, 1L),
|
||||
val darr: DoubleArray = doubleArrayOf(7.3),
|
||||
val sarr: Array<String> = arrayOf("a", "bc"),
|
||||
val cl: Class<*> = Foo::class.java,
|
||||
val clarr: Array<Class<*>> = arrayOf(Foo::class.java),
|
||||
val em: Em = Em.BAR,
|
||||
val emarr: Array<Em> = arrayOf(Em.FOO, Em.BAR)
|
||||
) {
|
||||
fun foo(a: Int = 5) {}
|
||||
}
|
||||
|
||||
enum class Em {
|
||||
FOO, BAR
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
import java.lang.System;
|
||||
|
||||
@kotlin.Metadata()
|
||||
public enum Em {
|
||||
/*public static final*/ FOO /* = new Em() */,
|
||||
/*public static final*/ BAR /* = new Em() */;
|
||||
|
||||
Em() {
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////
|
||||
|
||||
|
||||
import java.lang.System;
|
||||
|
||||
@kotlin.Metadata()
|
||||
public final class Foo {
|
||||
private final boolean z = true;
|
||||
private final byte b = (byte)0;
|
||||
private final char c = 'c';
|
||||
private final char c2 = '\n';
|
||||
private final short sh = (short)10;
|
||||
private final int i = 10;
|
||||
private final long l = -10L;
|
||||
private final float f = 1.0F;
|
||||
private final double d = -1.0;
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
private final java.lang.String s = "foo";
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
private final int[] iarr = {1, 2, 3};
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
private final long[] larr = {-1L, 0L, 1L};
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
private final double[] darr = {7.3};
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
private final java.lang.String[] sarr = {"a", "bc"};
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
private final java.lang.Class<?> cl = null;
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
private final java.lang.Class<?>[] clarr = null;
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
private final Em em = Em.BAR;
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
private final Em[] emarr = {Em.FOO, Em.BAR};
|
||||
|
||||
public final void foo(int a) {
|
||||
}
|
||||
|
||||
public final boolean getZ() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public final byte getB() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public final char getC() {
|
||||
return '\u0000';
|
||||
}
|
||||
|
||||
public final char getC2() {
|
||||
return '\u0000';
|
||||
}
|
||||
|
||||
public final short getSh() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public final int getI() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public final long getL() {
|
||||
return 0L;
|
||||
}
|
||||
|
||||
public final float getF() {
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
public final double getD() {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public final java.lang.String getS() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public final int[] getIarr() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public final long[] getLarr() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public final double[] getDarr() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public final java.lang.String[] getSarr() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public final java.lang.Class<?> getCl() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public final java.lang.Class<?>[] getClarr() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public final Em getEm() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public final Em[] getEmarr() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Foo(boolean z, byte b, char c, char c2, short sh, int i, long l, float f, double d, @org.jetbrains.annotations.NotNull()
|
||||
java.lang.String s, @org.jetbrains.annotations.NotNull()
|
||||
int[] iarr, @org.jetbrains.annotations.NotNull()
|
||||
long[] larr, @org.jetbrains.annotations.NotNull()
|
||||
double[] darr, @org.jetbrains.annotations.NotNull()
|
||||
java.lang.String[] sarr, @org.jetbrains.annotations.NotNull()
|
||||
java.lang.Class<?> cl, @org.jetbrains.annotations.NotNull()
|
||||
java.lang.Class<?>[] clarr, @org.jetbrains.annotations.NotNull()
|
||||
Em em, @org.jetbrains.annotations.NotNull()
|
||||
Em[] emarr) {
|
||||
super();
|
||||
}
|
||||
|
||||
public Foo() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
package error;
|
||||
|
||||
public final class NonExistentClass {
|
||||
}
|
||||
|
||||
////////////////////
|
||||
|
||||
package test;
|
||||
|
||||
import java.lang.System;
|
||||
|
||||
@kotlin.Metadata()
|
||||
@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME)
|
||||
public abstract @interface Anno {
|
||||
}
|
||||
|
||||
////////////////////
|
||||
|
||||
package test;
|
||||
|
||||
import java.lang.System;
|
||||
|
||||
@kotlin.Metadata()
|
||||
@Anno()
|
||||
public final class User {
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
private final java.lang.String name = "John";
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public final java.lang.String getName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public User(@org.jetbrains.annotations.NotNull()
|
||||
java.lang.String name, int age) {
|
||||
super();
|
||||
}
|
||||
|
||||
public User() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
// DUMP_DEFAULT_PARAMETER_VALUES
|
||||
|
||||
package test
|
||||
|
||||
@Anno
|
||||
class User(val name: String = "John", age: Int = 18)
|
||||
|
||||
internal annotation class Anno
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
Reference in New Issue
Block a user