Skip to content

Commit

Permalink
[J2KT] Add readable test to cover b/289049603 - a problem in Kotlin c…
Browse files Browse the repository at this point in the history
…ompiler with packages starting with "java".

PiperOrigin-RevId: 550813436
  • Loading branch information
Googler authored and copybara-github committed Jul 25, 2023
1 parent ae767f7 commit 0887558
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright 2023 Google Inc.
*
* 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
*
* https://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.
*/
package javapkg;

// TODO(b/289049603): Kotlin compiler crashes with
// "Companion object javapkg.PackageWithJavaPrefix$Companion cannot be interpreted" message.
// However, it's already fixed in 1.9.20.
// Move this file to "j2kt" when 1.9.20 toolchain is available for JVM and Native.
public class PackageWithJavaPrefix {
public static final int VALUE = 128;

public static int value() {
return VALUE;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Generated by J2KT from "javapkg/PackageWithJavaPrefix.java"

#import <Foundation/NSObjCRuntime.h>

#import "third_party/java_src/j2objc/jre_emul/Classes/J2ObjC_types.h"

@class J2ktJavapkgPackageWithJavaPrefix;
@class J2ktJavapkgPackageWithJavaPrefixCompanion;

NS_ASSUME_NONNULL_BEGIN

@compatibility_alias JavapkgPackageWithJavaPrefix J2ktJavapkgPackageWithJavaPrefix;

@compatibility_alias JavapkgPackageWithJavaPrefixCompanion J2ktJavapkgPackageWithJavaPrefixCompanion;

#define JavapkgPackageWithJavaPrefix_VALUE 128

NS_INLINE jint JavapkgPackageWithJavaPrefix_get_VALUE(void) {
return J2ktJavapkgPackageWithJavaPrefixCompanion.shared.VALUE_;
}

NS_INLINE jint JavapkgPackageWithJavaPrefix_value(void) {
return [J2ktJavapkgPackageWithJavaPrefixCompanion.shared value];
}

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Generated from "javapkg/PackageWithJavaPrefix.java"
@file:OptIn(ExperimentalObjCName::class)
@file:Suppress(
"ALWAYS_NULL",
"PARAMETER_NAME_CHANGED_ON_OVERRIDE",
"REPEATED_BOUND",
"SENSELESS_COMPARISON",
"UNCHECKED_CAST",
"UNNECESSARY_LATEINIT",
"UNNECESSARY_NOT_NULL_ASSERTION",
"UNREACHABLE_CODE",
"UNUSED_PARAMETER",
"UNUSED_VARIABLE",
"USELESS_CAST",
"VARIABLE_IN_SINGLETON_WITHOUT_THREAD_LOCAL",
"VARIABLE_WITH_REDUNDANT_INITIALIZER")

package javapkg

import javaemul.lang.*
import kotlin.Int
import kotlin.OptIn
import kotlin.Suppress
import kotlin.experimental.ExperimentalObjCName
import kotlin.jvm.JvmStatic
import kotlin.native.ObjCName

@ObjCName("J2ktJavapkgPackageWithJavaPrefix", exact = true)
open class PackageWithJavaPrefix {
@ObjCName("J2ktJavapkgPackageWithJavaPrefixCompanion", exact = true)
companion object {
@ObjCName("VALUE_")
const val VALUE: Int = 128

@JvmStatic
@ObjCName("value")
fun value(): Int {
return PackageWithJavaPrefix.VALUE
}
}
}

0 comments on commit 0887558

Please sign in to comment.