From 915455ebe919db71d09dea65504593facdb04572 Mon Sep 17 00:00:00 2001 From: Mikhail Zarechenskiy Date: Tue, 23 Jan 2018 16:16:32 +0300 Subject: [PATCH] Introduce `InlineClasses` language feature Allow to write `inline` modifier in front of class declaration --- .../SyntheticClassOrObjectDescriptor.kt | 16 ++----- .../kotlin/resolve/ModifiersChecker.kt | 22 +++------ .../lazy/descriptors/LazyClassDescriptor.java | 22 ++++----- .../jvm/descriptors/KnownDescriptors.kt | 16 ++----- .../serialization/DescriptorSerializer.kt | 17 ++----- .../basicInlineClassDeclaration.kt | 8 ++++ .../basicInlineClassDeclaration.txt | 46 +++++++++++++++++++ .../basicInlineClassDeclarationDisabled.kt | 7 +++ .../basicInlineClassDeclarationDisabled.txt | 40 ++++++++++++++++ .../checkers/DiagnosticsTestGenerated.java | 21 +++++++++ .../DiagnosticsUsingJavacTestGenerated.java | 21 +++++++++ .../kotlin/config/LanguageVersionSettings.kt | 16 ++----- .../descriptors/LazyJavaClassDescriptor.kt | 16 ++----- .../functions/FunctionClassDescriptor.kt | 16 ++----- .../kotlin/descriptors/ClassDescriptor.java | 17 ++----- .../kotlin/descriptors/NotFoundClasses.kt | 16 ++----- .../descriptors/impl/ClassDescriptorImpl.java | 20 +++----- .../EnumEntrySyntheticClassDescriptor.java | 20 +++----- .../impl/LazySubstitutingClassDescriptor.java | 20 +++----- .../impl/MutableClassDescriptor.java | 20 +++----- .../kotlin/renderer/DescriptorRenderer.kt | 16 ++----- .../kotlin/renderer/DescriptorRendererImpl.kt | 16 ++----- .../jetbrains/kotlin/serialization/Flags.java | 20 +++----- .../DeserializedClassDescriptor.kt | 17 ++----- 24 files changed, 227 insertions(+), 239 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/inlineClasses/basicInlineClassDeclaration.kt create mode 100644 compiler/testData/diagnostics/tests/inlineClasses/basicInlineClassDeclaration.txt create mode 100644 compiler/testData/diagnostics/tests/inlineClasses/basicInlineClassDeclarationDisabled.kt create mode 100644 compiler/testData/diagnostics/tests/inlineClasses/basicInlineClassDeclarationDisabled.txt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/synthetics/SyntheticClassOrObjectDescriptor.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/synthetics/SyntheticClassOrObjectDescriptor.kt index 694219db1ff..bc65efcc523 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/synthetics/SyntheticClassOrObjectDescriptor.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/synthetics/SyntheticClassOrObjectDescriptor.kt @@ -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 2000-2018 JetBrains s.r.o. 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.psi.synthetics @@ -76,6 +65,7 @@ class SyntheticClassOrObjectDescriptor( override fun isCompanionObject() = isCompanionObject override fun isInner() = false override fun isData() = false + override fun isInline() = false override fun isExpect() = false override fun isActual() = false diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/ModifiersChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/ModifiersChecker.kt index 85c8ba68363..8c2e1ec1cda 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/ModifiersChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/ModifiersChecker.kt @@ -1,17 +1,6 @@ /* - * Copyright 2010-2016 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 2000-2018 JetBrains s.r.o. 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.resolve @@ -80,7 +69,7 @@ object ModifierCheckerCore { COMPANION_KEYWORD to EnumSet.of(OBJECT), LATEINIT_KEYWORD to EnumSet.of(MEMBER_PROPERTY, TOP_LEVEL_PROPERTY, LOCAL_VARIABLE), DATA_KEYWORD to EnumSet.of(CLASS_ONLY, LOCAL_CLASS), - INLINE_KEYWORD to EnumSet.of(FUNCTION, PROPERTY, PROPERTY_GETTER, PROPERTY_SETTER), + INLINE_KEYWORD to EnumSet.of(FUNCTION, PROPERTY, PROPERTY_GETTER, PROPERTY_SETTER, CLASS_ONLY), NOINLINE_KEYWORD to EnumSet.of(VALUE_PARAMETER), TAILREC_KEYWORD to EnumSet.of(FUNCTION), SUSPEND_KEYWORD to EnumSet.of(MEMBER_FUNCTION, TOP_LEVEL_FUNCTION), @@ -122,7 +111,7 @@ object ModifierCheckerCore { private val featureDependencies = mapOf( SUSPEND_KEYWORD to listOf(LanguageFeature.Coroutines), - INLINE_KEYWORD to listOf(LanguageFeature.InlineProperties), + INLINE_KEYWORD to listOf(LanguageFeature.InlineProperties, LanguageFeature.InlineClasses), HEADER_KEYWORD to listOf(LanguageFeature.MultiPlatformProjects), IMPL_KEYWORD to listOf(LanguageFeature.MultiPlatformProjects), EXPECT_KEYWORD to listOf(LanguageFeature.MultiPlatformProjects), @@ -133,7 +122,8 @@ object ModifierCheckerCore { private val featureDependenciesTargets = mapOf( LanguageFeature.InlineProperties to setOf(PROPERTY, PROPERTY_GETTER, PROPERTY_SETTER), LanguageFeature.LateinitLocalVariables to setOf(LOCAL_VARIABLE), - LanguageFeature.LateinitTopLevelProperties to setOf(TOP_LEVEL_PROPERTY) + LanguageFeature.LateinitTopLevelProperties to setOf(TOP_LEVEL_PROPERTY), + LanguageFeature.InlineClasses to setOf(CLASS_ONLY) ) // NOTE: deprecated targets must be possible! diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java index bb0b13cf786..8aa04bcb953 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java @@ -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 2000-2018 JetBrains s.r.o. 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.resolve.lazy.descriptors; @@ -91,6 +80,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes private final ClassKind kind; private final boolean isInner; private final boolean isData; + private final boolean isInline; private final boolean isExpect; private final boolean isActual; @@ -166,6 +156,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes this.isInner = modifierList != null && modifierList.hasModifier(INNER_KEYWORD) && !isIllegalInner(this); this.isData = modifierList != null && modifierList.hasModifier(KtTokens.DATA_KEYWORD); + this.isInline = modifierList != null && modifierList.hasModifier(KtTokens.INLINE_KEYWORD); this.isActual = modifierList != null && PsiUtilsKt.hasActualModifier(modifierList); this.isExpect = modifierList != null && PsiUtilsKt.hasExpectModifier(modifierList) || @@ -492,6 +483,11 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes return isData; } + @Override + public boolean isInline() { + return isInline; + } + @Override public boolean isCompanionObject() { return isCompanionObject; diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/descriptors/KnownDescriptors.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/descriptors/KnownDescriptors.kt index a7d5d065a6d..4de43dda51d 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/descriptors/KnownDescriptors.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/descriptors/KnownDescriptors.kt @@ -1,17 +1,6 @@ /* - * Copyright 2010-2016 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 2000-2018 JetBrains s.r.o. 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.backend.jvm.descriptors @@ -142,6 +131,7 @@ open class KnownClassDescriptor( override fun isCompanionObject(): Boolean = false override fun isData(): Boolean = false + override fun isInline(): Boolean = false override fun isInner(): Boolean = false override fun isExpect(): Boolean = false override fun isActual(): Boolean = false diff --git a/compiler/serialization/src/org/jetbrains/kotlin/serialization/DescriptorSerializer.kt b/compiler/serialization/src/org/jetbrains/kotlin/serialization/DescriptorSerializer.kt index 838eb6192c0..463810d4fee 100644 --- a/compiler/serialization/src/org/jetbrains/kotlin/serialization/DescriptorSerializer.kt +++ b/compiler/serialization/src/org/jetbrains/kotlin/serialization/DescriptorSerializer.kt @@ -1,17 +1,6 @@ /* - * Copyright 2010-2016 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 2000-2018 JetBrains s.r.o. 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.serialization @@ -73,7 +62,7 @@ class DescriptorSerializer private constructor( val flags = Flags.getClassFlags( hasAnnotations(classDescriptor), normalizeVisibility(classDescriptor), classDescriptor.modality, classDescriptor.kind, classDescriptor.isInner, classDescriptor.isCompanionObject, classDescriptor.isData, classDescriptor.isExternal, - classDescriptor.isExpect + classDescriptor.isExpect, classDescriptor.isInline ) if (flags != builder.flags) { builder.flags = flags diff --git a/compiler/testData/diagnostics/tests/inlineClasses/basicInlineClassDeclaration.kt b/compiler/testData/diagnostics/tests/inlineClasses/basicInlineClassDeclaration.kt new file mode 100644 index 00000000000..f1efb38b7fb --- /dev/null +++ b/compiler/testData/diagnostics/tests/inlineClasses/basicInlineClassDeclaration.kt @@ -0,0 +1,8 @@ +// !LANGUAGE: +InlineClasses + +inline class Foo(val x: Int) + +inline interface InlineInterface +inline annotation class InlineAnn +inline object InlineObject +inline enum class InlineEnum diff --git a/compiler/testData/diagnostics/tests/inlineClasses/basicInlineClassDeclaration.txt b/compiler/testData/diagnostics/tests/inlineClasses/basicInlineClassDeclaration.txt new file mode 100644 index 00000000000..de62f290381 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inlineClasses/basicInlineClassDeclaration.txt @@ -0,0 +1,46 @@ +package + +public final inline class Foo { + public constructor Foo(/*0*/ x: kotlin.Int) + public final val x: kotlin.Int + 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 inline annotation class InlineAnn : kotlin.Annotation { + public constructor InlineAnn() + 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 inline enum class InlineEnum : kotlin.Enum { + private constructor InlineEnum() + public final override /*1*/ /*fake_override*/ val name: kotlin.String + public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int + protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: InlineEnum): kotlin.Int + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit + public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class! + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): InlineEnum + public final /*synthesized*/ fun values(): kotlin.Array +} + +public inline interface InlineInterface { + 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 inline object InlineObject { + private constructor InlineObject() + 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 +} diff --git a/compiler/testData/diagnostics/tests/inlineClasses/basicInlineClassDeclarationDisabled.kt b/compiler/testData/diagnostics/tests/inlineClasses/basicInlineClassDeclarationDisabled.kt new file mode 100644 index 00000000000..05858b6c8ff --- /dev/null +++ b/compiler/testData/diagnostics/tests/inlineClasses/basicInlineClassDeclarationDisabled.kt @@ -0,0 +1,7 @@ +// !LANGUAGE: -InlineClasses + +inline class Foo(val x: Int) + +inline annotation class InlineAnn +inline object InlineObject +inline enum class InlineEnum diff --git a/compiler/testData/diagnostics/tests/inlineClasses/basicInlineClassDeclarationDisabled.txt b/compiler/testData/diagnostics/tests/inlineClasses/basicInlineClassDeclarationDisabled.txt new file mode 100644 index 00000000000..932bd635c32 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inlineClasses/basicInlineClassDeclarationDisabled.txt @@ -0,0 +1,40 @@ +package + +public final inline class Foo { + public constructor Foo(/*0*/ x: kotlin.Int) + public final val x: kotlin.Int + 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 inline annotation class InlineAnn : kotlin.Annotation { + public constructor InlineAnn() + 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 inline enum class InlineEnum : kotlin.Enum { + private constructor InlineEnum() + public final override /*1*/ /*fake_override*/ val name: kotlin.String + public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int + protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: InlineEnum): kotlin.Int + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit + public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class! + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): InlineEnum + public final /*synthesized*/ fun values(): kotlin.Array +} + +public inline object InlineObject { + private constructor InlineObject() + 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 +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index 9af5962a335..21a73c2644b 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -12063,6 +12063,27 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { } } + @TestMetadata("compiler/testData/diagnostics/tests/inlineClasses") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class InlineClasses extends AbstractDiagnosticsTest { + public void testAllFilesPresentInInlineClasses() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/inlineClasses"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("basicInlineClassDeclaration.kt") + public void testBasicInlineClassDeclaration() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inlineClasses/basicInlineClassDeclaration.kt"); + doTest(fileName); + } + + @TestMetadata("basicInlineClassDeclarationDisabled.kt") + public void testBasicInlineClassDeclarationDisabled() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inlineClasses/basicInlineClassDeclarationDisabled.kt"); + doTest(fileName); + } + } + @TestMetadata("compiler/testData/diagnostics/tests/inner") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java index fbcc9d5a850..cea86cc2294 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java @@ -12063,6 +12063,27 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing } } + @TestMetadata("compiler/testData/diagnostics/tests/inlineClasses") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class InlineClasses extends AbstractDiagnosticsUsingJavacTest { + public void testAllFilesPresentInInlineClasses() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/inlineClasses"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("basicInlineClassDeclaration.kt") + public void testBasicInlineClassDeclaration() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inlineClasses/basicInlineClassDeclaration.kt"); + doTest(fileName); + } + + @TestMetadata("basicInlineClassDeclarationDisabled.kt") + public void testBasicInlineClassDeclarationDisabled() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inlineClasses/basicInlineClassDeclarationDisabled.kt"); + doTest(fileName); + } + } + @TestMetadata("compiler/testData/diagnostics/tests/inner") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt index 965d987819f..ae636bcf9ea 100644 --- a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt +++ b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt @@ -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 2000-2018 JetBrains s.r.o. 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.config @@ -76,6 +65,7 @@ enum class LanguageFeature( ProperForInArrayLoopRangeVariableAssignmentSemantic(KOTLIN_1_3), NestedClassesInAnnotations(KOTLIN_1_3), JvmStaticInInterface(KOTLIN_1_3), + InlineClasses(KOTLIN_1_3), StrictJavaNullabilityAssertions(sinceVersion = null, defaultState = State.DISABLED), diff --git a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassDescriptor.kt b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassDescriptor.kt index 0ac09c45023..ead17cc45b8 100644 --- a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassDescriptor.kt +++ b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassDescriptor.kt @@ -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 2000-2018 JetBrains s.r.o. 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.load.java.lazy.descriptors @@ -101,6 +90,7 @@ class LazyJavaClassDescriptor( override fun isInner() = isInner override fun isData() = false + override fun isInline() = false override fun isCompanionObject() = false override fun isExpect() = false override fun isActual() = false diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassDescriptor.kt b/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassDescriptor.kt index d1be8c85ddb..9060a9984e9 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassDescriptor.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassDescriptor.kt @@ -1,17 +1,6 @@ /* - * Copyright 2010-2016 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 2000-2018 JetBrains s.r.o. 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.builtins.functions @@ -100,6 +89,7 @@ class FunctionClassDescriptor( override fun isCompanionObject() = false override fun isInner() = false override fun isData() = false + override fun isInline() = false override fun isExpect() = false override fun isActual() = false override fun isExternal() = false diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/ClassDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/ClassDescriptor.java index fc74bb0a76c..8fe61f7a63a 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/ClassDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/ClassDescriptor.java @@ -1,17 +1,6 @@ /* - * Copyright 2010-2016 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 2000-2018 JetBrains s.r.o. 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.descriptors; @@ -79,6 +68,8 @@ public interface ClassDescriptor extends ClassifierDescriptorWithTypeParameters, boolean isData(); + boolean isInline(); + @NotNull ReceiverParameterDescriptor getThisAsReceiverParameter(); diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/NotFoundClasses.kt b/core/descriptors/src/org/jetbrains/kotlin/descriptors/NotFoundClasses.kt index cccec98a941..1876351513c 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/NotFoundClasses.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/NotFoundClasses.kt @@ -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 2000-2018 JetBrains s.r.o. 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.descriptors @@ -78,6 +67,7 @@ class NotFoundClasses(private val storageManager: StorageManager, private val mo override fun isCompanionObject() = false override fun isData() = false + override fun isInline() = false override fun isExpect() = false override fun isActual() = false override fun isExternal() = false diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ClassDescriptorImpl.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ClassDescriptorImpl.java index 9776753b34e..2982cd4615d 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ClassDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ClassDescriptorImpl.java @@ -1,17 +1,6 @@ /* - * Copyright 2010-2015 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 2000-2018 JetBrains s.r.o. 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.descriptors.impl; @@ -147,6 +136,11 @@ public class ClassDescriptorImpl extends ClassDescriptorBase { return false; } + @Override + public boolean isInline() { + return false; + } + @Override public boolean isInner() { return false; diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/EnumEntrySyntheticClassDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/EnumEntrySyntheticClassDescriptor.java index b12098749fa..21a02dd43ca 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/EnumEntrySyntheticClassDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/EnumEntrySyntheticClassDescriptor.java @@ -1,17 +1,6 @@ /* - * Copyright 2010-2015 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 2000-2018 JetBrains s.r.o. 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.descriptors.impl; @@ -149,6 +138,11 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase { return false; } + @Override + public boolean isInline() { + return false; + } + @Override public boolean isCompanionObject() { return false; diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/LazySubstitutingClassDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/LazySubstitutingClassDescriptor.java index 329a2c7a0ce..c89b833e7ad 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/LazySubstitutingClassDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/LazySubstitutingClassDescriptor.java @@ -1,17 +1,6 @@ /* - * Copyright 2010-2016 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 2000-2018 JetBrains s.r.o. 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.descriptors.impl; @@ -216,6 +205,11 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor { return original.isData(); } + @Override + public boolean isInline() { + return original.isInline(); + } + @Override public boolean isExternal() { return original.isExternal(); diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/MutableClassDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/MutableClassDescriptor.java index 4aa0d5aaf7b..3270545b7d9 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/MutableClassDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/MutableClassDescriptor.java @@ -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 2000-2018 JetBrains s.r.o. 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.descriptors.impl; @@ -101,6 +90,11 @@ public class MutableClassDescriptor extends ClassDescriptorBase { return false; } + @Override + public boolean isInline() { + return false; + } + @Override public boolean isCompanionObject() { return false; diff --git a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRenderer.kt b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRenderer.kt index df71556b348..dcb4061548b 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRenderer.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRenderer.kt @@ -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 2000-2018 JetBrains s.r.o. 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.renderer @@ -263,6 +252,7 @@ enum class DescriptorRendererModifier(val includeByDefault: Boolean) { INNER(true), MEMBER_KIND(true), DATA(true), + INLINE(true), EXPECT(true), ACTUAL(true), ; diff --git a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt index 2bac4688bec..b5ef03bd433 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt @@ -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 2000-2018 JetBrains s.r.o. 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.renderer @@ -883,6 +872,7 @@ internal class DescriptorRendererImpl( renderMemberModifiers(klass, builder) renderModifier(builder, DescriptorRendererModifier.INNER in modifiers && klass.isInner, "inner") renderModifier(builder, DescriptorRendererModifier.DATA in modifiers && klass.isData, "data") + renderModifier(builder, DescriptorRendererModifier.INLINE in modifiers && klass.isInline, "inline") renderClassKindPrefix(klass, builder) } diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/Flags.java b/core/deserialization/src/org/jetbrains/kotlin/serialization/Flags.java index 374706c903c..14e730250a1 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/Flags.java +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/Flags.java @@ -1,17 +1,6 @@ /* - * Copyright 2010-2015 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 2000-2018 JetBrains s.r.o. 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.serialization; @@ -40,6 +29,7 @@ public class Flags { public static final BooleanFlagField IS_DATA = FlagField.booleanAfter(IS_INNER); public static final BooleanFlagField IS_EXTERNAL_CLASS = FlagField.booleanAfter(IS_DATA); public static final BooleanFlagField IS_EXPECT_CLASS = FlagField.booleanAfter(IS_EXTERNAL_CLASS); + public static final BooleanFlagField IS_INLINE_CLASS = FlagField.booleanAfter(IS_EXPECT_CLASS); // Constructors @@ -103,7 +93,8 @@ public class Flags { boolean isCompanionObject, boolean isData, boolean isExternal, - boolean isExpect + boolean isExpect, + boolean isInline ) { return HAS_ANNOTATIONS.toFlags(hasAnnotations) | MODALITY.toFlags(modality(modality)) @@ -113,6 +104,7 @@ public class Flags { | IS_DATA.toFlags(isData) | IS_EXTERNAL_CLASS.toFlags(isExternal) | IS_EXPECT_CLASS.toFlags(isExpect) + | IS_INLINE_CLASS.toFlags(isInline) ; } diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt index ecb4131ad5e..fd82e60f90d 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt @@ -1,17 +1,6 @@ /* - * Copyright 2010-2016 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 2000-2018 JetBrains s.r.o. 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.serialization.deserialization.descriptors @@ -98,6 +87,8 @@ class DeserializedClassDescriptor( override fun isData() = Flags.IS_DATA.get(classProto.flags) + override fun isInline() = Flags.IS_INLINE_CLASS.get(classProto.flags) + override fun isExpect() = Flags.IS_EXPECT_CLASS.get(classProto.flags) override fun isActual() = false