KT-224 "Overload ambiguity" when calling toString() method

This commit is contained in:
Andrey Breslav
2012-02-17 21:01:06 +04:00
parent bf508ae03e
commit a87c0903f2
20 changed files with 92 additions and 78 deletions
+3
View File
@@ -7,6 +7,9 @@
<depends optional="true">JUnit</depends>
<project-components>
<component>
<implementation-class>org.jetbrains.jet.plugin.JetStandardLibraryInitializer</implementation-class>
</component>
<component>
<implementation-class>org.jetbrains.jet.plugin.compiler.JetCompilerManager</implementation-class>
</component>
@@ -76,7 +76,7 @@ public class JetPluginUtil {
return true;
}
JetStandardLibrary standardLibrary = JetStandardLibrary.getJetStandardLibrary(project);
JetStandardLibrary standardLibrary = JetStandardLibrary.getInstance();
JetScope libraryScope = standardLibrary.getLibraryScope();
DeclarationDescriptor declaration = type.getMemberScope().getContainingDeclaration();
@@ -0,0 +1,39 @@
/*
* Copyright 2000-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.plugin;
import com.intellij.openapi.progress.ProgressManager;
import com.intellij.openapi.project.Project;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.types.JetStandardLibrary;
/**
* This project component initializes JetStandardLibrary so that throwing a ProcessCanceledException while
* loading PSI from declaration files is prevented.
*
* @author abreslav
*/
public class JetStandardLibraryInitializer {
public JetStandardLibraryInitializer(@NotNull final Project project) {
ProgressManager.getInstance().executeNonCancelableSection(new Runnable() {
@Override
public void run() {
JetStandardLibrary.initialize(project);
}
});
}
}
@@ -94,7 +94,7 @@ public abstract class OverrideImplementMethodsHandler implements LanguageCodeIns
}
bodyBuilder.append(descriptor.getName()).append(": ").append(descriptor.getOutType());
ImportClassHelper.addImportDirectiveIfNeeded(descriptor.getOutType(), file);
String initializer = defaultInitializer(descriptor.getOutType(), JetStandardLibrary.getJetStandardLibrary(project));
String initializer = defaultInitializer(descriptor.getOutType(), JetStandardLibrary.getInstance());
if (initializer != null) {
bodyBuilder.append("=").append(initializer);
}
@@ -122,7 +122,7 @@ public abstract class OverrideImplementMethodsHandler implements LanguageCodeIns
}
bodyBuilder.append(")");
final JetType returnType = descriptor.getReturnType();
final JetStandardLibrary stdlib = JetStandardLibrary.getJetStandardLibrary(project);
final JetStandardLibrary stdlib = JetStandardLibrary.getInstance();
if (!returnType.equals(stdlib.getTuple0Type())) {
bodyBuilder.append(": ").append(returnType.toString());
ImportClassHelper.addImportDirectiveIfNeeded(returnType, file);
@@ -153,7 +153,7 @@ public class JetPositionManager implements PositionManager {
return mapper;
}
final BindingContext bindingContext = WholeProjectAnalyzerFacade.analyzeProjectWithCacheOnAFile(file);
final JetStandardLibrary standardLibrary = JetStandardLibrary.getJetStandardLibrary(myDebugProcess.getProject());
final JetStandardLibrary standardLibrary = JetStandardLibrary.getInstance();
final JetTypeMapper typeMapper = new JetTypeMapper(standardLibrary, bindingContext);
file.acceptChildren(new JetVisitorVoid() {
@Override
@@ -78,7 +78,7 @@ public class JetNameSuggester {
}
private static void addNamesForType(ArrayList<String> result, JetType jetType, JetNameValidator validator) {
JetStandardLibrary standardLibrary = JetStandardLibrary.getJetStandardLibrary(validator.getProject());
JetStandardLibrary standardLibrary = JetStandardLibrary.getInstance();
JetTypeChecker typeChecker = JetTypeChecker.INSTANCE;
if (typeChecker.equalTypes(standardLibrary.getBooleanType(), jetType)) {
addName(result, "b", validator);
@@ -107,7 +107,7 @@ public class JetRefactoringUtil {
JetType expressionType = bindingContext.get(BindingContext.EXPRESSION_TYPE, expression);
if (expressionType == null || !(expressionType instanceof NamespaceType) &&
!JetTypeChecker.INSTANCE.equalTypes(JetStandardLibrary.
getJetStandardLibrary(element.getProject()).getTuple0Type(), expressionType)) {
getInstance().getTuple0Type(), expressionType)) {
expressions.add(expression);
}
}
@@ -102,7 +102,7 @@ public class JetIntroduceVariableHandler extends JetIntroduceHandlerBase {
showErrorHint(project, editor, JetRefactoringBundle.message("cannot.refactor.namespace.expression"));
return;
} if (expressionType != null &&
JetTypeChecker.INSTANCE.equalTypes(JetStandardLibrary.getJetStandardLibrary(project).getTuple0Type(), expressionType)) {
JetTypeChecker.INSTANCE.equalTypes(JetStandardLibrary.getInstance().getTuple0Type(), expressionType)) {
showErrorHint(project, editor, JetRefactoringBundle.message("cannot.refactor.expression.has.unit.type"));
return;
}