Skip to content

Commit

Permalink
Merge remote-tracking branch 'neo/3.3' into 3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Lojjs committed Mar 6, 2018
2 parents 48a9003 + 6a21780 commit 3f4611b
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,25 @@ class AddTest extends InfixExpressionTestBase(Add(_, _)(DummyPosition(0))) {

testValidTypes(CTNode, CTList(CTNode))(CTList(CTNode))
testValidTypes(CTFloat, CTList(CTFloat))(CTList(CTFloat))

testValidTypes(CTList(CTAny), CTList(CTAny))(CTList(CTAny))
}

test("should handle covariant types") {
testValidTypes(CTString.covariant, CTString.covariant)(CTString)
testValidTypes(CTString.covariant, CTInteger)(CTString)
testValidTypes(CTString, CTInteger.covariant)(CTString)
testValidTypes(CTInteger.covariant, CTInteger.covariant)(CTInteger)
testValidTypes(CTInteger.covariant, CTFloat)(CTFloat)
testValidTypes(CTInteger, CTFloat.covariant)(CTFloat)
testValidTypes(CTFloat.covariant, CTFloat.covariant)(CTFloat)

testValidTypes(CTList(CTFloat).covariant, CTList(CTFloat).covariant)(CTList(CTFloat))

testValidTypes(CTList(CTNode).covariant, CTNode)(CTList(CTNode))
testValidTypes(CTList(CTNode), CTNode.covariant)(CTList(CTNode))

testValidTypes(CTList(CTAny).covariant, CTList(CTAny).covariant)(CTList(CTAny).covariant)
}

test("shouldHandleCombinedSpecializations") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,9 @@ class TypeSpecTest extends CypherFunSuite {
(CTFloat | CTInteger).coercions should equal(CTFloat.invariant)
CTList(CTAny).covariant.coercions should equal(CTBoolean.invariant)
TypeSpec.exact(CTList(CTPath)).coercions should equal(CTBoolean.invariant)
TypeSpec.all.coercions should equal(CTBoolean | CTFloat)
CTList(CTAny).covariant.coercions should equal(CTBoolean.invariant)
TypeSpec.all.coercions should equal(TypeSpec.none)
CTInteger.contravariant.coercions should equal(TypeSpec.none)
}

test("should intersect with coercions") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package org.neo4j.cypher.internal.util.v3_4.symbols
object IntegerType {
val instance = new IntegerType() {
val parentType = CTNumber
override lazy val coercibleTo: Set[CypherType] = Set(CTFloat)
override lazy val coercibleTo: Set[CypherType] = Set(CTFloat) ++ parentType.coercibleTo
override val toString = "Integer"
override val toNeoTypeString = "INTEGER?"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ object ListType {
val parentType = CTAny
override val legacyIteratedType = innerType

override lazy val coercibleTo: Set[CypherType] = Set(CTBoolean)
override lazy val coercibleTo: Set[CypherType] = Set(CTBoolean) ++ parentType.coercibleTo

override def parents = innerType.parents.map(copy) ++ super.parents

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,7 @@ class TypeSpec(val ranges: Seq[TypeRange]) extends Equals {
def unwrapLists: TypeSpec = TypeSpec(ranges.map(_.reparent { case c: ListType => c.innerType }))

def coercions: TypeSpec = {
val simpleCoercions = TypeSpec.simpleTypes.filter(this contains).flatMap(_.coercibleTo)
if (this containsAny CTList(CTAny).covariant)
TypeSpec.exact(simpleCoercions ++ CTList(CTAny).coercibleTo)
else
val simpleCoercions = ranges.flatMap(_.lower.coercibleTo)
TypeSpec.exact(simpleCoercions)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -946,4 +946,11 @@ class MatchAcceptanceTest extends ExecutionEngineFunSuite with QueryStatisticsTe

result.toList should equal(List.empty)
}

test("Reduce and concat gh #10978") {

// Fixed in 3.3.4
val result = executeWith(Configs.Interpreted - Configs.Version3_3, "RETURN REDUCE(s = 0, p in [5,8,2,9] + [1,2] | s + p) as num")
result.toList should be(List(Map("num" -> 27)))
}
}

0 comments on commit 3f4611b

Please sign in to comment.