Skip to content

Commit

Permalink
Merge remote-tracking branch 'systay/type-errors' into type-errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jexp committed Aug 22, 2012
2 parents 9ab2c60 + e84f643 commit 9e3eaf0
Show file tree
Hide file tree
Showing 40 changed files with 146 additions and 103 deletions.
4 changes: 2 additions & 2 deletions cypher/src/docs/dev/ql/functions/index.txt
Expand Up @@ -36,8 +36,8 @@ include::last.txt[]


:leveloffset: 2 :leveloffset: 2


== Iterable functions == == Collection functions ==
Iterable functions return an iterable of things -- nodes in a path, and so on. Collection functions return collections of things -- nodes in a path, and so on.


:leveloffset: 3 :leveloffset: 3


Expand Down
Expand Up @@ -33,7 +33,7 @@ class CypherTypeException(message: String, cause: Throwable = null) extends Cyph


class IterableRequiredException(message:String, cause:Throwable) extends CypherException(message, cause) { class IterableRequiredException(message:String, cause:Throwable) extends CypherException(message, cause) {
def this(message:String) = this(message, null) def this(message:String) = this(message, null)
def this(expression:Expression) = this("Expected " + expression.identifier.name + " to be an iterable, but it is not.", null) def this(expression:Expression) = this("Expected " + expression.identifier.name + " to be a collection, but it is not.", null)
} }


class ParameterNotFoundException(message:String, cause:Throwable) extends CypherException(message, cause) { class ParameterNotFoundException(message:String, cause:Throwable) extends CypherException(message, cause) {
Expand Down
Expand Up @@ -153,7 +153,7 @@ case class Avg(anInner: Expression) extends AggregationWithInnerExpression(anInn
} }


case class Collect(anInner: Expression) extends AggregationWithInnerExpression(anInner) { case class Collect(anInner: Expression) extends AggregationWithInnerExpression(anInner) {
def typ = new IterableType(anInner.identifier.typ) def typ = new CollectionType(anInner.identifier.typ)


def name = "collect" def name = "collect"


Expand Down
Expand Up @@ -34,7 +34,7 @@ abstract class Expression extends (Map[String, Any] => Any) {
def dependencies(expectedType: AnyType): Seq[Identifier] = { def dependencies(expectedType: AnyType): Seq[Identifier] = {
val myType = identifier.typ val myType = identifier.typ
if (!expectedType.isAssignableFrom(myType)) if (!expectedType.isAssignableFrom(myType))
throw new SyntaxException(identifier.name + " expected to be of type " + expectedType + " but it is of type " + identifier.typ) throw new SyntaxException("`%s` expected to be a %s but it is a %s".format(identifier.name, expectedType, identifier.typ))
declareDependencies(expectedType) declareDependencies(expectedType)
} }


Expand Down Expand Up @@ -238,7 +238,9 @@ case class Entity(entityName: String) extends CastableExpression {


case class Collection(expressions:Expression*) extends CastableExpression { case class Collection(expressions:Expression*) extends CastableExpression {
def compute(m: Map[String, Any]): Any = expressions.map(e=>e(m)) def compute(m: Map[String, Any]): Any = expressions.map(e=>e(m))

val identifier: Identifier = Identifier(name, AnyIterableType()) val identifier: Identifier = Identifier(name, AnyIterableType())

private def name = expressions.map(_.identifier.name).mkString("[", ", ", "]") private def name = expressions.map(_.identifier.name).mkString("[", ", ", "]")
def declareDependencies(extectedType: AnyType): Seq[Identifier] = expressions.flatMap(_.declareDependencies(AnyType())) def declareDependencies(extectedType: AnyType): Seq[Identifier] = expressions.flatMap(_.declareDependencies(AnyType()))
def rewrite(f: (Expression) => Expression): Expression = f(Collection(expressions.map(f):_*)) def rewrite(f: (Expression) => Expression): Expression = f(Collection(expressions.map(f):_*))
Expand Down
Expand Up @@ -36,28 +36,28 @@ abstract class NullInNullOutExpression(argument: Expression) extends Expression
} }
} }


case class ExtractFunction(iterable: Expression, id: String, expression: Expression) case class ExtractFunction(collection: Expression, id: String, expression: Expression)
extends NullInNullOutExpression(iterable) extends NullInNullOutExpression(collection)
with IterableSupport with IterableSupport
{ {
def compute(value: Any, m: Map[String, Any]) = makeTraversable(value).map(iterValue => { def compute(value: Any, m: Map[String, Any]) = makeTraversable(value).map(iterValue => {
val innerMap = m + (id -> iterValue) val innerMap = m + (id -> iterValue)
expression(innerMap) expression(innerMap)
}).toList }).toList


val identifier = Identifier("extract(" + id + " in " + iterable.identifier.name + " : " + expression.identifier.name + ")", new IterableType(expression.identifier.typ)) val identifier = Identifier("extract(" + id + " in " + collection.identifier.name + " : " + expression.identifier.name + ")", new CollectionType(expression.identifier.typ))


def declareDependencies(extectedType: AnyType): Seq[Identifier] = def declareDependencies(extectedType: AnyType): Seq[Identifier] =
// Extract depends on everything that the iterable and the expression depends on, except // Extract depends on everything that the iterable and the expression depends on, except
// the new identifier inserted into the expression context, named with id // the new identifier inserted into the expression context, named with id
iterable.dependencies(AnyIterableType()) ++ expression.dependencies(AnyType()).filterNot(_.name == id) collection.dependencies(AnyIterableType()) ++ expression.dependencies(AnyType()).filterNot(_.name == id)


def rewrite(f: (Expression) => Expression) = f(ExtractFunction(iterable.rewrite(f), id, expression.rewrite(f))) def rewrite(f: (Expression) => Expression) = f(ExtractFunction(collection.rewrite(f), id, expression.rewrite(f)))


def filter(f: (Expression) => Boolean) = if (f(this)) def filter(f: (Expression) => Boolean) = if (f(this))
Seq(this) ++ iterable.filter(f) ++ expression.filter(f) Seq(this) ++ collection.filter(f) ++ expression.filter(f)
else else
iterable.filter(f) ++ expression.filter(f) collection.filter(f) ++ expression.filter(f)
} }


case class RelationshipFunction(path: Expression) extends NullInNullOutExpression(path) { case class RelationshipFunction(path: Expression) extends NullInNullOutExpression(path) {
Expand All @@ -66,7 +66,7 @@ case class RelationshipFunction(path: Expression) extends NullInNullOutExpressio
case x => throw new SyntaxException("Expected " + path.identifier.name + " to be a path.") case x => throw new SyntaxException("Expected " + path.identifier.name + " to be a path.")
} }


val identifier = Identifier("RELATIONSHIPS(" + path.identifier.name + ")", new IterableType(RelationshipType())) val identifier = Identifier("RELATIONSHIPS(" + path.identifier.name + ")", new CollectionType(RelationshipType()))


def declareDependencies(extectedType: AnyType): Seq[Identifier] = path.dependencies(PathType()) def declareDependencies(extectedType: AnyType): Seq[Identifier] = path.dependencies(PathType())


Expand Down Expand Up @@ -160,7 +160,7 @@ case class HeadFunction(collection: Expression) extends NullInNullOutExpression(
def compute(value: Any, m: Map[String, Any]) = makeTraversable(value).head def compute(value: Any, m: Map[String, Any]) = makeTraversable(value).head


private def myType = collection.identifier.typ match { private def myType = collection.identifier.typ match {
case x: IterableType => x.iteratedType case x: CollectionType => x.iteratedType
case _ => ScalarType() case _ => ScalarType()
} }


Expand Down Expand Up @@ -214,7 +214,7 @@ case class NodesFunction(path: Expression) extends NullInNullOutExpression(path)
case x => throw new SyntaxException("Expected " + path.identifier.name + " to be a path.") case x => throw new SyntaxException("Expected " + path.identifier.name + " to be a path.")
} }


val identifier = Identifier("NODES(" + path.identifier.name + ")", new IterableType(NodeType())) val identifier = Identifier("NODES(" + path.identifier.name + ")", new CollectionType(NodeType()))


def declareDependencies(extectedType: AnyType): Seq[Identifier] = path.dependencies(PathType()) def declareDependencies(extectedType: AnyType): Seq[Identifier] = path.dependencies(PathType())


Expand Down
Expand Up @@ -54,36 +54,36 @@ abstract class InIterable(expression: Expression, symbol: String, closure: Predi
def filter(f: (Expression) => Boolean): Seq[Expression] = expression.filter(f) ++ closure.filter(f) def filter(f: (Expression) => Boolean): Seq[Expression] = expression.filter(f) ++ closure.filter(f)
} }


case class AllInIterable(iterable: Expression, symbolName: String, inner: Predicate) extends InIterable(iterable, symbolName, inner) { case class AllInIterable(collection: Expression, symbolName: String, inner: Predicate) extends InIterable(collection, symbolName, inner) {
def seqMethod[U](f: Seq[U]): ((U) => Boolean) => Boolean = f.forall _ def seqMethod[U](f: Seq[U]): ((U) => Boolean) => Boolean = f.forall _


def name = "all" def name = "all"


def rewrite(f: (Expression) => Expression) = AllInIterable(iterable.rewrite(f), symbolName, inner.rewrite(f)) def rewrite(f: (Expression) => Expression) = AllInIterable(collection.rewrite(f), symbolName, inner.rewrite(f))
} }


case class AnyInIterable(iterable: Expression, symbolName: String, inner: Predicate) extends InIterable(iterable, symbolName, inner) { case class AnyInIterable(collection: Expression, symbolName: String, inner: Predicate) extends InIterable(collection, symbolName, inner) {
def seqMethod[U](f: Seq[U]): ((U) => Boolean) => Boolean = f.exists _ def seqMethod[U](f: Seq[U]): ((U) => Boolean) => Boolean = f.exists _


def name = "any" def name = "any"


def rewrite(f: (Expression) => Expression) = AnyInIterable(iterable.rewrite(f), symbolName, inner.rewrite(f)) def rewrite(f: (Expression) => Expression) = AnyInIterable(collection.rewrite(f), symbolName, inner.rewrite(f))
} }


case class NoneInIterable(iterable: Expression, symbolName: String, inner: Predicate) extends InIterable(iterable, symbolName, inner) { case class NoneInIterable(collection: Expression, symbolName: String, inner: Predicate) extends InIterable(collection, symbolName, inner) {
def seqMethod[U](f: Seq[U]): ((U) => Boolean) => Boolean = x => !f.exists(x) def seqMethod[U](f: Seq[U]): ((U) => Boolean) => Boolean = x => !f.exists(x)


def name = "none" def name = "none"


def rewrite(f: (Expression) => Expression) = NoneInIterable(iterable.rewrite(f), symbolName, inner.rewrite(f)) def rewrite(f: (Expression) => Expression) = NoneInIterable(collection.rewrite(f), symbolName, inner.rewrite(f))
} }


case class SingleInIterable(iterable: Expression, symbolName: String, inner: Predicate) extends InIterable(iterable, symbolName, inner) { case class SingleInIterable(collection: Expression, symbolName: String, inner: Predicate) extends InIterable(collection, symbolName, inner) {
def seqMethod[U](f: Seq[U]): ((U) => Boolean) => Boolean = x => f.filter(x).length == 1 def seqMethod[U](f: Seq[U]): ((U) => Boolean) => Boolean = x => f.filter(x).length == 1


def name = "single" def name = "single"


def rewrite(f: (Expression) => Expression) = SingleInIterable(iterable.rewrite(f), symbolName, inner.rewrite(f)) def rewrite(f: (Expression) => Expression) = SingleInIterable(collection.rewrite(f), symbolName, inner.rewrite(f))
} }


object IsIterable extends IterableSupport { object IsIterable extends IterableSupport {
Expand Down
Expand Up @@ -85,7 +85,7 @@ case class RangeFunction(start: Expression, end: Expression, step: Expression) e
} }
} }


val identifier = Identifier("range("+ start + "," + end + "," + step + ")", new IterableType(NumberType())) val identifier = Identifier("range("+ start + "," + end + "," + step + ")", new CollectionType(NumberType()))


def rewrite(f: (Expression) => Expression) = f(RangeFunction(start.rewrite(f), end.rewrite(f), step.rewrite(f))) def rewrite(f: (Expression) => Expression) = f(RangeFunction(start.rewrite(f), end.rewrite(f), step.rewrite(f)))
} }
Expand Down
Expand Up @@ -99,10 +99,10 @@ trait PatternGraphBuilder {


patternRelMap(rel) = leftNode.relateTo(rel, rightNode, relType, dir, optional, predicate) patternRelMap(rel) = leftNode.relateTo(rel, rightNode, relType, dir, optional, predicate)
} }
case VarLengthRelatedTo(pathName, start, end, minHops, maxHops, relType, dir, iterableRel, optional, predicate) => { case VarLengthRelatedTo(pathName, start, end, minHops, maxHops, relType, dir, relsCollection, optional, predicate) => {
val startNode: PatternNode = patternNodeMap.getOrElseUpdate(start, new PatternNode(start)) val startNode: PatternNode = patternNodeMap.getOrElseUpdate(start, new PatternNode(start))
val endNode: PatternNode = patternNodeMap.getOrElseUpdate(end, new PatternNode(end)) val endNode: PatternNode = patternNodeMap.getOrElseUpdate(end, new PatternNode(end))
patternRelMap(pathName) = startNode.relateViaVariableLengthPathTo(pathName, endNode, minHops, maxHops, relType, dir, iterableRel, optional, predicate) patternRelMap(pathName) = startNode.relateViaVariableLengthPathTo(pathName, endNode, minHops, maxHops, relType, dir, relsCollection, optional, predicate)
} }
case _ => case _ =>
}) })
Expand Down
Expand Up @@ -24,7 +24,7 @@ import org.neo4j.cypher.internal.symbols.AnyIterableType
import org.neo4j.cypher.internal.pipes.{QueryState, ExecutionContext} import org.neo4j.cypher.internal.pipes.{QueryState, ExecutionContext}




case class ForeachAction(iterable: Expression, symbol: String, actions: Seq[UpdateAction]) case class ForeachAction(collection: Expression, symbol: String, actions: Seq[UpdateAction])
extends UpdateAction extends UpdateAction
with IterableSupport { with IterableSupport {
def dependencies = { def dependencies = {
Expand All @@ -34,13 +34,13 @@ case class ForeachAction(iterable: Expression, symbol: String, actions: Seq[Upda
filterNot(_.name == symbol). //remove dependencies to the symbol we're introducing filterNot(_.name == symbol). //remove dependencies to the symbol we're introducing
filterNot(ownIdentifiers contains) //remove dependencies to identifiers we are introducing filterNot(ownIdentifiers contains) //remove dependencies to identifiers we are introducing


iterable.dependencies(AnyIterableType()) ++ updateDeps collection.dependencies(AnyIterableType()) ++ updateDeps
} }


def exec(context: ExecutionContext, state: QueryState) = { def exec(context: ExecutionContext, state: QueryState) = {
val before = context.get(symbol) val before = context.get(symbol)


val seq = makeTraversable(iterable(context)) val seq = makeTraversable(collection(context))
seq.foreach(element => { seq.foreach(element => {
context.put(symbol, element) context.put(symbol, element)


Expand All @@ -59,9 +59,9 @@ case class ForeachAction(iterable: Expression, symbol: String, actions: Seq[Upda
Stream(context) Stream(context)
} }


def filter(f: (Expression) => Boolean) = Some(iterable).filter(f).toSeq ++ actions.flatMap(_.filter(f)) def filter(f: (Expression) => Boolean) = Some(collection).filter(f).toSeq ++ actions.flatMap(_.filter(f))


def rewrite(f: (Expression) => Expression) = ForeachAction(f(iterable), symbol, actions.map(_.rewrite(f))) def rewrite(f: (Expression) => Expression) = ForeachAction(f(collection), symbol, actions.map(_.rewrite(f)))


def identifier = Seq.empty def identifier = Seq.empty
} }
Expand Up @@ -57,7 +57,7 @@ trait Predicates extends Base with Expressions with ReturnItems {
def sequencePredicate: Parser[Predicate] = allInSeq | anyInSeq | noneInSeq | singleInSeq def sequencePredicate: Parser[Predicate] = allInSeq | anyInSeq | noneInSeq | singleInSeq


def symbolIterablePredicate: Parser[(Expression, String, Predicate)] = def symbolIterablePredicate: Parser[(Expression, String, Predicate)] =
(identity ~ ignoreCase("in") ~ expression ~ ignoreCase("where") ~ predicate ^^ { case symbol ~ in ~ iterable ~ where ~ klas => (iterable, symbol, klas) } (identity ~ ignoreCase("in") ~ expression ~ ignoreCase("where") ~ predicate ^^ { case symbol ~ in ~ collection ~ where ~ klas => (collection, symbol, klas) }
|identity ~> ignoreCase("in") ~ expression ~> failure("expected where")) |identity ~> ignoreCase("in") ~ expression ~> failure("expected where"))




Expand Down
Expand Up @@ -181,7 +181,7 @@ trait Expressions extends Base {
def sequencePredicate: Parser[Predicate] = allInSeq | anyInSeq | noneInSeq | singleInSeq | in def sequencePredicate: Parser[Predicate] = allInSeq | anyInSeq | noneInSeq | singleInSeq | in


def symbolIterablePredicate: Parser[(Expression, String, Predicate)] = def symbolIterablePredicate: Parser[(Expression, String, Predicate)] =
(identity ~ ignoreCase("in") ~ expression ~ ignoreCase("where") ~ predicate ^^ { case symbol ~ in ~ iterable ~ where ~ klas => (iterable, symbol, klas) } (identity ~ ignoreCase("in") ~ expression ~ ignoreCase("where") ~ predicate ^^ { case symbol ~ in ~ collection ~ where ~ klas => (collection, symbol, klas) }
|identity ~> ignoreCase("in") ~ expression ~> failure("expected where")) |identity ~> ignoreCase("in") ~ expression ~> failure("expected where"))


def in : Parser[Predicate] = expression ~ ignoreCase("in") ~ expression ^^ { def in : Parser[Predicate] = expression ~ ignoreCase("in") ~ expression ^^ {
Expand Down
Expand Up @@ -47,7 +47,7 @@ trait Predicates extends Base with ParserPattern with StringLiteral {
def sequencePredicate: Parser[Predicate] = allInSeq | anyInSeq | noneInSeq | singleInSeq | in def sequencePredicate: Parser[Predicate] = allInSeq | anyInSeq | noneInSeq | singleInSeq | in


def symbolIterablePredicate: Parser[(Expression, String, Predicate)] = def symbolIterablePredicate: Parser[(Expression, String, Predicate)] =
(identity ~ ignoreCase("in") ~ expression ~ ignoreCase("where") ~ predicate ^^ { case symbol ~ in ~ iterable ~ where ~ klas => (iterable, symbol, klas) } (identity ~ ignoreCase("in") ~ expression ~ ignoreCase("where") ~ predicate ^^ { case symbol ~ in ~ collection ~ where ~ klas => (collection, symbol, klas) }
|identity ~> ignoreCase("in") ~ expression ~> failure("expected where")) |identity ~> ignoreCase("in") ~ expression ~> failure("expected where"))


def in: Parser[Predicate] = expression ~ ignoreCase("in") ~ expression ^^ { def in: Parser[Predicate] = expression ~ ignoreCase("in") ~ expression ^^ {
Expand Down
Expand Up @@ -27,13 +27,13 @@ trait Updates extends Base with Expressions with StartClause {
def updates: Parser[(Seq[UpdateAction], Seq[NamedPath])] = rep(delete | set | foreach) ^^ (cmds => reduce(cmds)) def updates: Parser[(Seq[UpdateAction], Seq[NamedPath])] = rep(delete | set | foreach) ^^ (cmds => reduce(cmds))


def foreach: Parser[(Seq[UpdateAction], Seq[NamedPath])] = ignoreCase("foreach") ~> "(" ~> identity ~ ignoreCase("in") ~ expression ~ ":" ~ opt(createStart) ~ opt(updates) <~ ")" ^^ { def foreach: Parser[(Seq[UpdateAction], Seq[NamedPath])] = ignoreCase("foreach") ~> "(" ~> identity ~ ignoreCase("in") ~ expression ~ ":" ~ opt(createStart) ~ opt(updates) <~ ")" ^^ {
case id ~ in ~ iterable ~ ":" ~ creates ~ innerUpdates => { case id ~ in ~ collection ~ ":" ~ creates ~ innerUpdates => {
val createCmds = creates.toSeq.map(_._1.map(_.asInstanceOf[UpdateAction])).flatten val createCmds = creates.toSeq.map(_._1.map(_.asInstanceOf[UpdateAction])).flatten
val reducedItems: (Seq[UpdateAction], Seq[NamedPath]) = reduce(innerUpdates.toSeq) val reducedItems: (Seq[UpdateAction], Seq[NamedPath]) = reduce(innerUpdates.toSeq)
val updateCmds = reducedItems._1 val updateCmds = reducedItems._1
val namedPaths = reducedItems._2 ++ creates.toSeq.flatMap(_._2) val namedPaths = reducedItems._2 ++ creates.toSeq.flatMap(_._2)
if(namedPaths.nonEmpty) throw new SyntaxException("Paths can't be created inside of foreach") if(namedPaths.nonEmpty) throw new SyntaxException("Paths can't be created inside of foreach")
(Seq(ForeachAction(iterable, id, createCmds ++ updateCmds)), Seq()) (Seq(ForeachAction(collection, id, createCmds ++ updateCmds)), Seq())
} }
} }


Expand Down
Expand Up @@ -38,7 +38,16 @@ class MatchingContext(boundIdentifiers: SymbolTable,


private def identifiers:Seq[Identifier] = patternGraph.patternRels.values.flatMap(p => p.identifiers).toSeq private def identifiers:Seq[Identifier] = patternGraph.patternRels.values.flatMap(p => p.identifiers).toSeq


lazy val symbols = boundIdentifiers.add(identifiers: _*) lazy val symbols = {
val ids = identifiers

val identifiersAlreadyInContext = ids.filter(identifier => boundIdentifiers.keys.contains(identifier.name))

identifiersAlreadyInContext.foreach( boundIdentifiers.assertHas )

boundIdentifiers.keys.filter(_)
boundIdentifiers.add(ids: _*)
}


def getMatches(sourceRow: Map[String, Any]): Traversable[Map[String, Any]] = { def getMatches(sourceRow: Map[String, Any]): Traversable[Map[String, Any]] = {
builder.getMatches(sourceRow) builder.getMatches(sourceRow)
Expand Down
Expand Up @@ -43,10 +43,10 @@ class PatternNode(key: String) extends PatternElement(key) {
maxHops: Option[Int], maxHops: Option[Int],
relType: Seq[String], relType: Seq[String],
dir: Direction, dir: Direction,
iterableRel: Option[String], collectionOfRels: Option[String],
optional: Boolean, optional: Boolean,
predicate: Predicate): PatternRelationship = { predicate: Predicate): PatternRelationship = {
val rel = new VariableLengthPatternRelationship(pathName, this, end, iterableRel, minHops, maxHops, relType, dir, optional, predicate) val rel = new VariableLengthPatternRelationship(pathName, this, end, collectionOfRels, minHops, maxHops, relType, dir, optional, predicate)
relationships.add(rel) relationships.add(rel)
end.relationships.add(rel) end.relationships.add(rel)
rel rel
Expand Down
Expand Up @@ -119,8 +119,8 @@ class VariableLengthPatternRelationship(pathName: String,
override def identifiers : Seq[Identifier] = Seq( override def identifiers : Seq[Identifier] = Seq(
Identifier(startNode.key, NodeType()), Identifier(startNode.key, NodeType()),
Identifier(endNode.key, NodeType()), Identifier(endNode.key, NodeType()),
Identifier(key, new IterableType(RelationshipType()))) ++ Identifier(key, new CollectionType(RelationshipType()))) ++
relIterable.toSeq.map(Identifier(_, new IterableType(RelationshipType()))) relIterable.toSeq.map(Identifier(_, new CollectionType(RelationshipType())))


override def getGraphRelationships(node: PatternNode, realNode: Node): Seq[GraphRelationship] = { override def getGraphRelationships(node: PatternNode, realNode: Node): Seq[GraphRelationship] = {


Expand Down
Expand Up @@ -20,6 +20,6 @@
package org.neo4j.cypher.internal.symbols package org.neo4j.cypher.internal.symbols


object AnyIterableType { object AnyIterableType {
val instance = new IterableType(AnyType()) val instance = new CollectionType(AnyType())
def apply() = instance def apply() = instance
} }
Expand Up @@ -55,7 +55,7 @@ class AnyType {


def isAssignableFrom(other: AnyType): Boolean = this.getClass.isAssignableFrom(other.getClass) def isAssignableFrom(other: AnyType): Boolean = this.getClass.isAssignableFrom(other.getClass)


override def toString: String = this.getClass.getSimpleName override def toString: String = "Any"
} }




Expand Down
Expand Up @@ -25,4 +25,6 @@ object BooleanType {
def apply() = instance def apply() = instance
} }


class BooleanType extends ScalarType class BooleanType extends ScalarType {
override def toString = "Boolean"
}
Expand Up @@ -22,11 +22,15 @@ package org.neo4j.cypher.internal.symbols
import java.lang.String import java.lang.String




class IterableType(val iteratedType: AnyType) extends AnyType { class CollectionType(val iteratedType: AnyType) extends AnyType {


override def toString: String = "IterableType<" + iteratedType + ">" override def toString: String =
if (iteratedType.isInstanceOf[AnyType])
"Collection"
else
"Collection<" + iteratedType + ">"


override def isAssignableFrom(other:AnyType):Boolean = super.isAssignableFrom(other) && iteratedType.isAssignableFrom(other.asInstanceOf[IterableType].iteratedType) override def isAssignableFrom(other: AnyType): Boolean = super.isAssignableFrom(other) && iteratedType.isAssignableFrom(other.asInstanceOf[CollectionType].iteratedType)
} }




Expand Down
Expand Up @@ -25,7 +25,9 @@ object DoubleType {
def apply() = instance def apply() = instance
} }


class DoubleType extends NumberType class DoubleType extends NumberType {
override def toString = "Double"
}






Expand Down
Expand Up @@ -26,7 +26,9 @@ object IntegerType {
def apply() = instance def apply() = instance
} }


class IntegerType extends NumberType class IntegerType extends NumberType {
override def toString = "Integer"
}






Expand Down
Expand Up @@ -25,7 +25,9 @@ object LongType {
def apply() = instance def apply() = instance
} }


class LongType extends NumberType class LongType extends NumberType {
override def toString = "Long"
}






Expand Down
Expand Up @@ -26,7 +26,9 @@ object MapType {
} }




class MapType extends AnyType class MapType extends AnyType {
override def toString = "Map"
}






Expand Down

0 comments on commit 9e3eaf0

Please sign in to comment.