From d76a2812ca56cd0d093fbbeb3ab60b35cd9c3180 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Thu, 6 Nov 2014 17:35:12 +1000 Subject: SI-7602 Avoid crash in LUBs with erroneous code If a class contains a double defintion of a method that overrides an interface method, LUBs could run into a spot where filtering overloaded alternatives to those that match the interface method fails to resolve to a single overload, which crashes the compiler. This commit uses `filter` rather than `suchThat` to avoid the crash. --- src/reflect/scala/reflect/internal/tpe/GlbLubs.scala | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/reflect') diff --git a/src/reflect/scala/reflect/internal/tpe/GlbLubs.scala b/src/reflect/scala/reflect/internal/tpe/GlbLubs.scala index 876685e24a..123b44aa05 100644 --- a/src/reflect/scala/reflect/internal/tpe/GlbLubs.scala +++ b/src/reflect/scala/reflect/internal/tpe/GlbLubs.scala @@ -347,7 +347,9 @@ private[internal] trait GlbLubs { def lubsym(proto: Symbol): Symbol = { val prototp = lubThisType.memberInfo(proto) val syms = narrowts map (t => - t.nonPrivateMember(proto.name).suchThat(sym => + // SI-7602 With erroneous code, we could end up with overloaded symbols after filtering + // so `suchThat` unsuitable. + t.nonPrivateMember(proto.name).filter(sym => sym.tpe matches prototp.substThis(lubThisType.typeSymbol, t))) if (syms contains NoSymbol) NoSymbol -- cgit v1.2.3