Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1393,10 +1393,10 @@ object SymDenotations {
def thisType(using Context): Type = NoPrefix

def typeRef(using Context): TypeRef =
TypeRef(owner.thisType, symbol)
TypeRef(maybeOwner.thisType, symbol)

def termRef(using Context): TermRef =
TermRef(owner.thisType, symbol)
TermRef(maybeOwner.thisType, symbol)

/** The typeRef applied to its own type parameters */
def appliedRef(using Context): Type =
Expand Down
17 changes: 9 additions & 8 deletions compiler/src/dotty/tools/dotc/typer/Implicits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1657,14 +1657,15 @@ sealed class TermRefSet(using Context):

def += (ref: TermRef): Unit =
val pre = ref.prefix
val sym = ref.symbol.asTerm
elems.get(sym) match
case null =>
elems.put(sym, pre)
case prefix: Type =>
if !(prefix =:= pre) then elems.put(sym, pre :: prefix :: Nil)
case prefixes: List[Type] =>
if !prefixes.exists(_ =:= pre) then elems.put(sym, pre :: prefixes)
if ref.symbol.exists then
val sym = ref.symbol.asTerm
elems.get(sym) match
case null =>
elems.put(sym, pre)
case prefix: Type =>
if !(prefix =:= pre) then elems.put(sym, pre :: prefix :: Nil)
case prefixes: List[Type] =>
if !prefixes.exists(_ =:= pre) then elems.put(sym, pre :: prefixes)

def ++= (that: TermRefSet): Unit =
if !that.isEmpty then that.foreach(+=)
Expand Down
21 changes: 21 additions & 0 deletions tests/neg/i9328.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// fuzz test to avoid NoSymbol.owner
type Id[T] = T match {
case _ => T
}

class Foo2[T <: Id[T]] // error // error

object Foo { // error
object Foo { }
Foo { }
}
implicit class Foo(a: Float) // error
case class Foo()

case class Bar(
} { ; // error
object Bar { // error
class Foo(a: Int) extends AnyVal
Foo()
}
type Bar // error