Fix for RangeTo intrinsic for the case of LongRange
This commit is contained in:
@@ -50,7 +50,7 @@ public class RangeTo implements IntrinsicMethod {
|
||||
if (arguments.size() == 1) {
|
||||
final Type leftType = receiver.type;
|
||||
final Type rightType = codegen.expressionType(arguments.get(0));
|
||||
receiver.put(Type.INT_TYPE, v);
|
||||
receiver.put(leftType, v);
|
||||
codegen.gen(arguments.get(0), rightType);
|
||||
v.invokestatic("jet/runtime/Ranges", "rangeTo",
|
||||
"(" + receiver.type.getDescriptor() + leftType.getDescriptor() + ")" + expectedType.getDescriptor());
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
fun box(): String {
|
||||
val l: Long = 1
|
||||
val l2: Long = 2
|
||||
val r = l.rangeTo(l2)
|
||||
return if (r.start == l && r.end == l2) "OK" else "fail"
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.codegen;
|
||||
|
||||
import org.jetbrains.jet.test.generator.SimpleTestClassModel;
|
||||
import org.jetbrains.jet.test.generator.TestGenerator;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
*/
|
||||
public abstract class AbstractIntrinsicsTestCase extends CodegenTestCase {
|
||||
@Override
|
||||
protected String getPrefix() {
|
||||
return "intrinsic";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
createEnvironmentWithMockJdkAndIdeaAnnotations();
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
Class<AbstractIntrinsicsTestCase> thisClass = AbstractIntrinsicsTestCase.class;
|
||||
String aPackage = thisClass.getPackage().getName();
|
||||
new TestGenerator(
|
||||
"compiler/tests/",
|
||||
aPackage,
|
||||
"IntrinsicsTestGenerated",
|
||||
thisClass,
|
||||
Arrays.asList(
|
||||
new SimpleTestClassModel(new File("compiler/testData/codegen/intrinsics"), true, "kt", "blackBoxFileByFullPath")
|
||||
),
|
||||
thisClass
|
||||
).generateAndSave();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package org.jetbrains.jet.codegen;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import java.io.File;
|
||||
import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.test.TestMetadata;
|
||||
|
||||
import org.jetbrains.jet.codegen.AbstractIntrinsicsTestCase;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.jet.codegen.AbstractIntrinsicsTestCase}. DO NOT MODIFY MANUALLY */
|
||||
@TestMetadata("compiler/testData/codegen/intrinsics")
|
||||
public class IntrinsicsTestGenerated extends AbstractIntrinsicsTestCase {
|
||||
public void testAllFilesPresentInIntrinsics() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.codegen.AbstractIntrinsicsTestCase", new File("compiler/testData/codegen/intrinsics"), "kt", false);
|
||||
}
|
||||
|
||||
@TestMetadata("longRangeWithExplicitDot.kt")
|
||||
public void testLongRangeWithExplicitDot() throws Exception {
|
||||
blackBoxFileByFullPath("compiler/testData/codegen/intrinsics/longRangeWithExplicitDot.kt");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user