Skip to content

Commit 7fdddd4

Browse files
committed
Avoid crash if prefix if selection is higher-kinded
The test case caused a crash in NamedType, because `Lambda` is higher-kinded. We now report an error instead.
1 parent 962b4bf commit 7fdddd4

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

compiler/src/dotty/tools/dotc/typer/ProtoTypes.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ object ProtoTypes {
126126
val mbr = if (privateOK) tp1.member(name) else tp1.nonPrivateMember(name)
127127
def qualifies(m: SingleDenotation) =
128128
memberProto.isRef(defn.UnitClass) ||
129-
compat.normalizedCompatible(NamedType(tp1, name, m), memberProto)
129+
tp1.isValueType && compat.normalizedCompatible(NamedType(tp1, name, m), memberProto)
130130
// Note: can't use `m.info` here because if `m` is a method, `m.info`
131131
// loses knowledge about `m`'s default arguments.
132132
mbr match { // hasAltWith inlined for performance

tests/neg/hkprefix.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class Lambda[T] { class Tp }
2+
3+
object Test {
4+
def f(x: Lambda # Tp) = ??? // error
5+
}

0 commit comments

Comments
 (0)