diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/JetStandardLibrary.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/JetStandardLibrary.java index 6c641719c65..62923713125 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/JetStandardLibrary.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/JetStandardLibrary.java @@ -49,6 +49,7 @@ public class JetStandardLibrary { private JetScope libraryScope; + private ClassDescriptor numberClass; private ClassDescriptor byteClass; private ClassDescriptor charClass; private ClassDescriptor shortClass; @@ -152,6 +153,7 @@ public class JetStandardLibrary { private void initStdClasses() { if(libraryScope == null) { this.libraryScope = JetStandardClasses.STANDARD_CLASSES_NAMESPACE.getMemberScope(); + this.numberClass = (ClassDescriptor) libraryScope.getClassifier("Number"); this.byteClass = (ClassDescriptor) libraryScope.getClassifier("Byte"); this.charClass = (ClassDescriptor) libraryScope.getClassifier("Char"); this.shortClass = (ClassDescriptor) libraryScope.getClassifier("Short"); @@ -221,6 +223,12 @@ public class JetStandardLibrary { } } + @NotNull + public ClassDescriptor getNumber() { + initStdClasses(); + return numberClass; + } + @NotNull public ClassDescriptor getByte() { initStdClasses(); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java index 4e19232a122..f9ebc9d4a9c 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java @@ -468,7 +468,9 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { JetExpression receiverExpression = expression.getReceiverExpression(); CompileTimeConstant receiverValue = context.trace.getBindingContext().get(BindingContext.COMPILE_TIME_VALUE, receiverExpression); CompileTimeConstant wholeExpressionValue = context.trace.getBindingContext().get(BindingContext.COMPILE_TIME_VALUE, expression); - if (wholeExpressionValue == null && receiverValue != null && !(receiverValue instanceof ErrorValue) && receiverValue.getValue() instanceof Number) { + DeclarationDescriptor declarationDescriptor = context.trace.getBindingContext().get(BindingContext.REFERENCE_TARGET, selectorExpression); + if (wholeExpressionValue == null && receiverValue != null && !(receiverValue instanceof ErrorValue) && receiverValue.getValue() instanceof Number + && context.semanticServices.getStandardLibrary().getNumber() == declarationDescriptor) { Number value = (Number) receiverValue.getValue(); String referencedName = selectorExpression.getReferencedName(); if (OperatorConventions.NUMBER_CONVERSIONS.contains(referencedName)) {