correct access flags for package private (coming from java) #KT-2781 fixed
This commit is contained in:
@@ -19,7 +19,8 @@ package org.jetbrains.jet.compiler.android;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Natalia.Ukhorskaya
|
||||
@@ -120,6 +121,8 @@ public class SpecialFiles {
|
||||
excludedFiles.add("kt1779.kt"); // Bug KT-2202 - private fun tryToComputeNext() in AbstractIterator.kt
|
||||
excludedFiles.add("kt344.jet"); // Bug KT-2251
|
||||
excludedFiles.add("kt529.kt"); // Bug
|
||||
|
||||
excludedFiles.add("kt2981.kt"); // with java
|
||||
}
|
||||
|
||||
private SpecialFiles() {
|
||||
|
||||
@@ -37,10 +37,7 @@ import org.jetbrains.jet.lang.psi.JetClassObject;
|
||||
import org.jetbrains.jet.lang.psi.JetClassOrObject;
|
||||
import org.jetbrains.jet.lang.psi.JetObjectDeclaration;
|
||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmClassName;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmPrimitiveType;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmStdlibNames;
|
||||
import org.jetbrains.jet.lang.resolve.java.*;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
@@ -70,6 +67,7 @@ public class CodegenUtil {
|
||||
.put(Visibilities.PUBLIC, ACC_PUBLIC)
|
||||
.put(Visibilities.INTERNAL, ACC_PUBLIC)
|
||||
.put(Visibilities.LOCAL, NO_FLAG_LOCAL)
|
||||
.put(JavaDescriptorResolver.PACKAGE_VISIBILITY, NO_FLAG_PACKAGE_PRIVATE)
|
||||
.build();
|
||||
|
||||
private static final Set<ClassDescriptor> PRIMITIVE_NUMBER_CLASSES = Sets.newHashSet(
|
||||
|
||||
@@ -18,14 +18,18 @@ package org.jetbrains.jet.codegen;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
* @author alex.tkachman
|
||||
*/
|
||||
public class GeneratedClassLoader extends ClassLoader {
|
||||
public class GeneratedClassLoader extends URLClassLoader {
|
||||
private ClassFileFactory state;
|
||||
|
||||
public GeneratedClassLoader(@NotNull ClassFileFactory state, ClassLoader parentClassLoader) {
|
||||
super(parentClassLoader);
|
||||
public GeneratedClassLoader(@NotNull ClassFileFactory state, ClassLoader parentClassLoader, URL...urls) {
|
||||
super(urls, parentClassLoader);
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -72,7 +72,7 @@ public class JavaDescriptorResolver implements DependencyClassByQualifiedNameRes
|
||||
|
||||
public static final ModuleDescriptor FAKE_ROOT_MODULE = new ModuleDescriptor(JAVA_ROOT);
|
||||
|
||||
private static Visibility PACKAGE_VISIBILITY = new Visibility("package", false) {
|
||||
public static Visibility PACKAGE_VISIBILITY = new Visibility("package", false) {
|
||||
@Override
|
||||
protected boolean isVisible(@NotNull DeclarationDescriptorWithVisibility what, @NotNull DeclarationDescriptor from) {
|
||||
NamespaceDescriptor parentPackage = DescriptorUtils.getParentOfType(what, NamespaceDescriptor.class);
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2010-2012 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.
|
||||
*/
|
||||
|
||||
import java.lang.String;
|
||||
|
||||
class J {
|
||||
String value;
|
||||
|
||||
J(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
fun box() = J("OK").value
|
||||
@@ -601,4 +601,9 @@ public class ClassGenTest extends CodegenTestCase {
|
||||
createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY);
|
||||
blackBoxFile("regressions/kt2626.kt");
|
||||
}
|
||||
|
||||
public void testKt2781() throws Exception {
|
||||
createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY);
|
||||
blackBoxFileWithJava("regressions/kt2781.kt", true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,8 +156,12 @@ public abstract class CodegenTestCase extends UsefulTestCase {
|
||||
}
|
||||
|
||||
protected void blackBoxFile(String filename, String expected) {
|
||||
blackBoxFile(filename, expected, false);
|
||||
}
|
||||
|
||||
protected void blackBoxFile(String filename, String expected, boolean classPathInTheSameClassLoader) {
|
||||
loadFile(filename);
|
||||
blackBox(expected);
|
||||
blackBox(expected, classPathInTheSameClassLoader);
|
||||
}
|
||||
|
||||
protected void blackBoxFileByFullPath(String filename) {
|
||||
@@ -214,9 +218,13 @@ public abstract class CodegenTestCase extends UsefulTestCase {
|
||||
}
|
||||
|
||||
protected void blackBox(String expected) {
|
||||
blackBox(expected, false);
|
||||
}
|
||||
|
||||
protected void blackBox(String expected, boolean classPathInTheSameClassLoader) {
|
||||
GenerationState state = generateClassesInFileGetState();
|
||||
|
||||
GeneratedClassLoader loader = createClassLoader(state.getFactory());
|
||||
GeneratedClassLoader loader = createClassLoader(state.getFactory(), classPathInTheSameClassLoader);
|
||||
|
||||
String r;
|
||||
|
||||
@@ -275,6 +283,10 @@ public abstract class CodegenTestCase extends UsefulTestCase {
|
||||
}
|
||||
|
||||
protected void blackBoxFileWithJava(@NotNull String ktFile) throws Exception {
|
||||
blackBoxFileWithJava(ktFile, false);
|
||||
}
|
||||
|
||||
protected void blackBoxFileWithJava(@NotNull String ktFile, boolean classPathInTheSameClassLoader) throws Exception {
|
||||
File javaClassesTempDirectory = new File(FileUtil.getTempDirectory(), "java-classes");
|
||||
JetTestUtils.mkdirs(javaClassesTempDirectory);
|
||||
List<String> options = Arrays.asList(
|
||||
@@ -287,10 +299,14 @@ public abstract class CodegenTestCase extends UsefulTestCase {
|
||||
myEnvironment = new JetCoreEnvironment(getTestRootDisposable(), CompileCompilerDependenciesTest.compilerConfigurationForTests(
|
||||
ConfigurationKind.JDK_ONLY, TestJdkKind.MOCK_JDK, JetTestUtils.getAnnotationsJar(), javaClassesTempDirectory));
|
||||
|
||||
blackBoxFile(ktFile);
|
||||
blackBoxFile(ktFile, "OK", classPathInTheSameClassLoader);
|
||||
}
|
||||
|
||||
protected GeneratedClassLoader createClassLoader(ClassFileFactory codegens) {
|
||||
return createClassLoader(codegens, false);
|
||||
}
|
||||
|
||||
protected GeneratedClassLoader createClassLoader(ClassFileFactory codegens, boolean classPathInTheSameClassLoader) {
|
||||
List<URL> urls = Lists.newArrayList();
|
||||
for (File file : myEnvironment.getConfiguration().getList(JVMConfigurationKeys.CLASSPATH_KEY)) {
|
||||
try {
|
||||
@@ -299,8 +315,16 @@ public abstract class CodegenTestCase extends UsefulTestCase {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
ClassLoader parentClassLoader = new URLClassLoader(urls.toArray(new URL[0]), CodegenTestCase.class.getClassLoader());
|
||||
return new GeneratedClassLoader(codegens, parentClassLoader);
|
||||
|
||||
final URL[] urlsArray = urls.toArray(new URL[0]);
|
||||
|
||||
if (!classPathInTheSameClassLoader) {
|
||||
ClassLoader parentClassLoader = new URLClassLoader(urlsArray, CodegenTestCase.class.getClassLoader());
|
||||
return new GeneratedClassLoader(codegens, parentClassLoader);
|
||||
}
|
||||
else {
|
||||
return new GeneratedClassLoader(codegens, CodegenTestCase.class.getClassLoader(), urlsArray);
|
||||
}
|
||||
}
|
||||
|
||||
protected String generateToText() {
|
||||
|
||||
Reference in New Issue
Block a user