Basic inline class mapping to the underlying representation

This commit is contained in:
Mikhail Zarechenskiy
2018-01-24 14:33:30 +03:00
parent 4b4525ec17
commit d5400f11a3
7 changed files with 106 additions and 27 deletions
@@ -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.codegen.state;
@@ -399,7 +388,7 @@ public class KotlinTypeMapper {
@NotNull
public Type mapClass(@NotNull ClassifierDescriptor classifier) {
return mapType(classifier.getDefaultType(), null, TypeMappingMode.DEFAULT);
return mapType(classifier.getDefaultType(), null, TypeMappingMode.CLASS_DECLARATION);
}
@NotNull
@@ -0,0 +1,26 @@
// !LANGUAGE: +InlineClasses
inline class Foo(val x: Int)
object Test {
fun asParam(a: Foo) {}
fun asReturn(): Foo = TODO()
fun Foo.asExtension() {}
fun Foo.asAll(x: Any?, a: Foo, b: Int): Foo = TODO()
}
// method: Test::asParam
// jvm signature: (I)V
// generic signature: null
// method: Test::asReturn
// jvm signature: ()I
// generic signature: null
// method: Test::asExtension
// jvm signature: (I)V
// generic signature: null
// method: Test::asAll
// jvm signature: (ILjava/lang/Object;II)I
// generic signature: null
@@ -0,0 +1,19 @@
// !LANGUAGE: +InlineClasses
inline class Foo(val x: Int?)
class SimpleClass
inline class Bar(val x: SimpleClass)
object Test {
fun asParam(a: Foo) {}
fun asReturn(): Bar = TODO()
}
// method: Test::asParam
// jvm signature: (Ljava/lang/Integer;)V
// generic signature: null
// method: Test::asReturn
// jvm signature: ()LSimpleClass;
// generic signature: null
@@ -550,6 +550,27 @@ public class WriteSignatureTestGenerated extends AbstractWriteSignatureTest {
}
}
@TestMetadata("compiler/testData/writeSignature/inlineClasses")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class InlineClasses extends AbstractWriteSignatureTest {
public void testAllFilesPresentInInlineClasses() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/writeSignature/inlineClasses"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("simpleSignatureWithInlineClassTypesAsPrimitive.kt")
public void testSimpleSignatureWithInlineClassTypesAsPrimitive() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/writeSignature/inlineClasses/simpleSignatureWithInlineClassTypesAsPrimitive.kt");
doTest(fileName);
}
@TestMetadata("simpleSignatureWithInlineClassTypesAsReference.kt")
public void testSimpleSignatureWithInlineClassTypesAsReference() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/writeSignature/inlineClasses/simpleSignatureWithInlineClassTypesAsReference.kt");
doTest(fileName);
}
}
@TestMetadata("compiler/testData/writeSignature/nothing")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)