Fix detection of erased this for inline class
This commit is contained in:
@@ -1673,8 +1673,11 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
PropertyDescriptor propertyDescriptor = (PropertyDescriptor) descriptor;
|
||||
|
||||
// `this` is represented as first parameter of function in erased inline class
|
||||
if (contextKind() == OwnerKind.ERASED_INLINE_CLASS &&
|
||||
InlineClassesUtilsKt.isInlineClass(propertyDescriptor.getContainingDeclaration())) {
|
||||
boolean isThisOfErasedInlineClass =
|
||||
contextKind() == OwnerKind.ERASED_INLINE_CLASS &&
|
||||
InlineClassesUtilsKt.isInlineClass(propertyDescriptor.getContainingDeclaration()) &&
|
||||
JvmCodegenUtil.hasBackingField(propertyDescriptor, contextKind(), bindingContext);
|
||||
if (isThisOfErasedInlineClass) {
|
||||
Type underlyingRepresentationType = typeMapper.mapType(propertyDescriptor.getType());
|
||||
return StackValue.local(0, underlyingRepresentationType);
|
||||
}
|
||||
|
||||
@@ -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.codegen;
|
||||
@@ -338,4 +327,12 @@ public class JvmCodegenUtil {
|
||||
isJvmInterface(companionObject.getContainingDeclaration()) &&
|
||||
!JvmAbi.isMappedIntrinsicCompanionObject((ClassDescriptor) companionObject);
|
||||
}
|
||||
|
||||
public static boolean hasBackingField(
|
||||
@NotNull PropertyDescriptor descriptor, @NotNull OwnerKind kind, @NotNull BindingContext bindingContext
|
||||
) {
|
||||
return !isJvmInterface(descriptor.getContainingDeclaration()) &&
|
||||
kind != OwnerKind.DEFAULT_IMPLS &&
|
||||
!Boolean.FALSE.equals(bindingContext.get(BindingContext.BACKING_FIELD_REQUIRED, descriptor));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,7 +156,7 @@ public class PropertyCodegen {
|
||||
private void genBackingFieldAndAnnotations(
|
||||
@Nullable KtNamedDeclaration declaration, @NotNull PropertyDescriptor descriptor, boolean isParameter
|
||||
) {
|
||||
boolean hasBackingField = hasBackingField(descriptor);
|
||||
boolean hasBackingField = JvmCodegenUtil.hasBackingField(descriptor, kind, bindingContext);
|
||||
boolean hasDelegate = declaration instanceof KtProperty && ((KtProperty) declaration).hasDelegate();
|
||||
|
||||
AnnotationSplitter annotationSplitter =
|
||||
@@ -303,12 +303,6 @@ public class PropertyCodegen {
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean hasBackingField(@NotNull PropertyDescriptor descriptor) {
|
||||
return !isJvmInterface(descriptor.getContainingDeclaration()) &&
|
||||
kind != OwnerKind.DEFAULT_IMPLS &&
|
||||
!Boolean.FALSE.equals(bindingContext.get(BindingContext.BACKING_FIELD_REQUIRED, descriptor));
|
||||
}
|
||||
|
||||
private boolean generateBackingField(
|
||||
@NotNull KtNamedDeclaration p,
|
||||
@NotNull PropertyDescriptor descriptor,
|
||||
|
||||
Reference in New Issue
Block a user