@@ -1923,7 +1923,12 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
19231923 || symInfo.isInstanceOf [MethodType ]
19241924 && symInfo.signature.consistentParams(info2.signature)
19251925
1926- def tp1IsSingleton : Boolean = tp1.isInstanceOf [SingletonType ]
1926+ def allowGadt : Boolean =
1927+ def rec (tp : Type ): Boolean = tp match
1928+ case RefinedType (parent, name1, _) => name == name1 || rec(parent)
1929+ case tp : TypeRef => tp.symbol.isClass
1930+ case _ => false
1931+ ! approx.low && rec(tp1)
19271932
19281933 // A relaxed version of isSubType, which compares method types
19291934 // under the standard arrow rule which is contravarient in the parameter types,
@@ -1939,8 +1944,8 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
19391944 matchingMethodParams(info1, info2, precise = false )
19401945 && isSubInfo(info1.resultType, info2.resultType.subst(info2, info1), symInfo1.resultType)
19411946 && sigsOK(symInfo1, info2)
1942- case _ => inFrozenGadtIf(tp1IsSingleton ) { isSubType(info1, info2) }
1943- case _ => inFrozenGadtIf(tp1IsSingleton ) { isSubType(info1, info2) }
1947+ case _ => inFrozenGadtIf(! allowGadt ) { isSubType(info1, info2) }
1948+ case _ => inFrozenGadtIf(! allowGadt ) { isSubType(info1, info2) }
19441949
19451950 def qualifies (m : SingleDenotation ): Boolean =
19461951 val info1 = m.info.widenExpr
0 commit comments