Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
h3. Control structures
|
h2. Control structures
|
||||||
|
|
||||||
bq. See [Control structures]
|
bq. See [Control structures]
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ alpha{color:blue}*{*{color}beta{color:blue}*}*{color} denotes a nonempty _beta_-
|
|||||||
|
|
||||||
h1. Semicolons
|
h1. Semicolons
|
||||||
|
|
||||||
*Up* provides "semicolon inference": syntactically, subsentences (e.g., statements, declarations etc) are separated by
|
[Up] provides "semicolon inference": syntactically, subsentences (e.g., statements, declarations etc) are separated by
|
||||||
the pseudo-token [SEMI|#SEMI], which stands for "semicolon or newline". In most cases, there's no need for semicolons in
|
the pseudo-token [SEMI|#SEMI], which stands for "semicolon or newline". In most cases, there's no need for semicolons in
|
||||||
*Up* code.
|
[Up] code.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -7,6 +7,30 @@ namespace typeinfo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace io {
|
||||||
|
fun print(message : Any?)
|
||||||
|
fun print(message : Int)
|
||||||
|
fun print(message : Long)
|
||||||
|
fun print(message : Byte)
|
||||||
|
fun print(message : Short)
|
||||||
|
fun print(message : Char)
|
||||||
|
fun print(message : Boolean)
|
||||||
|
fun print(message : Float)
|
||||||
|
fun print(message : Double)
|
||||||
|
|
||||||
|
fun println(message : Any?)
|
||||||
|
fun println(message : Int)
|
||||||
|
fun println(message : Long)
|
||||||
|
fun println(message : Byte)
|
||||||
|
fun println(message : Short)
|
||||||
|
fun println(message : Char)
|
||||||
|
fun println(message : Boolean)
|
||||||
|
fun println(message : Float)
|
||||||
|
fun println(message : Double)
|
||||||
|
|
||||||
|
fun readLine() : String?
|
||||||
|
}
|
||||||
|
|
||||||
// Can't write a body due to a bootstrapping problem (see JET-74)
|
// Can't write a body due to a bootstrapping problem (see JET-74)
|
||||||
fun Any?.equals(other : Any?) : Boolean// = this === other
|
fun Any?.equals(other : Any?) : Boolean// = this === other
|
||||||
|
|
||||||
|
|||||||
@@ -275,12 +275,14 @@ public class TopDownAnalyzer {
|
|||||||
List<JetImportDirective> importDirectives = namespace.getImportDirectives();
|
List<JetImportDirective> importDirectives = namespace.getImportDirectives();
|
||||||
for (JetImportDirective importDirective : importDirectives) {
|
for (JetImportDirective importDirective : importDirectives) {
|
||||||
if (importDirective.isAbsoluteInRootNamespace()) {
|
if (importDirective.isAbsoluteInRootNamespace()) {
|
||||||
throw new UnsupportedOperationException();
|
trace.getErrorHandler().genericError(namespace.getNode(), "Unsupported by TDA"); // TODO
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
if (importDirective.isAllUnder()) {
|
if (importDirective.isAllUnder()) {
|
||||||
JetExpression importedReference = importDirective.getImportedReference();
|
JetExpression importedReference = importDirective.getImportedReference();
|
||||||
if (importedReference != null) {
|
if (importedReference != null) {
|
||||||
JetType type = semanticServices.getTypeInferrerServices(trace, JetFlowInformationProvider.THROW_EXCEPTION).getTypeWithNamespaces(namespaceScope, importedReference, false);
|
JetTypeInferrer.Services typeInferrerServices = semanticServices.getTypeInferrerServices(trace, JetFlowInformationProvider.THROW_EXCEPTION);
|
||||||
|
JetType type = typeInferrerServices.getTypeWithNamespaces(namespaceScope, importedReference, false);
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
namespaceScope.importScope(type.getMemberScope());
|
namespaceScope.importScope(type.getMemberScope());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -539,7 +539,7 @@ public class JetTypeInferrer {
|
|||||||
|
|
||||||
if (someNamed) {
|
if (someNamed) {
|
||||||
// TODO : check that all are named
|
// TODO : check that all are named
|
||||||
throw new UnsupportedOperationException(); // TODO
|
trace.getErrorHandler().genericError(call.asElement().getNode(), "Named arguments are not supported"); // TODO
|
||||||
|
|
||||||
// result = overloadDomain.getFunctionDescriptorForNamedArguments(typeArguments, valueArguments, functionLiteralArgument);
|
// result = overloadDomain.getFunctionDescriptorForNamedArguments(typeArguments, valueArguments, functionLiteralArgument);
|
||||||
} else {
|
} else {
|
||||||
@@ -1093,7 +1093,10 @@ public class JetTypeInferrer {
|
|||||||
|
|
||||||
if (context.expectedReturnType != null && returnedType != null) {
|
if (context.expectedReturnType != null && returnedType != null) {
|
||||||
if (!semanticServices.getTypeChecker().isSubtypeOf(returnedType, context.expectedReturnType)) {
|
if (!semanticServices.getTypeChecker().isSubtypeOf(returnedType, context.expectedReturnType)) {
|
||||||
context.trace.getErrorHandler().typeMismatch(returnedExpression == null ? expression : returnedExpression, context.expectedReturnType, returnedType);
|
JetType enrichedType = enrichOutType(returnedExpression, returnedType);
|
||||||
|
if (!semanticServices.getTypeChecker().isSubtypeOf(enrichedType, context.expectedReturnType)) {
|
||||||
|
context.trace.getErrorHandler().typeMismatch(returnedExpression == null ? expression : returnedExpression, context.expectedReturnType, returnedType);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1570,7 +1573,7 @@ public class JetTypeInferrer {
|
|||||||
condition.accept(new JetVisitor() {
|
condition.accept(new JetVisitor() {
|
||||||
@Override
|
@Override
|
||||||
public void visitIsExpression(JetIsExpression expression) {
|
public void visitIsExpression(JetIsExpression expression) {
|
||||||
if (conditionValue) {
|
if (conditionValue && !expression.isNegated() || !conditionValue && expression.isNegated()) {
|
||||||
JetPattern pattern = expression.getPattern();
|
JetPattern pattern = expression.getPattern();
|
||||||
result[0] = patternsToDataFlowInfo.get(pattern);
|
result[0] = patternsToDataFlowInfo.get(pattern);
|
||||||
if (scopeToExtend != null) {
|
if (scopeToExtend != null) {
|
||||||
@@ -2015,12 +2018,13 @@ public class JetTypeInferrer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private JetType enrichOutType(JetExpression receiverExpression, JetType receiverType) {
|
private JetType enrichOutType(JetExpression expression, JetType initialType) {
|
||||||
VariableDescriptor variableDescriptor = getVariableDescriptorFromSimpleName(receiverExpression);
|
if (expression == null) return initialType;
|
||||||
|
VariableDescriptor variableDescriptor = getVariableDescriptorFromSimpleName(expression);
|
||||||
if (variableDescriptor != null) {
|
if (variableDescriptor != null) {
|
||||||
return context.dataFlowInfo.getOutType(variableDescriptor);
|
return context.dataFlowInfo.getOutType(variableDescriptor);
|
||||||
}
|
}
|
||||||
return receiverType;
|
return initialType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|||||||
@@ -272,3 +272,9 @@ fun f8(b : String?, a : String) {
|
|||||||
b.get(0)
|
b.get(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun f9(a : Int?) : Int {
|
||||||
|
if (a != null)
|
||||||
|
return a
|
||||||
|
return 1
|
||||||
|
}
|
||||||
@@ -147,3 +147,9 @@ fun f15(a : A?) {
|
|||||||
<info descr="Automatically cast to B">a</info>.bar()
|
<info descr="Automatically cast to B">a</info>.bar()
|
||||||
<error>c</error>.bar()
|
<error>c</error>.bar()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getStringLength(obj : Any) : Char? {
|
||||||
|
if (obj !is String)
|
||||||
|
return null
|
||||||
|
return <info>obj</info>.get(0) // no cast to String is needed
|
||||||
|
}
|
||||||
@@ -37,7 +37,7 @@ public class TypeInfo<T> implements JetObject {
|
|||||||
if (!theClass.isAssignableFrom(other.theClass)) {
|
if (!theClass.isAssignableFrom(other.theClass)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (nullable != other.nullable) {
|
if (nullable && !other.nullable) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (typeParameters != null) {
|
if (typeParameters != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user