Skip to content
Permalink
Browse files

Fix lampepfl#7425: Handle nullary/parameterless conflicts in infoMeet

We did handle ():T & (=> T), but not (=> T) & ():T.
  • Loading branch information...
odersky committed Oct 15, 2019
1 parent 42e3ad4 commit 20818af67555002a8c389df295ad9b736a3e0303
Showing with 22 additions and 7 deletions.
  1. +10 −7 compiler/src/dotty/tools/dotc/core/Denotations.scala
  2. +12 −0 tests/neg/i7425.scala
@@ -653,15 +653,18 @@ object Denotations {
case ExprType(rtp1) =>
tp2 match {
case ExprType(rtp2) => ExprType(rtp1 & rtp2)
case _ => rtp1 & tp2
case _ => infoMeet(rtp1, tp2, sym1, sym2, safeIntersection)
}
case _ =>
try tp1 & tp2.widenExpr
catch {
case ex: Throwable =>
println(i"error for meet: $tp1 &&& $tp2, ${tp1.getClass}, ${tp2.getClass}")
throw ex
}
tp2 match
case _: MethodType | _: PolyType =>
mergeConflict(sym1, sym2, tp1, tp2)
case _ =>
try tp1 & tp2.widenExpr
catch
case ex: Throwable =>
println(i"error for meet: $tp1 &&& $tp2, ${tp1.getClass}, ${tp2.getClass}")
throw ex
}

/** Normally, `tp1 | tp2`.
@@ -0,0 +1,12 @@
class C { def f: Int = 0 }

trait D { def f(): Int = 0 }

def foo1(x: C & D) = x.f // error: method f must be called with () argument
def foo2(x: C | D) = x.f // error: value f is not a member of C | D
def foo3(x: D & C) = x.f // ok
def foo4(x: D | C) = x.f // error: value f is not a member of D | C
def foo5(x: C & D) = x.f() // ok
def foo6(x: C | D) = x.f() // error: value f is not a member of C | D
def foo7(x: D & C) = x.f() // error: method f in class C does not take parameters
def foo8(x: D | C) = x.f() // error: value f is not a member of D | C

0 comments on commit 20818af

Please sign in to comment.
You can’t perform that action at this time.