@@ -2,7 +2,7 @@ package dotty.tools
22package dotc
33package core
44
5- import Types ._ , Contexts ._ , Symbols ._ , Flags ._ , Names ._ , NameOps ._ , Denotations ._
5+ import Types ._ , Contexts ._ , Symbols ._ , Flags ._ , Names ._ , NameOps ._ , Denotations ._ , SymDenotations . *
66import Decorators ._
77import Phases .{gettersPhase , elimByNamePhase }
88import StdNames .nme
@@ -1888,7 +1888,8 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
18881888 * rebase both itself and the member info of `tp` on a freshly created skolem type.
18891889 */
18901890 def hasMatchingMember (name : Name , tp1 : Type , tp2 : RefinedType ): Boolean =
1891- trace(i " hasMatchingMember( $tp1 . $name :? ${tp2.refinedInfo}), mbr: ${tp1.member(name).info}" , subtyping) {
1891+ val mbr = tp1.member(name)
1892+ trace(i " hasMatchingMember( $tp1 . $name :? ${tp2.refinedInfo}), mbr: ${mbr.info}" , subtyping) {
18921893
18931894 // If the member is an abstract type and the prefix is a path, compare the member itself
18941895 // instead of its bounds. This case is needed situations like:
@@ -1931,7 +1932,10 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
19311932 || symInfo.isInstanceOf [MethodType ]
19321933 && symInfo.signature.consistentParams(info2.signature)
19331934
1934- def tp1IsSingleton : Boolean = tp1.isInstanceOf [SingletonType ]
1935+ def allowGadt = mbr match
1936+ case _ if tp1.isInstanceOf [SingletonType ] => false
1937+ case d : UniqueRefDenotation if d.prefix == NoPrefix && d.symbol != NoSymbol => false
1938+ case _ => true
19351939
19361940 // A relaxed version of isSubType, which compares method types
19371941 // under the standard arrow rule which is contravarient in the parameter types,
@@ -1947,15 +1951,15 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling
19471951 matchingMethodParams(info1, info2, precise = false )
19481952 && isSubInfo(info1.resultType, info2.resultType.subst(info2, info1), symInfo1.resultType)
19491953 && sigsOK(symInfo1, info2)
1950- case _ => inFrozenGadtIf(tp1IsSingleton ) { isSubType(info1, info2) }
1951- case _ => inFrozenGadtIf(tp1IsSingleton ) { isSubType(info1, info2) }
1954+ case _ => inFrozenGadtIf(! allowGadt ) { isSubType(info1, info2) }
1955+ case _ => inFrozenGadtIf(! allowGadt ) { isSubType(info1, info2) }
19521956
19531957 def qualifies (m : SingleDenotation ): Boolean =
19541958 val info1 = m.info.widenExpr
19551959 isSubInfo(info1, tp2.refinedInfo.widenExpr, m.symbol.info.orElse(info1))
19561960 || matchAbstractTypeMember(m.info)
19571961
1958- tp1.member(name) match // inlined hasAltWith for performance
1962+ mbr match // inlined hasAltWith for performance
19591963 case mbr : SingleDenotation => qualifies(mbr)
19601964 case mbr => mbr hasAltWith qualifies
19611965 }
0 commit comments