Skip to content

Commit 0c2c7ec

Browse files
committed
Warn-unused uses type alias in nesting check
A reference from the body of a class is not a usage of the class, but a reference to a local type alias of it is a usage of the type alias.
1 parent b2c87cd commit 0c2c7ec

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

src/compiler/scala/tools/nsc/typechecker/TypeDiagnostics.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ trait TypeDiagnostics {
527527
// Only record type references which don't originate within the
528528
// definition of the class being referenced.
529529
if (t.tpe ne null) {
530-
for (tp <- t.tpe if !treeTypes(tp) && !currentOwner.ownerChain.contains(tp.typeSymbol)) {
530+
for (tp <- t.tpe if !treeTypes(tp) && !currentOwner.hasTransOwner(tp.typeSymbolDirect)) {
531531
tp match {
532532
case NoType | NoPrefix =>
533533
case NullaryMethodType(_) =>
@@ -550,7 +550,7 @@ trait TypeDiagnostics {
550550
m.isType
551551
&& !m.isTypeParameterOrSkolem // would be nice to improve this
552552
&& (m.isPrivate || m.isLocalToBlock)
553-
&& !(treeTypes.exists(tp => tp exists (t => t.typeSymbolDirect == m)))
553+
&& !(treeTypes.exists(_.exists(_.typeSymbolDirect == m)))
554554
)
555555
def isSyntheticWarnable(sym: Symbol) = (
556556
sym.isDefaultGetter

test/files/pos/t10623.flags

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-Xfatal-warnings -Xlint:unused

test/files/pos/t10623.scala

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
import language.higherKinds
3+
4+
object `package` {
5+
def refl[A]: A Is A = ???
6+
}
7+
8+
sealed trait Is[A, B] { ab =>
9+
def subst[F[_]](fa: F[A]): F[B]
10+
final def flip: B Is A = {
11+
type f[a] = a Is A
12+
subst[f](refl)
13+
}
14+
}
15+

0 commit comments

Comments
 (0)