Use type from compile time value for prefix expression
This commit is contained in:
+2
@@ -50,4 +50,6 @@ public interface AnnotationArgumentVisitor<R, D> {
|
||||
R visitAnnotationValue(AnnotationValue value, D data);
|
||||
|
||||
R visitJavaClassValue(JavaClassValue value, D data);
|
||||
|
||||
R visitNumberTypeValue(NumberValueTypeConstant value, D data);
|
||||
}
|
||||
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright 2010-2013 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.lang.resolve.constants;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationArgumentVisitor;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.types.ErrorUtils;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lang.types.JetTypeImpl;
|
||||
import org.jetbrains.jet.lang.types.TypeProjection;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
public abstract class NumberValueTypeConstant<T extends Number> implements CompileTimeConstant<NumberValueTypeConstructor<T>> {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public JetType getType(@NotNull KotlinBuiltIns kotlinBuiltIns) {
|
||||
return new JetTypeImpl(
|
||||
Collections.<AnnotationDescriptor>emptyList(), getValue(),
|
||||
false, Collections.<TypeProjection>emptyList(),
|
||||
ErrorUtils.createErrorScope("Scope for number value type (" + getValue().toString() + ")", true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R, D> R accept(AnnotationArgumentVisitor<R, D> visitor, D data) {
|
||||
return visitor.visitNumberTypeValue(this, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public abstract NumberValueTypeConstructor<T> getValue();
|
||||
}
|
||||
+3
-1
@@ -26,7 +26,7 @@ import org.jetbrains.jet.lang.types.TypeConstructor;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class NumberValueTypeConstructor implements TypeConstructor {
|
||||
public abstract class NumberValueTypeConstructor<T extends Number> implements TypeConstructor {
|
||||
@NotNull
|
||||
@Override
|
||||
public List<TypeParameterDescriptor> getParameters() {
|
||||
@@ -54,4 +54,6 @@ public abstract class NumberValueTypeConstructor implements TypeConstructor {
|
||||
public List<AnnotationDescriptor> getAnnotations() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public abstract T getValue();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user