Merge branch 'master' of ssh://git.labs.intellij.net/jet
This commit is contained in:
@@ -19,6 +19,11 @@
|
||||
<keyboard-shortcut keymap="$default" first-keystroke="control shift Q"/>
|
||||
<add-to-group group-id="CodeMenu" anchor="last"/>
|
||||
</action>
|
||||
<action id="CopyAsDiagnosticTest" class="org.jetbrains.jet.plugin.actions.CopyAsDiagnosticTestAction"
|
||||
text="Copy Current File As Diagnostic Test">
|
||||
<keyboard-shortcut keymap="$default" first-keystroke="control alt shift T"/>
|
||||
<add-to-group group-id="CodeMenu" anchor="last"/>
|
||||
</action>
|
||||
<action id="ToggleJetErrorReporting" class="org.jetbrains.jet.plugin.actions.ToggleErrorReportingAction"
|
||||
text="Toggle Error Reporting">
|
||||
<keyboard-shortcut keymap="$default" first-keystroke="control alt shift E"/>
|
||||
|
||||
@@ -0,0 +1,316 @@
|
||||
package org.jetbrains.jet.checkers;
|
||||
|
||||
import com.google.common.collect.*;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.jet.lang.diagnostics.Diagnostic;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
*/
|
||||
public class CheckerTestUtil {
|
||||
public static final Comparator<Diagnostic> DIAGNOSTIC_COMPARATOR = new Comparator<Diagnostic>() {
|
||||
@Override
|
||||
public int compare(Diagnostic o1, Diagnostic o2) {
|
||||
TextRange range1 = getTextRange(o1);
|
||||
TextRange range2 = getTextRange(o2);
|
||||
int startOffset1 = range1.getStartOffset();
|
||||
int startOffset2 = range2.getStartOffset();
|
||||
if (startOffset1 != startOffset2) {
|
||||
// Start early -- go first
|
||||
return startOffset1 - range2.getStartOffset();
|
||||
}
|
||||
// start at the same offset, the one who end later is the outer, i.e. goes first
|
||||
return range2.getEndOffset() - range1.getEndOffset();
|
||||
}
|
||||
};
|
||||
private static final Pattern RANGE_START_OR_END_PATTERN = Pattern.compile("(<!\\w+(,\\s*\\w+)*!>)|(<!>)");
|
||||
private static final Pattern INDIVIDUAL_DIAGNOSTIC_PATTERN = Pattern.compile("\\w+");
|
||||
|
||||
public interface DiagnosticDiffCallbacks {
|
||||
void missingDiagnostic(String type, int expectedStart, int expectedEnd);
|
||||
void unexpectedDiagnostic(String type, int actualStart, int actualEnd);
|
||||
}
|
||||
|
||||
public static void diagnosticsDiff(List<DiagnosedRange> expected, Collection<Diagnostic> actual, DiagnosticDiffCallbacks callbacks) {
|
||||
Iterator<DiagnosedRange> expectedDiagnostics = expected.iterator();
|
||||
List<DiagnosticDescriptor> sortedDiagnosticDescriptors = getSortedDiagnosticDescriptors(actual);
|
||||
Iterator<DiagnosticDescriptor> actualDiagnostics = sortedDiagnosticDescriptors.iterator();
|
||||
|
||||
DiagnosedRange currentExpected = safeAdvance(expectedDiagnostics);
|
||||
DiagnosticDescriptor currentActual = safeAdvance(actualDiagnostics);
|
||||
while (currentExpected != null || currentActual != null) {
|
||||
if (currentExpected != null) {
|
||||
if (currentActual == null) {
|
||||
missingDiagnostics(callbacks, currentExpected);
|
||||
currentExpected = safeAdvance(expectedDiagnostics);
|
||||
}
|
||||
else {
|
||||
int expectedStart = currentExpected.getStart();
|
||||
int actualStart = currentActual.getStart();
|
||||
int expectedEnd = currentExpected.getEnd();
|
||||
int actualEnd = currentActual.getEnd();
|
||||
if (expectedStart < actualStart) {
|
||||
missingDiagnostics(callbacks, currentExpected);
|
||||
currentExpected = safeAdvance(expectedDiagnostics);
|
||||
}
|
||||
else if (expectedStart > actualStart) {
|
||||
unexpectedDiagnostics(currentActual.getDiagnostics(), callbacks);
|
||||
currentActual = safeAdvance(actualDiagnostics);
|
||||
}
|
||||
else if (expectedEnd > actualEnd) {
|
||||
assert expectedStart == actualStart;
|
||||
missingDiagnostics(callbacks, currentExpected);
|
||||
currentExpected = safeAdvance(expectedDiagnostics);
|
||||
}
|
||||
else if (expectedEnd < actualEnd) {
|
||||
assert expectedStart == actualStart;
|
||||
unexpectedDiagnostics(currentActual.getDiagnostics(), callbacks);
|
||||
currentActual = safeAdvance(actualDiagnostics);
|
||||
}
|
||||
else {
|
||||
assert expectedStart == actualStart && expectedEnd == actualEnd;
|
||||
Multiset<String> actualDiagnosticTypes = currentActual.getDiagnosticTypeStrings();
|
||||
Multiset<String> expectedDiagnosticTypes = currentExpected.getDiagnostics();
|
||||
if (!actualDiagnosticTypes.equals(expectedDiagnosticTypes)) {
|
||||
Multiset<String> expectedCopy = HashMultiset.create(expectedDiagnosticTypes);
|
||||
expectedCopy.removeAll(actualDiagnosticTypes);
|
||||
Multiset<String> actualCopy = HashMultiset.create(actualDiagnosticTypes);
|
||||
actualCopy.removeAll(expectedDiagnosticTypes);
|
||||
|
||||
for (String type : expectedCopy) {
|
||||
callbacks.missingDiagnostic(type, expectedStart, expectedEnd);
|
||||
}
|
||||
for (String type : actualCopy) {
|
||||
callbacks.unexpectedDiagnostic(type, actualStart, actualEnd);
|
||||
}
|
||||
}
|
||||
currentExpected = safeAdvance(expectedDiagnostics);
|
||||
currentActual = safeAdvance(actualDiagnostics);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (currentActual != null) {
|
||||
unexpectedDiagnostics(currentActual.getDiagnostics(), callbacks);
|
||||
currentActual = safeAdvance(actualDiagnostics);
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// assert expectedDiagnostics.hasNext() || actualDiagnostics.hasNext();
|
||||
}
|
||||
}
|
||||
|
||||
private static void unexpectedDiagnostics(List<Diagnostic> actual, DiagnosticDiffCallbacks callbacks) {
|
||||
for (Diagnostic diagnostic : actual) {
|
||||
TextRange textRange = getTextRange(diagnostic);
|
||||
callbacks.unexpectedDiagnostic(diagnostic.getFactory().getName(), textRange.getStartOffset(), textRange.getEndOffset());
|
||||
}
|
||||
}
|
||||
|
||||
private static void missingDiagnostics(DiagnosticDiffCallbacks callbacks, DiagnosedRange currentExpected) {
|
||||
for (String type : currentExpected.getDiagnostics()) {
|
||||
callbacks.missingDiagnostic(type, currentExpected.getStart(), currentExpected.getEnd());
|
||||
}
|
||||
}
|
||||
|
||||
private static <T> T safeAdvance(Iterator<T> iterator) {
|
||||
return iterator.hasNext() ? iterator.next() : null;
|
||||
}
|
||||
|
||||
public static String parseDiagnosedRanges(String text, List<DiagnosedRange> result) {
|
||||
Matcher matcher = RANGE_START_OR_END_PATTERN.matcher(text);
|
||||
|
||||
Stack<DiagnosedRange> opened = new Stack<DiagnosedRange>();
|
||||
|
||||
int offsetCompensation = 0;
|
||||
|
||||
while (matcher.find()) {
|
||||
int effectiveOffset = matcher.start() - offsetCompensation;
|
||||
String matchedText = matcher.group();
|
||||
if ("<!>".equals(matchedText)) {
|
||||
opened.pop().setEnd(effectiveOffset);
|
||||
}
|
||||
else {
|
||||
Matcher diagnosticTypeMatcher = INDIVIDUAL_DIAGNOSTIC_PATTERN.matcher(matchedText);
|
||||
DiagnosedRange range = new DiagnosedRange(effectiveOffset);
|
||||
while (diagnosticTypeMatcher.find()) {
|
||||
range.addDiagnostic(diagnosticTypeMatcher.group());
|
||||
}
|
||||
opened.push(range);
|
||||
result.add(range);
|
||||
}
|
||||
offsetCompensation += matchedText.length();
|
||||
}
|
||||
|
||||
assert opened.isEmpty() : "Stack is not empty";
|
||||
|
||||
matcher.reset();
|
||||
return matcher.replaceAll("");
|
||||
}
|
||||
|
||||
public static StringBuffer addDiagnosticMarkersToText(PsiFile psiFile, BindingContext bindingContext) {
|
||||
Collection<Diagnostic> diagnostics = bindingContext.getDiagnostics();
|
||||
|
||||
StringBuffer result = new StringBuffer();
|
||||
String text = psiFile.getText();
|
||||
if (!diagnostics.isEmpty()) {
|
||||
List<DiagnosticDescriptor> diagnosticDescriptors = getSortedDiagnosticDescriptors(diagnostics);
|
||||
|
||||
Stack<DiagnosticDescriptor> opened = new Stack<DiagnosticDescriptor>();
|
||||
ListIterator<DiagnosticDescriptor> iterator = diagnosticDescriptors.listIterator();
|
||||
DiagnosticDescriptor currentDescriptor = iterator.next();
|
||||
|
||||
for (int i = 0; i < text.length(); i++) {
|
||||
char c = text.charAt(i);
|
||||
while (!opened.isEmpty() && i == opened.peek().end) {
|
||||
closeDiagnosticString(result);
|
||||
opened.pop();
|
||||
}
|
||||
while (currentDescriptor != null && i == currentDescriptor.start) {
|
||||
openDiagnosticsString(result, currentDescriptor);
|
||||
if (currentDescriptor.getEnd() == i) {
|
||||
closeDiagnosticString(result);
|
||||
}
|
||||
else {
|
||||
opened.push(currentDescriptor);
|
||||
}
|
||||
if (iterator.hasNext()) {
|
||||
currentDescriptor = iterator.next();
|
||||
}
|
||||
else {
|
||||
currentDescriptor = null;
|
||||
}
|
||||
}
|
||||
result.append(c);
|
||||
}
|
||||
while (!opened.isEmpty() && text.length() == opened.peek().end) {
|
||||
closeDiagnosticString(result);
|
||||
opened.pop();
|
||||
}
|
||||
|
||||
assert opened.isEmpty() : "Stack is not empty";
|
||||
|
||||
}
|
||||
else {
|
||||
result.append(text);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void openDiagnosticsString(StringBuffer result, DiagnosticDescriptor currentDescriptor) {
|
||||
result.append("<!");
|
||||
for (Iterator<Diagnostic> iterator = currentDescriptor.diagnostics.iterator(); iterator.hasNext(); ) {
|
||||
Diagnostic diagnostic = iterator.next();
|
||||
result.append(diagnostic.getFactory().getName());
|
||||
if (iterator.hasNext()) {
|
||||
result.append(", ");
|
||||
}
|
||||
}
|
||||
result.append("!>");
|
||||
}
|
||||
|
||||
private static void closeDiagnosticString(StringBuffer result) {
|
||||
result.append("<!>");
|
||||
}
|
||||
|
||||
private static List<DiagnosticDescriptor> getSortedDiagnosticDescriptors(Collection<Diagnostic> diagnostics) {
|
||||
List<Diagnostic> list = Lists.newArrayList(diagnostics);
|
||||
Collections.sort(list, DIAGNOSTIC_COMPARATOR);
|
||||
|
||||
List<DiagnosticDescriptor> diagnosticDescriptors = Lists.newArrayList();
|
||||
DiagnosticDescriptor currentDiagnosticDescriptor = null;
|
||||
for (Iterator<Diagnostic> iterator = list.iterator(); iterator.hasNext(); ) {
|
||||
Diagnostic diagnostic = iterator.next();
|
||||
|
||||
TextRange textRange = getTextRange(diagnostic);
|
||||
if (currentDiagnosticDescriptor != null && currentDiagnosticDescriptor.equalRange(textRange)) {
|
||||
currentDiagnosticDescriptor.diagnostics.add(diagnostic);
|
||||
}
|
||||
else {
|
||||
currentDiagnosticDescriptor = new DiagnosticDescriptor(textRange.getStartOffset(), textRange.getEndOffset(), diagnostic);
|
||||
diagnosticDescriptors.add(currentDiagnosticDescriptor);
|
||||
}
|
||||
}
|
||||
return diagnosticDescriptors;
|
||||
}
|
||||
|
||||
private static TextRange getTextRange(Diagnostic currentDiagnostic) {
|
||||
return currentDiagnostic.getFactory().getTextRange(currentDiagnostic);
|
||||
}
|
||||
|
||||
private static class DiagnosticDescriptor {
|
||||
private final int start;
|
||||
private final int end;
|
||||
private final List<Diagnostic> diagnostics = Lists.newArrayList();
|
||||
|
||||
DiagnosticDescriptor(int start, int end, Diagnostic diagnostic) {
|
||||
this.start = start;
|
||||
this.end = end;
|
||||
this.diagnostics.add(diagnostic);
|
||||
}
|
||||
|
||||
public boolean equalRange(TextRange textRange) {
|
||||
return start == textRange.getStartOffset() && end == textRange.getEndOffset();
|
||||
}
|
||||
|
||||
public Multiset<String> getDiagnosticTypeStrings() {
|
||||
Multiset<String> actualDiagnosticTypes = HashMultiset.create();
|
||||
for (Diagnostic diagnostic : diagnostics) {
|
||||
actualDiagnosticTypes.add(diagnostic.getFactory().getName());
|
||||
}
|
||||
return actualDiagnosticTypes;
|
||||
}
|
||||
|
||||
public int getStart() {
|
||||
return start;
|
||||
}
|
||||
|
||||
public int getEnd() {
|
||||
return end;
|
||||
}
|
||||
|
||||
public List<Diagnostic> getDiagnostics() {
|
||||
return diagnostics;
|
||||
}
|
||||
}
|
||||
|
||||
public static class DiagnosedRange {
|
||||
private final int start;
|
||||
private int end;
|
||||
private final Multiset<String> diagnostics = HashMultiset.create();
|
||||
|
||||
private DiagnosedRange(int start) {
|
||||
this.start = start;
|
||||
}
|
||||
|
||||
public int getStart() {
|
||||
return start;
|
||||
}
|
||||
|
||||
public int getEnd() {
|
||||
return end;
|
||||
}
|
||||
|
||||
public Multiset<String> getDiagnostics() {
|
||||
return diagnostics;
|
||||
}
|
||||
|
||||
public void setEnd(int end) {
|
||||
this.end = end;
|
||||
}
|
||||
|
||||
public void addDiagnostic(String diagnostic) {
|
||||
diagnostics.add(diagnostic);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -97,6 +97,24 @@ public class JetHighlighter extends SyntaxHighlighterBase {
|
||||
JET_AUTO_CAST_EXPRESSION = TextAttributesKey.createTextAttributesKey("JET.AUTO.CAST.EXPRESSION", clone);
|
||||
}
|
||||
|
||||
public static final TextAttributesKey JET_AUTOCREATED_IT;
|
||||
|
||||
static {
|
||||
TextAttributes attributes = new TextAttributes();
|
||||
attributes.setFontType(Font.BOLD);
|
||||
// TODO: proper attributes
|
||||
JET_AUTOCREATED_IT = TextAttributesKey.createTextAttributesKey("JET.AUTO.CREATED.IT", attributes);
|
||||
}
|
||||
|
||||
public static final TextAttributesKey JET_FUNCTION_LITERAL_DELIMITER;
|
||||
|
||||
static {
|
||||
TextAttributes attributes = new TextAttributes();
|
||||
attributes.setFontType(Font.BOLD);
|
||||
// TODO: proper attributes
|
||||
JET_FUNCTION_LITERAL_DELIMITER = TextAttributesKey.createTextAttributesKey("JET.AUTO.CREATED.IT", attributes);
|
||||
}
|
||||
|
||||
public static final TextAttributesKey JET_DEBUG_INFO;
|
||||
|
||||
static {
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package org.jetbrains.jet.plugin.actions;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.LangDataKeys;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.jet.checkers.CheckerTestUtil;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.plugin.AnalyzerFacade;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.datatransfer.Clipboard;
|
||||
import java.awt.datatransfer.ClipboardOwner;
|
||||
import java.awt.datatransfer.StringSelection;
|
||||
import java.awt.datatransfer.Transferable;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
*/
|
||||
public class CopyAsDiagnosticTestAction extends AnAction {
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
Editor editor = e.getData(PlatformDataKeys.EDITOR);
|
||||
PsiFile psiFile = e.getData(LangDataKeys.PSI_FILE);
|
||||
assert editor != null && psiFile != null;
|
||||
|
||||
BindingContext bindingContext = AnalyzerFacade.analyzeFileWithCache((JetFile) psiFile);
|
||||
|
||||
String result = CheckerTestUtil.addDiagnosticMarkersToText(psiFile, bindingContext).toString();
|
||||
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
clipboard.setContents(new StringSelection(result), new ClipboardOwner() {
|
||||
@Override
|
||||
public void lostOwnership(Clipboard clipboard, Transferable contents) {}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
Editor editor = e.getData(PlatformDataKeys.EDITOR);
|
||||
PsiFile psiFile = e.getData(LangDataKeys.PSI_FILE);
|
||||
e.getPresentation().setEnabled(editor != null && psiFile instanceof JetFile && ApplicationManager.getApplication().isInternal());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import com.intellij.psi.PsiReference;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.PropertyDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.VariableDescriptor;
|
||||
import org.jetbrains.jet.lang.diagnostics.*;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
@@ -28,6 +29,10 @@ import org.jetbrains.jet.plugin.quickfix.QuickFixes;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContext.AUTOCAST;
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContext.AUTO_CREATED_IT;
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContext.REFERENCE_TARGET;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
*/
|
||||
@@ -52,7 +57,7 @@ public class JetPsiChecker implements Annotator {
|
||||
|
||||
if (errorReportingEnabled) {
|
||||
Collection<Diagnostic> diagnostics = bindingContext.getDiagnostics();
|
||||
Set<DeclarationDescriptor> redeclarations = Sets.newHashSet();
|
||||
Set<PsiElement> redeclarations = Sets.newHashSet();
|
||||
for (Diagnostic diagnostic : diagnostics) {
|
||||
Annotation annotation = null;
|
||||
if (diagnostic.getSeverity() == Severity.ERROR) {
|
||||
@@ -72,8 +77,7 @@ public class JetPsiChecker implements Annotator {
|
||||
}
|
||||
else if (diagnostic instanceof RedeclarationDiagnostic) {
|
||||
RedeclarationDiagnostic redeclarationDiagnostic = (RedeclarationDiagnostic) diagnostic;
|
||||
markRedeclaration(redeclarations, redeclarationDiagnostic.getA(), bindingContext, holder);
|
||||
markRedeclaration(redeclarations, redeclarationDiagnostic.getB(), bindingContext, holder);
|
||||
annotation = markRedeclaration(redeclarations, redeclarationDiagnostic, holder);
|
||||
}
|
||||
else {
|
||||
annotation = holder.createErrorAnnotation(diagnostic.getFactory().getTextRange(diagnostic), getMessage(diagnostic));
|
||||
@@ -82,7 +86,7 @@ public class JetPsiChecker implements Annotator {
|
||||
else if (diagnostic.getSeverity() == Severity.WARNING) {
|
||||
annotation = holder.createWarningAnnotation(diagnostic.getFactory().getTextRange(diagnostic), getMessage(diagnostic));
|
||||
}
|
||||
if (annotation != null && diagnostic instanceof DiagnosticWithPsiElement) {
|
||||
if (annotation != null && diagnostic instanceof DiagnosticWithPsiElementImpl) {
|
||||
DiagnosticWithPsiElement diagnosticWithPsiElement = (DiagnosticWithPsiElement) diagnostic;
|
||||
if (diagnostic.getFactory() instanceof PsiElementOnlyDiagnosticFactory) {
|
||||
PsiElementOnlyDiagnosticFactory factory = (PsiElementOnlyDiagnosticFactory) diagnostic.getFactory();
|
||||
@@ -102,9 +106,21 @@ public class JetPsiChecker implements Annotator {
|
||||
highlightBackingFields(holder, file, bindingContext);
|
||||
|
||||
file.acceptChildren(new JetVisitorVoid() {
|
||||
@Override
|
||||
public void visitSimpleNameExpression(JetSimpleNameExpression expression) {
|
||||
DeclarationDescriptor target = bindingContext.get(REFERENCE_TARGET, expression);
|
||||
if (target instanceof ValueParameterDescriptor) {
|
||||
ValueParameterDescriptor parameterDescriptor = (ValueParameterDescriptor) target;
|
||||
if (bindingContext.get(AUTO_CREATED_IT, parameterDescriptor)) {
|
||||
holder.createInfoAnnotation(expression, "Automatically declared based on the expected type").setTextAttributes(JetHighlighter.JET_AUTOCREATED_IT);
|
||||
}
|
||||
}
|
||||
super.visitSimpleNameExpression(expression);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitExpression(JetExpression expression) {
|
||||
JetType autoCast = bindingContext.get(BindingContext.AUTOCAST, expression);
|
||||
JetType autoCast = bindingContext.get(AUTOCAST, expression);
|
||||
if (autoCast != null) {
|
||||
holder.createInfoAnnotation(expression, "Automatically cast to " + autoCast).setTextAttributes(JetHighlighter.JET_AUTO_CAST_EXPRESSION);
|
||||
}
|
||||
@@ -135,19 +151,10 @@ public class JetPsiChecker implements Annotator {
|
||||
return diagnostic.getMessage();
|
||||
}
|
||||
|
||||
private void markRedeclaration(Set<DeclarationDescriptor> redeclarations, DeclarationDescriptor redeclaration, BindingContext bindingContext, AnnotationHolder holder) {
|
||||
if (!redeclarations.add(redeclaration)) return;
|
||||
PsiElement declarationPsiElement = bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, redeclaration);
|
||||
if (declarationPsiElement instanceof JetNamedDeclaration) {
|
||||
PsiElement nameIdentifier = ((JetNamedDeclaration) declarationPsiElement).getNameIdentifier();
|
||||
if (nameIdentifier != null) {
|
||||
holder.createErrorAnnotation(nameIdentifier, "Redeclaration");
|
||||
}
|
||||
}
|
||||
else if (declarationPsiElement != null) {
|
||||
holder.createErrorAnnotation(declarationPsiElement, "Redeclaration");
|
||||
}
|
||||
}
|
||||
private Annotation markRedeclaration(Set<PsiElement> redeclarations, RedeclarationDiagnostic diagnostic, AnnotationHolder holder) {
|
||||
if (!redeclarations.add(diagnostic.getPsiElement())) return null;
|
||||
return holder.createErrorAnnotation(diagnostic.getFactory().getTextRange(diagnostic), getMessage(diagnostic));
|
||||
}
|
||||
|
||||
|
||||
private void highlightBackingFields(final AnnotationHolder holder, JetFile file, final BindingContext bindingContext) {
|
||||
|
||||
@@ -3,8 +3,10 @@
|
||||
*/
|
||||
package org.jetbrains.jet.plugin.annotations;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.lang.annotation.AnnotationHolder;
|
||||
import com.intellij.lang.annotation.Annotator;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.impl.source.tree.LeafPsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -13,20 +15,41 @@ import org.jetbrains.jet.plugin.JetHighlighter;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
|
||||
public class SoftKeywordsAnnotator implements Annotator {
|
||||
public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder holder) {
|
||||
if (element instanceof LeafPsiElement) {
|
||||
if (JetTokens.SOFT_KEYWORDS.contains(((LeafPsiElement) element).getElementType())) {
|
||||
holder.createInfoAnnotation(element, null).setTextAttributes(JetHighlighter.JET_SOFT_KEYWORD);
|
||||
public void annotate(@NotNull PsiElement element, @NotNull final AnnotationHolder holder) {
|
||||
element.accept(new JetVisitorVoid() {
|
||||
@Override
|
||||
public void visitElement(PsiElement element) {
|
||||
if (element instanceof LeafPsiElement) {
|
||||
if (JetTokens.SOFT_KEYWORDS.contains(((LeafPsiElement) element).getElementType())) {
|
||||
holder.createInfoAnnotation(element, null).setTextAttributes(JetHighlighter.JET_SOFT_KEYWORD);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (element instanceof JetAnnotationEntry) {
|
||||
JetAnnotationEntry entry = (JetAnnotationEntry) element;
|
||||
JetTypeReference typeReference = entry.getTypeReference();
|
||||
if (typeReference != null) {
|
||||
JetTypeElement typeElement = typeReference.getTypeElement();
|
||||
markAnnotationIdentifiers(typeElement, holder);
|
||||
|
||||
@Override
|
||||
public void visitAnnotationEntry(JetAnnotationEntry annotationEntry) {
|
||||
JetTypeReference typeReference = annotationEntry.getTypeReference();
|
||||
if (typeReference != null) {
|
||||
JetTypeElement typeElement = typeReference.getTypeElement();
|
||||
markAnnotationIdentifiers(typeElement, holder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitFunctionLiteralExpression(JetFunctionLiteralExpression expression) {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) return;
|
||||
JetFunctionLiteral functionLiteral = expression.getFunctionLiteral();
|
||||
holder.createInfoAnnotation(functionLiteral.getOpenBraceNode(), null).setTextAttributes(JetHighlighter.JET_FUNCTION_LITERAL_DELIMITER);
|
||||
ASTNode closingBraceNode = functionLiteral.getClosingBraceNode();
|
||||
if (closingBraceNode != null) {
|
||||
holder.createInfoAnnotation(closingBraceNode, null).setTextAttributes(JetHighlighter.JET_FUNCTION_LITERAL_DELIMITER);
|
||||
}
|
||||
ASTNode arrowNode = functionLiteral.getArrowNode();
|
||||
if (arrowNode != null) {
|
||||
holder.createInfoAnnotation(arrowNode, null).setTextAttributes(JetHighlighter.JET_FUNCTION_LITERAL_DELIMITER);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void markAnnotationIdentifiers(JetTypeElement typeElement, @NotNull AnnotationHolder holder) {
|
||||
|
||||
@@ -89,7 +89,7 @@ public abstract class JetPsiReference implements PsiPolyVariantReference {
|
||||
JetFile file = (JetFile) getElement().getContainingFile();
|
||||
BindingContext bindingContext = AnalyzerFacade.analyzeFileWithCache(file);
|
||||
Collection<? extends DeclarationDescriptor> declarationDescriptors = bindingContext.get(AMBIGUOUS_REFERENCE_TARGET, myExpression);
|
||||
assert declarationDescriptors != null;
|
||||
if (declarationDescriptors != null) return ResolveResult.EMPTY_ARRAY;
|
||||
ResolveResult[] results = new ResolveResult[declarationDescriptors.size()];
|
||||
int i = 0;
|
||||
for (DeclarationDescriptor descriptor : declarationDescriptors) {
|
||||
|
||||
@@ -13,7 +13,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.plugin.AnalyzerFacade;
|
||||
import org.jetbrains.jet.resolve.DescriptorRenderer;
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
fun foo(u : Unit) : Int = 1
|
||||
|
||||
fun test() : Int {
|
||||
foo(1)
|
||||
val a : fun() : Unit = {
|
||||
foo(1)
|
||||
}
|
||||
return 1 - "1"
|
||||
}
|
||||
|
||||
class A() {
|
||||
val x : Int = foo1(xx)
|
||||
}
|
||||
|
||||
fun foo1() {}
|
||||
@@ -0,0 +1,241 @@
|
||||
namespace abstract
|
||||
|
||||
class MyClass() {
|
||||
//properties
|
||||
val <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>a<!>: Int
|
||||
val a1: Int = 1
|
||||
<!ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS!>abstract<!> val a2: Int
|
||||
<!ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS!>abstract<!> val a3: Int = 1
|
||||
|
||||
var <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>b<!>: Int private set
|
||||
var b1: Int = 0; private set
|
||||
<!ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS!>abstract<!> var b2: Int private set
|
||||
<!ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS!>abstract<!> var b3: Int = 0; private set
|
||||
|
||||
var <!MUST_BE_INITIALIZED!>c<!>: Int set(v: Int) { $c = v }
|
||||
var c1: Int = 0; set(v: Int) { $c1 = v }
|
||||
<!ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS!>abstract<!> var c2: Int set(v: Int) { $c2 = v }
|
||||
<!ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS!>abstract<!> var c3: Int = 0; set(v: Int) { $c3 = v }
|
||||
|
||||
val e: Int get() = a
|
||||
val e1: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>0<!>; get() = a
|
||||
<!ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS!>abstract<!> val e2: Int get() = a
|
||||
<!ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS!>abstract<!> val e3: Int = 0; get() = a
|
||||
|
||||
//methods
|
||||
fun <!NON_ABSTRACT_FUNCTION_WITH_NO_BODY!>f<!>()
|
||||
fun g() {}
|
||||
<!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS!>abstract<!> fun h()
|
||||
<!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS, ABSTRACT_FUNCTION_WITH_BODY!>abstract<!> fun j() {}
|
||||
|
||||
//property accessors
|
||||
var i: Int <!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS!>abstract<!> get <!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS!>abstract<!> set
|
||||
var i1: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>0<!>; <!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS!>abstract<!> get <!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS!>abstract<!> set
|
||||
|
||||
var j: Int get() = i; <!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS!>abstract<!> set
|
||||
var j1: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>0<!>; get() = i; <!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS!>abstract<!> set
|
||||
|
||||
var <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>k<!>: Int <!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS!>abstract<!> set
|
||||
var k1: Int = 0; <!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS!>abstract<!> set
|
||||
|
||||
var l: Int <!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS!>abstract<!> get <!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS!>abstract<!> set
|
||||
var l1: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>0<!>; <!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS!>abstract<!> get <!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS!>abstract<!> set
|
||||
|
||||
var n: Int <!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS!>abstract<!> get <!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS, ABSTRACT_FUNCTION_WITH_BODY!>abstract<!> set(v: Int) {}
|
||||
}
|
||||
|
||||
abstract class MyAbstractClass() {
|
||||
//properties
|
||||
val <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>a<!>: Int
|
||||
val a1: Int = 1
|
||||
abstract val a2: Int
|
||||
abstract val a3: Int = <!ABSTRACT_PROPERTY_WITH_INITIALIZER!>1<!>
|
||||
|
||||
var <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>b<!>: Int private set
|
||||
var b1: Int = 0; private set
|
||||
abstract var b2: Int private set
|
||||
abstract var b3: Int = <!ABSTRACT_PROPERTY_WITH_INITIALIZER!>0<!>; private set
|
||||
|
||||
var <!MUST_BE_INITIALIZED!>c<!>: Int set(v: Int) { $c = v }
|
||||
var c1: Int = 0; set(v: Int) { $c1 = v }
|
||||
abstract var c2: Int <!ABSTRACT_PROPERTY_WITH_SETTER!>set(v: Int) { $c2 = v }<!>
|
||||
abstract var c3: Int = <!ABSTRACT_PROPERTY_WITH_INITIALIZER!>0<!>; <!ABSTRACT_PROPERTY_WITH_SETTER!>set(v: Int) { $c3 = v }<!>
|
||||
|
||||
val e: Int get() = a
|
||||
val e1: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>0<!>; get() = a
|
||||
abstract val e2: Int <!ABSTRACT_PROPERTY_WITH_GETTER!>get() = a<!>
|
||||
abstract val e3: Int = <!ABSTRACT_PROPERTY_WITH_INITIALIZER!>0<!>; <!ABSTRACT_PROPERTY_WITH_GETTER!>get() = a<!>
|
||||
|
||||
//methods
|
||||
fun <!NON_ABSTRACT_FUNCTION_WITH_NO_BODY!>f<!>()
|
||||
fun g() {}
|
||||
abstract fun h()
|
||||
<!ABSTRACT_FUNCTION_WITH_BODY!>abstract<!> fun j() {}
|
||||
|
||||
//property accessors
|
||||
var i: Int abstract get abstract set
|
||||
var i1: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>0<!>; abstract get abstract set
|
||||
|
||||
var j: Int get() = i; abstract set
|
||||
var j1: Int get() = i; abstract set
|
||||
|
||||
var <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>k<!>: Int abstract set
|
||||
var k1: Int = 0; abstract set
|
||||
|
||||
var l: Int abstract get abstract set
|
||||
var l1: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>0<!>; abstract get abstract set
|
||||
|
||||
var n: Int abstract get <!ABSTRACT_FUNCTION_WITH_BODY!>abstract<!> set(v: Int) {}
|
||||
}
|
||||
|
||||
trait MyTrait {
|
||||
//properties
|
||||
val a: Int
|
||||
val a1: Int = <!PROPERTY_INITIALIZER_IN_TRAIT!>1<!>
|
||||
<!REDUNDANT_ABSTRACT!>abstract<!> val a2: Int
|
||||
<!REDUNDANT_ABSTRACT!>abstract<!> val a3: Int = <!ABSTRACT_PROPERTY_WITH_INITIALIZER!>1<!>
|
||||
|
||||
var b: Int private set
|
||||
var b1: Int = <!PROPERTY_INITIALIZER_IN_TRAIT!>0<!>; private set
|
||||
<!REDUNDANT_ABSTRACT!>abstract<!> var b2: Int private set
|
||||
<!REDUNDANT_ABSTRACT!>abstract<!> var b3: Int = <!ABSTRACT_PROPERTY_WITH_INITIALIZER!>0<!>; private set
|
||||
|
||||
var <!BACKING_FIELD_IN_TRAIT!>c<!>: Int set(v: Int) { $c = v }
|
||||
var <!BACKING_FIELD_IN_TRAIT!>c1<!>: Int = <!PROPERTY_INITIALIZER_IN_TRAIT!>0<!>; set(v: Int) { $c1 = v }
|
||||
<!REDUNDANT_ABSTRACT!>abstract<!> var c2: Int <!ABSTRACT_PROPERTY_WITH_SETTER!>set(v: Int) { $c2 = v }<!>
|
||||
<!REDUNDANT_ABSTRACT!>abstract<!> var c3: Int = <!ABSTRACT_PROPERTY_WITH_INITIALIZER!>0<!>; <!ABSTRACT_PROPERTY_WITH_SETTER!>set(v: Int) { $c3 = v }<!>
|
||||
|
||||
val e: Int get() = a
|
||||
val e1: Int = <!PROPERTY_INITIALIZER_IN_TRAIT!>0<!>; get() = a
|
||||
<!REDUNDANT_ABSTRACT!>abstract<!> val e2: Int <!ABSTRACT_PROPERTY_WITH_GETTER!>get() = a<!>
|
||||
<!REDUNDANT_ABSTRACT!>abstract<!> val e3: Int = <!ABSTRACT_PROPERTY_WITH_INITIALIZER!>0<!>; <!ABSTRACT_PROPERTY_WITH_GETTER!>get() = a<!>
|
||||
|
||||
//methods
|
||||
fun f()
|
||||
fun g() {}
|
||||
<!REDUNDANT_ABSTRACT!>abstract<!> fun h()
|
||||
<!REDUNDANT_ABSTRACT, ABSTRACT_FUNCTION_WITH_BODY!>abstract<!> fun j() {}
|
||||
|
||||
//property accessors
|
||||
var i: Int abstract get abstract set
|
||||
var i1: Int = <!PROPERTY_INITIALIZER_IN_TRAIT!>0<!>; abstract get abstract set
|
||||
|
||||
var j: Int get() = i; abstract set
|
||||
var j1: Int = <!PROPERTY_INITIALIZER_IN_TRAIT!>0<!>; get() = i; abstract set
|
||||
|
||||
var k: Int abstract set
|
||||
var k1: Int = <!PROPERTY_INITIALIZER_IN_TRAIT!>0<!>; abstract set
|
||||
|
||||
var l: Int abstract get abstract set
|
||||
var l1: Int = <!PROPERTY_INITIALIZER_IN_TRAIT!>0<!>; abstract get abstract set
|
||||
|
||||
var n: Int abstract get <!ABSTRACT_FUNCTION_WITH_BODY!>abstract<!> set(v: Int) {}
|
||||
}
|
||||
|
||||
enum class MyEnum() {
|
||||
//properties
|
||||
val <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>a<!>: Int
|
||||
val a1: Int = 1
|
||||
abstract val a2: Int
|
||||
abstract val a3: Int = <!ABSTRACT_PROPERTY_WITH_INITIALIZER!>1<!>
|
||||
|
||||
var <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>b<!>: Int private set
|
||||
var b1: Int = 0; private set
|
||||
abstract var b2: Int private set
|
||||
abstract var b3: Int = <!ABSTRACT_PROPERTY_WITH_INITIALIZER!>0<!>; private set
|
||||
|
||||
var <!MUST_BE_INITIALIZED!>c<!>: Int set(v: Int) { $c = v }
|
||||
var c1: Int = 0; set(v: Int) { $c1 = v }
|
||||
abstract var c2: Int <!ABSTRACT_PROPERTY_WITH_SETTER!>set(v: Int) { $c2 = v }<!>
|
||||
abstract var c3: Int = <!ABSTRACT_PROPERTY_WITH_INITIALIZER!>0<!>; <!ABSTRACT_PROPERTY_WITH_SETTER!>set(v: Int) { $c3 = v }<!>
|
||||
|
||||
val e: Int get() = a
|
||||
val e1: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>0<!>; get() = a
|
||||
abstract val e2: Int <!ABSTRACT_PROPERTY_WITH_GETTER!>get() = a<!>
|
||||
abstract val e3: Int = <!ABSTRACT_PROPERTY_WITH_INITIALIZER!>0<!>; <!ABSTRACT_PROPERTY_WITH_GETTER!>get() = a<!>
|
||||
|
||||
//methods
|
||||
fun <!NON_ABSTRACT_FUNCTION_WITH_NO_BODY!>f<!>()
|
||||
fun g() {}
|
||||
abstract fun h()
|
||||
<!ABSTRACT_FUNCTION_WITH_BODY!>abstract<!> fun j() {}
|
||||
|
||||
//property accessors
|
||||
var i: Int abstract get abstract set
|
||||
var i1: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>0<!>; abstract get abstract set
|
||||
|
||||
var j: Int get() = i; abstract set
|
||||
var j1: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>0<!>; get() = i; abstract set
|
||||
|
||||
var <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>k<!>: Int abstract set
|
||||
var k1: Int = 0; abstract set
|
||||
|
||||
var l: Int abstract get abstract set
|
||||
var l1: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>0<!>; abstract get abstract set
|
||||
|
||||
var n: Int abstract get <!ABSTRACT_FUNCTION_WITH_BODY!>abstract<!> set(v: Int) {}
|
||||
}
|
||||
|
||||
abstract enum class MyAbstractEnum() {}
|
||||
|
||||
namespace MyNamespace {
|
||||
//properties
|
||||
val <!MUST_BE_INITIALIZED!>a<!>: Int
|
||||
val a1: Int = 1
|
||||
<!ABSTRACT_PROPERTY_NOT_IN_CLASS!>abstract<!> val a2: Int
|
||||
<!ABSTRACT_PROPERTY_NOT_IN_CLASS!>abstract<!> val a3: Int = 1
|
||||
|
||||
var <!MUST_BE_INITIALIZED!>b<!>: Int private set
|
||||
var b1: Int = 0; private set
|
||||
<!ABSTRACT_PROPERTY_NOT_IN_CLASS!>abstract<!> var b2: Int private set
|
||||
<!ABSTRACT_PROPERTY_NOT_IN_CLASS!>abstract<!> var b3: Int = 0; private set
|
||||
|
||||
var <!MUST_BE_INITIALIZED!>c<!>: Int set(v: Int) { $c = v }
|
||||
var c1: Int = 0; set(v: Int) { $c1 = v }
|
||||
<!ABSTRACT_PROPERTY_NOT_IN_CLASS!>abstract<!> var c2: Int set(v: Int) { $c2 = v }
|
||||
<!ABSTRACT_PROPERTY_NOT_IN_CLASS!>abstract<!> var c3: Int = 0; set(v: Int) { $c3 = v }
|
||||
|
||||
val e: Int get() = a
|
||||
val e1: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>0<!>; get() = a
|
||||
<!ABSTRACT_PROPERTY_NOT_IN_CLASS!>abstract<!> val e2: Int get() = a
|
||||
<!ABSTRACT_PROPERTY_NOT_IN_CLASS!>abstract<!> val e3: Int = 0; get() = a
|
||||
|
||||
//methods
|
||||
fun <!NON_MEMBER_FUNCTION_NO_BODY!>f<!>()
|
||||
fun g() {}
|
||||
<!NON_MEMBER_ABSTRACT_FUNCTION!>abstract<!> fun h()
|
||||
<!NON_MEMBER_ABSTRACT_FUNCTION!>abstract<!> fun j() {}
|
||||
|
||||
//property accessors
|
||||
var i: Int <!NON_MEMBER_ABSTRACT_ACCESSOR!>abstract<!> get <!NON_MEMBER_ABSTRACT_ACCESSOR!>abstract<!> set
|
||||
var i1: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>0<!>; <!NON_MEMBER_ABSTRACT_ACCESSOR!>abstract<!> get <!NON_MEMBER_ABSTRACT_ACCESSOR!>abstract<!> set
|
||||
|
||||
var j: Int get() = i; <!NON_MEMBER_ABSTRACT_ACCESSOR!>abstract<!> set
|
||||
var j1: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>0<!>; get() = i; <!NON_MEMBER_ABSTRACT_ACCESSOR!>abstract<!> set
|
||||
|
||||
var <!MUST_BE_INITIALIZED!>k<!>: Int <!NON_MEMBER_ABSTRACT_ACCESSOR!>abstract<!> set
|
||||
var k1: Int = 0; <!NON_MEMBER_ABSTRACT_ACCESSOR!>abstract<!> set
|
||||
|
||||
var l: Int <!NON_MEMBER_ABSTRACT_ACCESSOR!>abstract<!> get <!NON_MEMBER_ABSTRACT_ACCESSOR!>abstract<!> set
|
||||
var l1: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>0<!>; <!NON_MEMBER_ABSTRACT_ACCESSOR!>abstract<!> get <!NON_MEMBER_ABSTRACT_ACCESSOR!>abstract<!> set
|
||||
|
||||
var n: Int <!NON_MEMBER_ABSTRACT_ACCESSOR!>abstract<!> get <!NON_MEMBER_ABSTRACT_ACCESSOR!>abstract<!> set(v: Int) {}
|
||||
}
|
||||
|
||||
//creating an instance
|
||||
abstract class B1(
|
||||
val i: Int,
|
||||
val s: String
|
||||
) {
|
||||
}
|
||||
|
||||
class B2() : B1(1, "r") {}
|
||||
|
||||
abstract class B3(i: Int) {
|
||||
this(): this(1)
|
||||
}
|
||||
|
||||
fun foo(a: B3) {
|
||||
val a = <!CREATING_AN_INSTANCE_OF_ABSTRACT_CLASS!>B3()<!>
|
||||
val b = <!CREATING_AN_INSTANCE_OF_ABSTRACT_CLASS!>B1(2, "s")<!>
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
class NoC {
|
||||
<!ANONYMOUS_INITIALIZER_WITHOUT_CONSTRUCTOR!>{
|
||||
|
||||
}<!>
|
||||
|
||||
val a : Int get() = 1
|
||||
|
||||
<!ANONYMOUS_INITIALIZER_WITHOUT_CONSTRUCTOR!>{
|
||||
|
||||
}<!>
|
||||
}
|
||||
|
||||
class WithC() {
|
||||
val x : Int
|
||||
{
|
||||
$x = 1
|
||||
<!UNRESOLVED_REFERENCE!>$y<!> = 2
|
||||
val b = x
|
||||
|
||||
}
|
||||
|
||||
val a : Int get() = 1
|
||||
|
||||
{
|
||||
val z = <!UNRESOLVED_REFERENCE!>b<!>
|
||||
val zz = x
|
||||
val zzz = <!NO_BACKING_FIELD!>$a<!>
|
||||
}
|
||||
|
||||
this(a : Int) : this() {
|
||||
val b = x
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
class A() {
|
||||
fun equals(a : Any?) : Boolean = false
|
||||
}
|
||||
|
||||
class B() {
|
||||
fun equals(a : Any?) : Boolean? = false
|
||||
}
|
||||
|
||||
class C() {
|
||||
fun equals(a : Any?) : Int = 0
|
||||
}
|
||||
|
||||
fun f(): Unit {
|
||||
var x: Int? = 1
|
||||
x = 1
|
||||
x <!UNSAFE_INFIX_CALL!>+<!> 1
|
||||
x <!UNSAFE_INFIX_CALL!>plus<!> 1
|
||||
x <!UNSAFE_INFIX_CALL!><<!> 1
|
||||
x <!UNSAFE_INFIX_CALL!>+=<!> 1
|
||||
|
||||
x == 1
|
||||
x != 1
|
||||
|
||||
<!EQUALITY_NOT_APPLICABLE!>A() == 1<!>
|
||||
B() <!RESULT_TYPE_MISMATCH!>==<!> 1
|
||||
C() <!RESULT_TYPE_MISMATCH!>==<!> 1
|
||||
|
||||
<!EQUALITY_NOT_APPLICABLE!>x === "1"<!>
|
||||
<!EQUALITY_NOT_APPLICABLE!>x !== "1"<!>
|
||||
|
||||
x === 1
|
||||
x !== 1
|
||||
|
||||
x<!UNSAFE_INFIX_CALL!>..<!>2
|
||||
<!TYPE_MISMATCH!>x<!> in 1..2
|
||||
|
||||
val y : Boolean? = true
|
||||
false || <!TYPE_MISMATCH!>y<!>
|
||||
<!TYPE_MISMATCH!>y<!> && true
|
||||
<!TYPE_MISMATCH!>y<!> && <!TYPE_MISMATCH!>1<!>
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
namespace boundsWithSubstitutors {
|
||||
open class A<T>
|
||||
class B<X : A<X>>()
|
||||
|
||||
class C : A<C>
|
||||
|
||||
val a = B<C>()
|
||||
val a1 = B<<!UPPER_BOUND_VIOLATED!>Int<!>>()
|
||||
|
||||
class X<A, B : A>()
|
||||
|
||||
val b = X<Any, X<A<C>, C>>
|
||||
val b0 = X<Any, <!UPPER_BOUND_VIOLATED!>Any?<!>>
|
||||
val b1 = X<Any, X<A<C>, <!UPPER_BOUND_VIOLATED!>String<!>>>
|
||||
|
||||
}
|
||||
|
||||
open class A {}
|
||||
open class B<T : A>()
|
||||
|
||||
abstract class C<T : B<<!UPPER_BOUND_VIOLATED!>Int<!>>, X : fun (B<<!UPPER_BOUND_VIOLATED!>Char<!>>) : (B<<!UPPER_BOUND_VIOLATED!>Any<!>>, B<A>)>() : B<<!UPPER_BOUND_VIOLATED, UPPER_BOUND_VIOLATED!>Any<!>>() { // 2 errors
|
||||
val a = B<<!UPPER_BOUND_VIOLATED!>Char<!>>() // error
|
||||
|
||||
abstract val x : fun (B<<!UPPER_BOUND_VIOLATED!>Char<!>>) : B<<!UPPER_BOUND_VIOLATED!>Any<!>>
|
||||
}
|
||||
|
||||
|
||||
fun test() {
|
||||
foo<<!UPPER_BOUND_VIOLATED!>Int?<!>>()
|
||||
foo<Int>()
|
||||
bar<Int?>()
|
||||
bar<Int>()
|
||||
bar<<!UPPER_BOUND_VIOLATED!>Double?<!>>()
|
||||
bar<<!UPPER_BOUND_VIOLATED!>Double<!>>()
|
||||
1.buzz<<!UPPER_BOUND_VIOLATED!>Double<!>>()
|
||||
}
|
||||
|
||||
fun foo<T : Any>() {}
|
||||
fun bar<T : Int?>() {}
|
||||
fun <T : <!FINAL_UPPER_BOUND!>Int<!>> Int.buzz() : Unit {}
|
||||
@@ -0,0 +1,28 @@
|
||||
class C {
|
||||
|
||||
fun f (a : Boolean, b : Boolean) {
|
||||
@b (while (true)
|
||||
@a {
|
||||
<!NOT_A_LOOP_LABEL!>break@f<!>
|
||||
break
|
||||
break@b
|
||||
<!NOT_A_LOOP_LABEL!>break@a<!>
|
||||
})
|
||||
|
||||
<!BREAK_OR_CONTINUE_OUTSIDE_A_LOOP!>continue<!>
|
||||
|
||||
@b (while (true)
|
||||
@a {
|
||||
<!NOT_A_LOOP_LABEL!>continue@f<!>
|
||||
continue
|
||||
continue@b
|
||||
<!NOT_A_LOOP_LABEL!>continue@a<!>
|
||||
})
|
||||
|
||||
<!BREAK_OR_CONTINUE_OUTSIDE_A_LOOP!>break<!>
|
||||
|
||||
<!NOT_A_LOOP_LABEL!>continue@f<!>
|
||||
<!NOT_A_LOOP_LABEL!>break@f<!>
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
import java.util.*
|
||||
|
||||
namespace html {
|
||||
|
||||
abstract class Factory<T> {
|
||||
abstract fun create() : T
|
||||
}
|
||||
|
||||
abstract class Element
|
||||
|
||||
class TextElement(val text : String) : Element
|
||||
|
||||
abstract class Tag(val name : String) : Element {
|
||||
val children = ArrayList<Element>()
|
||||
val attributes = HashMap<String, String>()
|
||||
|
||||
protected fun initTag<T : Element>(init : fun T.() : Unit) : T
|
||||
where class object T : Factory<T>{
|
||||
val tag = T.create()
|
||||
tag.init()
|
||||
children.add(tag)
|
||||
return tag
|
||||
}
|
||||
}
|
||||
|
||||
abstract class TagWithText(name : String) : Tag(name) {
|
||||
fun String.plus() {
|
||||
children.add(TextElement(this))
|
||||
}
|
||||
}
|
||||
|
||||
class HTML() : TagWithText("html") {
|
||||
class object : Factory<HTML> {
|
||||
override fun create() = HTML()
|
||||
}
|
||||
|
||||
fun head(init : fun Head.() : Unit) = initTag<Head>(init)
|
||||
|
||||
fun body(init : fun Body.() : Unit) = initTag<Body>(init)
|
||||
}
|
||||
|
||||
class Head() : TagWithText("head") {
|
||||
class object : Factory<Head> {
|
||||
override fun create() = Head()
|
||||
}
|
||||
|
||||
fun title(init : fun Title.() : Unit) = initTag<Title>(init)
|
||||
}
|
||||
|
||||
class Title() : TagWithText("title")
|
||||
|
||||
abstract class BodyTag(name : String) : TagWithText(name) {
|
||||
}
|
||||
|
||||
class Body() : BodyTag("body") {
|
||||
class object : Factory<Body> {
|
||||
override fun create() = Body()
|
||||
}
|
||||
|
||||
fun b(init : fun B.() : Unit) = initTag<B>(init)
|
||||
fun p(init : fun P.() : Unit) = initTag<P>(init)
|
||||
fun h1(init : fun H1.() : Unit) = initTag<H1>(init)
|
||||
fun a(href : String, init : fun A.() : Unit) {
|
||||
val a = initTag<A>(init)
|
||||
a.href = href
|
||||
}
|
||||
}
|
||||
|
||||
class B() : BodyTag("b")
|
||||
class P() : BodyTag("p")
|
||||
class H1() : BodyTag("h1")
|
||||
class A() : BodyTag("a") {
|
||||
var href : String
|
||||
get() = attributes["href"]
|
||||
set(value) { attributes["href"] = value }
|
||||
}
|
||||
|
||||
fun Map<String, String>.set(key : String, value : String) = this.put(key, value)
|
||||
|
||||
fun html(init : fun HTML.() : Unit) : HTML {
|
||||
val html = HTML()
|
||||
html.init()
|
||||
return html
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace foo {
|
||||
|
||||
import html.*
|
||||
|
||||
fun result(args : Array<String>) =
|
||||
html {
|
||||
head {
|
||||
title {+"XML encoding with Groovy"}
|
||||
}
|
||||
body {
|
||||
h1 {+"XML encoding with Groovy"}
|
||||
p {+"this format can be used as an alternative markup to XML"}
|
||||
|
||||
// an element with attributes and text content
|
||||
a(href = "http://groovy.codehaus.org") {+"Groovy"}
|
||||
|
||||
// mixed content
|
||||
p {
|
||||
+"This is some"
|
||||
b {+"mixed"}
|
||||
+"text. For more see the"
|
||||
a(href = "http://groovy.codehaus.org") {+"Groovy"}
|
||||
+"project"
|
||||
}
|
||||
p {+"some text"}
|
||||
|
||||
// content generated by
|
||||
p {
|
||||
for (arg in args)
|
||||
+arg
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
fun test() : Unit {
|
||||
var x : Int? = 0
|
||||
var y : Int = 0
|
||||
|
||||
x : Int?
|
||||
y : Int
|
||||
x as Int : Int
|
||||
y <!USELESS_CAST!>as<!> Int : Int
|
||||
x <!USELESS_CAST!>as<!> Int? : Int?
|
||||
y <!USELESS_CAST_STATIC_ASSERT_IS_FINE!>as<!> Int? : Int?
|
||||
x as? Int : Int?
|
||||
y <!USELESS_CAST!>as?<!> Int : Int?
|
||||
x <!USELESS_CAST!>as?<!> Int? : Int?
|
||||
y <!USELESS_CAST_STATIC_ASSERT_IS_FINE!>as?<!> Int? : Int?
|
||||
()
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
namespace Jet86
|
||||
|
||||
class A {
|
||||
class object {
|
||||
val x = 1
|
||||
}
|
||||
<!MANY_CLASS_OBJECTS!>class object { // error
|
||||
val x = 1
|
||||
}<!>
|
||||
}
|
||||
|
||||
class B() {
|
||||
val x = 12
|
||||
}
|
||||
|
||||
object b {
|
||||
<!CLASS_OBJECT_NOT_ALLOWED!>class object {
|
||||
val x = 1
|
||||
}<!> // error
|
||||
}
|
||||
|
||||
val a = A.x
|
||||
val c = <!NO_CLASS_OBJECT!>B<!>.x
|
||||
val d = b.<!UNRESOLVED_REFERENCE!>x<!>
|
||||
|
||||
val s = <!NO_CLASS_OBJECT!>System<!> // error
|
||||
fun test() {
|
||||
System.out?.println()
|
||||
java.lang.System.out?.println()
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fun test() {
|
||||
1 : Byte
|
||||
1 : Int
|
||||
<!TYPE_MISMATCH, TYPE_MISMATCH!>1<!> : Double
|
||||
1 <!USELESS_CAST!>as<!> Byte
|
||||
1 <!USELESS_CAST!>as<!> Int
|
||||
<!ERROR_COMPILE_TIME_VALUE!>1<!> <!CAST_NEVER_SUCCEEDS!>as<!> Double
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
|
||||
open class NoC
|
||||
class NoC1 : NoC
|
||||
|
||||
class WithC0() : NoC<!NO_CONSTRUCTOR!>()<!>
|
||||
open class WithC1() : NoC
|
||||
class NoC2 : <!SUPERTYPE_NOT_INITIALIZED!>WithC1<!>
|
||||
class NoC3 : WithC1<!PRIMARY_CONSTRUCTOR_MISSING_SUPER_CONSTRUCTOR_CALL!>()<!>
|
||||
class WithC2() : <!SUPERTYPE_NOT_INITIALIZED!>WithC1<!>
|
||||
|
||||
class NoPC {
|
||||
<!SECONDARY_CONSTRUCTOR_BUT_NO_PRIMARY!>this<!>() {}
|
||||
}
|
||||
|
||||
class WithPC0() {
|
||||
this(a : Int) : this() {}
|
||||
}
|
||||
|
||||
class WithPC1(a : Int) {
|
||||
<!SECONDARY_CONSTRUCTOR_NO_INITIALIZER_LIST!>this<!>() {}
|
||||
|
||||
this(b : Long) : this("") {}
|
||||
|
||||
this(s : String) : this(1) {}
|
||||
|
||||
this(b : Char) : <!NONE_APPLICABLE!>this("", 2)<!> {}
|
||||
|
||||
this(b : Byte) : this(""), <!MANY_CALLS_TO_THIS!>this(1)<!> {}
|
||||
}
|
||||
|
||||
|
||||
class Foo() : <!SUPERTYPE_NOT_INITIALIZED, FINAL_SUPERTYPE!>WithPC0<!>, <!MANY_CLASSES_IN_SUPERTYPE_LIST!>this<!>() {
|
||||
|
||||
}
|
||||
|
||||
class WithCPI_Dup(<!REDECLARATION, REDECLARATION!>x<!> : Int) {
|
||||
var <!REDECLARATION, REDECLARATION, MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>x<!> : Int
|
||||
}
|
||||
|
||||
class WithCPI(x : Int) {
|
||||
val a = 1
|
||||
val b : Int = $a
|
||||
val xy : Int = x
|
||||
}
|
||||
|
||||
class <!PRIMARY_CONSTRUCTOR_MISSING_STATEFUL_PROPERTY!>NoCPI<!> {
|
||||
val a = <!PROPERTY_INITIALIZER_NO_PRIMARY_CONSTRUCTOR!>1<!>
|
||||
var ab = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>1<!>
|
||||
get() = 1
|
||||
set(v) {}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
open trait A {
|
||||
fun foo() {}
|
||||
}
|
||||
open trait B : A, <!CYCLIC_INHERITANCE_HIERARCHY!>E<!> {}
|
||||
open trait C : B {}
|
||||
open trait D : <!CYCLIC_INHERITANCE_HIERARCHY!>B<!> {}
|
||||
open trait E : <!CYCLIC_INHERITANCE_HIERARCHY!>F<!> {}
|
||||
open trait F : <!CYCLIC_INHERITANCE_HIERARCHY!>D<!>, C {}
|
||||
open trait G : F {}
|
||||
open trait H : F {}
|
||||
|
||||
val a : A? = null
|
||||
val b : B? = null
|
||||
val c : C? = null
|
||||
val d : D? = null
|
||||
val e : E? = null
|
||||
val f : F? = null
|
||||
val g : G? = null
|
||||
val h : H? = null
|
||||
|
||||
fun test() {
|
||||
a?.foo()
|
||||
b?.foo()
|
||||
c?.foo()
|
||||
d?.foo()
|
||||
e?.<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
f?.foo()
|
||||
g?.foo()
|
||||
h?.foo()
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
enum class List<out T>(val size : Int) {
|
||||
Nil : List<Nothing>(0) {
|
||||
val a = 1
|
||||
}
|
||||
Cons<out T>(val head : T, val tail : List<T>) : List<T>(tail.size + 1)
|
||||
|
||||
}
|
||||
|
||||
val foo = List.Nil
|
||||
val foo1 = foo.a
|
||||
@@ -0,0 +1,71 @@
|
||||
fun Int?.optint() : Unit {}
|
||||
val Int?.optval : Unit = ()
|
||||
|
||||
fun <T, E> T.foo(x : E, y : A) : T {
|
||||
y.plus(1)
|
||||
y plus 1
|
||||
y + 1.0
|
||||
|
||||
this<!UNNECESSARY_SAFE_CALL!>?.<!>minus<T>(this)
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
class A
|
||||
|
||||
fun A.plus(a : Any) {
|
||||
|
||||
1.foo()
|
||||
true.<!NONE_APPLICABLE!>foo()<!>
|
||||
|
||||
1
|
||||
}
|
||||
|
||||
fun A.plus(a : Int) {
|
||||
1
|
||||
}
|
||||
|
||||
fun <T> T.minus(t : T) : Int = 1
|
||||
|
||||
fun test() {
|
||||
val y = 1.abs
|
||||
}
|
||||
val Int.abs : Int
|
||||
get() = if (this > 0) this else -this;
|
||||
|
||||
val <T> T.<!MUST_BE_INITIALIZED!>foo<!> : T
|
||||
|
||||
fun Int.foo() = this
|
||||
|
||||
namespace null_safety {
|
||||
|
||||
fun parse(cmd: String): Command? { return null }
|
||||
class Command() {
|
||||
// fun equals(other : Any?) : Boolean
|
||||
val foo : Int = 0
|
||||
}
|
||||
|
||||
fun Any.equals(other : Any?) : Boolean = true
|
||||
fun Any?.equals1(other : Any?) : Boolean = true
|
||||
fun Any.equals2(other : Any?) : Boolean = true
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
|
||||
System.out?.print(1)
|
||||
|
||||
val command = parse("")
|
||||
|
||||
command<!UNSAFE_CALL!>.<!>foo
|
||||
|
||||
command.equals(null)
|
||||
command<!UNNECESSARY_SAFE_CALL!>?.<!>equals(null)
|
||||
command.equals1(null)
|
||||
command<!UNNECESSARY_SAFE_CALL!>?.<!>equals1(null)
|
||||
|
||||
val c = Command()
|
||||
c<!UNNECESSARY_SAFE_CALL!>?.<!>equals2(null)
|
||||
|
||||
if (command == null) 1
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
import java.util.*;
|
||||
|
||||
class NotRange1() {
|
||||
|
||||
}
|
||||
|
||||
abstract class NotRange2() {
|
||||
abstract fun iterator() : Unit
|
||||
}
|
||||
|
||||
abstract class ImproperIterator1 {
|
||||
abstract fun hasNext() : Boolean
|
||||
}
|
||||
|
||||
abstract class NotRange3() {
|
||||
abstract fun iterator() : ImproperIterator1
|
||||
}
|
||||
|
||||
abstract class ImproperIterator2 {
|
||||
abstract fun next() : Boolean
|
||||
}
|
||||
|
||||
abstract class NotRange4() {
|
||||
abstract fun iterator() : ImproperIterator2
|
||||
}
|
||||
|
||||
abstract class ImproperIterator3 {
|
||||
abstract fun hasNext() : Int
|
||||
abstract fun next() : Int
|
||||
}
|
||||
|
||||
abstract class NotRange5() {
|
||||
abstract fun iterator() : ImproperIterator3
|
||||
}
|
||||
|
||||
abstract class AmbiguousHasNextIterator {
|
||||
abstract fun hasNext() : Boolean
|
||||
val hasNext : Boolean get() = false
|
||||
abstract fun next() : Int
|
||||
}
|
||||
|
||||
abstract class NotRange6() {
|
||||
abstract fun iterator() : AmbiguousHasNextIterator
|
||||
}
|
||||
|
||||
abstract class ImproperIterator4 {
|
||||
val hasNext : Int get() = 1
|
||||
abstract fun next() : Int
|
||||
}
|
||||
|
||||
abstract class NotRange7() {
|
||||
abstract fun iterator() : ImproperIterator3
|
||||
}
|
||||
|
||||
abstract class GoodIterator {
|
||||
abstract fun hasNext() : Boolean
|
||||
abstract fun next() : Int
|
||||
}
|
||||
|
||||
abstract class Range0() {
|
||||
abstract fun iterator() : GoodIterator
|
||||
}
|
||||
|
||||
abstract class Range1() {
|
||||
abstract fun iterator() : Iterator<Int>
|
||||
}
|
||||
|
||||
fun test(notRange1: NotRange1, notRange2: NotRange2, notRange3: NotRange3, notRange4: NotRange4, notRange5: NotRange5, notRange6: NotRange6, notRange7: NotRange7, range0: Range0, range1: Range1) {
|
||||
for (i in <!ITERATOR_MISSING!>notRange1<!>);
|
||||
for (i in <!HAS_NEXT_MISSING, NEXT_MISSING!>notRange2<!>);
|
||||
for (i in <!NEXT_MISSING!>notRange3<!>);
|
||||
for (i in <!HAS_NEXT_MISSING!>notRange4<!>);
|
||||
for (i in <!HAS_NEXT_FUNCTION_TYPE_MISMATCH!>notRange5<!>);
|
||||
for (i in <!HAS_NEXT_PROPERTY_AND_FUNCTION_AMBIGUITY!>notRange6<!>);
|
||||
for (i in <!HAS_NEXT_FUNCTION_TYPE_MISMATCH!>notRange7<!>);
|
||||
for (i in range0);
|
||||
for (i in range1);
|
||||
|
||||
for (i in (ArrayList<Int>() : List<Int>));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,166 @@
|
||||
fun none() {}
|
||||
|
||||
fun unitEmptyInfer() {}
|
||||
fun unitEmpty() : Unit {}
|
||||
fun unitEmptyReturn() : Unit {return}
|
||||
fun unitIntReturn() : Unit {return <!TYPE_MISMATCH!>1<!>}
|
||||
fun unitUnitReturn() : Unit {return ()}
|
||||
fun test1() : Any = {<!RETURN_NOT_ALLOWED, RETURN_IN_FUNCTION_WITH_EXPRESSION_BODY!>return<!>}
|
||||
fun test2() : Any = @a {return@a 1}
|
||||
fun test3() : Any { <!RETURN_TYPE_MISMATCH!>return<!> }
|
||||
|
||||
fun bbb() {
|
||||
return <!TYPE_MISMATCH!>1<!>
|
||||
}
|
||||
|
||||
fun foo(expr: StringBuilder): Int {
|
||||
val c = 'a'
|
||||
when(c) {
|
||||
0.chr => throw Exception("zero")
|
||||
else => throw Exception("nonzero" + c)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun unitShort() : Unit = ()
|
||||
fun unitShortConv() : Unit = <!TYPE_MISMATCH!>1<!>
|
||||
fun unitShortNull() : Unit = <!TYPE_MISMATCH!>null<!>
|
||||
|
||||
fun intEmpty() : Int <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>{}<!>
|
||||
fun intShortInfer() = 1
|
||||
fun intShort() : Int = 1
|
||||
//fun intBlockInfer() {1}
|
||||
fun intBlock() : Int {return 1}
|
||||
fun intBlock() : Int {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>1<!>}
|
||||
|
||||
fun intString(): Int = <!TYPE_MISMATCH!>"s"<!>
|
||||
fun intFunctionLiteral(): Int = <!TYPE_MISMATCH!>{ 10 }<!>
|
||||
|
||||
fun blockReturnUnitMismatch() : Int {<!RETURN_TYPE_MISMATCH!>return<!>}
|
||||
fun blockReturnValueTypeMismatch() : Int {return <!ERROR_COMPILE_TIME_VALUE!>3.4<!>}
|
||||
fun blockReturnValueTypeMatch() : Int {return 1}
|
||||
fun blockReturnValueTypeMismatchUnit() : Int {return <!TYPE_MISMATCH!>()<!>}
|
||||
|
||||
fun blockAndAndMismatch() : Int {
|
||||
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>true && false<!>
|
||||
}
|
||||
fun blockAndAndMismatch() : Int {
|
||||
return <!TYPE_MISMATCH!>true && false<!>
|
||||
}
|
||||
fun blockAndAndMismatch() : Int {
|
||||
<!UNREACHABLE_CODE!>(return <!ERROR_COMPILE_TIME_VALUE!>true<!>) && (return <!ERROR_COMPILE_TIME_VALUE!>false<!>)<!>
|
||||
}
|
||||
|
||||
fun blockAndAndMismatch() : Int {
|
||||
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>true || false<!>
|
||||
}
|
||||
fun blockAndAndMismatch() : Int {
|
||||
return <!TYPE_MISMATCH!>true || false<!>
|
||||
}
|
||||
fun blockAndAndMismatch() : Int {
|
||||
<!UNREACHABLE_CODE!>(return <!ERROR_COMPILE_TIME_VALUE!>true<!>) || (return <!ERROR_COMPILE_TIME_VALUE!>false<!>)<!>
|
||||
}
|
||||
fun blockReturnValueTypeMatch() : Int {
|
||||
return if (1 > 2) <!ERROR_COMPILE_TIME_VALUE!>1.0<!> else <!ERROR_COMPILE_TIME_VALUE!>2.0<!>
|
||||
}
|
||||
fun blockReturnValueTypeMatch() : Int {
|
||||
return <!TYPE_MISMATCH!>if (1 > 2) 1<!>
|
||||
}
|
||||
fun blockReturnValueTypeMatch() : Int {
|
||||
return <!TYPE_MISMATCH!>if (1 > 2) else 1<!>
|
||||
}
|
||||
fun blockReturnValueTypeMatch() : Int {
|
||||
if (1 > 2)
|
||||
return <!ERROR_COMPILE_TIME_VALUE!>1.0<!>
|
||||
else return <!ERROR_COMPILE_TIME_VALUE!>2.0<!>
|
||||
}
|
||||
fun blockReturnValueTypeMatch() : Int {
|
||||
if (1 > 2)
|
||||
return <!ERROR_COMPILE_TIME_VALUE!>1.0<!>
|
||||
return <!ERROR_COMPILE_TIME_VALUE!>2.0<!>
|
||||
}
|
||||
fun blockReturnValueTypeMatch() : Int {
|
||||
if (1 > 2)
|
||||
else return <!ERROR_COMPILE_TIME_VALUE!>1.0<!>
|
||||
return <!ERROR_COMPILE_TIME_VALUE!>2.0<!>
|
||||
}
|
||||
fun blockReturnValueTypeMatch() : Int {
|
||||
if (1 > 2)
|
||||
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>1.0<!>
|
||||
else <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>2.0<!>
|
||||
}
|
||||
fun blockReturnValueTypeMatch() : Int {
|
||||
if (1 > 2)
|
||||
1.0
|
||||
else 2.0
|
||||
return 1
|
||||
}
|
||||
fun blockReturnValueTypeMatch() : Int {
|
||||
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>if (1 > 2)
|
||||
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>1.0<!><!>
|
||||
}
|
||||
fun blockReturnValueTypeMatch() : Int {
|
||||
return <!TYPE_MISMATCH!>if (1 > 2)
|
||||
1<!>
|
||||
}
|
||||
fun blockReturnValueTypeMatch() : Int {
|
||||
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>if (1 > 2)
|
||||
else <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>1.0<!><!>
|
||||
}
|
||||
fun blockReturnValueTypeMatch() : Int {
|
||||
if (1 > 2)
|
||||
return 1
|
||||
else return <!ERROR_COMPILE_TIME_VALUE!>1.0<!>
|
||||
}
|
||||
fun blockNoReturnIfValDeclaration(): Int {
|
||||
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>val x = 1<!>
|
||||
}
|
||||
fun blockNoReturnIfEmptyIf(): Int {
|
||||
if (1 < 2) <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>{}<!> else <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>{}<!>
|
||||
}
|
||||
fun blockNoReturnIfUnitInOneBranch(): Int {
|
||||
if (1 < 2) {
|
||||
return 1
|
||||
} else {
|
||||
if (3 < 4) <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>{
|
||||
}<!> else {
|
||||
return 2
|
||||
}
|
||||
}
|
||||
}
|
||||
fun nonBlockReturnIfEmptyIf(): Int = if (1 < 2) <!TYPE_MISMATCH!>{}<!> else <!TYPE_MISMATCH!>{}<!>
|
||||
fun nonBlockNoReturnIfUnitInOneBranch(): Int = if (1 < 2) <!TYPE_MISMATCH!>{}<!> else 2
|
||||
|
||||
val a = <!RETURN_NOT_ALLOWED!>return 1<!>
|
||||
|
||||
class A() {
|
||||
this(a : Int) : this() {
|
||||
if (a == 1)
|
||||
return
|
||||
return <!TYPE_MISMATCH!>1<!>
|
||||
}
|
||||
|
||||
}
|
||||
fun illegalConstantBody(): Int = <!TYPE_MISMATCH!>"s"<!>
|
||||
fun illegalConstantBlock(): String {
|
||||
return <!ERROR_COMPILE_TIME_VALUE!>1<!>
|
||||
}
|
||||
fun illegalIfBody(): Int =
|
||||
if (1 < 2) <!ERROR_COMPILE_TIME_VALUE!>'a'<!> else { <!ERROR_COMPILE_TIME_VALUE!>1.0<!> }
|
||||
fun illegalIfBlock(): Boolean {
|
||||
if (1 < 2)
|
||||
return false
|
||||
else { return <!ERROR_COMPILE_TIME_VALUE!>1<!> }
|
||||
}
|
||||
fun illegalReturnIf(): Char {
|
||||
return if (1 < 2) 'a' else { <!ERROR_COMPILE_TIME_VALUE!>1<!> }
|
||||
}
|
||||
|
||||
fun returnNothing(): Nothing {
|
||||
throw 1
|
||||
}
|
||||
fun f(): Int {
|
||||
if (1 < 2) { return 1 } else returnNothing()
|
||||
}
|
||||
|
||||
fun f(): Int = if (1 < 2) 1 else returnNothing()
|
||||
@@ -0,0 +1,42 @@
|
||||
trait A<in T> {}
|
||||
trait B<T> : A<Int> {}
|
||||
trait C<T> : <!INCONSISTENT_TYPE_PARAMETER_VALUES!>B<T>, A<T><!> {}
|
||||
trait C1<T> : B<T>, A<Any> {}
|
||||
trait D : <!INCONSISTENT_TYPE_PARAMETER_VALUES, INCONSISTENT_TYPE_PARAMETER_VALUES!>C<Boolean>, B<Double><!>{}
|
||||
|
||||
trait A1<out T> {}
|
||||
trait B1 : A1<Int> {}
|
||||
trait B2 : A1<Any>, B1 {}
|
||||
|
||||
trait BA1<T> {}
|
||||
trait BB1 : BA1<Int> {}
|
||||
trait BB2 : <!INCONSISTENT_TYPE_PARAMETER_VALUES!>BA1<Any>, BB1<!> {}
|
||||
|
||||
|
||||
namespace x {
|
||||
trait AA1<out T> {}
|
||||
trait AB1 : AA1<Int> {}
|
||||
trait AB3 : AA1<Comparable<Int>> {}
|
||||
trait AB2 : AA1<Number>, AB1, AB3 {}
|
||||
}
|
||||
|
||||
namespace x2 {
|
||||
trait AA1<out T> {}
|
||||
trait AB1 : AA1<Any> {}
|
||||
trait AB3 : AA1<Comparable<Int>> {}
|
||||
trait AB2 : <!INCONSISTENT_TYPE_PARAMETER_VALUES!>AA1<Number>, AB1, AB3<!> {}
|
||||
}
|
||||
|
||||
namespace x3 {
|
||||
trait AA1<in T> {}
|
||||
trait AB1 : AA1<Any> {}
|
||||
trait AB3 : AA1<Comparable<Int>> {}
|
||||
trait AB2 : AA1<Number>, AB1, AB3 {}
|
||||
}
|
||||
|
||||
namespace sx2 {
|
||||
trait AA1<in T> {}
|
||||
trait AB1 : AA1<Int> {}
|
||||
trait AB3 : AA1<Comparable<Int>> {}
|
||||
trait AB2 : <!INCONSISTENT_TYPE_PARAMETER_VALUES!>AA1<Number>, AB1, AB3<!> {}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
class IncDec() {
|
||||
fun inc() : IncDec = this
|
||||
fun dec() : IncDec = this
|
||||
}
|
||||
|
||||
fun testIncDec() {
|
||||
var x = IncDec()
|
||||
x++
|
||||
++x
|
||||
x--
|
||||
--x
|
||||
x = x++
|
||||
x = x--
|
||||
x = ++x
|
||||
x = --x
|
||||
}
|
||||
|
||||
class WrongIncDec() {
|
||||
fun inc() : Int = 1
|
||||
fun dec() : Int = 1
|
||||
}
|
||||
|
||||
fun testWrongIncDec() {
|
||||
var x = WrongIncDec()
|
||||
x<!RESULT_TYPE_MISMATCH!>++<!>
|
||||
<!RESULT_TYPE_MISMATCH!>++<!>x
|
||||
x<!RESULT_TYPE_MISMATCH!>--<!>
|
||||
<!RESULT_TYPE_MISMATCH!>--<!>x
|
||||
}
|
||||
|
||||
class UnitIncDec() {
|
||||
fun inc() : Unit {}
|
||||
fun dec() : Unit {}
|
||||
}
|
||||
|
||||
fun testUnitIncDec() {
|
||||
var x = UnitIncDec()
|
||||
x++
|
||||
++x
|
||||
x--
|
||||
--x
|
||||
x = <!TYPE_MISMATCH!>x++<!>
|
||||
x = <!TYPE_MISMATCH!>x--<!>
|
||||
x = <!TYPE_MISMATCH!>++x<!>
|
||||
x = <!TYPE_MISMATCH!>--x<!>
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fun test() {
|
||||
if (1 is Int) {
|
||||
if (1 is <!INCOMPATIBLE_TYPES!>Boolean<!>) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
namespace Jet87
|
||||
|
||||
open class A() {
|
||||
fun foo() : Int = 1
|
||||
}
|
||||
|
||||
trait B {
|
||||
fun bar() : Double = 1.0;
|
||||
}
|
||||
|
||||
class C() : A(), B
|
||||
|
||||
class D() {
|
||||
class object : A(), B {}
|
||||
}
|
||||
|
||||
class Test1<T : A>()
|
||||
where
|
||||
T : B,
|
||||
<!NAME_IN_CONSTRAINT_IS_NOT_A_TYPE_PARAMETER!>B<!> : T, // error
|
||||
class object T : A,
|
||||
class object T : B,
|
||||
class object <!NAME_IN_CONSTRAINT_IS_NOT_A_TYPE_PARAMETER!>B<!> : T
|
||||
{
|
||||
|
||||
fun test(t : T) {
|
||||
T.foo()
|
||||
T.bar()
|
||||
t.foo()
|
||||
t.bar()
|
||||
}
|
||||
}
|
||||
|
||||
fun test() {
|
||||
Test1<<!UPPER_BOUND_VIOLATED!>B<!>>()
|
||||
Test1<<!UPPER_BOUND_VIOLATED!>A<!>>()
|
||||
Test1<C>()
|
||||
}
|
||||
|
||||
class Foo() {}
|
||||
|
||||
class Bar<T : <!FINAL_UPPER_BOUND!>Foo<!>>
|
||||
|
||||
class Buzz<T> where T : <!FINAL_UPPER_BOUND!>Bar<<!UPPER_BOUND_VIOLATED!>Int<!>><!>, T : <!UNRESOLVED_REFERENCE!>nioho<!>
|
||||
|
||||
class X<T : <!FINAL_UPPER_BOUND!>Foo<!>>
|
||||
class Y<<!CONFLICTING_UPPER_BOUNDS!>T<!> : <!FINAL_UPPER_BOUND!>Foo<!>> where T : <!FINAL_UPPER_BOUND!>Bar<Foo><!>
|
||||
|
||||
fun <T : A> test2(t : T)
|
||||
where
|
||||
T : B,
|
||||
<!NAME_IN_CONSTRAINT_IS_NOT_A_TYPE_PARAMETER!>B<!> : T,
|
||||
class object <!NAME_IN_CONSTRAINT_IS_NOT_A_TYPE_PARAMETER!>B<!> : T,
|
||||
class object T : B,
|
||||
class object T : A
|
||||
{
|
||||
T.foo()
|
||||
T.bar()
|
||||
t.foo()
|
||||
t.bar()
|
||||
}
|
||||
|
||||
val t1 = test2<<!UPPER_BOUND_VIOLATED!>A<!>>(A())
|
||||
val t2 = test2<<!UPPER_BOUND_VIOLATED!>B<!>>(C())
|
||||
val t3 = test2<C>(C())
|
||||
|
||||
class Test<<!CONFLICTING_CLASS_OBJECT_UPPER_BOUNDS!>T<!>>
|
||||
where
|
||||
class object T : <!FINAL_CLASS_OBJECT_UPPER_BOUND!>Foo<!>,
|
||||
class object T : A {}
|
||||
|
||||
val <T, B : T> x : Int = 0
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace root
|
||||
|
||||
namespace a {
|
||||
|
||||
}
|
||||
|
||||
val x = <!EXPRESSION_EXPECTED_NAMESPACE_FOUND, UNRESOLVED_REFERENCE!>a<!>
|
||||
val y2 = <!NAMESPACE_IS_NOT_AN_EXPRESSION!>namespace<!>
|
||||
@@ -0,0 +1,63 @@
|
||||
namespace foobar
|
||||
|
||||
namespace a {
|
||||
import java.*
|
||||
|
||||
val a : util.List<Int>? = null
|
||||
val a1 : <!UNRESOLVED_REFERENCE!>List<!><Int>? = null
|
||||
|
||||
}
|
||||
|
||||
abstract class Foo<T>() {
|
||||
abstract val x : T<Int>
|
||||
}
|
||||
|
||||
namespace a {
|
||||
import java.util.*
|
||||
|
||||
val b : List<Int>? = a
|
||||
val b1 : <!UNRESOLVED_REFERENCE!>util<!>.List<Int>? = a
|
||||
}
|
||||
|
||||
val x1 = a.a
|
||||
|
||||
val y1 = a.b
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
fun done<O>(result : O) : Iteratee<Any?, O> = StrangeIterateeImpl<Any?, O>(result)
|
||||
|
||||
abstract class Iteratee<in I, out O> {
|
||||
abstract fun process(item : I) : Iteratee<I, O>
|
||||
abstract val isDone : Boolean
|
||||
abstract val result : O
|
||||
abstract fun done() : O
|
||||
}
|
||||
|
||||
class StrangeIterateeImpl<in I, out O>(val obj: O) : Iteratee<I, O> {
|
||||
override fun process(item: I): Iteratee<I, O> = StrangeIterateeImpl<I, O>(obj)
|
||||
override val isDone = true
|
||||
override val result = obj
|
||||
override fun done() = obj
|
||||
}
|
||||
|
||||
abstract class Sum() : Iteratee<Int, Int> {
|
||||
override fun process(item : Int) : Iteratee<Int, Int> {
|
||||
return foobar.done<Int>(item);
|
||||
}
|
||||
abstract override val isDone : Boolean
|
||||
abstract override val result : Int
|
||||
abstract override fun done() : Int
|
||||
}
|
||||
|
||||
abstract class Collection<E> : Iterable<E> {
|
||||
fun iterate<O>(iteratee : Iteratee<E, O>) : O {
|
||||
for (x in this) {
|
||||
val it = iteratee.process(x)
|
||||
if (it.isDone) return it.result
|
||||
iteratee = it
|
||||
}
|
||||
return iteratee.done()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,280 @@
|
||||
fun test() {
|
||||
val a : Int? = 0
|
||||
if (a != null) {
|
||||
a.plus(1)
|
||||
}
|
||||
else {
|
||||
a?.plus(1)
|
||||
}
|
||||
|
||||
val out : java.io.PrintStream? = null//= System.out
|
||||
val ins = System.`in`
|
||||
|
||||
out?.println()
|
||||
ins?.read()
|
||||
|
||||
if (ins != null) {
|
||||
ins.read()
|
||||
out?.println()
|
||||
if (out != null) {
|
||||
ins.read();
|
||||
out.println();
|
||||
}
|
||||
}
|
||||
|
||||
if (out != null && ins != null) {
|
||||
ins.read();
|
||||
out.println();
|
||||
}
|
||||
|
||||
if (out == null) {
|
||||
out?.println()
|
||||
} else {
|
||||
out.println()
|
||||
}
|
||||
|
||||
if (out != null && ins != null || out != null) {
|
||||
ins?.read();
|
||||
out.println();
|
||||
}
|
||||
|
||||
if (out == null || out.println(0) == ()) {
|
||||
out?.println(1)
|
||||
}
|
||||
else {
|
||||
out.println(2)
|
||||
}
|
||||
|
||||
if (out != null && out.println() == ()) {
|
||||
out.println();
|
||||
}
|
||||
else {
|
||||
out?.println();
|
||||
}
|
||||
|
||||
if (out == null || out != null && out.println() == ()) {
|
||||
out?.println();
|
||||
}
|
||||
else {
|
||||
out.println();
|
||||
}
|
||||
|
||||
if (1 == 2 || out != null && out.println(1) == ()) {
|
||||
out?.println(2);
|
||||
}
|
||||
else {
|
||||
out?.println(3)
|
||||
}
|
||||
|
||||
out?.println()
|
||||
ins?.read()
|
||||
|
||||
if (ins != null) {
|
||||
ins.read()
|
||||
out?.println()
|
||||
if (out != null) {
|
||||
ins.read();
|
||||
out.println();
|
||||
}
|
||||
}
|
||||
|
||||
if (out != null && ins != null) {
|
||||
ins.read();
|
||||
out.println();
|
||||
}
|
||||
|
||||
if (out == null) {
|
||||
out?.println()
|
||||
} else {
|
||||
out.println()
|
||||
}
|
||||
|
||||
if (out != null && ins != null || out != null) {
|
||||
ins?.read();
|
||||
out.println();
|
||||
}
|
||||
|
||||
if (out == null || out.println(0) == ()) {
|
||||
out?.println(1)
|
||||
}
|
||||
else {
|
||||
out.println(2)
|
||||
}
|
||||
|
||||
if (out != null && out.println() == ()) {
|
||||
out.println();
|
||||
}
|
||||
else {
|
||||
out?.println();
|
||||
}
|
||||
|
||||
if (out == null || out != null && out.println() == ()) {
|
||||
out?.println();
|
||||
}
|
||||
else {
|
||||
out.println();
|
||||
}
|
||||
|
||||
if (1 == 2 || out != null && out.println(1) == ()) {
|
||||
out?.println(2);
|
||||
}
|
||||
else {
|
||||
out?.println(3)
|
||||
}
|
||||
|
||||
if (1 > 2) {
|
||||
if (out == null) return;
|
||||
out.println();
|
||||
}
|
||||
out?.println();
|
||||
|
||||
while (out != null) {
|
||||
out.println();
|
||||
}
|
||||
out?.println();
|
||||
|
||||
while (out == null) {
|
||||
out?.println();
|
||||
}
|
||||
out.println()
|
||||
|
||||
}
|
||||
|
||||
|
||||
fun f(out : String?) {
|
||||
out?.get(0)
|
||||
if (out != null) else return;
|
||||
out.get(0)
|
||||
}
|
||||
|
||||
fun f1(out : String?) {
|
||||
out?.get(0)
|
||||
if (out != null) else {
|
||||
1 + 2
|
||||
return;
|
||||
}
|
||||
out.get(0)
|
||||
}
|
||||
|
||||
fun f2(out : String?) {
|
||||
out?.get(0)
|
||||
if (out == null) {
|
||||
1 + 2
|
||||
return;
|
||||
}
|
||||
out.get(0)
|
||||
}
|
||||
|
||||
fun f3(out : String?) {
|
||||
out?.get(0)
|
||||
if (out == null) {
|
||||
1 + 2
|
||||
return;
|
||||
}
|
||||
else {
|
||||
1 + 2
|
||||
}
|
||||
out.get(0)
|
||||
}
|
||||
|
||||
fun f4(s : String?) {
|
||||
s?.get(0)
|
||||
while (1 < 2 && s != null) {
|
||||
s.get(0)
|
||||
}
|
||||
s?.get(0)
|
||||
while (s == null || 1 < 2) {
|
||||
s?.get(0)
|
||||
}
|
||||
s.get(0)
|
||||
}
|
||||
|
||||
fun f5(s : String?) {
|
||||
s?.get(0)
|
||||
while (1 < 2 && s != null) {
|
||||
s.get(0)
|
||||
}
|
||||
s?.get(0)
|
||||
while (s == null || 1 < 2) {
|
||||
if (1 > 2) break
|
||||
s?.get(0)
|
||||
}
|
||||
s?.get(0);
|
||||
}
|
||||
|
||||
fun f6(s : String?) {
|
||||
s?.get(0)
|
||||
do {
|
||||
s?.get(0)
|
||||
if (1 < 2) break;
|
||||
} while (s == null)
|
||||
s?.get(0)
|
||||
do {
|
||||
s?.get(0)
|
||||
} while (s == null)
|
||||
s.get(0)
|
||||
}
|
||||
|
||||
fun f7(s : String?, t : String?) {
|
||||
s?.get(0)
|
||||
if (!(s == null)) {
|
||||
s.get(0)
|
||||
}
|
||||
s?.get(0)
|
||||
if (!(s != null)) {
|
||||
s?.get(0)
|
||||
}
|
||||
else {
|
||||
s.get(0)
|
||||
}
|
||||
s?.get(0)
|
||||
if (!!(s != null)) {
|
||||
s.get(0)
|
||||
}
|
||||
else {
|
||||
s?.get(0)
|
||||
}
|
||||
s?.get(0)
|
||||
t?.get(0)
|
||||
if (!(s == null || t == null)) {
|
||||
s.get(0)
|
||||
t.get(0)
|
||||
}
|
||||
else {
|
||||
s?.get(0)
|
||||
t?.get(0)
|
||||
}
|
||||
s?.get(0)
|
||||
t?.get(0)
|
||||
if (!(s == null && s == null)) {
|
||||
s.get(0)
|
||||
t?.get(0)
|
||||
}
|
||||
else {
|
||||
s?.get(0)
|
||||
t?.get(0)
|
||||
}
|
||||
}
|
||||
|
||||
fun f8(b : String?, a : String) {
|
||||
b?.get(0)
|
||||
if (b == a) {
|
||||
b.get(0);
|
||||
}
|
||||
b?.get(0)
|
||||
if (a == b) {
|
||||
b.get(0)
|
||||
}
|
||||
if (a != b) {
|
||||
b?.get(0)
|
||||
}
|
||||
else {
|
||||
b.get(0)
|
||||
}
|
||||
}
|
||||
|
||||
fun f9(a : Int?) : Int {
|
||||
if (a != null)
|
||||
return a
|
||||
return 1
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
namespace toplevelObjectDeclarations {
|
||||
open class Foo(y : Int) {
|
||||
open fun foo() : Int = 1
|
||||
}
|
||||
|
||||
class T : <!SUPERTYPE_NOT_INITIALIZED!>Foo<!> {}
|
||||
|
||||
object A : <!SUPERTYPE_NOT_INITIALIZED!>Foo<!> {
|
||||
val x : Int = 2
|
||||
|
||||
fun test() : Int {
|
||||
return x + foo()
|
||||
}
|
||||
}
|
||||
|
||||
object B : <!UNRESOLVED_REFERENCE!>A<!> {}
|
||||
|
||||
val x = A.foo()
|
||||
|
||||
val y = object : Foo(x) {
|
||||
{
|
||||
x + 12
|
||||
}
|
||||
|
||||
override fun foo() : Int = 1
|
||||
}
|
||||
|
||||
val z = y.foo()
|
||||
}
|
||||
|
||||
namespace nestedObejcts {
|
||||
object A {
|
||||
val b = B
|
||||
val d = A.B.A
|
||||
|
||||
object B {
|
||||
val a = A
|
||||
val e = B.A
|
||||
|
||||
object A {
|
||||
val a = A
|
||||
val b = B
|
||||
val x = nestedObejcts.A.B.A
|
||||
val y = this<!AMBIGUOUS_LABEL!>@A<!>
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
object B {
|
||||
val b = B
|
||||
val c = A.B
|
||||
}
|
||||
|
||||
val a = A
|
||||
val b = B
|
||||
val c = A.B
|
||||
val d = A.B.A
|
||||
val e = B.<!UNRESOLVED_REFERENCE!>A<!>.B
|
||||
}
|
||||
|
||||
namespace localObjects {
|
||||
object A {
|
||||
val x : Int = 0
|
||||
}
|
||||
|
||||
open class Foo {
|
||||
fun foo() : Int = 1
|
||||
}
|
||||
|
||||
fun test() {
|
||||
A.x
|
||||
val b = object : Foo {
|
||||
}
|
||||
b.foo()
|
||||
|
||||
object B {
|
||||
fun foo() {}
|
||||
}
|
||||
B.foo()
|
||||
}
|
||||
|
||||
val bb = <!UNRESOLVED_REFERENCE!>B<!>.foo()
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
namespace override
|
||||
|
||||
namespace normal {
|
||||
trait MyTrait {
|
||||
fun foo()
|
||||
}
|
||||
|
||||
abstract class MyAbstractClass {
|
||||
abstract fun bar()
|
||||
}
|
||||
|
||||
open class MyClass : MyTrait, MyAbstractClass {
|
||||
override fun foo() {}
|
||||
override fun bar() {}
|
||||
}
|
||||
|
||||
class MyChildClass : MyClass {}
|
||||
|
||||
class <!ABSTRACT_METHOD_NOT_IMPLEMENTED!>MyIllegalClass<!> : MyTrait, MyAbstractClass {}
|
||||
|
||||
class <!ABSTRACT_METHOD_NOT_IMPLEMENTED!>MyIllegalClass2<!> : MyTrait, MyAbstractClass {
|
||||
override fun foo() {}
|
||||
}
|
||||
|
||||
class <!ABSTRACT_METHOD_NOT_IMPLEMENTED!>MyIllegalClass3<!> : MyTrait, MyAbstractClass {
|
||||
override fun bar() {}
|
||||
}
|
||||
|
||||
class <!ABSTRACT_METHOD_NOT_IMPLEMENTED!>MyIllegalClass4<!> : MyTrait, MyAbstractClass {
|
||||
fun <!VIRTUAL_METHOD_HIDDEN!>foo<!>() {}
|
||||
<!NOTHING_TO_OVERRIDE!>override<!> fun other() {}
|
||||
}
|
||||
|
||||
class MyChildClass1 : MyClass {
|
||||
fun <!VIRTUAL_METHOD_HIDDEN!>foo<!>() {}
|
||||
override fun bar() {}
|
||||
}
|
||||
}
|
||||
|
||||
namespace generics {
|
||||
trait MyTrait<T> {
|
||||
fun foo(t: T) : T
|
||||
}
|
||||
|
||||
abstract class MyAbstractClass<T> {
|
||||
abstract fun bar(t: T) : T
|
||||
}
|
||||
|
||||
open class MyGenericClass<T> : MyTrait<T>, MyAbstractClass<T> {
|
||||
override fun foo(t: T) = t
|
||||
override fun bar(t: T) = t
|
||||
}
|
||||
|
||||
class MyChildClass : MyGenericClass<Int> {}
|
||||
class MyChildClass1<T> : MyGenericClass<T> {}
|
||||
class MyChildClass2<T> : MyGenericClass<T> {
|
||||
fun <!VIRTUAL_METHOD_HIDDEN!>foo<!>(t: T) = t
|
||||
override fun bar(t: T) = t
|
||||
}
|
||||
|
||||
open class MyClass : MyTrait<Int>, MyAbstractClass<String> {
|
||||
override fun foo(i: Int) = i
|
||||
override fun bar(s: String) = s
|
||||
}
|
||||
|
||||
class <!ABSTRACT_METHOD_NOT_IMPLEMENTED!>MyIllegalGenericClass1<!><T> : MyTrait<T>, MyAbstractClass<T> {}
|
||||
class <!ABSTRACT_METHOD_NOT_IMPLEMENTED!>MyIllegalGenericClass2<!><T, R> : MyTrait<T>, MyAbstractClass<R> {
|
||||
<!NOTHING_TO_OVERRIDE!>override<!> fun foo(r: R) = r
|
||||
}
|
||||
class <!ABSTRACT_METHOD_NOT_IMPLEMENTED!>MyIllegalClass1<!> : MyTrait<Int>, MyAbstractClass<String> {}
|
||||
|
||||
class <!ABSTRACT_METHOD_NOT_IMPLEMENTED!>MyIllegalClass2<!><T> : MyTrait<Int>, MyAbstractClass<Int> {
|
||||
fun foo(t: T) = t
|
||||
fun bar(t: T) = t
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
class <!PRIMARY_CONSTRUCTOR_MISSING_STATEFUL_PROPERTY!>X<!> {
|
||||
val <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>x<!> : Int
|
||||
}
|
||||
|
||||
open class Y() {
|
||||
val x : Int = 2
|
||||
}
|
||||
|
||||
class Y1 {
|
||||
val x : Int get() = 1
|
||||
}
|
||||
|
||||
class Z : Y<!PRIMARY_CONSTRUCTOR_MISSING_SUPER_CONSTRUCTOR_CALL!>()<!> {
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
trait A<T> {}
|
||||
trait B<T> {}
|
||||
trait C<T> {}
|
||||
trait D<T> {}
|
||||
|
||||
trait Test : A<<!PROJECTION_IN_IMMEDIATE_ARGUMENT_TO_SUPERTYPE!>in<!> Int>, B<<!PROJECTION_IN_IMMEDIATE_ARGUMENT_TO_SUPERTYPE!>out<!> Int>, C<<!PROJECTION_IN_IMMEDIATE_ARGUMENT_TO_SUPERTYPE!>*<!>><!NULLABLE_SUPERTYPE!>?<!><!NULLABLE_SUPERTYPE!>?<!><!NULLABLE_SUPERTYPE!>?<!>, D<Int> {}
|
||||
@@ -0,0 +1,28 @@
|
||||
var x : Int = 1 + x
|
||||
get() : Int = 1
|
||||
set(<!REF_SETTER_PARAMETER!>ref<!> value : <!WRONG_SETTER_PARAMETER_TYPE!>Long<!>) {
|
||||
$x = value.int
|
||||
$x = <!TYPE_MISMATCH!>1.lng<!>
|
||||
}
|
||||
|
||||
val xx : Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>1 + x<!>
|
||||
get() : Int = 1
|
||||
<!VAL_WITH_SETTER!>set(value : Long) {}<!>
|
||||
|
||||
val p : Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>1<!>
|
||||
get() = 1
|
||||
|
||||
class Test() {
|
||||
var a : Int = 111
|
||||
var b : Int get() = <!UNRESOLVED_REFERENCE!>$a<!>; set(x) {a = x; <!UNRESOLVED_REFERENCE!>$a<!> = x}
|
||||
|
||||
this(i : Int) : this() {
|
||||
<!NO_BACKING_FIELD!>$b<!> = $a
|
||||
$a = <!NO_BACKING_FIELD!>$b<!>
|
||||
a = <!NO_BACKING_FIELD!>$b<!>
|
||||
}
|
||||
fun f() {
|
||||
<!UNRESOLVED_REFERENCE!>$b<!> = <!UNRESOLVED_REFERENCE!>$a<!>
|
||||
a = <!UNRESOLVED_REFERENCE!>$b<!>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace qualified_expressions
|
||||
|
||||
fun test(s: String?) {
|
||||
val a: Int = <!TYPE_MISMATCH!>s?.length<!>
|
||||
val b: Int? = s?.length
|
||||
val c: Int = s?.length ?: -11
|
||||
val d: Int = s?.length ?: <!TYPE_MISMATCH!>"empty"<!>
|
||||
val e: String = <!TYPE_MISMATCH!>s?.length<!> ?: "empty"
|
||||
val f: Int = s?.length ?: b ?: 1
|
||||
val g: Int? = e? startsWith("s")?.length
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
class Dup {
|
||||
fun Dup() : Unit {
|
||||
this<!AMBIGUOUS_LABEL!>@Dup<!>
|
||||
}
|
||||
}
|
||||
|
||||
class A() {
|
||||
fun foo() : Unit {
|
||||
this@A
|
||||
this<!UNRESOLVED_REFERENCE!>@a<!>
|
||||
this
|
||||
}
|
||||
|
||||
val x = this@A.foo()
|
||||
val y = this.foo()
|
||||
val z = foo()
|
||||
}
|
||||
|
||||
fun foo1() : Unit {
|
||||
<!NO_THIS!>this<!>
|
||||
this<!UNRESOLVED_REFERENCE!>@a<!>
|
||||
}
|
||||
|
||||
namespace closures {
|
||||
class A(val a:Int) {
|
||||
|
||||
class B() {
|
||||
val x = this@B : B
|
||||
val y = this@A : A
|
||||
val z = this : B
|
||||
val Int.xx = this : Int
|
||||
fun Char.xx() : Any {
|
||||
this : Char
|
||||
val a = {Double.() => this : Double + this@xx : Char}
|
||||
val b = @a{Double.() => this@a : Double + this@xx : Char}
|
||||
val c = @a{() => <!NO_THIS!>this@a<!> + this@xx : Char}
|
||||
return (@a{Double.() => this@a : Double + this@xx : Char})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
namespace a {
|
||||
val foo = <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!>bar()<!>
|
||||
|
||||
fun bar() = foo
|
||||
}
|
||||
|
||||
namespace b {
|
||||
fun foo() = <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!>bar()<!>
|
||||
|
||||
fun bar() = foo()
|
||||
}
|
||||
|
||||
namespace c {
|
||||
fun bazz() = <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!>bar()<!>
|
||||
|
||||
fun foo() = bazz()
|
||||
|
||||
fun bar() = foo()
|
||||
}
|
||||
|
||||
namespace ok {
|
||||
|
||||
namespace a {
|
||||
val foo = bar()
|
||||
|
||||
fun bar() : Int = foo
|
||||
}
|
||||
|
||||
namespace b {
|
||||
fun foo() : Int = bar()
|
||||
|
||||
fun bar() = foo()
|
||||
}
|
||||
|
||||
namespace c {
|
||||
fun bazz() = bar()
|
||||
|
||||
fun foo() : Int = bazz()
|
||||
|
||||
fun bar() = foo()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
namespace redeclarations {
|
||||
object <!REDECLARATION, REDECLARATION!>A<!> {
|
||||
val x : Int = 0
|
||||
|
||||
val A = 1
|
||||
}
|
||||
|
||||
namespace <!REDECLARATION!>A<!> {
|
||||
class A {}
|
||||
}
|
||||
|
||||
class <!REDECLARATION, REDECLARATION!>A<!> {}
|
||||
|
||||
val <!REDECLARATION!>A<!> = 1
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
import java.*
|
||||
import util.*
|
||||
import <!UNRESOLVED_REFERENCE!>utils<!>.*
|
||||
|
||||
import java.io.PrintStream
|
||||
import java.lang.Comparable as Com
|
||||
|
||||
val l : List<in Int> = ArrayList<Int>()
|
||||
|
||||
fun test(l : java.util.List<Int>) {
|
||||
val x : java.<!UNRESOLVED_REFERENCE!>List<!>
|
||||
val y : java.util.List<Int>
|
||||
val b : java.lang.Object
|
||||
val a : util.List<Int>
|
||||
val z : java.<!UNRESOLVED_REFERENCE!>utils<!>.List<Int>
|
||||
|
||||
val f : java.io.File? = null
|
||||
|
||||
Collections.<!UNRESOLVED_REFERENCE!>emptyList<!>
|
||||
Collections.emptyList<Int>
|
||||
Collections.emptyList<Int>()
|
||||
Collections.emptyList()
|
||||
|
||||
Collections.singleton<Int>(1) : Set<Int>?
|
||||
Collections.singleton<Int>(<!ERROR_COMPILE_TIME_VALUE!>1.0<!>)
|
||||
|
||||
<!UNRESOLVED_REFERENCE!>List<!><Int>
|
||||
|
||||
|
||||
val o = "sdf" <!CAST_NEVER_SUCCEEDS!>as<!> Object
|
||||
|
||||
try {
|
||||
// ...
|
||||
}
|
||||
catch(e: Exception) {
|
||||
System.out?.println(e.getMessage())
|
||||
}
|
||||
|
||||
PrintStream("sdf")
|
||||
|
||||
val c : Com<Int>? = null
|
||||
|
||||
c : java.lang.Comparable<Int>?
|
||||
|
||||
// Collections.sort<Integer>(ArrayList<Integer>())
|
||||
xxx.<!UNRESOLVED_REFERENCE!>Class<!>()
|
||||
}
|
||||
|
||||
|
||||
namespace xxx {
|
||||
import java.lang.Class;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
fun demo() {
|
||||
val abc = 1
|
||||
val a = ""
|
||||
val asd = 1
|
||||
val bar = 5
|
||||
fun map(f : fun () : Any?) : Int = 1
|
||||
fun buzz(f : fun () : Any?) : Int = 1
|
||||
val sdf = 1
|
||||
val foo = 3;
|
||||
"$abc"
|
||||
"$"
|
||||
"$.$.asdf$\t"
|
||||
"asd\$"
|
||||
"asd$a<!ILLEGAL_ESCAPE_SEQUENCE!>\x<!>"
|
||||
"asd$a$asd$ $<!UNRESOLVED_REFERENCE!>xxx<!>"
|
||||
"fosdfasdo${1 + bar + 100}}sdsdfgdsfsdf"
|
||||
"foo${bar + map {foo}}sdfsdf"
|
||||
"foo${bar + map { "foo" }}sdfsdf"
|
||||
"foo${bar + map {
|
||||
"foo$sdf${ buzz{}}" }}sdfsdf"
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
// KT-286 Check supertype lists
|
||||
|
||||
/*
|
||||
In a supertype list:
|
||||
Same type should not be mentioned twice
|
||||
Same type should not be indirectly mentioned with incoherent type arguments
|
||||
Every trait's required dependencies should be satisfied
|
||||
No final types should appear
|
||||
Only one class is allowed
|
||||
*/
|
||||
|
||||
class C1()
|
||||
|
||||
open class OC1()
|
||||
|
||||
open class C2 {}
|
||||
|
||||
open class C3 {}
|
||||
|
||||
trait T1 {}
|
||||
|
||||
trait T2<T> {}
|
||||
|
||||
trait Test<!CONSTRUCTOR_IN_TRAIT!>()<!> {
|
||||
<!CONSTRUCTOR_IN_TRAIT, SECONDARY_CONSTRUCTOR_NO_INITIALIZER_LIST!>this<!>(x : Int) {}
|
||||
}
|
||||
|
||||
trait Test1 : C2<!SUPERTYPE_INITIALIZED_IN_TRAIT!>()<!> {}
|
||||
|
||||
trait Test2 : C2 {}
|
||||
|
||||
trait Test3 : C2, <!MANY_CLASSES_IN_SUPERTYPE_LIST!>C3<!> {}
|
||||
|
||||
trait Test4 : T1 {}
|
||||
|
||||
trait Test5 : T1, <!SUPERTYPE_APPEARS_TWICE!>T1<!> {}
|
||||
|
||||
trait Test6 : <!FINAL_SUPERTYPE!>C1<!> {}
|
||||
|
||||
class CTest1() : OC1() {}
|
||||
|
||||
class CTest2 : C2 {}
|
||||
|
||||
class CTest3 : C2, <!MANY_CLASSES_IN_SUPERTYPE_LIST!>C3<!> {}
|
||||
|
||||
class CTest4 : T1 {}
|
||||
|
||||
class CTest5 : T1, <!SUPERTYPE_APPEARS_TWICE!>T1<!> {}
|
||||
|
||||
class CTest6 : <!SUPERTYPE_NOT_INITIALIZED, FINAL_SUPERTYPE!>C1<!> {}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
open class bar()
|
||||
|
||||
trait Foo<!CONSTRUCTOR_IN_TRAIT!>()<!> : bar<!SUPERTYPE_INITIALIZED_IN_TRAIT!>()<!>, <!MANY_CLASSES_IN_SUPERTYPE_LIST, SUPERTYPE_APPEARS_TWICE!>bar<!>, <!MANY_CLASSES_IN_SUPERTYPE_LIST, SUPERTYPE_APPEARS_TWICE!>bar<!> {
|
||||
<!CONSTRUCTOR_IN_TRAIT, SECONDARY_CONSTRUCTOR_NO_INITIALIZER_LIST!>this<!>(x : Int) {}
|
||||
}
|
||||
|
||||
trait Foo2 : bar, Foo {
|
||||
}
|
||||
|
||||
open class Foo1() : bar(), <!SUPERTYPE_NOT_INITIALIZED, MANY_CLASSES_IN_SUPERTYPE_LIST, SUPERTYPE_APPEARS_TWICE!>bar<!>, Foo, <!SUPERTYPE_APPEARS_TWICE!>Foo<!><!CONSTRUCTOR_IN_TRAIT!>()<!> {}
|
||||
open class Foo12 : bar<!PRIMARY_CONSTRUCTOR_MISSING_SUPER_CONSTRUCTOR_CALL!>()<!>, <!SUPERTYPE_NOT_INITIALIZED, MANY_CLASSES_IN_SUPERTYPE_LIST, SUPERTYPE_APPEARS_TWICE!>bar<!> {}
|
||||
@@ -0,0 +1,161 @@
|
||||
fun t1() : Int{
|
||||
return 0
|
||||
<!UNREACHABLE_CODE!>1<!>
|
||||
}
|
||||
|
||||
fun t1a() : Int {
|
||||
<!RETURN_TYPE_MISMATCH!>return<!>
|
||||
<!UNREACHABLE_CODE!>return 1<!>
|
||||
<!UNREACHABLE_CODE!>1<!>
|
||||
}
|
||||
|
||||
fun t1b() : Int {
|
||||
return 1
|
||||
<!UNREACHABLE_CODE!>return 1<!>
|
||||
<!UNREACHABLE_CODE!>1<!>
|
||||
}
|
||||
|
||||
fun t1c() : Int {
|
||||
return 1
|
||||
<!RETURN_TYPE_MISMATCH, UNREACHABLE_CODE!>return<!>
|
||||
<!UNREACHABLE_CODE!>1<!>
|
||||
}
|
||||
|
||||
fun t2() : Int {
|
||||
if (1 > 2)
|
||||
return 1
|
||||
else return 1
|
||||
<!UNREACHABLE_CODE!>1<!>
|
||||
}
|
||||
|
||||
fun t2a() : Int {
|
||||
if (1 > 2) {
|
||||
return 1
|
||||
<!UNREACHABLE_CODE!>1<!>
|
||||
} else { return 1
|
||||
<!UNREACHABLE_CODE!>2<!>
|
||||
}
|
||||
<!UNREACHABLE_CODE!>1<!>
|
||||
}
|
||||
|
||||
fun t3() : Any {
|
||||
if (1 > 2)
|
||||
return 2
|
||||
else return ""
|
||||
<!UNREACHABLE_CODE!>1<!>
|
||||
}
|
||||
|
||||
fun t4(a : Boolean) : Int {
|
||||
do {
|
||||
return 1
|
||||
}
|
||||
while (<!UNREACHABLE_CODE!>a<!>)
|
||||
<!UNREACHABLE_CODE!>1<!>
|
||||
}
|
||||
|
||||
fun t4break(a : Boolean) : Int {
|
||||
do {
|
||||
break
|
||||
}
|
||||
while (<!UNREACHABLE_CODE!>a<!>)
|
||||
return 1
|
||||
}
|
||||
|
||||
fun t5() : Int {
|
||||
do {
|
||||
return 1
|
||||
<!UNREACHABLE_CODE!>2<!>
|
||||
}
|
||||
while (<!UNREACHABLE_CODE!>1 > 2<!>)
|
||||
<!UNREACHABLE_CODE!>return 1<!>
|
||||
}
|
||||
|
||||
fun t6() : Int {
|
||||
while (1 > 2) {
|
||||
return 1
|
||||
<!UNREACHABLE_CODE!>2<!>
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
fun t6break() : Int {
|
||||
while (1 > 2) {
|
||||
break
|
||||
<!UNREACHABLE_CODE!>2<!>
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
fun t7(b : Int) : Int {
|
||||
for (i in 1..b) {
|
||||
return 1
|
||||
<!UNREACHABLE_CODE!>2<!>
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
fun t7break(b : Int) : Int {
|
||||
for (i in 1..b) {
|
||||
return 1
|
||||
<!UNREACHABLE_CODE!>2<!>
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
fun t7() : Int {
|
||||
try {
|
||||
return 1
|
||||
<!UNREACHABLE_CODE!>2<!>
|
||||
}
|
||||
catch (e : Any) {
|
||||
2
|
||||
}
|
||||
return 1 // this is OK, like in Java
|
||||
}
|
||||
|
||||
fun t8() : Int {
|
||||
try {
|
||||
return 1
|
||||
<!UNREACHABLE_CODE!>2<!>
|
||||
}
|
||||
catch (e : Any) {
|
||||
return 1
|
||||
<!UNREACHABLE_CODE!>2<!>
|
||||
}
|
||||
<!UNREACHABLE_CODE!>return 1<!>
|
||||
}
|
||||
|
||||
fun blockAndAndMismatch() : Boolean {
|
||||
<!UNREACHABLE_CODE!>(return true) || (return false)<!>
|
||||
<!UNREACHABLE_CODE!>return true<!>
|
||||
}
|
||||
|
||||
fun tf() : Int {
|
||||
try {<!UNREACHABLE_CODE!>return 1<!>} finally{return 1}
|
||||
<!UNREACHABLE_CODE!>return 1<!>
|
||||
}
|
||||
|
||||
fun failtest(a : Int) : Int {
|
||||
<!UNREACHABLE_BECAUSE_OF_NOTHING!>if (fail() || true) {
|
||||
|
||||
}<!>
|
||||
<!UNREACHABLE_BECAUSE_OF_NOTHING!>return 1<!>
|
||||
}
|
||||
|
||||
fun foo(a : Nothing) : Unit {
|
||||
1
|
||||
a
|
||||
<!UNREACHABLE_BECAUSE_OF_NOTHING!>2<!>
|
||||
}
|
||||
|
||||
fun fail() : Nothing {
|
||||
throw java.lang.RuntimeException()
|
||||
}
|
||||
|
||||
fun nullIsNotNothing() : Unit {
|
||||
val x : Int? = 1
|
||||
if (x != null) {
|
||||
return
|
||||
}
|
||||
fail()
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
namespace unresolved
|
||||
|
||||
fun testGenericArgumentsCount() {
|
||||
val p1: Tuple2<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><Int><!> = (2, 2)
|
||||
val p2: <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>Tuple2<!> = (2, 2)
|
||||
}
|
||||
|
||||
fun testUnresolved() {
|
||||
if (<!UNRESOLVED_REFERENCE!>a<!> is String) {
|
||||
val s = <!UNRESOLVED_REFERENCE!>a<!>
|
||||
}
|
||||
<!UNRESOLVED_REFERENCE!>foo<!>(<!UNRESOLVED_REFERENCE!>a<!>)
|
||||
val s = "s"
|
||||
<!UNRESOLVED_REFERENCE!>foo<!>(s)
|
||||
foo1(<!UNRESOLVED_REFERENCE!>i<!>)
|
||||
s.<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
|
||||
when(<!UNRESOLVED_REFERENCE!>a<!>) {
|
||||
is Int => <!UNRESOLVED_REFERENCE!>a<!>
|
||||
is String => <!UNRESOLVED_REFERENCE!>a<!>
|
||||
}
|
||||
|
||||
//TODO
|
||||
for (j in <!UNRESOLVED_REFERENCE!>collection<!>) {
|
||||
val i: Int = j
|
||||
j += 1
|
||||
}
|
||||
}
|
||||
|
||||
fun foo1(i: Int) {}
|
||||
@@ -0,0 +1,40 @@
|
||||
namespace variance
|
||||
|
||||
abstract class Consumer<in T> {}
|
||||
|
||||
abstract class Producer<out T> {}
|
||||
|
||||
abstract class Usual<T> {}
|
||||
|
||||
fun foo(c: Consumer<Int>, p: Producer<Int>, u: Usual<Int>) {
|
||||
val c1: Consumer<Any> = <!TYPE_MISMATCH!>c<!>
|
||||
val c2: Consumer<Int> = c1
|
||||
|
||||
val p1: Producer<Any> = p
|
||||
val p2: Producer<Int> = <!TYPE_MISMATCH!>p1<!>
|
||||
|
||||
val u1: Usual<Any> = <!TYPE_MISMATCH!>u<!>
|
||||
val u2: Usual<Int> = <!TYPE_MISMATCH!>u1<!>
|
||||
}
|
||||
|
||||
//Arrays copy example
|
||||
class Array<T>(val length : Int) {
|
||||
fun get(index : Int) : T { return null }
|
||||
fun set(index : Int, value : T) { /* ... */ }
|
||||
}
|
||||
|
||||
fun copy1(from : Array<Any>, to : Array<Any>) {}
|
||||
|
||||
fun copy2(from : Array<out Any>, to : Array<in Any>) {}
|
||||
|
||||
fun <T> copy3(from : Array<out T>, to : Array<in T>) {}
|
||||
|
||||
fun copy4(from : Array<out Number>, to : Array<in Int>) {}
|
||||
|
||||
fun f(ints: Array<Int>, any: Array<Any>, numbers: Array<Number>) {
|
||||
copy1(<!TYPE_MISMATCH!>ints<!>, any)
|
||||
copy2(ints, any) //ok
|
||||
copy2(ints, <!TYPE_MISMATCH!>numbers<!>)
|
||||
copy3<Int>(ints, numbers)
|
||||
copy4(ints, numbers) //ok
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
fun foo() : Int {
|
||||
val s = ""
|
||||
val x = 1
|
||||
when (x) {
|
||||
is * => 1
|
||||
is <!INCOMPATIBLE_TYPES!>String<!> => 1
|
||||
!is Int => 1
|
||||
is Any? => 1
|
||||
<!INCOMPATIBLE_TYPES!>s<!> => 1
|
||||
1 => 1
|
||||
1 + <!UNRESOLVED_REFERENCE!>a<!> => 1
|
||||
in 1..<!UNRESOLVED_REFERENCE!>a<!> => 1
|
||||
!in 1..<!UNRESOLVED_REFERENCE!>a<!> => 1
|
||||
.<!UNRESOLVED_REFERENCE!>a<!> => 1
|
||||
.equals(1).<!UNRESOLVED_REFERENCE!>a<!> => 1
|
||||
<!UNNECESSARY_SAFE_CALL!>?.<!>equals(1) => 1
|
||||
else => 1
|
||||
}
|
||||
return when (<!USELESS_ELVIS!>x<!>?:null) {
|
||||
<!UNSAFE_CALL!>.<!>equals(1) => 1
|
||||
?.equals(1).equals(2) => 1
|
||||
}
|
||||
}
|
||||
|
||||
val _type_test : Int = foo() // this is needed to ensure the inferred return type of foo()
|
||||
|
||||
fun test() {
|
||||
val x = 1;
|
||||
val s = "";
|
||||
|
||||
when (x) {
|
||||
<!INCOMPATIBLE_TYPES!>s<!> => 1
|
||||
is <!INCOMPATIBLE_TYPES!>""<!> => 1
|
||||
x => 1
|
||||
is 1 => 1
|
||||
is <!TYPE_MISMATCH_IN_TUPLE_PATTERN!>(1, 1)<!> => 1
|
||||
}
|
||||
|
||||
val z = (1, 1)
|
||||
|
||||
when (z) {
|
||||
is (*, *) => 1
|
||||
is (*, 1) => 1
|
||||
is (1, 1) => 1
|
||||
is (1, <!INCOMPATIBLE_TYPES!>"1"<!>) => 1
|
||||
is <!TYPE_MISMATCH_IN_TUPLE_PATTERN!>(1, "1", *)<!> => 1
|
||||
is boo @ (1, <!INCOMPATIBLE_TYPES!>"a"<!>, *) => 1
|
||||
is boo @ <!TYPE_MISMATCH_IN_TUPLE_PATTERN!>(1, *)<!> => 1
|
||||
}
|
||||
|
||||
when (z) {
|
||||
<!ELSE_MISPLACED_IN_WHEN!>else => 1<!>
|
||||
(1, 1) => 2
|
||||
}
|
||||
|
||||
when (z) {
|
||||
else => 1
|
||||
}
|
||||
}
|
||||
|
||||
val (Int, Int).boo : (Int, Int, Int) = (1, 1, 1)
|
||||
@@ -0,0 +1,255 @@
|
||||
open class A() {
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
class B() : A() {
|
||||
fun bar() {}
|
||||
}
|
||||
|
||||
fun f9() {
|
||||
val a : A?
|
||||
a?.foo()
|
||||
a?.<!UNRESOLVED_REFERENCE!>bar<!>()
|
||||
if (a is B) {
|
||||
a.bar()
|
||||
a.foo()
|
||||
}
|
||||
a?.foo()
|
||||
a?.<!UNRESOLVED_REFERENCE!>bar<!>()
|
||||
if (!(a is B)) {
|
||||
a?.<!UNRESOLVED_REFERENCE!>bar<!>()
|
||||
a?.foo()
|
||||
}
|
||||
if (!(a is B) || a.bar() == ()) {
|
||||
a?.<!UNRESOLVED_REFERENCE!>bar<!>()
|
||||
}
|
||||
if (!(a is B)) {
|
||||
return;
|
||||
}
|
||||
a.bar()
|
||||
a.foo()
|
||||
}
|
||||
|
||||
fun f10() {
|
||||
val a : A?
|
||||
if (!(a is B)) {
|
||||
return;
|
||||
}
|
||||
if (!(a is B)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
class C() : A() {
|
||||
fun bar() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
fun f10(a : A?) {
|
||||
if (a is B) {
|
||||
if (a is C) {
|
||||
a.bar();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun f11(a : A?) {
|
||||
when (a) {
|
||||
is B => a.bar()
|
||||
is A => a.foo()
|
||||
is Any => a.foo()
|
||||
is Any? => a.<!UNRESOLVED_REFERENCE!>bar<!>()
|
||||
else => a?.foo()
|
||||
}
|
||||
}
|
||||
|
||||
fun f12(a : A?) {
|
||||
when (a) {
|
||||
is B => a.bar()
|
||||
is A => a.foo()
|
||||
is Any => a.foo();
|
||||
is Any? => a.<!UNRESOLVED_REFERENCE!>bar<!>()
|
||||
is val c : <!TYPE_MISMATCH_IN_BINDING_PATTERN!>B<!> => c.foo()
|
||||
is val c is C => c.bar()
|
||||
is val c is C => a.bar()
|
||||
else => a?.foo()
|
||||
}
|
||||
|
||||
if (a is val b) {
|
||||
a?.<!UNRESOLVED_REFERENCE!>bar<!>()
|
||||
b?.foo()
|
||||
}
|
||||
if (a is val b is B) {
|
||||
b.foo()
|
||||
a.bar()
|
||||
b.bar()
|
||||
}
|
||||
}
|
||||
|
||||
fun f13(a : A?) {
|
||||
if (a is val c is B) {
|
||||
c.foo()
|
||||
c.bar()
|
||||
}
|
||||
else {
|
||||
a?.foo()
|
||||
<!UNRESOLVED_REFERENCE!>c<!>.bar()
|
||||
}
|
||||
|
||||
a?.foo()
|
||||
if (!(a is val c is B)) {
|
||||
a?.foo()
|
||||
<!UNRESOLVED_REFERENCE!>c<!>.bar()
|
||||
}
|
||||
else {
|
||||
a.foo()
|
||||
<!UNRESOLVED_REFERENCE!>c<!>.bar()
|
||||
}
|
||||
|
||||
a?.foo()
|
||||
if (a is val c is B && a.foo() == () && c.bar() == ()) {
|
||||
c.foo()
|
||||
c.bar()
|
||||
}
|
||||
else {
|
||||
a?.foo()
|
||||
<!UNRESOLVED_REFERENCE!>c<!>.bar()
|
||||
}
|
||||
|
||||
if (!(a is val c is B) || !(a is val x is C)) {
|
||||
<!UNRESOLVED_REFERENCE!>x<!>
|
||||
<!UNRESOLVED_REFERENCE!>c<!>
|
||||
}
|
||||
else {
|
||||
<!UNRESOLVED_REFERENCE!>x<!>
|
||||
<!UNRESOLVED_REFERENCE!>c<!>
|
||||
}
|
||||
|
||||
if (!(a is val c is B) || !(a is val c is C)) {
|
||||
}
|
||||
|
||||
if (!(a is val c is B)) return
|
||||
a.bar()
|
||||
<!UNRESOLVED_REFERENCE!>c<!>.foo()
|
||||
<!UNRESOLVED_REFERENCE!>c<!>.bar()
|
||||
}
|
||||
|
||||
fun f14(a : A?) {
|
||||
while (!(a is val c is B)) {
|
||||
}
|
||||
a.bar()
|
||||
<!UNRESOLVED_REFERENCE!>c<!>.bar()
|
||||
}
|
||||
fun f15(a : A?) {
|
||||
do {
|
||||
} while (!(a is val c is B))
|
||||
a.bar()
|
||||
<!UNRESOLVED_REFERENCE!>c<!>.bar()
|
||||
}
|
||||
|
||||
fun getStringLength(obj : Any) : Char? {
|
||||
if (obj !is String)
|
||||
return null
|
||||
return obj.get(0) // no cast to String is needed
|
||||
}
|
||||
|
||||
fun toInt(i: Int?): Int = if (i != null) i else 0
|
||||
fun illegalWhenBody(a: Any): Int = when(a) {
|
||||
is Int => a
|
||||
is String => <!TYPE_MISMATCH!>a<!>
|
||||
}
|
||||
fun illegalWhenBlock(a: Any): Int {
|
||||
when(a) {
|
||||
is Int => return a
|
||||
is String => return <!TYPE_MISMATCH!>a<!>
|
||||
}
|
||||
}
|
||||
fun declarations(a: Any?) {
|
||||
if (a is String) {
|
||||
val p4: (Int, String) = (2, a)
|
||||
}
|
||||
if (a is String?) {
|
||||
if (a != null) {
|
||||
val s: String = a
|
||||
}
|
||||
}
|
||||
if (a != null) {
|
||||
if (a is String?) {
|
||||
val s: String = a
|
||||
}
|
||||
}
|
||||
}
|
||||
fun vars(a: Any?) {
|
||||
var b: Int = 0
|
||||
if (a is Int) {
|
||||
b = a
|
||||
}
|
||||
}
|
||||
fun tuples(a: Any?) {
|
||||
if (a != null) {
|
||||
val s: (Any, String) = (a, <!TYPE_MISMATCH!>a<!>)
|
||||
}
|
||||
if (a is String) {
|
||||
val s: (Any, String) = (a, a)
|
||||
}
|
||||
fun illegalTupleReturnType(): (Any, String) = (<!TYPE_MISMATCH!>a<!>, <!TYPE_MISMATCH!>a<!>)
|
||||
if (a is String) {
|
||||
fun legalTupleReturnType(): (Any, String) = (a, a)
|
||||
}
|
||||
val illegalFunctionLiteral: Function0<Int> = <!TYPE_MISMATCH!>{ <!TYPE_MISMATCH!>a<!> }<!>
|
||||
val illegalReturnValueInFunctionLiteral: Function0<Int> = { (): Int => <!TYPE_MISMATCH!>a<!> }
|
||||
|
||||
if (a is Int) {
|
||||
val legalFunctionLiteral: Function0<Int> = { a }
|
||||
val alsoLegalFunctionLiteral: Function0<Int> = { (): Int => a }
|
||||
}
|
||||
}
|
||||
fun returnFunctionLiteralBlock(a: Any?): Function0<Int> {
|
||||
if (a is Int) return { a }
|
||||
else return { 1 }
|
||||
}
|
||||
fun returnFunctionLiteral(a: Any?): Function0<Int> =
|
||||
if (a is Int) { (): Int => a }
|
||||
else { () => 1 }
|
||||
|
||||
fun illegalTupleReturnType(a: Any): (Any, String) = (a, <!TYPE_MISMATCH!>a<!>)
|
||||
|
||||
fun declarationInsidePattern(x: (Any, Any)): String = when(x) { is (val a is String, *) => a; else => "something" }
|
||||
|
||||
fun mergeAutocasts(a: Any?) {
|
||||
if (a is String || a is Int) {
|
||||
a.<!UNRESOLVED_REFERENCE!>compareTo<!>("")
|
||||
a.toString()
|
||||
}
|
||||
if (a is Int || a is String) {
|
||||
a.<!UNRESOLVED_REFERENCE!>compareTo<!>("")
|
||||
}
|
||||
when (a) {
|
||||
is String, is Any => a.<!UNRESOLVED_REFERENCE!>compareTo<!>("")
|
||||
}
|
||||
if (a is String && a is Any) {
|
||||
val i: Int = a.compareTo("")
|
||||
}
|
||||
if (a is String && a.compareTo("") == 0) {}
|
||||
if (a is String || a.<!UNRESOLVED_REFERENCE!>compareTo<!>("") == 0) {}
|
||||
}
|
||||
|
||||
//mutability
|
||||
fun f(): String {
|
||||
var a: Any = 11
|
||||
if (a is String) {
|
||||
val i: String = <!AUTOCAST_IMPOSSIBLE!>a<!>
|
||||
<!AUTOCAST_IMPOSSIBLE!>a<!>.compareTo("f")
|
||||
val f: Function0<String> = { <!AUTOCAST_IMPOSSIBLE!>a<!> }
|
||||
return <!AUTOCAST_IMPOSSIBLE!>a<!>
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
fun foo(var a: Any): Int {
|
||||
if (a is Int) {
|
||||
return <!AUTOCAST_IMPOSSIBLE!>a<!>
|
||||
}
|
||||
return 1
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
abstract class Test() {
|
||||
abstract val x : Int
|
||||
abstract val x1 : Int get
|
||||
abstract val x2 : Int <!ABSTRACT_PROPERTY_WITH_GETTER!>get() = 1<!>
|
||||
|
||||
val <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>a<!> : Int
|
||||
val <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>b<!> : Int get
|
||||
val c = 1
|
||||
|
||||
val c1 = 1
|
||||
get
|
||||
val c2 : Int
|
||||
get() = 1
|
||||
val c3 : Int
|
||||
get() { return 1 }
|
||||
val c4 : Int
|
||||
get() = 1
|
||||
val <!MUST_BE_INITIALIZED!>c5<!> : Int
|
||||
get() = $c5 + 1
|
||||
|
||||
abstract var y : Int
|
||||
abstract var y1 : Int get
|
||||
abstract var y2 : Int set
|
||||
abstract var y3 : Int set get
|
||||
abstract var y4 : Int set <!ABSTRACT_PROPERTY_WITH_GETTER!>get() = 1<!>
|
||||
abstract var y5 : Int <!ABSTRACT_PROPERTY_WITH_SETTER!>set(x) {}<!> <!ABSTRACT_PROPERTY_WITH_GETTER!>get() = 1<!>
|
||||
abstract var y6 : Int <!ABSTRACT_PROPERTY_WITH_SETTER!>set(x) {}<!>
|
||||
|
||||
var <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>v<!> : Int
|
||||
var <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>v1<!> : Int get
|
||||
var <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>v2<!> : Int get set
|
||||
var <!MUST_BE_INITIALIZED!>v3<!> : Int get() = 1; set
|
||||
var v4 : Int get() = 1; set(x){}
|
||||
|
||||
var <!MUST_BE_INITIALIZED!>v5<!> : Int get() = 1; set(x){$v5 = x}
|
||||
var <!MUST_BE_INITIALIZED!>v6<!> : Int get() = $v6 + 1; set(x){}
|
||||
|
||||
val v7 : Int abstract get
|
||||
var v8 : Int abstract get abstract set
|
||||
var <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>v9<!> : Int abstract set
|
||||
var <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>v10<!> : Int abstract get
|
||||
|
||||
}
|
||||
|
||||
open class Super(i : Int)
|
||||
|
||||
class TestPCParameters(w : Int, x : Int, val y : Int, var z : Int) : Super(w) {
|
||||
|
||||
val xx = w
|
||||
|
||||
{
|
||||
w + 1
|
||||
}
|
||||
|
||||
fun foo() = x
|
||||
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// One of the two passes is making a scope and turning vals into functions
|
||||
// See KT-76
|
||||
|
||||
namespace x
|
||||
|
||||
val b : Foo = Foo()
|
||||
val a1 = b.compareTo(2)
|
||||
|
||||
class Foo() {
|
||||
fun compareTo(other : Byte) : Int = 0
|
||||
fun compareTo(other : Char) : Int = 0
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
fun test() {
|
||||
val a : Any? = null
|
||||
if (a is Any) else a = null;
|
||||
while (a is Any) a = null
|
||||
while (true) a = null
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
fun foo(u : Unit) : Int = 1
|
||||
|
||||
fun test() : Int {
|
||||
foo(<!TYPE_MISMATCH!>1<!>)
|
||||
val a : fun() : Unit = {
|
||||
foo(<!TYPE_MISMATCH!>1<!>)
|
||||
}
|
||||
return 1
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
import java.*
|
||||
import util.*
|
||||
|
||||
import java.io.*
|
||||
|
||||
fun takeFirst(expr: StringBuilder): Char {
|
||||
val c = expr.charAt(0)
|
||||
expr.deleteCharAt(0)
|
||||
return c
|
||||
}
|
||||
|
||||
fun evaluateArg(expr: AbstractStringBuilder, numbers: ArrayList<Int>): Int {
|
||||
if (expr.length() == 0) throw Exception("Syntax error: Character expected");
|
||||
val c = takeFirst(<!TYPE_MISMATCH!>expr<!>)
|
||||
if (c >= '0' && c <= '9') {
|
||||
val n = c - '0'
|
||||
if (!numbers.contains(n)) throw Exception("You used incorrect number: " + n)
|
||||
numbers.remove(n)
|
||||
return n
|
||||
}
|
||||
throw Exception("Syntax error: Unrecognized character " + c)
|
||||
}
|
||||
|
||||
fun evaluateAdd(expr: StringBuilder, numbers: ArrayList<Int>): Int {
|
||||
val lhs = evaluateArg(expr, numbers)
|
||||
if (expr.length() > 0) {
|
||||
|
||||
}
|
||||
return lhs
|
||||
}
|
||||
|
||||
fun evaluate(expr: StringBuilder, numbers: ArrayList<Int>): Int {
|
||||
val lhs = evaluateAdd(expr, numbers)
|
||||
if (expr.length() > 0) {
|
||||
val c = expr.charAt(0)
|
||||
expr.deleteCharAt(0)
|
||||
}
|
||||
return lhs
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
System.out?.println("24 game")
|
||||
val numbers = ArrayList<Int>(4)
|
||||
val rnd = Random();
|
||||
val prompt = StringBuilder()
|
||||
for(val i in 0..3) {
|
||||
val n = rnd.nextInt(9) + 1
|
||||
numbers.add(n)
|
||||
if (i > 0) prompt.append(" ");
|
||||
prompt.append(n)
|
||||
}
|
||||
System.out?.println("Your numbers: " + prompt)
|
||||
System.out?.println("Enter your expression:")
|
||||
val reader = BufferedReader(InputStreamReader(System.`in`))
|
||||
val expr = StringBuilder(reader.readLine())
|
||||
try {
|
||||
val result = evaluate(expr, numbers)
|
||||
if (result != 24)
|
||||
System.out?.println("Sorry, that's " + result)
|
||||
else
|
||||
System.out?.println("You won!");
|
||||
}
|
||||
catch(e: Throwable) {
|
||||
System.out?.println(e.getMessage())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
// JET-11 Redeclaration & Forward reference for classes cause an exception
|
||||
open class <!REDECLARATION!>NoC<!>
|
||||
class NoC1 : NoC
|
||||
open class <!REDECLARATION!>NoC<!>
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace jet121 {
|
||||
fun box() : String {
|
||||
val answer = apply("OK") { String.() : Int =>
|
||||
get(0)
|
||||
length
|
||||
}
|
||||
|
||||
return if (answer == 2) "OK" else "FAIL"
|
||||
}
|
||||
|
||||
fun apply(arg:String, f : fun String.() : Int) : Int {
|
||||
return arg.f()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fun foo1() : fun (Int) : Int = { (x: Int) => x }
|
||||
|
||||
fun foo() {
|
||||
val h : fun (Int) : Int = foo1();
|
||||
h(1)
|
||||
val m : fun (Int) : Int = {(a : Int) => 1}//foo1()
|
||||
m(1)
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fun set(key : String, value : String) {
|
||||
val a : String? = ""
|
||||
when (a) {
|
||||
"" => a<!UNSAFE_CALL!>.<!>get(0)
|
||||
is String, is Any => a.compareTo("")
|
||||
else => a.toString()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// JET-17 Do not infer property types by the initializer before the containing scope is ready
|
||||
|
||||
class WithC() {
|
||||
val a = 1
|
||||
val b = $a // error here, but must not be
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
abstract enum class ProtocolState {
|
||||
WAITING {
|
||||
override fun signal() = ProtocolState.TALKING
|
||||
}
|
||||
|
||||
TALKING {
|
||||
override fun signal() = ProtocolState.WAITING
|
||||
}
|
||||
|
||||
abstract fun signal() : ProtocolState
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
val x: ProtocolState = ProtocolState.WAITING
|
||||
x = x.signal()
|
||||
if (x != ProtocolState.TALKING) return "fail 1"
|
||||
x = x.signal()
|
||||
if (x != ProtocolState.WAITING) return "fail 2"
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
abstract enum class ProtocolState {
|
||||
WAITING {
|
||||
override fun signal() = ProtocolState.TALKING
|
||||
}
|
||||
|
||||
TALKING {
|
||||
override fun signal() = ProtocolState.WAITING
|
||||
}
|
||||
|
||||
abstract fun signal() : ProtocolState
|
||||
}
|
||||
|
||||
enum class Foo<T> {
|
||||
<!NO_GENERICS_IN_SUPERTYPE_SPECIFIER!>X<!>
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
fun box() {
|
||||
val x: ProtocolState = ProtocolState.WAITING
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import java.util.Collections
|
||||
import java.util.List
|
||||
|
||||
val ab = Collections.emptyList<Int>() : List<Int>?
|
||||
@@ -0,0 +1,4 @@
|
||||
abstract class XXX {
|
||||
val a : Int abstract get
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
class Foo()
|
||||
|
||||
fun test() {
|
||||
val f : Foo? = null
|
||||
if (f == null) {
|
||||
|
||||
}
|
||||
if (f != null) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
class Command() {}
|
||||
|
||||
fun parse(cmd: String): Command? { return null }
|
||||
|
||||
fun Any.equals(other : Any?) : Boolean = this === other
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val command = parse("")
|
||||
if (command == null) 1 // error on this line, but must be OK
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
// JET-72 Type inference doesn't work when iterating over ArrayList
|
||||
|
||||
import java.util.ArrayList
|
||||
|
||||
abstract class Item(val room: Object) {
|
||||
abstract val name : String
|
||||
}
|
||||
|
||||
val items: ArrayList<Item> = ArrayList<Item>
|
||||
|
||||
fun test(room : Object) {
|
||||
for(val item: Item in items) {
|
||||
if (item.room === room) {
|
||||
System.out?.println("You see " + item.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// JET-81 Assertion fails when processing self-referring anonymous objects
|
||||
|
||||
val y = object {
|
||||
val a = y;
|
||||
}
|
||||
|
||||
val z = y.a;
|
||||
|
||||
object A {
|
||||
val x = A
|
||||
}
|
||||
|
||||
val a = object {
|
||||
{
|
||||
b + 1
|
||||
}
|
||||
val x = <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!>b<!>
|
||||
val y = 1
|
||||
}
|
||||
|
||||
val b = a.x
|
||||
val c = a.y
|
||||
@@ -0,0 +1,16 @@
|
||||
fun box() {
|
||||
val a : C
|
||||
a.foo()
|
||||
}
|
||||
|
||||
open class A {
|
||||
open fun foo() {}
|
||||
}
|
||||
|
||||
open class B : A {
|
||||
override fun foo() {}
|
||||
}
|
||||
|
||||
open class C : B {
|
||||
override fun foo() {}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
class Foo(var bar : Int, barr : Int, val barrr : Int) {
|
||||
{
|
||||
bar = 1
|
||||
barr = 1
|
||||
barrr = 1
|
||||
1 : Int
|
||||
this : Foo
|
||||
}
|
||||
|
||||
this(val bar : Int) : this(1, 1, 1) {
|
||||
bar = 1
|
||||
this.bar
|
||||
1 : Int
|
||||
val a : Int =1
|
||||
this : Foo
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
fun Any.equals(other : Any?) : Boolean = true
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
|
||||
val command : Any = 1
|
||||
|
||||
command<!UNNECESSARY_SAFE_CALL!>?.<!>equals(null)
|
||||
command.equals(null)
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
class Z() {
|
||||
this(x : Int) : this() {}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
open class Foo {}
|
||||
open class Bar {}
|
||||
|
||||
fun <T : Bar, T1> foo(x : Int) {}
|
||||
fun <T1, T : Foo> foo(x : Long) {}
|
||||
|
||||
fun f(): Unit {
|
||||
foo<<!UPPER_BOUND_VIOLATED!>Int<!>, Int>(1)
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
class A() {
|
||||
var x: Int = 0
|
||||
get() = <!TYPE_MISMATCH!>"s"<!>
|
||||
set(value: <!WRONG_SETTER_PARAMETER_TYPE!>String<!>) {
|
||||
$x = <!TYPE_MISMATCH!>value<!>
|
||||
}
|
||||
val y: Int
|
||||
get(): <!WRONG_GETTER_RETURN_TYPE!>String<!> = "s"
|
||||
val z: Int
|
||||
get() {
|
||||
return <!TYPE_MISMATCH!>"s"<!>
|
||||
}
|
||||
|
||||
var a: Any = 1
|
||||
set(v: <!WRONG_SETTER_PARAMETER_TYPE!>String<!>) {
|
||||
$a = v
|
||||
}
|
||||
val b: Int
|
||||
get(): <!WRONG_GETTER_RETURN_TYPE!>Any<!> = "s"
|
||||
val c: Int
|
||||
get() {
|
||||
return 1
|
||||
}
|
||||
val d = 1
|
||||
get() {
|
||||
return $d
|
||||
}
|
||||
val e = 1
|
||||
get(): <!WRONG_GETTER_RETURN_TYPE!>String<!> {
|
||||
return <!TYPE_MISMATCH!>$e<!>
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// KT-303 Stack overflow on a cyclic class hierarchy
|
||||
|
||||
open class Foo() : <!CYCLIC_INHERITANCE_HIERARCHY!>Bar<!>() {
|
||||
val a : Int = 1
|
||||
}
|
||||
|
||||
open class Bar() : <!CYCLIC_INHERITANCE_HIERARCHY!>Foo<!>() {
|
||||
|
||||
}
|
||||
|
||||
val x : Int = <!TYPE_MISMATCH!>Foo()<!>
|
||||
@@ -0,0 +1,32 @@
|
||||
fun text() {
|
||||
"direct:a" to "mock:a"
|
||||
"direct:a" on {it.body == "<hello/>"} to "mock:a"
|
||||
"direct:a" on {it => it.body == "<hello/>"} to "mock:a"
|
||||
bar <!TYPE_MISMATCH!>{1}<!>
|
||||
bar <!TYPE_MISMATCH!>{<!UNRESOLVED_REFERENCE!>it<!> <!UNRESOLVED_REFERENCE!>+<!> 1}<!>
|
||||
bar {it, it1 => it}
|
||||
|
||||
bar1 {1}
|
||||
bar1 {it + 1}
|
||||
|
||||
bar2 <!TYPE_MISMATCH!>{<!TYPE_MISMATCH!><!>}<!>
|
||||
bar2 {1}
|
||||
bar2 {<!UNRESOLVED_REFERENCE!>it<!>}
|
||||
bar2 <!TYPE_MISMATCH!>{<!CANNOT_INFER_PARAMETER_TYPE!>it<!> => it}<!>
|
||||
}
|
||||
|
||||
fun bar(f : fun (Int, Int) : Int) {}
|
||||
fun bar1(f : fun (Int) : Int) {}
|
||||
fun bar2(f : fun () : Int) {}
|
||||
|
||||
fun String.to(dest : String) {
|
||||
|
||||
}
|
||||
|
||||
fun String.on(predicate : fun (s : URI) : Boolean) : URI {
|
||||
return URI(this)
|
||||
}
|
||||
|
||||
class URI(val body : Any) {
|
||||
fun to(dest : String) {}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
fun foo(u : Unit) : Int = 1
|
||||
|
||||
fun test() : Int {
|
||||
foo(<!TYPE_MISMATCH!>1<!>)
|
||||
val a : fun() : Unit = {
|
||||
foo(<!TYPE_MISMATCH!>1<!>)
|
||||
}
|
||||
return 1 <!NONE_APPLICABLE!>-<!> "1"
|
||||
}
|
||||
|
||||
class A() {
|
||||
val x : Int = <!TYPE_MISMATCH!>foo1(<!TOO_MANY_ARGUMENTS, UNRESOLVED_REFERENCE!>xx<!>)<!>
|
||||
}
|
||||
|
||||
fun foo1() {}
|
||||
@@ -0,0 +1,2 @@
|
||||
val x = 1 : Int?:Any?
|
||||
val y = null ?: 1
|
||||
@@ -0,0 +1,48 @@
|
||||
JetFile: ElvisSplit.jet
|
||||
NAMESPACE
|
||||
PROPERTY
|
||||
PsiElement(val)('val')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('x')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
BINARY_WITH_TYPE
|
||||
BINARY_WITH_TYPE
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('1')
|
||||
PsiWhiteSpace(' ')
|
||||
OPERATION_REFERENCE
|
||||
PsiElement(COLON)(':')
|
||||
PsiWhiteSpace(' ')
|
||||
TYPE_REFERENCE
|
||||
NULLABLE_TYPE
|
||||
USER_TYPE
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('Int')
|
||||
PsiElement(QUEST)('?')
|
||||
OPERATION_REFERENCE
|
||||
PsiElement(COLON)(':')
|
||||
TYPE_REFERENCE
|
||||
NULLABLE_TYPE
|
||||
USER_TYPE
|
||||
REFERENCE_EXPRESSION
|
||||
PsiElement(IDENTIFIER)('Any')
|
||||
PsiElement(QUEST)('?')
|
||||
PsiWhiteSpace('\n')
|
||||
PROPERTY
|
||||
PsiElement(val)('val')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(IDENTIFIER)('y')
|
||||
PsiWhiteSpace(' ')
|
||||
PsiElement(EQ)('=')
|
||||
PsiWhiteSpace(' ')
|
||||
BINARY_EXPRESSION
|
||||
NULL
|
||||
PsiElement(null)('null')
|
||||
PsiWhiteSpace(' ')
|
||||
OPERATION_REFERENCE
|
||||
PsiElement(ELVIS)('?:')
|
||||
PsiWhiteSpace(' ')
|
||||
INTEGER_CONSTANT
|
||||
PsiElement(INTEGER_LITERAL)('1')
|
||||
@@ -0,0 +1,189 @@
|
||||
package org.jetbrains.jet;
|
||||
|
||||
import com.intellij.ide.startup.impl.StartupManagerImpl;
|
||||
import com.intellij.lang.*;
|
||||
import com.intellij.lang.impl.PsiBuilderFactoryImpl;
|
||||
import com.intellij.mock.*;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.EditorFactory;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl;
|
||||
import com.intellij.openapi.fileEditor.impl.LoadTextUtil;
|
||||
import com.intellij.openapi.fileTypes.FileTypeFactory;
|
||||
import com.intellij.openapi.fileTypes.FileTypeManager;
|
||||
import com.intellij.openapi.options.SchemesManagerFactory;
|
||||
import com.intellij.openapi.progress.impl.ProgressManagerImpl;
|
||||
import com.intellij.openapi.startup.StartupManager;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.PsiCachedValuesFactory;
|
||||
import com.intellij.psi.impl.PsiFileFactoryImpl;
|
||||
import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry;
|
||||
import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistryImpl;
|
||||
import com.intellij.psi.util.CachedValuesManager;
|
||||
import com.intellij.testFramework.LightVirtualFile;
|
||||
import com.intellij.testFramework.MockSchemesManagerFactory;
|
||||
import com.intellij.testFramework.PlatformLiteFixture;
|
||||
import com.intellij.testFramework.TestDataFile;
|
||||
import com.intellij.util.CachedValuesManagerImpl;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
import com.intellij.util.messages.MessageBusFactory;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.jet.lang.parsing.JetParserDefinition;
|
||||
import org.picocontainer.MutablePicoContainer;
|
||||
import org.picocontainer.PicoContainer;
|
||||
import org.picocontainer.PicoInitializationException;
|
||||
import org.picocontainer.PicoIntrospectionException;
|
||||
import org.picocontainer.defaults.AbstractComponentAdapter;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
*/
|
||||
public abstract class JetLiteFixture extends PlatformLiteFixture {
|
||||
protected String myFileExt;
|
||||
@NonNls
|
||||
protected final String myFullDataPath;
|
||||
protected PsiFile myFile;
|
||||
private MockPsiManager myPsiManager;
|
||||
private PsiFileFactoryImpl myFileFactory;
|
||||
protected Language myLanguage;
|
||||
protected final ParserDefinition[] myDefinitions;
|
||||
|
||||
public JetLiteFixture(@NonNls String dataPath) {
|
||||
myFileExt = "jet";
|
||||
myFullDataPath = getTestDataPath() + "/" + dataPath;
|
||||
myDefinitions = new ParserDefinition[] {new JetParserDefinition()};
|
||||
}
|
||||
|
||||
protected String getTestDataPath() {
|
||||
return JetTestCaseBase.getTestDataPathBase();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
initApplication();
|
||||
getApplication().getPicoContainer().registerComponent(new AbstractComponentAdapter("com.intellij.openapi.progress.ProgressManager", Object.class) {
|
||||
@Override
|
||||
public Object getComponentInstance(PicoContainer container) throws PicoInitializationException, PicoIntrospectionException {
|
||||
return new ProgressManagerImpl(getApplication());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void verify(PicoContainer container) throws PicoIntrospectionException {
|
||||
}
|
||||
});
|
||||
myProject = disposeOnTearDown(new MockProjectEx());
|
||||
myPsiManager = new MockPsiManager(myProject);
|
||||
myFileFactory = new PsiFileFactoryImpl(myPsiManager);
|
||||
final MutablePicoContainer appContainer = getApplication().getPicoContainer();
|
||||
registerComponentInstance(appContainer, MessageBus.class, MessageBusFactory.newMessageBus(getApplication()));
|
||||
registerComponentInstance(appContainer, SchemesManagerFactory.class, new MockSchemesManagerFactory());
|
||||
final MockEditorFactory editorFactory = new MockEditorFactory();
|
||||
registerComponentInstance(appContainer, EditorFactory.class, editorFactory);
|
||||
registerComponentInstance(appContainer, FileDocumentManager.class, new MockFileDocumentManagerImpl(new Function<CharSequence, Document>() {
|
||||
@Override
|
||||
public Document fun(CharSequence charSequence) {
|
||||
return editorFactory.createDocument(charSequence);
|
||||
}
|
||||
}, FileDocumentManagerImpl.DOCUMENT_KEY));
|
||||
registerComponentInstance(appContainer, PsiDocumentManager.class, new MockPsiDocumentManager());
|
||||
myLanguage = myLanguage == null && myDefinitions != null && myDefinitions.length > 0
|
||||
? myDefinitions[0].getFileNodeType().getLanguage()
|
||||
: myLanguage;
|
||||
registerComponentInstance(appContainer, FileTypeManager.class, new MockFileTypeManager(new MockLanguageFileType(myLanguage, myFileExt)));
|
||||
registerApplicationService(PsiBuilderFactory.class, new PsiBuilderFactoryImpl());
|
||||
registerApplicationService(DefaultASTFactory.class, new DefaultASTFactoryImpl());
|
||||
registerApplicationService(ReferenceProvidersRegistry.class, new ReferenceProvidersRegistryImpl());
|
||||
myProject.registerService(CachedValuesManager.class, new CachedValuesManagerImpl(myProject, new PsiCachedValuesFactory(myPsiManager)));
|
||||
myProject.registerService(PsiManager.class, myPsiManager);
|
||||
myProject.registerService(StartupManager.class, new StartupManagerImpl(myProject));
|
||||
myProject.registerService(PsiFileFactory.class, new PsiFileFactoryImpl(myPsiManager));
|
||||
|
||||
registerExtensionPoint(FileTypeFactory.FILE_TYPE_FACTORY_EP, FileTypeFactory.class);
|
||||
|
||||
for (ParserDefinition definition : myDefinitions) {
|
||||
addExplicitExtension(LanguageParserDefinitions.INSTANCE, definition.getFileNodeType().getLanguage(), definition);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
myFile = null;
|
||||
myProject = null;
|
||||
myPsiManager = null;
|
||||
}
|
||||
|
||||
protected String loadFile(@NonNls @TestDataFile String name) throws IOException {
|
||||
return doLoadFile(myFullDataPath, name);
|
||||
}
|
||||
|
||||
protected static String doLoadFile(String myFullDataPath, String name) throws IOException {
|
||||
String fullName = myFullDataPath + File.separatorChar + name;
|
||||
String text = FileUtil.loadFile(new File(fullName), CharsetToolkit.UTF8).trim();
|
||||
text = StringUtil.convertLineSeparators(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
protected PsiFile createPsiFile(String name, String text) {
|
||||
return createFile(name + "." + myFileExt, text);
|
||||
}
|
||||
|
||||
protected PsiFile createFile(@NonNls String name, String text) {
|
||||
LightVirtualFile virtualFile = new LightVirtualFile(name, myLanguage, text);
|
||||
virtualFile.setCharset(CharsetToolkit.UTF8_CHARSET);
|
||||
return myFileFactory.trySetupPsiForFile(virtualFile, myLanguage, true, false);
|
||||
}
|
||||
|
||||
protected static void ensureParsed(PsiFile file) {
|
||||
file.accept(new PsiElementVisitor() {
|
||||
@Override
|
||||
public void visitElement(PsiElement element) {
|
||||
element.acceptChildren(this);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected <T> void registerApplicationService(final Class<T> aClass, T object) {
|
||||
getApplication().registerService(aClass, object);
|
||||
Disposer.register(myProject, new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
getApplication().getPicoContainer().unregisterComponent(aClass.getName());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected <T> void addExplicitExtension(final LanguageExtension<T> instance, final Language language, final T object) {
|
||||
instance.addExplicitExtension(language, object);
|
||||
Disposer.register(myProject, new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
instance.removeExplicitExtension(language, object);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void prepareForTest(String name) throws IOException {
|
||||
String text = loadFile(name + "." + myFileExt);
|
||||
createAndCheckPsiFile(name, text);
|
||||
}
|
||||
|
||||
protected void createAndCheckPsiFile(String name, String text) {
|
||||
myFile = createPsiFile(name, text);
|
||||
ensureParsed(myFile);
|
||||
assertEquals("light virtual file text mismatch", text, ((LightVirtualFile) myFile.getVirtualFile()).getContent().toString());
|
||||
assertEquals("virtual file text mismatch", text, LoadTextUtil.loadText(myFile.getVirtualFile()));
|
||||
assertEquals("doc text mismatch", text, myFile.getViewProvider().getDocument().getText());
|
||||
assertEquals("psi text mismatch", text, myFile.getText());
|
||||
}
|
||||
}
|
||||
@@ -43,11 +43,11 @@ public abstract class JetTestCaseBase extends LightDaemonAnalyzerTestCase {
|
||||
return getTestDataPathBase();
|
||||
}
|
||||
|
||||
protected static String getTestDataPathBase() {
|
||||
public static String getTestDataPathBase() {
|
||||
return getHomeDirectory() + "/idea/testData";
|
||||
}
|
||||
|
||||
private static String getHomeDirectory() {
|
||||
public static String getHomeDirectory() {
|
||||
return new File(PathManager.getResourceRoot(JetTestCaseBase.class, "/org/jetbrains/jet/JetTestCaseBase.class")).getParentFile().getParentFile().getParent();
|
||||
}
|
||||
|
||||
@@ -68,7 +68,11 @@ public abstract class JetTestCaseBase extends LightDaemonAnalyzerTestCase {
|
||||
|
||||
@NotNull
|
||||
protected String getTestFilePath() {
|
||||
return dataPath + name + ".jet";
|
||||
return dataPath + File.separator + name + ".jet";
|
||||
}
|
||||
|
||||
protected String getDataPath() {
|
||||
return dataPath;
|
||||
}
|
||||
|
||||
public interface NamedTestFactory {
|
||||
|
||||
@@ -0,0 +1,125 @@
|
||||
package org.jetbrains.jet.checkers;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.jet.JetLiteFixture;
|
||||
import org.jetbrains.jet.lang.diagnostics.Diagnostic;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.AnalyzingUtils;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.ImportingStrategy;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
*/
|
||||
public class CheckerTestUtilTest extends JetLiteFixture {
|
||||
|
||||
public CheckerTestUtilTest() {
|
||||
super("checkerWithErrorTypes/checkerTestUtil");
|
||||
}
|
||||
|
||||
protected void doTest(TheTest theTest) throws Exception {
|
||||
prepareForTest("test");
|
||||
theTest.test(myFile);
|
||||
}
|
||||
|
||||
public void testEquals() throws Exception {
|
||||
doTest(new TheTest() {
|
||||
@Override
|
||||
protected void makeTestData(List<Diagnostic> diagnostics, List<CheckerTestUtil.DiagnosedRange> diagnosedRanges) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void testMissing() throws Exception {
|
||||
doTest(new TheTest("Missing TYPE_MISMATCH at 56 to 57") {
|
||||
@Override
|
||||
protected void makeTestData(List<Diagnostic> diagnostics, List<CheckerTestUtil.DiagnosedRange> diagnosedRanges) {
|
||||
diagnostics.remove(0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void testUnexpected() throws Exception {
|
||||
doTest(new TheTest("Unexpected TYPE_MISMATCH at 56 to 57") {
|
||||
@Override
|
||||
protected void makeTestData(List<Diagnostic> diagnostics, List<CheckerTestUtil.DiagnosedRange> diagnosedRanges) {
|
||||
diagnosedRanges.remove(0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void testBoth() throws Exception {
|
||||
doTest(new TheTest("Unexpected TYPE_MISMATCH at 56 to 57", "Missing UNRESOLVED_REFERENCE at 166 to 168") {
|
||||
@Override
|
||||
protected void makeTestData(List<Diagnostic> diagnostics, List<CheckerTestUtil.DiagnosedRange> diagnosedRanges) {
|
||||
diagnosedRanges.remove(0);
|
||||
diagnostics.remove(diagnostics.size() - 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void testMissingInTheMiddle() throws Exception {
|
||||
doTest(new TheTest("Unexpected NONE_APPLICABLE at 122 to 123", "Missing TYPE_MISMATCH at 161 to 169") {
|
||||
@Override
|
||||
protected void makeTestData(List<Diagnostic> diagnostics, List<CheckerTestUtil.DiagnosedRange> diagnosedRanges) {
|
||||
diagnosedRanges.remove(2);
|
||||
diagnostics.remove(diagnostics.size() - 3);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static abstract class TheTest {
|
||||
private final String[] expected;
|
||||
|
||||
protected TheTest(String... expectedMessages) {
|
||||
this.expected = expectedMessages;
|
||||
}
|
||||
|
||||
public void test(PsiFile psiFile) {
|
||||
BindingContext bindingContext = AnalyzingUtils.getInstance(ImportingStrategy.NONE).analyzeFileWithCache((JetFile) psiFile);
|
||||
String expectedText = CheckerTestUtil.addDiagnosticMarkersToText(psiFile, bindingContext).toString();
|
||||
|
||||
List<CheckerTestUtil.DiagnosedRange> diagnosedRanges = Lists.newArrayList();
|
||||
CheckerTestUtil.parseDiagnosedRanges(expectedText, diagnosedRanges);
|
||||
|
||||
List<Diagnostic> diagnostics = Lists.newArrayList(bindingContext.getDiagnostics());
|
||||
Collections.sort(diagnostics, CheckerTestUtil.DIAGNOSTIC_COMPARATOR);
|
||||
|
||||
makeTestData(diagnostics, diagnosedRanges);
|
||||
|
||||
final List<String> expectedMessages = Lists.newArrayList(expected);
|
||||
final List<String> actualMessages = Lists.newArrayList();
|
||||
|
||||
CheckerTestUtil.diagnosticsDiff(diagnosedRanges, diagnostics, new CheckerTestUtil.DiagnosticDiffCallbacks() {
|
||||
@Override
|
||||
public void missingDiagnostic(String type, int expectedStart, int expectedEnd) {
|
||||
String message = "Missing " + type + " at " + expectedStart + " to " + expectedEnd;
|
||||
actualMessages.add(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unexpectedDiagnostic(String type, int actualStart, int actualEnd) {
|
||||
String message = "Unexpected " + type + " at " + actualStart + " to " + actualEnd;
|
||||
actualMessages.add(message);
|
||||
}
|
||||
});
|
||||
|
||||
assertEquals(listToString(expectedMessages), listToString(actualMessages));
|
||||
}
|
||||
|
||||
private String listToString(List<String> expectedMessages) {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (String expectedMessage : expectedMessages) {
|
||||
stringBuilder.append(expectedMessage).append("\n");
|
||||
}
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
protected abstract void makeTestData(List<Diagnostic> diagnostics, List<CheckerTestUtil.DiagnosedRange> diagnosedRanges);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package org.jetbrains.jet.checkers;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import junit.framework.Test;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.JetTestCaseBase;
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.plugin.AnalyzerFacade;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
*/
|
||||
public class FullJetPsiCheckerTest extends JetTestCaseBase {
|
||||
|
||||
public FullJetPsiCheckerTest(@NonNls String dataPath, String name) {
|
||||
super(dataPath, name);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void runTest() throws Exception {
|
||||
String fileName = name + ".jet";
|
||||
String fullPath = getTestDataPath() + getTestFilePath();
|
||||
|
||||
|
||||
String expectedText = loadFile(fullPath);
|
||||
|
||||
List<CheckerTestUtil.DiagnosedRange> diagnosedRanges = Lists.newArrayList();
|
||||
String clearText = CheckerTestUtil.parseDiagnosedRanges(expectedText, diagnosedRanges);
|
||||
|
||||
configureFromFileText(fileName, clearText);
|
||||
JetFile jetFile = (JetFile) myFile;
|
||||
BindingContext bindingContext = AnalyzerFacade.analyzeFileWithCache(jetFile);
|
||||
|
||||
CheckerTestUtil.diagnosticsDiff(diagnosedRanges, bindingContext.getDiagnostics(), new CheckerTestUtil.DiagnosticDiffCallbacks() {
|
||||
@Override
|
||||
public void missingDiagnostic(String type, int expectedStart, int expectedEnd) {
|
||||
String message = "Missing " + type + DiagnosticUtils.atLocation(myFile, new TextRange(expectedStart, expectedEnd));
|
||||
System.err.println(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unexpectedDiagnostic(String type, int actualStart, int actualEnd) {
|
||||
String message = "Unexpected " + type + DiagnosticUtils.atLocation(myFile, new TextRange(actualStart, actualEnd));
|
||||
System.err.println(message);
|
||||
}
|
||||
});
|
||||
|
||||
String actualText = CheckerTestUtil.addDiagnosticMarkersToText(jetFile, bindingContext).toString();
|
||||
|
||||
assertEquals(expectedText, actualText);
|
||||
|
||||
// String myFullDataPath = getTestDataPath() + getDataPath();
|
||||
// System.out.println("myFullDataPath = " + myFullDataPath);
|
||||
// convert(new File(myFullDataPath + "/../../checker/"), new File(myFullDataPath));
|
||||
}
|
||||
|
||||
private String loadFile(String fullPath) throws IOException {
|
||||
final File ioFile = new File(fullPath);
|
||||
String fileText = FileUtil.loadFile(ioFile, CharsetToolkit.UTF8);
|
||||
return StringUtil.convertLineSeparators(fileText);
|
||||
}
|
||||
|
||||
private void convert(File src, File dest) throws IOException {
|
||||
File[] files = src.listFiles();
|
||||
for (File file : files) {
|
||||
try {
|
||||
if (file.isDirectory()) {
|
||||
File destDir = new File(dest, file.getName());
|
||||
destDir.mkdir();
|
||||
convert(file, destDir);
|
||||
continue;
|
||||
}
|
||||
if (!file.getName().endsWith(".jet")) continue;
|
||||
String text = loadFile(file.getAbsolutePath());
|
||||
Pattern pattern = Pattern.compile("</?(error|warning|info( descr=\"[\\w ]+\")?)>");
|
||||
String clearText = pattern.matcher(text).replaceAll("");
|
||||
|
||||
configureFromFileText(file.getName(), clearText);
|
||||
|
||||
BindingContext bindingContext = AnalyzerFacade.analyzeFileWithCache((JetFile) myFile);
|
||||
String expectedText = CheckerTestUtil.addDiagnosticMarkersToText(myFile, bindingContext).toString();
|
||||
|
||||
File destFile = new File(dest, file.getName());
|
||||
FileWriter fileWriter = new FileWriter(destFile);
|
||||
fileWriter.write(expectedText);
|
||||
fileWriter.close();
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return JetTestCaseBase.suiteForDirectory(JetTestCaseBase.getTestDataPathBase(), "/checkerWithErrorTypes/full/", true, new JetTestCaseBase.NamedTestFactory() {
|
||||
@NotNull
|
||||
@Override
|
||||
public Test createTest(@NotNull String dataPath, @NotNull String name) {
|
||||
return new FullJetPsiCheckerTest(dataPath, name);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
package org.jetbrains.jet.checkers;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import junit.framework.Test;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.JetLiteFixture;
|
||||
import org.jetbrains.jet.JetTestCaseBase;
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.AnalyzingUtils;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.ImportingStrategy;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
*/
|
||||
public class QuickJetPsiCheckerTest extends JetLiteFixture {
|
||||
private String name;
|
||||
|
||||
public QuickJetPsiCheckerTest(@NonNls String dataPath, String name) {
|
||||
super(dataPath);
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "test" + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runTest() throws Exception {
|
||||
String expectedText = loadFile(name + ".jet");
|
||||
List<CheckerTestUtil.DiagnosedRange> diagnosedRanges = Lists.newArrayList();
|
||||
String clearText = CheckerTestUtil.parseDiagnosedRanges(expectedText, diagnosedRanges);
|
||||
|
||||
createAndCheckPsiFile(name, clearText);
|
||||
JetFile jetFile = (JetFile) myFile;
|
||||
BindingContext bindingContext = AnalyzingUtils.getInstance(ImportingStrategy.NONE).analyzeFileWithCache(jetFile);
|
||||
|
||||
CheckerTestUtil.diagnosticsDiff(diagnosedRanges, bindingContext.getDiagnostics(), new CheckerTestUtil.DiagnosticDiffCallbacks() {
|
||||
@Override
|
||||
public void missingDiagnostic(String type, int expectedStart, int expectedEnd) {
|
||||
String message = "Missing " + type + DiagnosticUtils.atLocation(myFile, new TextRange(expectedStart, expectedEnd));
|
||||
System.err.println(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unexpectedDiagnostic(String type, int actualStart, int actualEnd) {
|
||||
String message = "Unexpected " + type + DiagnosticUtils.atLocation(myFile, new TextRange(actualStart, actualEnd));
|
||||
System.err.println(message);
|
||||
}
|
||||
});
|
||||
|
||||
String actualText = CheckerTestUtil.addDiagnosticMarkersToText(jetFile, bindingContext).toString();
|
||||
|
||||
assertEquals(expectedText, actualText);
|
||||
|
||||
// convert(new File(myFullDataPath + "/../../checker/"), new File(myFullDataPath));
|
||||
}
|
||||
|
||||
// private void convert(File src, File dest) throws IOException {
|
||||
// File[] files = src.listFiles();
|
||||
// for (File file : files) {
|
||||
// try {
|
||||
// if (file.isDirectory()) {
|
||||
// File destDir = new File(dest, file.getName());
|
||||
// destDir.mkdir();
|
||||
// convert(file, destDir);
|
||||
// continue;
|
||||
// }
|
||||
// if (!file.getName().endsWith(".jet")) continue;
|
||||
// String text = doLoadFile(file.getParentFile().getAbsolutePath(), file.getName());
|
||||
// Pattern pattern = Pattern.compile("</?(error|warning)>");
|
||||
// String clearText = pattern.matcher(text).replaceAll("");
|
||||
// createAndCheckPsiFile(name, clearText);
|
||||
//
|
||||
// BindingContext bindingContext = AnalyzingUtils.getInstance(ImportingStrategy.NONE).analyzeFileWithCache((JetFile) myFile);
|
||||
// String expectedText = CheckerTestUtil.addDiagnosticMarkersToText(myFile, bindingContext).toString();
|
||||
//
|
||||
// File destFile = new File(dest, file.getName());
|
||||
// FileWriter fileWriter = new FileWriter(destFile);
|
||||
// fileWriter.write(expectedText);
|
||||
// fileWriter.close();
|
||||
// }
|
||||
// catch (RuntimeException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
public static Test suite() {
|
||||
return JetTestCaseBase.suiteForDirectory(JetTestCaseBase.getTestDataPathBase(), "/checkerWithErrorTypes/quick", true, new JetTestCaseBase.NamedTestFactory() {
|
||||
@NotNull
|
||||
@Override
|
||||
public Test createTest(@NotNull String dataPath, @NotNull String name) {
|
||||
return new QuickJetPsiCheckerTest(dataPath, name);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -143,42 +143,6 @@ public class JetResolveTest extends ExtensibleResolveTestCase {
|
||||
doTest(path, true, false);
|
||||
}
|
||||
|
||||
// public void testBasic() throws Exception {
|
||||
// doTest("/resolve/Basic.jet", true, true);
|
||||
// }
|
||||
//
|
||||
// public void testResolveToJava() throws Exception {
|
||||
// doTest("/resolve/ResolveToJava.jet", true, true);
|
||||
// }
|
||||
//
|
||||
// public void testResolveOfInfixExpressions() throws Exception {
|
||||
// doTest("/resolve/ResolveOfInfixExpressions.jet", true, true);
|
||||
// }
|
||||
//
|
||||
// public void testProjections() throws Exception {
|
||||
// doTest("/resolve/Projections.jet", true, true);
|
||||
// }
|
||||
//
|
||||
// public void testPrimaryConstructors() throws Exception {
|
||||
// doTest("/resolve/PrimaryConstructors.jet", true, true);
|
||||
// }
|
||||
//
|
||||
// public void testClassifiers() throws Exception {
|
||||
// doTest("/resolve/Classifiers.jet", true, true);
|
||||
// }
|
||||
//
|
||||
// public void testConstructorsAndInitializers() throws Exception {
|
||||
// doTest("/resolve/ConstructorsAndInitializers.jet", true, true);
|
||||
// }
|
||||
//
|
||||
// public void testNamespaces() throws Exception {
|
||||
// doTest("/resolve/Namespaces.jet", true, true);
|
||||
// }
|
||||
//
|
||||
// public void testTryCatch() throws Exception {
|
||||
// doTest("/resolve/TryCatch.jet", true, true);
|
||||
// }
|
||||
|
||||
public static Test suite() {
|
||||
return JetTestCaseBase.suiteForDirectory(getHomeDirectory() + "/idea/testData/", "/resolve/", true, new JetTestCaseBase.NamedTestFactory() {
|
||||
@NotNull
|
||||
|
||||
@@ -13,11 +13,13 @@ import org.jetbrains.jet.lang.JetSemanticServices;
|
||||
import org.jetbrains.jet.lang.cfg.JetFlowInformationProvider;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticHolder;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.*;
|
||||
import org.jetbrains.jet.lang.resolve.java.JavaPackageScope;
|
||||
import org.jetbrains.jet.lang.resolve.java.JavaSemanticServices;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.*;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ExplicitReceiver;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
import org.jetbrains.jet.parsing.JetParsingTest;
|
||||
@@ -507,8 +509,8 @@ public class JetTypeCheckerTest extends LightDaemonAnalyzerTestCase {
|
||||
JetScope scope = new JetScopeAdapter(classDefinitions.BASIC_SCOPE) {
|
||||
@NotNull
|
||||
@Override
|
||||
public JetType getThisType() {
|
||||
return thisType;
|
||||
public ReceiverDescriptor getImplicitReceiver() {
|
||||
return new ExplicitReceiver(thisType);
|
||||
}
|
||||
};
|
||||
assertType(scope, expression, expectedType);
|
||||
@@ -527,7 +529,7 @@ public class JetTypeCheckerTest extends LightDaemonAnalyzerTestCase {
|
||||
}
|
||||
|
||||
private WritableScopeImpl addImports(JetScope scope) {
|
||||
WritableScopeImpl writableScope = new WritableScopeImpl(scope, scope.getContainingDeclaration(), DiagnosticHolder.DO_NOTHING);
|
||||
WritableScopeImpl writableScope = new WritableScopeImpl(scope, scope.getContainingDeclaration(), RedeclarationHandler.DO_NOTHING);
|
||||
writableScope.importScope(library.getLibraryScope());
|
||||
JavaSemanticServices javaSemanticServices = new JavaSemanticServices(getProject(), semanticServices, JetTestUtils.DUMMY_TRACE);
|
||||
writableScope.importScope(new JavaPackageScope("", null, javaSemanticServices));
|
||||
@@ -637,7 +639,7 @@ public class JetTypeCheckerTest extends LightDaemonAnalyzerTestCase {
|
||||
|
||||
trace.record(BindingContext.CLASS, classElement, classDescriptor);
|
||||
|
||||
final WritableScope parameterScope = new WritableScopeImpl(scope, classDescriptor, trace);
|
||||
final WritableScope parameterScope = new WritableScopeImpl(scope, classDescriptor, new TraceBasedRedeclarationHandler(trace));
|
||||
|
||||
// This call has side-effects on the parameterScope (fills it in)
|
||||
List<TypeParameterDescriptor> typeParameters
|
||||
@@ -656,7 +658,7 @@ public class JetTypeCheckerTest extends LightDaemonAnalyzerTestCase {
|
||||
// }
|
||||
boolean open = classElement.hasModifier(JetTokens.OPEN_KEYWORD);
|
||||
|
||||
final WritableScope memberDeclarations = new WritableScopeImpl(JetScope.EMPTY, classDescriptor, trace);
|
||||
final WritableScope memberDeclarations = new WritableScopeImpl(JetScope.EMPTY, classDescriptor, new TraceBasedRedeclarationHandler(trace));
|
||||
|
||||
List<JetDeclaration> declarations = classElement.getDeclarations();
|
||||
for (JetDeclaration declaration : declarations) {
|
||||
|
||||
Reference in New Issue
Block a user